Skip to content

Commit

Permalink
大量重构:以ConstructionConfig管理设施相关的配置;移除GameArea, 使用ScreenId
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Sep 17, 2023
1 parent c32de4f commit b079660
Show file tree
Hide file tree
Showing 33 changed files with 262 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.logic.DemoConstructionPrototypeId;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.DemoScreenId;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.ui.screen.DemoMenuScreen;
import hundun.gdxgame.idledemo.ui.screen.CookiePlayScreen;
import hundun.gdxgame.idleshare.gamelib.framework.data.ChildGameConfig;

/**
Expand All @@ -22,40 +20,44 @@ public DemoChildGameConfig() {

// BuiltinConstructionsLoader builtinConstructionsLoader = new BuiltinConstructionsLoader(game);
// this.setConstructions(builtinConstructionsLoader.load());

Map<String, List<String>> areaControlableConstructionVMPrototypeIds = new HashMap<>();
areaControlableConstructionVMPrototypeIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER,
DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER,
DemoConstructionPrototypeId.COOKIE_AUTO_SELLER
));
this.setAreaControlableConstructionVMPrototypeIds(areaControlableConstructionVMPrototypeIds);

Map<String, List<String>> areaControlableConstructionPrototypeVMPrototypeIds = new HashMap<>();
areaControlableConstructionPrototypeVMPrototypeIds.put(GameArea.AREA_FOREST, JavaFeatureForGwt.listOf(
DemoConstructionPrototypeId.EMPTY_CELL
));
this.setAreaControlableConstructionPrototypeVMPrototypeIds(areaControlableConstructionPrototypeVMPrototypeIds);

this.setConstructionConfig(
ConstructionConfig.builder()
.emptyConstructionConfig(EmptyConstructionConfig.builder()
.prototypeId(DemoConstructionPrototypeId.EMPTY_CELL)
.buyCandidatePrototypeIds(JavaFeatureForGwt.listOf(
DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER
))
.build()
)
.singletonPrototypeIds(JavaFeatureForGwt.listOf(
DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER,
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER
))
.worldPrototypeIds(JavaFeatureForGwt.listOf(
DemoConstructionPrototypeId.EMPTY_CELL,
DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER
))
.build()
);



Map<String, List<String>> areaShownResourceIds = new HashMap<>();
areaShownResourceIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
ResourceType.COIN
));
Map<String, List<String>> areaShownResourceIds = new HashMap<>();
this.setAreaShowEntityByOwnAmountResourceIds(areaShownResourceIds);

Map<String, List<String>> areaShowEntityByChangeAmountResourceIds = new HashMap<>();
areaShowEntityByChangeAmountResourceIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
areaShowEntityByChangeAmountResourceIds.put(DemoScreenId.SCREEN_COOKIE, JavaFeatureForGwt.arraysAsList(
ResourceType.COOKIE
));
this.setAreaShowEntityByChangeAmountResourceIds(areaShowEntityByChangeAmountResourceIds);

this.setAreaShowEntityByOwnAmountConstructionPrototypeIds(new HashMap<>());

Map<String, String> screenIdToFilePathMap = JavaFeatureForGwt.mapOf(
DemoMenuScreen.class.getSimpleName(), "audio/Loop-Menu.wav",
CookiePlayScreen.class.getSimpleName(), "audio/forest.mp3"
DemoScreenId.SCREEN_COOKIE, "audio/Loop-Menu.wav",
DemoScreenId.SCREEN_WORLD, "audio/forest.mp3"
);
this.setScreenIdToFilePathMap(screenIdToFilePathMap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.ray3k.stripe.FreeTypeSkin;

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.logic.*;
import hundun.gdxgame.gamelib.base.save.ISaveTool;
import hundun.gdxgame.idledemo.ui.screen.DemoMenuScreen;
import hundun.gdxgame.idledemo.ui.screen.DemoScreenContext;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idleshare.core.framework.model.manager.AbstractIdleScreenContext;
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.util.text.TextFormatTool;
import lombok.Getter;


public class DemoIdleGame extends BaseIdleGame<RootSaveData> {


@Getter
protected AbstractIdleScreenContext<DemoIdleGame, RootSaveData> screenContext;



Expand All @@ -35,14 +39,15 @@ public DemoIdleGame(ISaveTool<RootSaveData> saveTool) {
this.screenContext = new DemoScreenContext(this);
this.audioPlayManager = new AudioPlayManager(this);
this.childGameConfig = new DemoChildGameConfig();


}

@Override
public List<String> getGameAreaValues() {
return GameArea.values;
this.controlBoardScreenIds = JavaFeatureForGwt.listOf(
DemoScreenId.SCREEN_COOKIE,
DemoScreenId.SCREEN_WORLD,
DemoScreenId.SCREEN_ACHIEVEMENT
);
}



@Override
protected void createStage1() {
Expand All @@ -59,15 +64,21 @@ protected void createStage1() {
this.getSaveHandler().registerSubHandler(idleGameplayExport);
saveHandler.systemSettingLoadOrStarter();
}


@Override
protected void createStage2() {
super.createStage2();
screenContext.lazyInit();
}

@Override
protected void createStage3() {
super.createStage3();



screenManager.pushScreen(DemoMenuScreen.class.getSimpleName(), null);
getAudioPlayManager().intoScreen(DemoMenuScreen.class.getSimpleName());
screenManager.pushScreen(DemoScreenId.SCREEN_MENU, null);
getAudioPlayManager().intoScreen(DemoScreenId.SCREEN_MENU);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Map<String, AbstractAchievement> getProviderMap(Language language) {
DemoAchievementId.STEP_2,
textMap,
JavaFeatureForGwt.mapOf(
DemoConstructionPrototypeId.COOKIE_AUTO_SELLER, new SimpleEntry<>(1, 2)
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER, new SimpleEntry<>(1, 2)
),
null,
new ResourcePair(ResourceType.COIN, 1000L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class DemoBuiltinConstructionsLoader implements IBuiltinConstructionsLoad
public Map<String, AbstractConstructionPrototype> getProviderMap(Language language) {
Map<String, AbstractConstructionPrototype> result = new HashMap<>();
result.put(DemoConstructionPrototypeId.EMPTY_CELL, new DirtPrototype(language));
result.put(DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER, new CookieClickProviderPrototype(language));
result.put(DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER, new CookieClickProviderPrototype(language));
result.put(DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER, new CookieAutoProviderPrototype(language));
result.put(DemoConstructionPrototypeId.COOKIE_AUTO_SELLER, new CookieAutoSellerPrototype(language));
result.put(DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER, new CookieAutoSellerPrototype(language));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

public class DemoConstructionPrototypeId {

public static final String COOKIE_CLICK_PROVIDER = "ENUM_CSTR@COOKIE_CLICK_PROVIDER";
public static final String SINGLETON_COOKIE_CLICK_PROVIDER = "ENUM_CSTR@COOKIE_CLICK_PROVIDER";
public static final String COOKIE_AUTO_PROVIDER = "ENUM_CSTR@COOKIE_AUTO_PROVIDER";
public static final String COOKIE_AUTO_SELLER = "ENUM_CSTR@COOKIE_AUTO_SELLER";
public static final String SINGLETON_COOKIE_AUTO_SELLER = "ENUM_CSTR@COOKIE_AUTO_SELLER";
public static final String EMPTY_CELL = "ENUM_CSTR@EMPTY";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ public String constructionPrototypeIdToShowName(Language language, String constr
switch (language) {
case CN:
switch (constructionId) {
case DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER:
case DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER:
return "点击器";
case DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "自动点击器";
case DemoConstructionPrototypeId.COOKIE_AUTO_SELLER:
case DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER:
return "自动出售器";
default:
return "口口";
}
default:
switch (constructionId) {
case DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER:
case DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER:
return "Clicker";
case DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "AutoClicker";
case DemoConstructionPrototypeId.COOKIE_AUTO_SELLER:
case DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER:
return "AutoSeller";
default:
return "[dic lost]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ protected RootSaveData genereateStarterRootSaveData() {
Map<String, ConstructionSaveData> map = new HashMap<>();

map.put(
DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER + "_" + UUID.randomUUID(),
DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER + "_" + UUID.randomUUID(),
ConstructionSaveData.builder()
.prototypeId(DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER)
.prototypeId(DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER)
.level(0)
.workingLevel(0)
.position( new GridPosition(0, 0))
Expand All @@ -48,9 +48,9 @@ protected RootSaveData genereateStarterRootSaveData() {
.build()
);
map.put(
DemoConstructionPrototypeId.COOKIE_AUTO_SELLER + "_" + UUID.randomUUID(),
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER + "_" + UUID.randomUUID(),
ConstructionSaveData.builder()
.prototypeId(DemoConstructionPrototypeId.COOKIE_AUTO_SELLER)
.prototypeId(DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER)
.level(1)
.workingLevel(0)
.position( new GridPosition(1, 0))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package hundun.gdxgame.idledemo.logic;


public class DemoScreenId {
public static final String SCREEN_MENU = "ENUM_AREA@SCREEN_MENU";
public static final String SCREEN_COOKIE = "ENUM_AREA@AREA_COOKIE";
public static final String SCREEN_WORLD = "ENUM_AREA@AREA_FOREST";

public static final String SCREEN_ACHIEVEMENT = "ENUM_AREA@SCREEN_ACHIEVEMENT";
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ public void lazyInitOnGameCreateStage2() {
{
Texture texture = new Texture(Gdx.files.internal("gameAreaIcons.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 100, 50);
gameAreaLeftPartRegionMap.put(GameArea.AREA_COOKIE, regions[0][0]);
gameAreaLeftPartRegionMap.put(GameArea.AREA_FOREST, regions[1][0]);
gameAreaLeftPartRegionMap.put(DemoScreenId.SCREEN_COOKIE, regions[0][0]);
gameAreaLeftPartRegionMap.put(DemoScreenId.SCREEN_WORLD, regions[1][0]);
//gameAreaLeftPartRegionMap.put(GameArea.AREA_WIN, regions[2][0]);
gameAreaRightPartRegionMap.put(GameArea.AREA_COOKIE, regions[0][1]);
gameAreaRightPartRegionMap.put(GameArea.AREA_FOREST, regions[1][1]);
gameAreaRightPartRegionMap.put(DemoScreenId.SCREEN_COOKIE, regions[0][1]);
gameAreaRightPartRegionMap.put(DemoScreenId.SCREEN_WORLD, regions[1][1]);
//gameAreaRightPartRegionMap.put(GameArea.AREA_WIN, regions[2][1]);
}
{
Texture texture = new Texture(Gdx.files.internal("areas.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 640, 480);
defaultAreaBack = regions[0][0];
gameAreaBackMap.put(GameArea.AREA_COOKIE, regions[0][1]);
gameAreaBackMap.put(GameArea.AREA_FOREST, regions[0][2]);
gameAreaBackMap.put(DemoScreenId.SCREEN_COOKIE, regions[0][1]);
gameAreaBackMap.put(DemoScreenId.SCREEN_WORLD, regions[0][2]);
//gameAreaBackMap.put(GameArea.AREA_WIN, regions[0][3]);
}
{
Texture texture = new Texture(Gdx.files.internal("CellIcons.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 128, 128);
defaultAreaBack = regions[0][1];
constructionHexImageMap.put(DemoConstructionPrototypeId.EMPTY_CELL, regions[0][0]);
constructionHexImageMap.put(DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER, regions[0][1]);
constructionHexImageMap.put(DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER, regions[0][1]);
constructionHexImageMap.put(DemoConstructionPrototypeId.COOKIE_AUTO_PROVIDER, regions[0][2]);
constructionHexImageMap.put(DemoConstructionPrototypeId.COOKIE_AUTO_SELLER, regions[0][3]);
constructionHexImageMap.put(DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER, regions[0][3]);
//gameAreaBackMap.put(GameArea.AREA_WIN, regions[0][3]);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CookieAutoSellerPrototype extends AbstractConstructionPrototype {

public CookieAutoSellerPrototype(Language language) {
super(
DemoConstructionPrototypeId.COOKIE_AUTO_SELLER,
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER,
language,
DemoBuiltinConstructionsLoader.toPack(JavaFeatureForGwt.mapOf())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CookieClickProviderPrototype extends AbstractConstructionPrototype

public CookieClickProviderPrototype(Language language) {
super(
DemoConstructionPrototypeId.COOKIE_CLICK_PROVIDER,
DemoConstructionPrototypeId.SINGLETON_COOKIE_CLICK_PROVIDER,
language,
DemoBuiltinConstructionsLoader.toPack(JavaFeatureForGwt.mapOf())
);
Expand Down
Loading

0 comments on commit b079660

Please sign in to comment.