Skip to content

Commit

Permalink
doChangeEpoch workable
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Oct 21, 2023
1 parent 4366311 commit a061fb2
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public DemoChildGameConfig() {
.worldPrototypeIds(JavaFeatureForGwt.listOf(
DemoConstructionPrototypeId.EPOCH_1_EMPTY_CELL,
DemoConstructionPrototypeId.EPOCH_1_TREE,
DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER
DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER,
DemoConstructionPrototypeId.EPOCH_2_MUSHROOM_AUTO_PROVIDER
))
.build()
);

Map<String, List<String>> areaShownResourceIds = new HashMap<>();
this.setAreaEntityEffectConfigMap(JavaFeatureForGwt.mapOf(
DemoScreenId.SCREEN_MAIN,
AreaEntityEffectConfig.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@
import hundun.gdxgame.idleshare.core.framework.model.manager.AudioPlayManager;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdleScreen;
import hundun.gdxgame.idleshare.gamelib.export.IdleGameplayExport;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.TextFormatTool;
import lombok.Getter;
import lombok.Setter;
import lombok.*;

import java.util.List;
import java.util.Map;

public class DemoIdleGame extends BaseIdleGame<RootSaveData> {

public class IdleMushroomGame extends BaseIdleGame<RootSaveData> {

@Getter
protected AbstractIdleScreenContext<DemoIdleGame, RootSaveData> screenContext;
protected AbstractIdleScreenContext<IdleMushroomGame, RootSaveData> screenContext;

@Getter
protected IdleMushroomTextureManager idleMushroomTextureManager;

Map<Integer, EpochConfig> epochConfigMap;

public DemoIdleGame(ISaveTool<RootSaveData> saveTool) {
public IdleMushroomGame(ISaveTool<RootSaveData> saveTool) {
super(960, 640);
this.debugMode = true;

Expand All @@ -46,6 +50,16 @@ public DemoIdleGame(ISaveTool<RootSaveData> saveTool) {
DemoScreenId.SCREEN_WORLD,
DemoScreenId.SCREEN_ACHIEVEMENT
);
this.epochConfigMap = JavaFeatureForGwt.mapOf(
1, EpochConfig.builder()
.constructionTransformConfigs(JavaFeatureForGwt.listOf(
EpochConstructionTransformConfig.builder()
.fromPrototypeId(DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER)
.toPrototypeId(DemoConstructionPrototypeId.EPOCH_2_MUSHROOM_AUTO_PROVIDER)
.build()
))
.build()
);
}


Expand Down Expand Up @@ -82,5 +96,35 @@ protected void createStage3() {
getAudioPlayManager().intoScreen(DemoScreenId.SCREEN_MENU);
}


@Data
@AllArgsConstructor
@Builder
public static class EpochConfig {
List<EpochConstructionTransformConfig> constructionTransformConfigs;
}

@Data
@AllArgsConstructor
@Builder
public static class EpochConstructionTransformConfig {
String fromPrototypeId;
String toPrototypeId;
}
public void doChangeEpoch(BaseConstruction epochCounter) {
int currentEpochLevel = epochCounter.getSaveData().getLevel();
EpochConfig epochConfig = epochConfigMap.get(currentEpochLevel);

idleGameplayExport.getGameplayContext().getConstructionManager().getWorldConstructionInstances().stream()
.forEach(it -> {
EpochConstructionTransformConfig transformConfig = epochConfig.getConstructionTransformConfigs().stream()
.filter(itt -> itt.getFromPrototypeId().equals(it.getPrototypeId()))
.findAny()
.orElse(null);
if (transformConfig != null) {
idleGameplayExport.getGameplayContext().getConstructionManager().addToRemoveQueue(it);
idleGameplayExport.getGameplayContext().getConstructionManager().addToCreateQueue(transformConfig.getToPrototypeId(), it.getPosition());
}
});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public Map<String, AbstractConstructionPrototype> getProviderMap(Language langua
result.put(DemoConstructionPrototypeId.EPOCH_1_EMPTY_CELL, new DirtPrototype(language));
result.put(DemoConstructionPrototypeId.MAIN_MUSHROOM, new MainMushroomPrototype(language));
result.put(DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER, new Epoch1AutoProviderPrototype(language));
result.put(DemoConstructionPrototypeId.EPOCH_2_MUSHROOM_AUTO_PROVIDER, new Epoch2AutoProviderPrototype(language));
result.put(DemoConstructionPrototypeId.MUSHROOM_AUTO_SELLER, new AutoSellerPrototype(language));
result.put(DemoConstructionPrototypeId.EPOCH_1_TREE, new TreePrototype(language));
result.put(DemoConstructionPrototypeId.EPOCH_COUNTER, new EpochCounterPrototype(language));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public String constructionPrototypeIdToShowName(Language language, String constr
return "自动点击器";
case DemoConstructionPrototypeId.MUSHROOM_AUTO_SELLER:
return "自动出售器";
case DemoConstructionPrototypeId.EPOCH_COUNTER:
return "EPOCH_COUNTER";
default:
return "口口";
}
Expand All @@ -39,6 +41,8 @@ public String constructionPrototypeIdToShowName(Language language, String constr
return "SimpleAutoClicker";
case DemoConstructionPrototypeId.MUSHROOM_AUTO_SELLER:
return "AutoSeller";
case DemoConstructionPrototypeId.EPOCH_COUNTER:
return "EPOCH_COUNTER";
default:
return "[dic lost]";
}
Expand All @@ -53,24 +57,30 @@ public String constructionPrototypeIdToDetailDescriptionConstPart(Language langu
case CN:
switch (constructionId) {
case DemoConstructionPrototypeId.EPOCH_2_MUSHROOM_AUTO_PROVIDER:
return "EPOCH_2自动获得饼干";
case DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER:
return "自动获得饼干";
return "EPOCH_1自动获得饼干";
case DemoConstructionPrototypeId.MUSHROOM_AUTO_SELLER:
return "自动出售饼干";
case DemoConstructionPrototypeId.EPOCH_1_EMPTY_CELL:
return "空位置";
case DemoConstructionPrototypeId.EPOCH_COUNTER:
return "the EPOCH_COUNTER";
default:
return "[dic lost]";
}
default:
switch (constructionId) {
case DemoConstructionPrototypeId.EPOCH_2_MUSHROOM_AUTO_PROVIDER:
return "EPOCH_2 Auto gain some cookie";
case DemoConstructionPrototypeId.EPOCH_1_MUSHROOM_AUTO_PROVIDER:
return "Auto gain some cookie";
return "EPOCH_1 Auto gain some cookie";
case DemoConstructionPrototypeId.MUSHROOM_AUTO_SELLER:
return "Auto sell some cookie";
case DemoConstructionPrototypeId.EPOCH_1_EMPTY_CELL:
return "Empty";
case DemoConstructionPrototypeId.EPOCH_COUNTER:
return "the EPOCH_COUNTER";
default:
return "[dic lost]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ protected RootSaveData genereateStarterRootSaveData() {
DemoConstructionPrototypeId.EPOCH_COUNTER + "_" + SINGLETON,
ConstructionSaveData.builder()
.prototypeId(DemoConstructionPrototypeId.EPOCH_COUNTER)
.level(3)
.workingLevel(1)
.level(0)
.workingLevel(0)
.position(uselessPosition)
.build()
);
Expand Down Expand Up @@ -91,6 +91,7 @@ protected RootSaveData genereateStarterRootSaveData() {
});

Map<String, Long> ownResources = new HashMap<>();
ownResources.put(ResourceType.MUSHROOM, 500L);
ownResources.put(ResourceType.DNA_POINT, 500L);

return RootSaveData.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

public class EpochCounterPrototype extends AbstractConstructionPrototype {
public static DescriptionPackage descriptionPackageEN = DescriptionPackage.builder()
.upgradeButtonText("Upgrade")
.upgradeCostDescriptionStart("Upgrade cost")
.upgradeMaxLevelDescription("(max)")
.levelDescriptionProvider(DescriptionPackageFactory.WORKING_LEVEL_IMP)
.proficiencyDescriptionProvider(DescriptionPackageFactory.EN_PROFICIENCY_IMP)
.build();


public static DescriptionPackage descriptionPackageCN = DescriptionPackage.builder()
.upgradeButtonText("升级")
.upgradeCostDescriptionStart("升级费用")
.upgradeMaxLevelDescription("(已达到最大等级)")
.levelDescriptionProvider(DescriptionPackageFactory.CN_WORKING_LEVEL_IMP)
.proficiencyDescriptionProvider(DescriptionPackageFactory.CN_PROFICIENCY_IMP)
.build();
Expand Down Expand Up @@ -73,7 +79,7 @@ public BaseConstruction getInstance(GridPosition position) {
return 1L;
}
});
thiz.getLevelComponent().maxLevel = 3;
thiz.getLevelComponent().maxLevel = 2;

return thiz;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;

import com.badlogic.gdx.utils.Null;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.IdleMushroomGame;
import hundun.gdxgame.idledemo.ui.screen.BaseDemoPlayScreen;
import hundun.gdxgame.idleshare.core.starter.ui.component.ResourceAmountPairNode;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.AbstractAchievement;
Expand Down Expand Up @@ -50,7 +50,7 @@ private void rebuildUi(@Null AbstractAchievement prototype) {
Label rewardLabel = new Label(texts.get(3), parent.getGame().getMainSkin());
this.add(rewardLabel).center().row();
for (ResourcePair entry : prototype.getAwardResourceMap()) {
ResourceAmountPairNode<DemoIdleGame> node = new ResourceAmountPairNode<>(parent.getGame(), entry.getType());
ResourceAmountPairNode<IdleMushroomGame> node = new ResourceAmountPairNode<>(parent.getGame(), entry.getType());
node.update(entry.getAmount());
this.add(node)
.height(parent.getLayoutConst().RESOURCE_AMOUNT_PAIR_NODE_HEIGHT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public EpochPart(
public void changed(ChangeEvent event, Actor actor) {
Gdx.app.log(SellerPart.class.getSimpleName(), "upgradeButton changed");
model.getUpgradeComponent().doUpgrade();
parent.getGame().doChangeEpoch(model);
}
});

Expand Down Expand Up @@ -258,7 +259,6 @@ public void clicked(InputEvent event, float x, float y) {

this.workingLevelLabel = new Label("", parent.getGame().getMainSkin());
workingLevelLabel.setAlignment(Align.center);
changeWorkingLevelGroup.add(workingLevelLabel).size(CHILD_WIDTH / 2, CHILD_HEIGHT);

this.upWorkingLevelButton = new TextButton("+", parent.getGame().getMainSkin());
upWorkingLevelButton.addListener(new ClickListener() {
Expand All @@ -276,6 +276,7 @@ public void clicked(InputEvent event, float x, float y) {
// ------ this ------
this.add(constructionNameLabel).size(CHILD_WIDTH, NAME_CHILD_HEIGHT).row();
this.add(upgradeButton).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(workingLevelLabel).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(changeWorkingLevelGroup).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(detailGroup).row();

Expand Down Expand Up @@ -313,7 +314,7 @@ private void update() {
model.getSaveData().getPosition().getY()
));
upgradeButton.setText(model.getDescriptionPackage().getUpgradeButtonText());
workingLevelLabel.setText(model.getLevelComponent().getWorkingLevelDescription() + "; max: " + model.getMaxLevel());
workingLevelLabel.setText(model.getLevelComponent().getWorkingLevelDescription() + "; max: " + model.getLevelComponent().maxLevel);


// ------ update clickable-state ------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.badlogic.gdx.Gdx;
import hundun.gdxgame.gamelib.starter.listerner.IGameAreaChangeListener;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.IdleMushroomGame;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idledemo.ui.main.FirstRunningAchievementBoardVM;
import hundun.gdxgame.idledemo.ui.world.HexCellVM;
Expand All @@ -16,18 +16,18 @@
import java.util.ArrayList;
import java.util.List;

public abstract class BaseDemoPlayScreen extends BaseIdleScreen<DemoIdleGame, RootSaveData>
public abstract class BaseDemoPlayScreen extends BaseIdleScreen<IdleMushroomGame, RootSaveData>
implements IGameAreaChangeListener, IAchievementBoardCallback, IAchievementStateChangeListener
{

protected FirstRunningAchievementBoardVM<DemoIdleGame, RootSaveData> firstRunningAchievementBoardVM;
protected FirstRunningAchievementBoardVM<IdleMushroomGame, RootSaveData> firstRunningAchievementBoardVM;
protected AchievementPopupBoard achievementPopupBoard;
DemoIdleGame demoIdleGame;
IdleMushroomGame idleMushroomGame;
protected List<AbstractAchievement> showAchievementMaskBoardQueue = new ArrayList<>();

public BaseDemoPlayScreen(DemoIdleGame game, String screenId) {
public BaseDemoPlayScreen(IdleMushroomGame game, String screenId) {
super(game, screenId, DemoScreenContext.customLayoutConst(game));
this.demoIdleGame = game;
this.idleMushroomGame = game;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hundun.gdxgame.idledemo.ui.screen;

import com.badlogic.gdx.InputProcessor;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.IdleMushroomGame;
import hundun.gdxgame.idledemo.logic.DemoScreenId;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.logic.RootSaveData;
Expand All @@ -11,13 +11,13 @@
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.AbstractAchievement;
import hundun.gdxgame.idleshare.gamelib.framework.model.manager.AchievementManager.AchievementState;

public class DemoAchievementScreen extends BaseIdleScreen<DemoIdleGame, RootSaveData> implements IAchievementStateChangeListener {
public class DemoAchievementScreen extends BaseIdleScreen<IdleMushroomGame, RootSaveData> implements IAchievementStateChangeListener {

AllAchievementBoardVM<DemoIdleGame, RootSaveData> allAchievementBoardVM;
AllAchievementBoardVM<IdleMushroomGame, RootSaveData> allAchievementBoardVM;



public DemoAchievementScreen(DemoIdleGame game) {
public DemoAchievementScreen(IdleMushroomGame game) {
super(game, DemoScreenId.SCREEN_ACHIEVEMENT, DemoScreenContext.customLayoutConst(game));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;

import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.IdleMushroomGame;
import hundun.gdxgame.idledemo.logic.DemoScreenId;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idleshare.core.starter.ui.screen.menu.BaseIdleMenuScreen;
Expand All @@ -12,9 +12,9 @@
* @author hundun
* Created on 2023/02/16
*/
public class DemoMenuScreen extends BaseIdleMenuScreen<DemoIdleGame, RootSaveData> {
public class DemoMenuScreen extends BaseIdleMenuScreen<IdleMushroomGame, RootSaveData> {

public DemoMenuScreen(DemoIdleGame game) {
public DemoMenuScreen(IdleMushroomGame game) {
super(game,
new InputListener(){
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.IdleMushroomGame;
import hundun.gdxgame.idledemo.logic.DemoScreenId;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idleshare.core.framework.model.manager.AbstractIdleScreenContext;
Expand All @@ -13,7 +13,7 @@
* @author hundun
* Created on 2023/02/17
*/
public class DemoScreenContext extends AbstractIdleScreenContext<DemoIdleGame, RootSaveData> {
public class DemoScreenContext extends AbstractIdleScreenContext<IdleMushroomGame, RootSaveData> {

DemoMenuScreen menuScreen;
MainPlayScreen mainPlayScreen;
Expand All @@ -22,7 +22,7 @@ public class DemoScreenContext extends AbstractIdleScreenContext<DemoIdleGame, R



public static PlayScreenLayoutConst customLayoutConst(DemoIdleGame game) {
public static PlayScreenLayoutConst customLayoutConst(IdleMushroomGame game) {
PlayScreenLayoutConst layoutConst = new PlayScreenLayoutConst(game.getWidth(), game.getHeight());
NinePatch ninePatch = new NinePatch(game.getTextureManager().getDefaultBoardNinePatchTexture(),
game.getTextureManager().getDefaultBoardNinePatchEdgeSize(),
Expand All @@ -35,7 +35,7 @@ public static PlayScreenLayoutConst customLayoutConst(DemoIdleGame game) {
return layoutConst;
}

public DemoScreenContext(DemoIdleGame game) {
public DemoScreenContext(IdleMushroomGame game) {
super(game);
}

Expand Down
Loading

0 comments on commit a061fb2

Please sign in to comment.