200 lines
7.0 KiB
TypeScript
200 lines
7.0 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 Baby from "./Baby";
|
|||
|
|
|||
|
export default class CarePannel extends cc.Component {
|
|||
|
static shared = new CarePannel();
|
|||
|
main: fgui.GComponent;
|
|||
|
config: any
|
|||
|
Baby: Baby
|
|||
|
|
|||
|
Type: number
|
|||
|
Index: number
|
|||
|
|
|||
|
static learnning = "[color=#2AAC57]{type=氣質}:[/color]" +
|
|||
|
"[color=#2AAC57]+{value=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curvaule=0})[/color]\n" +
|
|||
|
"[color=#FE7574]疲勞:[/color]" +
|
|||
|
"[color=#FE7574]+{pilao=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curpilao=0})[/color]"
|
|||
|
|
|||
|
static practice = "[color=#2AAC57]名氣:[/color]" +
|
|||
|
"[color=#2AAC57]+{mingqi=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curmingqi=0})[/color]\n" +
|
|||
|
"[color=#2AAC57]道德:[/color]" +
|
|||
|
"[color=#2AAC57]+{daode=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curdaode=0})[/color]\n" +
|
|||
|
"[color=#2AAC57]叛逆:[/color]" +
|
|||
|
"[color=#2AAC57]+{panni=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curpanni=0})[/color]\n" +
|
|||
|
"[color=#FE7574]疲勞:[/color]" +
|
|||
|
"[color=#FE7574]+{pilao=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curpilao=0})[/color]"
|
|||
|
|
|||
|
static enjoy = "[color=#FE7574]疲勞:[/color]" +
|
|||
|
"[color=#FE7574]{pilao=100}[/color]" +
|
|||
|
"[color=#BE9072](當前{curpilao=0})[/color]"
|
|||
|
|
|||
|
static learnPlace = ["音律", "習武", "研讀", "修行"]
|
|||
|
static practicePlace = ["家務", "留香閣", "禦花園", "酒樓", "丹房"]
|
|||
|
static enjoyPlayce = ["休息", "海灘", "踏青", "遊藝坊", "狩獵", "探險", "賞雪"]
|
|||
|
show(baby: Baby) {
|
|||
|
this.Baby = baby
|
|||
|
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_peiyang").asCom;
|
|||
|
FGUtil.root().addChild(this.main);
|
|||
|
FGUtil.fitScreen(this.main);
|
|||
|
this.initUI();
|
|||
|
this.initEvent();
|
|||
|
// this.loadHorseSkill();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
initUI() {
|
|||
|
this.main.getChild("close").onClick(this.hide, this)
|
|||
|
|
|||
|
let rich = FGUtil.getRichTextField(this.main, "txt_attr")
|
|||
|
rich.ubbEnabled = true
|
|||
|
this.onClickType(0)
|
|||
|
}
|
|||
|
|
|||
|
initEvent() {
|
|||
|
FGUtil.getButton(this.main, "n10").onClick(this.onClickType.bind(this, 0))
|
|||
|
FGUtil.getButton(this.main, "n11").onClick(this.onClickType.bind(this, 1))
|
|||
|
FGUtil.getButton(this.main, "n12").onClick(this.onClickType.bind(this, 2))
|
|||
|
|
|||
|
for (let index = 0; index < 4; index++) {
|
|||
|
FGUtil.getButton(this.main, "n13/btn" + (index + 1)).onClick(this.onClickLearn.bind(this, index))
|
|||
|
}
|
|||
|
|
|||
|
for (let index = 0; index < 5; index++) {
|
|||
|
FGUtil.getButton(this.main, "n14/btn" + (index + 1)).onClick(this.onClickPractice.bind(this, index))
|
|||
|
}
|
|||
|
|
|||
|
for (let index = 0; index < 7; index++) {
|
|||
|
FGUtil.getButton(this.main, "n15/btn" + (index + 1)).onClick(this.onClickEnjoy.bind(this, index))
|
|||
|
}
|
|||
|
FGUtil.getButton(this.main, "btnGetGirl").onClick(this.onClickCare.bind(this, 2))
|
|||
|
}
|
|||
|
|
|||
|
onBabyPractice(baby){
|
|||
|
if(this.main == null) return
|
|||
|
if (this.Type == 0){
|
|||
|
this.onClickLearn(this.Index)
|
|||
|
}
|
|||
|
|
|||
|
if (this.Type == 1){
|
|||
|
this.onClickPractice(this.Index)
|
|||
|
}
|
|||
|
|
|||
|
if (this.Type == 2){
|
|||
|
this.onClickEnjoy(this.Index)
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
onClickType(type) {
|
|||
|
FGUtil.getControl(this.main, "ctrl_tab").selectedIndex = type
|
|||
|
if (type == 0) {
|
|||
|
this.onClickLearn(0)
|
|||
|
}
|
|||
|
|
|||
|
if (type == 1) {
|
|||
|
this.onClickPractice(0)
|
|||
|
}
|
|||
|
|
|||
|
if (type == 2) {
|
|||
|
this.onClickEnjoy(0)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
onClickCare(){
|
|||
|
GameModel.send("c2s_babyPractice", { id: this.Baby.ID, type: this.Type, class: this.Index });
|
|||
|
}
|
|||
|
|
|||
|
onClickLearn(index) {
|
|||
|
FGUtil.getControl(this.main, "n13/ctrl_select").selectedIndex = index
|
|||
|
|
|||
|
this.Type = 0
|
|||
|
this.Index = index
|
|||
|
FGUtil.getObject(this.main, "txt_name").asLabel.text = CarePannel.learnPlace[index]
|
|||
|
|
|||
|
let rich = FGUtil.getRichTextField(this.main, "txt_attr")
|
|||
|
let list = ["氣質", "耐力", "內力", "智力"]
|
|||
|
let name_list = ["qizhi", "naili", "neili", "zhili"]
|
|||
|
let attr_list = ["qualitites", "endurance", "internalForce", "intelligence"]
|
|||
|
let config = MyModel.shared.BabyList.GetBabyPracticeConfig(0, index)
|
|||
|
if (config != null) {
|
|||
|
rich.text = CarePannel.learnning
|
|||
|
rich.setVar("type", list[index])
|
|||
|
rich.setVar("value", config[name_list[index]])
|
|||
|
rich.setVar("curvaule", this.Baby.Attr[attr_list[index]].toString())
|
|||
|
rich.setVar("pilao", config["pilao"])
|
|||
|
rich.setVar("curpilao", this.Baby.Attr.busy.toString())
|
|||
|
rich.flushVars()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
onClickPractice(index) {
|
|||
|
FGUtil.getControl(this.main, "n14/ctrl_select").selectedIndex = index
|
|||
|
this.Type = 1
|
|||
|
this.Index = index
|
|||
|
FGUtil.getObject(this.main, "txt_name").asLabel.text = CarePannel.practicePlace[index]
|
|||
|
|
|||
|
let rich = FGUtil.getRichTextField(this.main, "txt_attr")
|
|||
|
let config = MyModel.shared.BabyList.GetBabyPracticeConfig(1, index)
|
|||
|
if (config != null) {
|
|||
|
rich.text = CarePannel.practice
|
|||
|
rich.setVar("mingqi", config["mingqi"])
|
|||
|
rich.setVar("daode", config["daode"])
|
|||
|
rich.setVar("panni", config["pani"])
|
|||
|
rich.setVar("pilao", config["pilao"])
|
|||
|
|
|||
|
rich.setVar("curmingqi", this.Baby.Attr.fame.toString())
|
|||
|
rich.setVar("curdaode", this.Baby.Attr.moral.toString())
|
|||
|
rich.setVar("curpanni", this.Baby.Attr.rebel.toString())
|
|||
|
rich.setVar("curpilao", this.Baby.Attr.busy.toString())
|
|||
|
rich.flushVars()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
onClickEnjoy(index) {
|
|||
|
FGUtil.getControl(this.main, "n15/ctrl_select").selectedIndex = index
|
|||
|
this.Type = 2
|
|||
|
this.Index = index
|
|||
|
|
|||
|
FGUtil.getObject(this.main, "txt_name").asLabel.text = CarePannel.enjoyPlayce[index]
|
|||
|
|
|||
|
let rich = FGUtil.getRichTextField(this.main, "txt_attr")
|
|||
|
let config = MyModel.shared.BabyList.GetBabyPracticeConfig(2, index)
|
|||
|
if (config != null) {
|
|||
|
rich.text = CarePannel.enjoy
|
|||
|
rich.setVar("pilao", config["pilao"])
|
|||
|
rich.setVar("curpilao", this.Baby.Attr.busy.toString())
|
|||
|
rich.flushVars()
|
|||
|
}
|
|||
|
}
|
|||
|
}
|