Skip to content

Commit

Permalink
WIP idleShard apply idleForest's update
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Jul 22, 2023
1 parent f1a8bdc commit deef35c
Show file tree
Hide file tree
Showing 70 changed files with 1,644 additions and 953 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
package hundun.gdxgame.idledemo;

import java.io.File;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.badlogic.gdx.Gdx;

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.logic.BuffId;
import hundun.gdxgame.idledemo.logic.DemoBuiltinConstructionsLoader;
import hundun.gdxgame.idledemo.logic.ConstructionId;
import hundun.gdxgame.idledemo.logic.ConstructionPrototypeId;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.ui.screen.DemoMenuScreen;
import hundun.gdxgame.idledemo.ui.screen.DemoPlayScreen;
import hundun.gdxgame.idleshare.gamelib.framework.data.ChildGameConfig;
import hundun.gdxgame.idleshare.gamelib.framework.data.GameplaySaveData;
import hundun.gdxgame.idleshare.gamelib.framework.model.AchievementPrototype;
import hundun.gdxgame.idleshare.gamelib.framework.model.AbstractAchievement;

/**
* @author hundun
Expand All @@ -31,20 +26,19 @@ public DemoChildGameConfig() {
// BuiltinConstructionsLoader builtinConstructionsLoader = new BuiltinConstructionsLoader(game);
// this.setConstructions(builtinConstructionsLoader.load());

Map<String, List<String>> areaShownConstructionIds = new HashMap<>();
areaShownConstructionIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
ConstructionId.COOKIE_CLICK_PROVIDER
));
areaShownConstructionIds.put(GameArea.AREA_BUILDING, JavaFeatureForGwt.arraysAsList(
ConstructionId.COOKIE_AUTO_PROVIDER,
ConstructionId.COOKIE_SELLER
Map<String, List<String>> areaControlableConstructionVMPrototypeIds = new HashMap<>();
areaControlableConstructionVMPrototypeIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
ConstructionPrototypeId.COOKIE_AUTO_PROVIDER
));
areaShownConstructionIds.put(GameArea.AREA_WIN, JavaFeatureForGwt.arraysAsList(
ConstructionId.WIN_PROVIDER
this.setAreaControlableConstructionVMPrototypeIds(areaControlableConstructionVMPrototypeIds);

Map<String, List<String>> areaControlableConstructionPrototypeVMPrototypeIds = new HashMap<>();
areaControlableConstructionPrototypeVMPrototypeIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
ConstructionPrototypeId.COOKIE_AUTO_PROVIDER
));
this.setAreaControlableConstructionPrototypeVMPrototypeIds(areaControlableConstructionPrototypeVMPrototypeIds);


this.setAreaControlableConstructionIds(areaShownConstructionIds);
this.setAreaShowEntityByOwnAmountConstructionIds(areaShownConstructionIds);

Map<String, List<String>> areaShownResourceIds = new HashMap<>();
areaShownResourceIds.put(GameArea.AREA_COOKIE, JavaFeatureForGwt.arraysAsList(
Expand All @@ -57,20 +51,16 @@ public DemoChildGameConfig() {
ResourceType.COOKIE
));
this.setAreaShowEntityByChangeAmountResourceIds(areaShowEntityByChangeAmountResourceIds);


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

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

List<AchievementPrototype> achievementPrototypes = JavaFeatureForGwt.arraysAsList(
new AchievementPrototype("Game win", "You win the game!",
JavaFeatureForGwt.mapOf(BuffId.WIN, 1),
null
)
);
this.setAchievementPrototypes(achievementPrototypes);

this.setAchievementPrototypeIds(new ArrayList<>());
}


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

import hundun.gdxgame.idledemo.logic.DemoGameDictionary;
import hundun.gdxgame.idledemo.logic.DemoTextureManager;
import hundun.gdxgame.idledemo.logic.*;
import hundun.gdxgame.gamelib.base.save.ISaveTool;
import hundun.gdxgame.idledemo.logic.DemoBuiltinConstructionsLoader;
import hundun.gdxgame.idledemo.logic.DemoSaveHandler;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idledemo.ui.screen.DemoMenuScreen;
import hundun.gdxgame.idledemo.ui.screen.DemoScreenContext;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
Expand Down Expand Up @@ -65,6 +60,7 @@ protected void createStage1() {
frontend,
new DemoGameDictionary(),
new DemoBuiltinConstructionsLoader(),
new IdleForestAchievementLoader(),
BaseIdlePlayScreen.LOGIC_FRAME_PER_SECOND,
childGameConfig
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package hundun.gdxgame.idledemo.logic;




public class ConstructionPrototypeId {


public static final String COOKIE_AUTO_PROVIDER = "ENUM_CSTR@COOKIE_AUTO_PROVIDER";

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package hundun.gdxgame.idledemo.logic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idleshare.gamelib.framework.IdleGameplayContext;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.BaseAutoConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.BaseBuffConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.BaseClickGatherConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.BaseConstructionFactory;
import hundun.gdxgame.idledemo.logic.prototype.CookieAutoProviderPrototype;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.*;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.DescriptionPackageFactory;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.IBuiltinConstructionsLoader;
Expand All @@ -20,107 +16,19 @@
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.UpgradeComponent;
import hundun.gdxgame.idleshare.gamelib.framework.model.resource.ResourcePack;
import hundun.gdxgame.idleshare.gamelib.framework.model.resource.ResourcePair;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.IGameDictionary;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.Language;


public class DemoBuiltinConstructionsLoader implements IBuiltinConstructionsLoader {

@Override
public List<BaseConstruction> provide(Language language) {
List<BaseConstruction> constructions = new ArrayList<>();
// clicker-provider
{
BaseConstruction construction = new BaseClickGatherConstruction(ConstructionId.COOKIE_CLICK_PROVIDER);
construction.descriptionPackage = DescriptionPackageFactory.getGatherDescriptionPackage(language);

OutputComponent outputComponent = new OutputComponent(construction);
outputComponent.setOutputGainPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COOKIE, 1
)));
construction.setOutputComponent(outputComponent);

UpgradeComponent upgradeComponent = new UpgradeComponent(construction);
construction.setUpgradeComponent(upgradeComponent);

LevelComponent levelComponent = new LevelComponent(construction, false);
construction.setLevelComponent(levelComponent);

constructions.add(construction);
}
// auto-provider
{
BaseConstruction construction = new BaseAutoConstruction(ConstructionId.COOKIE_AUTO_PROVIDER);
construction.descriptionPackage = DescriptionPackageFactory.getMaxLevelAutoDescriptionPackage(language);

OutputComponent outputComponent = new OutputComponent(construction);
outputComponent.setOutputGainPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COOKIE, 1
)));
construction.setOutputComponent(outputComponent);

UpgradeComponent upgradeComponent = new UpgradeComponent(construction);
upgradeComponent.setUpgradeCostPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COIN, 25
)));
construction.setUpgradeComponent(upgradeComponent);

LevelComponent levelComponent = new LevelComponent(construction, false);
construction.setLevelComponent(levelComponent);

construction.setMaxDrawNum(9);
constructions.add(construction);
}
// seller
{
BaseConstruction construction = new BaseAutoConstruction(ConstructionId.COOKIE_SELLER);
construction.descriptionPackage = DescriptionPackageFactory.getWorkingLevelAutoDescriptionPackage(language);

OutputComponent outputComponent = new OutputComponent(construction);
outputComponent.setOutputCostPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COOKIE, 1
)));
outputComponent.setOutputGainPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COIN, 5
)));
construction.setOutputComponent(outputComponent);

UpgradeComponent upgradeComponent = new UpgradeComponent(construction);
upgradeComponent.setUpgradeCostPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COIN, 500
)));
construction.setUpgradeComponent(upgradeComponent);

LevelComponent levelComponent = new LevelComponent(construction, true);
construction.setLevelComponent(levelComponent);

construction.setMaxDrawNum(9);
constructions.add(construction);
}
// win
{
BaseConstruction construction = new BaseBuffConstruction(ConstructionId.WIN_PROVIDER, BuffId.WIN);
construction.descriptionPackage = DescriptionPackageFactory.getWinDescriptionPackage(language);

OutputComponent outputComponent = new OutputComponent(construction);
construction.setOutputComponent(outputComponent);

UpgradeComponent upgradeComponent = new UpgradeComponent(construction);
upgradeComponent.setUpgradeCostPack(toPack(JavaFeatureForGwt.mapOf(
ResourceType.COIN, 500
)));
construction.setUpgradeComponent(upgradeComponent);

LevelComponent levelComponent = new LevelComponent(construction, false);
construction.setLevelComponent(levelComponent);

construction.setMaxLevel(1);
constructions.add(construction);
}
return constructions;
public Map<String, AbstractConstructionPrototype> getProviderMap(Language language) {
Map<String, AbstractConstructionPrototype> result = new HashMap<>();
result.put(ConstructionPrototypeId.COOKIE_AUTO_PROVIDER, new CookieAutoProviderPrototype(language));
return result;
}

private static ResourcePack toPack(Map<String, Integer> map) {
public static ResourcePack toPack(Map<String, Integer> map) {
ResourcePack pack = new ResourcePack();
List<ResourcePair> pairs = new ArrayList<>(map.size());
map.entrySet().forEach(entry -> pairs.add(new ResourcePair(entry.getKey(), (long)entry.getValue())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,20 @@
public class DemoGameDictionary implements IGameDictionary {


public String constructionIdToShowName(Language language, String constructionId) {
public String constructionPrototypeIdToShowName(Language language, String constructionId) {
switch (language) {
case CN:
switch (constructionId) {
case ConstructionId.COOKIE_CLICK_PROVIDER:
return "大饼干";
case ConstructionId.COOKIE_AUTO_PROVIDER:

case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "自动点击器";
case ConstructionId.COOKIE_SELLER:
return "自动销售器";
case ConstructionId.WIN_PROVIDER:
return "奖杯购买处";
default:
return "口口";
}
default:
switch (constructionId) {
case ConstructionId.COOKIE_CLICK_PROVIDER:
return "main cookie";
case ConstructionId.COOKIE_AUTO_PROVIDER:
case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "cliker";
case ConstructionId.COOKIE_SELLER:
return "seller";
case ConstructionId.WIN_PROVIDER:
return "win";
default:
return "[dic lost]";
}
Expand All @@ -48,31 +37,19 @@ public String constructionIdToShowName(Language language, String constructionId)
}

@Override
public String constructionIdToDetailDescroptionConstPart(Language language, String constructionId) {
public String constructionPrototypeIdToDetailDescroptionConstPart(Language language, String constructionId) {
switch (language) {
case CN:
switch (constructionId) {
case ConstructionId.COOKIE_CLICK_PROVIDER:
return "戳一戳,获得饼干";
case ConstructionId.COOKIE_AUTO_PROVIDER:
return "自动获得饼干";
case ConstructionId.COOKIE_SELLER:
switch (constructionId) {
case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "自动获得饼干";
case ConstructionId.WIN_PROVIDER:
return "购买一个奖杯以赢得胜利";
default:
return "[dic lost]";
}
default:
switch (constructionId) {
case ConstructionId.COOKIE_CLICK_PROVIDER:
return "Click gain some cookie";
case ConstructionId.COOKIE_AUTO_PROVIDER:
case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "Auto gain some cookie";
case ConstructionId.COOKIE_SELLER:
return "Auto sell cookies";
case ConstructionId.WIN_PROVIDER:
return "Get a trophy and win the game";
default:
return "[dic lost]";
}
Expand All @@ -98,4 +75,40 @@ public Map<Language, String> getLanguageShowNameMap() {
Language.EN, "English"
);
}

@Override
public List<String> getAchievementTexts(Language language)
{
switch (language)
{
case CN:
return JavaFeatureForGwt.arraysAsList("当前任务:", "已完成:", "回到游戏");
default:
return JavaFeatureForGwt.arraysAsList("Quest: ", "Completed: ", "back");
}
}

@Override
public List<String> getPlayScreenTexts(Language language)
{
switch (language)
{
case CN:
return JavaFeatureForGwt.arraysAsList("购买", "购买费用");
default:
return JavaFeatureForGwt.arraysAsList("Build", "Build cost");
}
}

@Override
public List<String> getStageSelectMaskBoardTexts(Language language)
{
switch (language)
{
case CN:
return JavaFeatureForGwt.arraysAsList("返回", "关卡1", "关卡2", "关卡3");
default:
return JavaFeatureForGwt.arraysAsList("Back", "Stage1", "Stage2", "Stage3");
}
}
}
Loading

0 comments on commit deef35c

Please sign in to comment.