Skip to content

Commit

Permalink
add Achievement impl; some rename
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Sep 10, 2023
1 parent 1774488 commit 2879b5c
Show file tree
Hide file tree
Showing 29 changed files with 456 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package hundun.gdxgame.idledemo;

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.logic.ConstructionPrototypeId;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.DemoAchievementId;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.ui.screen.DemoMenuScreen;
import hundun.gdxgame.idledemo.ui.screen.CookiePlayScreen;
Expand All @@ -34,7 +34,7 @@ public DemoChildGameConfig() {

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

Expand All @@ -60,7 +60,10 @@ public DemoChildGameConfig() {
);
this.setScreenIdToFilePathMap(screenIdToFilePathMap);

this.setAchievementPrototypeIds(new ArrayList<>());
this.setAchievementPrototypeIds(JavaFeatureForGwt.listOf(
DemoAchievementId.STEP_1,
DemoAchievementId.STEP_2
));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public class ConstructionPrototypeId {
public static final String 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 DIRT = "ENUM_CSTR@DIRT";
public static final String EMPTY_CELL = "ENUM_CSTR@EMPTY";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package hundun.gdxgame.idledemo.logic;

public class DemoAchievementId {
public static final String STEP_1 = "ENUM_ACHI@STEP_1";
public static final String STEP_2 = "ENUM_ACHI@STEP_2";
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
package hundun.gdxgame.idledemo.logic;

import hundun.gdxgame.idleshare.gamelib.framework.model.AbstractAchievement;
import hundun.gdxgame.idleshare.gamelib.framework.model.IBuiltinAchievementsLoader;
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.util.text.Language;

import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DemoAchievementLoader implements IBuiltinAchievementsLoader {
@Override
public Map<String, AbstractAchievement> getProviderMap(Language language) {
return new HashMap<>();
Map<String, List<String>> textMap = new HashMap<>();
switch (language)
{
case CN:
textMap.put(DemoAchievementId.STEP_1, JavaFeatureForGwt.listOf(
"NO.1",
"拥有两个小森林。",
"你完成了任务NO.1。"
));
textMap.put(DemoAchievementId.STEP_2, JavaFeatureForGwt.listOf(
"NO.2",
"拥有两个小工厂。",
"你完成了任务NO.2。"
));
break;
default:
textMap.put(DemoAchievementId.STEP_1, JavaFeatureForGwt.listOf(
"NO.1",
"Own two small forests.",
"You completed Quest NO.1.\nThank you for your tireless efforts to protect our planet and make it a better place for future generations."
));
textMap.put(DemoAchievementId.STEP_2, JavaFeatureForGwt.listOf(
"NO.2",
"Own two small factories.",
"You completed Quest NO.2.\nWe are thrilled to see the positive impact on our local economy with more jobs and increased business opportunities. Thank you to all who have contributed to our economic success."
));
break;
}



Map<String, AbstractAchievement> map = new HashMap<>();
OwnConstructionAchievement.Companion.quickAddOwnConstructionAchievement(
map,
DemoAchievementId.STEP_1,
textMap,
JavaFeatureForGwt.mapOf(
ConstructionPrototypeId.COOKIE_AUTO_SELLER, new SimpleEntry<>(1, 2)
)
);
OwnConstructionAchievement.Companion.quickAddOwnConstructionAchievement(
map,
DemoAchievementId.STEP_2,
textMap,
JavaFeatureForGwt.mapOf(
ConstructionPrototypeId.COOKIE_AUTO_SELLER, new SimpleEntry<>(1, 2)
)
);
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
import java.util.List;
import java.util.Map;

import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.logic.prototype.CookieAutoProviderPrototype;
import hundun.gdxgame.idledemo.logic.prototype.CookieAutoSellerPrototype;
import hundun.gdxgame.idledemo.logic.prototype.CookieClickProviderPrototype;
import hundun.gdxgame.idledemo.logic.prototype.DirtPrototype;
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;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.LevelComponent;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.OutputComponent;
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.Language;
Expand All @@ -27,7 +21,7 @@ public class DemoBuiltinConstructionsLoader implements IBuiltinConstructionsLoad
@Override
public Map<String, AbstractConstructionPrototype> getProviderMap(Language language) {
Map<String, AbstractConstructionPrototype> result = new HashMap<>();
result.put(ConstructionPrototypeId.DIRT, new DirtPrototype(language));
result.put(ConstructionPrototypeId.EMPTY_CELL, new DirtPrototype(language));
result.put(ConstructionPrototypeId.COOKIE_CLICK_PROVIDER, new CookieClickProviderPrototype(language));
result.put(ConstructionPrototypeId.COOKIE_AUTO_PROVIDER, new CookieAutoProviderPrototype(language));
result.put(ConstructionPrototypeId.COOKIE_AUTO_SELLER, new CookieAutoSellerPrototype(language));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ public String constructionPrototypeIdToDetailDescroptionConstPart(Language langu
switch (constructionId) {
case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "自动获得饼干";
case ConstructionPrototypeId.EMPTY_CELL:
return "空位置";
default:
return "[dic lost]";
}
default:
switch (constructionId) {
case ConstructionPrototypeId.COOKIE_AUTO_PROVIDER:
return "Auto gain some cookie";
case ConstructionPrototypeId.EMPTY_CELL:
return "Empty";
default:
return "[dic lost]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ protected RootSaveData genereateStarterRootSaveData() {
);
dirtGridPositions.forEach(it -> {
map.put(
ConstructionPrototypeId.DIRT + "_" + UUID.randomUUID().toString(),
ConstructionPrototypeId.EMPTY_CELL + "_" + UUID.randomUUID().toString(),
ConstructionSaveData.builder()
.prototypeId(ConstructionPrototypeId.DIRT)
.prototypeId(ConstructionPrototypeId.EMPTY_CELL)
.level(0)
.workingLevel(0)
.position(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void lazyInitOnGameCreateStage2() {
Texture texture = new Texture(Gdx.files.internal("CellIcons.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 675, 733);
defaultAreaBack = regions[0][1];
constructionHexImageMap.put(ConstructionPrototypeId.DIRT, regions[0][0]);
constructionHexImageMap.put(ConstructionPrototypeId.EMPTY_CELL, regions[0][0]);
constructionHexImageMap.put(ConstructionPrototypeId.COOKIE_CLICK_PROVIDER, regions[1][0]);
constructionHexImageMap.put(ConstructionPrototypeId.COOKIE_AUTO_PROVIDER, regions[1][3]);
constructionHexImageMap.put(ConstructionPrototypeId.COOKIE_AUTO_SELLER, regions[2][1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.idledemo.logic.ConstructionPrototypeId;
import hundun.gdxgame.idledemo.logic.DemoBuiltinConstructionsLoader;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.logic.construction.BaseIdleDemoConstruction;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.AbstractConstructionPrototype;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction;
Expand All @@ -12,7 +11,6 @@
import hundun.gdxgame.idleshare.gamelib.framework.model.grid.GridPosition;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.Language;

import java.util.HashMap;
import java.util.UUID;

public class DirtPrototype extends AbstractConstructionPrototype {
Expand All @@ -29,7 +27,7 @@ public class DirtPrototype extends AbstractConstructionPrototype {

public DirtPrototype(Language language) {
super(
ConstructionPrototypeId.DIRT,
ConstructionPrototypeId.EMPTY_CELL,
language,
DemoBuiltinConstructionsLoader.toPack(JavaFeatureForGwt.mapOf())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package hundun.gdxgame.idledemo.ui.screen;

import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import hundun.gdxgame.gamelib.base.util.JavaFeatureForGwt;
import hundun.gdxgame.gamelib.starter.listerner.IGameAreaChangeListener;
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idledemo.ui.entity.HexCellVM;
import hundun.gdxgame.idledemo.ui.sub.FirstLockedAchievementBoardVM;
import hundun.gdxgame.idledemo.ui.world.HexCellVM;
import hundun.gdxgame.idleshare.core.starter.ui.component.GameAreaControlBoard;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdlePlayScreen;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.PlayScreenLayoutConst;

import java.util.Map;

public abstract class BaseDemoPlayScreen extends BaseIdlePlayScreen<DemoIdleGame, RootSaveData> implements IGameAreaChangeListener {

protected FirstLockedAchievementBoardVM<DemoIdleGame, RootSaveData> firstLockedAchievementBoardVM;

public BaseDemoPlayScreen(DemoIdleGame game) {
super(game, customLayoutConst(game));
}
Expand Down Expand Up @@ -43,6 +48,22 @@ protected void lazyInitLogicContext() {
super.lazyInitLogicContext();

gameAreaChangeListeners.add(this);
gameAreaChangeListeners.add(firstLockedAchievementBoardVM);
}

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

Table rightSideGroup = new Table();

firstLockedAchievementBoardVM = new FirstLockedAchievementBoardVM<>(this);
rightSideGroup.add(firstLockedAchievementBoardVM).expandX().height(200).row();

gameAreaControlBoard = new GameAreaControlBoard<>(this);
rightSideGroup.add(gameAreaControlBoard).expand().right();

uiRootTable.add(rightSideGroup).expand().right().row();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.logic.RootSaveData;
import hundun.gdxgame.idledemo.ui.entity.HexCellVM;
import hundun.gdxgame.idledemo.ui.world.HexCellVM;
import hundun.gdxgame.idledemo.ui.entity.GameEntityFactory;
import hundun.gdxgame.idleshare.core.framework.model.manager.GameEntityManager;
import hundun.gdxgame.idleshare.core.starter.ui.component.GameImageDrawer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import hundun.gdxgame.idledemo.DemoIdleGame;
import hundun.gdxgame.idledemo.logic.GameArea;
import hundun.gdxgame.idledemo.logic.ResourceType;
import hundun.gdxgame.idledemo.ui.entity.HexCellVM;
import hundun.gdxgame.idledemo.ui.entity.HexAreaVM;
import hundun.gdxgame.idledemo.ui.world.HexCellVM;
import hundun.gdxgame.idledemo.ui.world.HexAreaVM;
import hundun.gdxgame.idledemo.ui.world.WorldCellDetailBoardVM;
import hundun.gdxgame.idleshare.core.framework.model.CameraDataPackage;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction;
Expand Down Expand Up @@ -100,6 +100,6 @@ protected InputProcessor provideDefaultInputProcessor() {

@Override
public void onDeskClicked(HexCellVM vm) {
worldCellDetailBoardVM.updateDetail(vm.getDeskData());
worldCellDetailBoardVM.updateDetail(vm != null ? vm.getDeskData() : null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package hundun.gdxgame.idledemo.ui.sub;

import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import hundun.gdxgame.gamelib.starter.listerner.IGameAreaChangeListener;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdlePlayScreen;
import hundun.gdxgame.idleshare.gamelib.framework.model.manager.AchievementManager.AchievementInfoPackage;

public class FirstLockedAchievementBoardVM<T_GAME extends BaseIdleGame<T_SAVE>, T_SAVE> extends Table implements IGameAreaChangeListener {

BaseIdlePlayScreen<T_GAME, T_SAVE> parent;

Label nameStartLabel;
Label nameValueLabel;
Label descriptionLabel;
Label countStartLabel;
Label countValueLabel;


public FirstLockedAchievementBoardVM(BaseIdlePlayScreen<T_GAME, T_SAVE> parent)
{
this.parent = parent;
this.setBackground(new TextureRegionDrawable(parent.getGame().getTextureManager().getDefaultBoardNinePatchTexture()));


nameStartLabel = new Label("", parent.getGame().getMainSkin());
this.add(nameStartLabel).center();
nameValueLabel = new Label("", parent.getGame().getMainSkin());
this.add(nameValueLabel).center().row();
descriptionLabel = new Label("", parent.getGame().getMainSkin());
this.add(descriptionLabel).center().row();
countStartLabel = new Label("", parent.getGame().getMainSkin());
this.add(countStartLabel).center().row();
countValueLabel = new Label("", parent.getGame().getMainSkin());
this.add(countValueLabel).center().row();

nameStartLabel.setText(parent.getGame().getIdleGameplayExport().getGameDictionary().getAchievementTexts(parent.getGame().getIdleGameplayExport().getLanguage()).get(0));
countStartLabel.setText(parent.getGame().getIdleGameplayExport().getGameDictionary().getAchievementTexts(parent.getGame().getIdleGameplayExport().getLanguage()).get(1));
updateData();
}

private void updateData()
{
AchievementInfoPackage data = parent.getGame().getIdleGameplayExport().getGameplayContext().getAchievementManager().getAchievementInfoPackage();
if (data.getFirstLockedAchievement() != null)
{
nameValueLabel.setText(data.getFirstLockedAchievement().getName());
descriptionLabel.setText(data.getFirstLockedAchievement().getDescription());
}
else
{
nameValueLabel.setText("已完成");
descriptionLabel.setText("无");
}

countValueLabel.setText(" " + data.getUnLockedSize() + "/" + data.getTotal());


}

@Override
public void onGameAreaChange(String last, String current) {
updateData();
}
}
Loading

0 comments on commit 2879b5c

Please sign in to comment.