Skip to content

Commit

Permalink
update Achievement
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Sep 17, 2023
1 parent c8984f6 commit 324284c
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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.resource.ResourcePair;
import hundun.gdxgame.idleshare.gamelib.framework.util.text.Language;

import java.util.AbstractMap.SimpleEntry;
Expand Down Expand Up @@ -52,15 +53,17 @@ public Map<String, AbstractAchievement> getProviderMap(Language language) {
textMap,
JavaFeatureForGwt.mapOf(
ConstructionPrototypeId.COOKIE_AUTO_PROVIDER, new SimpleEntry<>(1, 2)
)
),
new ResourcePair(ResourceType.COIN, 1000L)
);
OwnConstructionAchievement.Companion.quickAddOwnConstructionAchievement(
map,
DemoAchievementId.STEP_2,
textMap,
JavaFeatureForGwt.mapOf(
ConstructionPrototypeId.COOKIE_AUTO_SELLER, new SimpleEntry<>(1, 2)
)
),
new ResourcePair(ResourceType.COIN, 1000L)
);
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@ public List<String> getAchievementTexts(Language language)
switch (language)
{
case CN:
return JavaFeatureForGwt.arraysAsList("当前任务:", "已完成:", "回到游戏");
return JavaFeatureForGwt.listOf(
"当前任务:", "已完成:", "回到游戏", "奖励内容:", "领取",
"无"
);
default:
return JavaFeatureForGwt.arraysAsList("Quest: ", "Completed: ", "back");
return JavaFeatureForGwt.listOf(
"Quest: ", "Completed: ", "back", "reward: ", "Get it",
"None"
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ protected void lazyInitUiRootContext() {
Table rightSideGroup = new Table();

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

gameAreaControlBoard = new GameAreaControlBoard<>(this);
rightSideGroup.add(gameAreaControlBoard).expand().right();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdlePlayScreen;
import hundun.gdxgame.idleshare.gamelib.framework.model.manager.AchievementManager.AchievementInfoPackage;

import java.util.List;

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

BaseIdlePlayScreen<T_GAME, T_SAVE> parent;
Expand All @@ -18,10 +20,13 @@ public class FirstLockedAchievementBoardVM<T_GAME extends BaseIdleGame<T_SAVE>,
Label countStartLabel;
Label countValueLabel;

List<String> texts;

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


Expand All @@ -36,8 +41,8 @@ public FirstLockedAchievementBoardVM(BaseIdlePlayScreen<T_GAME, T_SAVE> parent)
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));
nameStartLabel.setText(texts.get(0));
countStartLabel.setText(texts.get(1));
updateData();
}

Expand All @@ -51,8 +56,8 @@ private void updateData()
}
else
{
nameValueLabel.setText("已完成");
descriptionLabel.setText("无");
nameValueLabel.setText("");
descriptionLabel.setText(texts.get(5));
}

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;

import com.badlogic.gdx.utils.Null;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdlePlayScreen;
import hundun.gdxgame.idleshare.gamelib.framework.model.achievement.AbstractAchievement;
import hundun.gdxgame.idleshare.gamelib.framework.model.resource.ResourcePair;

import java.util.List;

/**
* @author hundun
Expand All @@ -23,29 +27,57 @@
public class AchievementMaskBoard<T_GAME extends BaseIdleGame<T_SAVE>, T_SAVE> extends Table {

BaseIdlePlayScreen<T_GAME, T_SAVE> parent;
Label label;

public AchievementMaskBoard(BaseIdlePlayScreen<T_GAME, T_SAVE> parent) {

List<String> texts;

public AchievementMaskBoard(BaseIdlePlayScreen<T_GAME, T_SAVE> parent, List<String> texts) {
this.parent = parent;
this.texts = texts;
this.setBackground(new SpriteDrawable(new Sprite(parent.getGame().getTextureManager().getAchievementMaskBoardTexture())));
this.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
rebuildUi(null);
this.setVisible(false);

}

private void rebuildUi(@Null AbstractAchievement prototype) {
this.clearChildren();

label = new Label("", parent.getGame().getMainSkin());
Label label = new Label(prototype != null ? prototype.getDescription() : "", parent.getGame().getMainSkin());
this.add(label).center().row();

Button textButton = new TextButton("continue", parent.getGame().getMainSkin());
if (prototype != null && prototype.getAwardResourceMap() != null) {
Label rewardLabel = new Label(texts.get(3), parent.getGame().getMainSkin());
this.add(rewardLabel).center().row();
for (ResourcePair entry : prototype.getAwardResourceMap()) {
ResourceAmountPairNode<T_GAME> node = new ResourceAmountPairNode<>(parent.getGame(), entry.getType());
node.update(entry.getAmount());
this.add(node)
.height(parent.getLayoutConst().RESOURCE_AMOUNT_PAIR_NODE_HEIGHT)
.width(parent.getLayoutConst().RESOURCE_AMOUNT_PAIR_NODE_WIDTH);
this.row();
}
}

Button textButton = new TextButton(texts.get(4), parent.getGame().getMainSkin());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (prototype != null && prototype.getAwardResourceMap() != null)
{
parent.getGame().getIdleGameplayExport().getGameplayContext().getStorageManager().modifyAllResourceNum(prototype.getAwardResourceMap(), true);
}
parent.hideAchievementMaskBoard();
}
});
this.add(textButton).center();
}

this.setVisible(false);

}
public void setAchievementPrototype(AbstractAchievement prototype) {
label.setText(prototype.getDescription());

rebuildUi(prototype);

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* Created on 2021/11/08
*/
public class PopupInfoBoard<T_GAME extends BaseIdleGame<T_SAVE>, T_SAVE> extends Table {
private static int NODE_HEIGHT = 25;
private static int NODE_WIDTH = 70;

BaseIdlePlayScreen<T_GAME, T_SAVE> parent;

Expand Down Expand Up @@ -74,7 +72,9 @@ private void buildOnePack(ResourcePack pack) {
for (ResourcePair entry : pack.getModifiedValues()) {
ResourceAmountPairNode<T_GAME> node = new ResourceAmountPairNode<>(parent.getGame(), entry.getType());
node.update(entry.getAmount());
this.add(wapperContainer(node)).height(NODE_HEIGHT).width(NODE_WIDTH);
this.add(wapperContainer(node))
.height(parent.getLayoutConst().RESOURCE_AMOUNT_PAIR_NODE_HEIGHT)
.width(parent.getLayoutConst().RESOURCE_AMOUNT_PAIR_NODE_WIDTH);
}
this.row();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ public void clicked(InputEvent event, float x, float y) {
model.getLevelComponent().changeWorkingLevel(-1);
}
});
changeWorkingLevelGroup.add(downWorkingLevelButton).size(CHILD_WIDTH / 4, CHILD_HEIGHT);
changeWorkingLevelGroup.add(downWorkingLevelButton).size(CHILD_WIDTH / 4.0f, CHILD_HEIGHT);

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

