Skip to content

Commit

Permalink
squash refactor mushroom
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Feb 18, 2024
1 parent ef86723 commit d5b92c5
Show file tree
Hide file tree
Showing 107 changed files with 1,919 additions and 2,386 deletions.

This file was deleted.

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

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.ray3k.stripe.FreeTypeSkin;

import hundun.gdxgame.corelib.base.BaseHundunGame;
import hundun.gdxgame.gamelib.base.LogicFrameHelper;
import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.gamelib.starter.listerner.ILogicFrameListener;
import hundun.gdxgame.idledemo.logic.*;
import hundun.gdxgame.gamelib.base.save.ISaveTool;
import hundun.gdxgame.idledemo.ui.screen.DemoScreenContext;
import hundun.gdxgame.idledemo.ui.shared.BaseIdleDemoScreen;
import hundun.gdxgame.idleshare.core.framework.StarterIdleFrontend;
import hundun.gdxgame.idleshare.gamelib.export.IdleGameplayExport;
import hundun.gdxgame.idleshare.gamelib.framework.data.ChildGameConfig;
import hundun.gdxgame.idleshare.gamelib.framework.model.buff.IBuffPrototypeLoader;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.TextFormatTool;
import lombok.Getter;
import lombok.Setter;

import java.util.List;


public class IdleDemoGame extends BaseHundunGame<RootSaveData> {
public static final int LOGIC_FRAME_PER_SECOND = 30;
@Getter
protected AudioPlayManager audioPlayManager;
@Getter
protected DemoGameDictionary demoGameDictionary;
@Getter
protected DemoTextureManager textureManager;
@Getter
protected TextFormatTool textFormatTool;

@Getter
protected Viewport sharedViewport;

@Getter
protected IdleGameplayExport idleGameplayExport;
@Getter
protected ChildGameConfig childGameConfig;
@Setter
@Getter
protected String lastScreenId;
@Getter
protected
List<String> controlBoardScreenIds;
@Getter
protected DemoScreenContext screenContext;


// /**
// * 作为新存档,也需要修改ModelContext
// */
// public void newSaveStarter(ManagerContext modelContext) {
// Collection<BaseConstruction> constructions = modelContext.getConstructionFactory().getConstructions();
// for (BaseConstruction construction : constructions) {
// construction.getSaveData().setLevel(starterData.getConstructionStarterLevelMap().getOrDefault(construction.getId(), 0));
// if (starterData.getConstructionStarterWorkingLevelMap().getOrDefault(construction.getId(), false)) {
// construction.getSaveData().setWorkingLevel(starterData.getConstructionStarterLevelMap().getOrDefault(construction.getId(), 0));
// }
// construction.updateModifiedValues();
// }
// }

@Override
public void dispose() {
super.dispose();

saveHandler.gameSaveCurrent();
}



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

this.sharedViewport = new ScreenViewport();
this.textFormatTool = new TextFormatTool();
this.saveHandler = new DemoSaveHandler(frontend, saveTool);
this.mainSkinFilePath = null;
this.textureManager = new DemoTextureManager();
this.screenContext = new DemoScreenContext(this);
this.audioPlayManager = new AudioPlayManager(this);
this.childGameConfig = new DemoChildGameConfig();

this.controlBoardScreenIds = JavaFeatureForGwt.listOf(
DemoScreenId.SCREEN_COOKIE,
DemoScreenId.SCREEN_WORLD,
DemoScreenId.SCREEN_ACHIEVEMENT
);
this.demoGameDictionary = new DemoGameDictionary();
}



@Override
protected void createStage1() {
super.createStage1();
this.mainSkin = new FreeTypeSkin(Gdx.files.internal("skins/DefaultSkinWithFreeType/DefaultSkinWithFreeType.json"));
this.idleGameplayExport = new IdleGameplayExport(
frontend,
new StarterIdleFrontend(this),
new DemoBuiltinConstructionsLoader(),
new DemoAchievementLoader(),
IBuffPrototypeLoader.emptyImpl(),
childGameConfig
);
this.getSaveHandler().registerSubHandler(idleGameplayExport);
saveHandler.systemSettingLoadOrStarter();
}

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

