93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import MyModel from "../core/MyModel";
|
|
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|
import FGUtil, { TipAlign } from "../gear_2.3.4/fgui/FGUtil";
|
|
import SKSocket from "../gear_2.3.4/net/SKSocket";
|
|
import GameModel from "../core/GameModel";
|
|
import MsgAlert from "../game/msg/MsgAlert";
|
|
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
|
|
import ItemUtil from "../core/ItemUtil";
|
|
import GameUtil from "../core/GameUtil";
|
|
import SkillUtil from "../game/skill/core/SkillUtil";
|
|
import SkillBase, { ESkillQuality } from "../game/skill/core/SkillBase";
|
|
import FGAlert from "../gear_2.3.4/fgui/FGAlert";
|
|
import SKLogger from "../gear_2.3.4/util/SKLogger";
|
|
import { LongPressSpeedProp } from "../core/EEnum";
|
|
import AdoptPannel from "./AdoptPannel";
|
|
import BabyMgrPannel from "./BabyMgrPannel";
|
|
import BabyList from "./BabyList";
|
|
import SKAnimation from "../gear_2.3.4/gui/SKAnimation";
|
|
|
|
export default class NurtureHome extends cc.Component {
|
|
static shared = new NurtureHome();
|
|
main: fgui.GComponent;
|
|
|
|
|
|
show() {
|
|
this.loadUI();
|
|
}
|
|
|
|
hide() {
|
|
FGUtil.dispose(this.main);
|
|
this.unscheduleAllCallbacks()
|
|
this.main = null;
|
|
}
|
|
|
|
loadUI() {
|
|
FGUtil.dispose(this.main);
|
|
this.unscheduleAllCallbacks()
|
|
this.main = fgui.UIPackage.createObject("main_ui", "home_main").asCom;
|
|
FGUtil.root().addChild(this.main);
|
|
FGUtil.fitScreen(this.main);
|
|
this.initUI();
|
|
this.initEvent();
|
|
// this.loadHorseSkill();
|
|
}
|
|
|
|
|
|
initUI(){
|
|
let name = GameModel.player.name
|
|
this.main.getChild("homeName").asLabel.text = `${name}的家園`
|
|
this.main.getChild("childName").asLabel.text = `${name}的寶貝`
|
|
|
|
this.main.getChild("close").onClick(this.hide, this)
|
|
this.main.getChild("btnEnterRoom").onClick(this.onClickEnterRoom, this)
|
|
this.main.getChild("btnRaise").onClick(this.onClickRaise, this)
|
|
this.main.getChild("btn_more").onClick(this.onClickAdopt, this)
|
|
|
|
let baby = MyModel.shared.BabyList.GetBattleBaby()
|
|
if (baby != null){
|
|
this.onBabyBattle(baby)
|
|
}
|
|
}
|
|
|
|
onClickEnterRoom(){
|
|
let gameLogic = cc.find("Canvas").getComponent("GameLogic")
|
|
gameLogic.mapLogic.changeMap(4001);
|
|
this.hide()
|
|
}
|
|
|
|
onClickRaise(){
|
|
if (MyModel.shared.BabyList.GetBabyCount() == 0){
|
|
MsgAlert.addMsg("請先領取寶寶, 才能進行培養!")
|
|
return
|
|
}
|
|
BabyMgrPannel.shared.show()
|
|
}
|
|
|
|
onClickAdopt(){
|
|
if(MyModel.shared.BabyList.GetBabyCount() == 3){
|
|
MsgAlert.addMsg("抱歉, 你只能領取三個小孩!")
|
|
return
|
|
}
|
|
AdoptPannel.shared.show()
|
|
}
|
|
|
|
onBabyBattle(baby){
|
|
if (this.main == null) return
|
|
this.main.getController("ctrl_hasChild").selectedIndex = baby.Attr.sex + 1;
|
|
}
|
|
|
|
initEvent(){
|
|
|
|
}
|
|
} |