this.upWorkingLevelButton = new TextButton("+", parent.getGame().getMainSkin());
upWorkingLevelButton.addListener(new ClickListener() {
Expand All @@ -130,7 +130,7 @@ public void clicked(InputEvent event, float x, float y) {
model.getLevelComponent().changeWorkingLevel(1);
}
});
changeWorkingLevelGroup.add(upWorkingLevelButton).size(CHILD_WIDTH / 4, CHILD_HEIGHT);
changeWorkingLevelGroup.add(upWorkingLevelButton).size(CHILD_WIDTH / 4.0f, CHILD_HEIGHT);

this.proficiencyLabel = new Label("", parent.getGame().getMainSkin());
this.positionLabel = new Label("", parent.getGame().getMainSkin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected int initChild(int areaShownConstructionsSize) {
childTable.clearChildren();

for (int i = 0; i < childrenSize; i++) {
ConstructionControlNode constructionView = new ConstructionControlNode(parent, callback, i, parent.getLayoutConst());
ConstructionControlNode<T_GAME, T_SAVE> constructionView = new ConstructionControlNode<>(parent, callback, i, parent.getLayoutConst());
constructionControlNodes.add(constructionView);
childTable.add(constructionView).spaceRight(10).expand();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;

import hundun.gdxgame.corelib.base.util.DrawableFactory;
import hundun.gdxgame.idleshare.core.framework.BaseIdleGame;
import hundun.gdxgame.idleshare.core.starter.ui.component.board.construction.AbstractConstructionControlBoard;
import hundun.gdxgame.idleshare.core.starter.ui.component.board.construction.impl.ConstructionControlNode;
import hundun.gdxgame.idleshare.core.starter.ui.screen.play.BaseIdlePlayScreen;
Expand All @@ -18,7 +19,7 @@
* @author hundun
* Created on 2021/11/05
*/
public class ScrollConstructionControlBoard extends AbstractConstructionControlBoard {
public class ScrollConstructionControlBoard<T_GAME extends BaseIdleGame<T_SAVE>, T_SAVE> extends AbstractConstructionControlBoard<T_GAME, T_SAVE> {



Expand All @@ -35,7 +36,7 @@ public class ScrollConstructionControlBoard extends AbstractConstructionControlB



public ScrollConstructionControlBoard(BaseIdlePlayScreen<?, ?> parent, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
public ScrollConstructionControlBoard(BaseIdlePlayScreen<T_GAME, T_SAVE> parent, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
super(parent, callback);

this.LR_BUTTON_HEIGHT = parent.getLayoutConst().CONSTRUCION_BOARD_ROOT_BOX_HEIGHT;
Expand Down Expand Up @@ -76,17 +77,16 @@ public void clicked(InputEvent event, float x, float y) {

@Override
protected int initChild(int areaShownConstructionsSize) {
int childrenSize = areaShownConstructionsSize;

constructionControlNodes.clear();
childTable.clearChildren();

for (int i = 0; i < childrenSize; i++) {
ConstructionControlNode constructionView = new ConstructionControlNode(parent, callback, i, parent.getLayoutConst());
for (int i = 0; i < areaShownConstructionsSize; i++) {
ConstructionControlNode<T_GAME, T_SAVE> constructionView = new ConstructionControlNode<>(parent, callback, i, parent.getLayoutConst());
constructionControlNodes.add(constructionView);
childTable.add(constructionView).spaceRight(10).expand();
}
return childrenSize;
return areaShownConstructionsSize;
}


Expand Down
Loading

0 comments on commit 324284c

Please sign in to comment.