@Override
protected void createStage3() {
audioPlayManager.lazyInitOnGameCreate(childGameConfig.getScreenIdToFilePathMap());

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

@Override
protected void onLogicFrame(ILogicFrameListener source) {
source.onLogicFrame();
idleGameplayExport.onLogicFrame();
if (this.getLogicFrameHelper().getClockCount() % this.getLogicFrameHelper().secondToFrameNum(10) == 0)
{
this.getSaveHandler().gameSaveCurrent();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package hundun.gdxgame.idleshare.core.framework.model.manager;
package hundun.gdxgame.idledemo.logic;

import java.util.HashMap;
import java.util.Map;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.utils.Disposable;

import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idledemo.IdleDemoGame;

/**
* @author hundun
Expand All @@ -18,11 +17,11 @@ public class AudioPlayManager implements Disposable {
long currentBgmId;
Sound currentBgmSound;

BaseIdleGame game;
IdleDemoGame game;

Map<String, Sound> screenIdToSoundMap = new HashMap<>();

public AudioPlayManager(BaseIdleGame game) {
public AudioPlayManager(IdleDemoGame game) {
this.game = game;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package hundun.gdxgame.idledemo.logic;

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.AbstractAchievement;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.IBuiltinAchievementsLoader;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.OwnConstructionAchievement;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.AbstractAchievementPrototype;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.IAchievementPrototypeLoader;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.OwnConstructionAchievementPrototype;
import hundun.gdxgame.idleshare.gamelib.framework.model.resource.ResourcePair;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.Language;

Expand All @@ -12,42 +12,46 @@
import java.util.List;
import java.util.Map;

public class DemoAchievementLoader implements IBuiltinAchievementsLoader {
public class DemoAchievementLoader implements IAchievementPrototypeLoader {
@Override
public Map<String, AbstractAchievement> getProviderMap(Language language) {
public Map<String, AbstractAchievementPrototype> getProviderMap(Language language) {
Map<String, List<String>> textMap = new HashMap<>();
switch (language)
{
case CN:
textMap.put(DemoAchievementId.STEP_1, JavaFeatureForGwt.listOf(
"NO.1",
"拥有2级AUTO_PROVIDER。",
"你完成了任务NO.1。"
"拥有2级{PrototypeName}。",
"你完成了任务NO.1。",
DemoConstructionPrototypeId.COOKIE_SIMPLE_AUTO_PROVIDER
));
textMap.put(DemoAchievementId.STEP_2, JavaFeatureForGwt.listOf(
"NO.2",
"拥有2级AUTO_SELLER。",
"你完成了任务NO.2。"
"拥有2级{PrototypeName}。",
"你完成了任务NO.2。",
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER
));
break;
default:
textMap.put(DemoAchievementId.STEP_1, JavaFeatureForGwt.listOf(
"NO.1",
"Own lv.2 AUTO_PROVIDER.",
"You completed Quest NO.1."
"Own lv.2 {PrototypeName}.",
"You completed Quest NO.1.",
DemoConstructionPrototypeId.COOKIE_SIMPLE_AUTO_PROVIDER
));
textMap.put(DemoAchievementId.STEP_2, JavaFeatureForGwt.listOf(
"NO.2",
"Own lv.2 AUTO_SELLER.",
"You completed Quest NO.2."
"Own lv.2 {PrototypeName}.",
"You completed Quest NO.2.",
DemoConstructionPrototypeId.SINGLETON_COOKIE_AUTO_SELLER
));
break;
}



Map<String, AbstractAchievement> map = new HashMap<>();
OwnConstructionAchievement.Companion.quickAddOwnConstructionAchievement(
Map<String, AbstractAchievementPrototype> map = new HashMap<>();
OwnConstructionAchievementPrototype.Companion.quickAddOwnConstructionAchievement(
map,
DemoAchievementId.STEP_1,
textMap,
Expand All @@ -57,7 +61,7 @@ public Map<String, AbstractAchievement> getProviderMap(Language language) {
JavaFeatureForGwt.listOf(DemoAchievementId.STEP_2),
new ResourcePair(ResourceType.COIN, 1000L)
);
OwnConstructionAchievement.Companion.quickAddOwnConstructionAchievement(
OwnConstructionAchievementPrototype.Companion.quickAddOwnConstructionAchievement(
map,
DemoAchievementId.STEP_2,
textMap,
Expand Down
Loading

0 comments on commit d5b92c5

Please sign in to comment.