first commit
This commit is contained in:
131
assets/scripts/map/ui/ArmySelectItemLogic.ts
Normal file
131
assets/scripts/map/ui/ArmySelectItemLogic.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
import { _decorator, Component, Node, Label, Sprite, ProgressBar } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { ArmyCmd, ArmyData } from "../../general/ArmyProxy";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { GeneralCommonConfig, GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('ArmySelectItemLogic')
|
||||
export default class ArmySelectItemLogic extends Component {
|
||||
@property(Node)
|
||||
tipNode: Node = null;
|
||||
@property(Label)
|
||||
labelTip: Label = null;
|
||||
@property(Sprite)
|
||||
headIcon: Sprite = null;
|
||||
@property(Label)
|
||||
labelLv: Label = null;
|
||||
@property(Label)
|
||||
labelName: Label = null;
|
||||
@property(Label)
|
||||
labelState: Label = null;
|
||||
@property(Label)
|
||||
labelMorale: Label = null;
|
||||
@property(Label)
|
||||
labelSoldierCnt: Label = null;
|
||||
@property(Label)
|
||||
labelVice1: Label = null;
|
||||
@property(Label)
|
||||
labelVice2: Label = null;
|
||||
@property(ProgressBar)
|
||||
progressSoldier: ProgressBar = null;
|
||||
|
||||
protected _data: ArmyData = null;
|
||||
protected _cmd: number = 0;
|
||||
protected _toX: number = 0;
|
||||
protected _toY: number = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("update_army", this.onUpdateArmy, this);
|
||||
this.tipNode.active = false;
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected onUpdateArmy(armyData: ArmyData): void {
|
||||
if (armyData.id == this._data.id) {
|
||||
this.setArmyData(armyData, this._cmd, this._toX, this._toY);
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickItem(): void {
|
||||
if (this.tipNode.active == false) {
|
||||
ArmyCommand.getInstance().generalAssignArmy(this._data.id, this._cmd, this._toX, this._toY);
|
||||
EventMgr.emit("close_army_select_ui");
|
||||
} else {
|
||||
console.log("军队忙");
|
||||
}
|
||||
}
|
||||
|
||||
protected updateItem(): void {
|
||||
if (this._data && this._data.generals[0] != 0) {
|
||||
console.log("updateItem", this._data);
|
||||
let commonCfg: GeneralCommonConfig = GeneralCommand.getInstance().proxy.getCommonCfg();
|
||||
let generals: GeneralData[] = ArmyCommand.getInstance().getArmyGenerals(this._data);
|
||||
let firstGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[0].cfgId);
|
||||
let power: number = ArmyCommand.getInstance().getArmyPhysicalPowerByGenerals(generals);
|
||||
let curSoldierCnt: number = ArmyCommand.getInstance().getArmyCurSoldierCnt(this._data);
|
||||
let totalSoldierCnt: number = ArmyCommand.getInstance().getArmyTotalSoldierCntByGenerals(generals);
|
||||
|
||||
if (this._data.cmd == ArmyCmd.Conscript) {
|
||||
//体力不足
|
||||
this.tipNode.active = true;
|
||||
this.labelTip.string = "征兵中...";
|
||||
}else if (power < commonCfg.recovery_physical_power) {
|
||||
//体力不足
|
||||
this.tipNode.active = true;
|
||||
this.labelTip.string = "体力不足";
|
||||
} else if (this._data.soldiers[0] <= 0) {
|
||||
//兵力不足
|
||||
this.tipNode.active = true;
|
||||
this.labelTip.string = "主将兵力不足";
|
||||
} else if (this._data.state > 0) {
|
||||
//行军中
|
||||
this.tipNode.active = true;
|
||||
this.labelTip.string = "行军中...";
|
||||
} else if (this._data.cmd == ArmyCmd.Reclaim) {
|
||||
//屯田中
|
||||
this.tipNode.active = true;
|
||||
this.labelTip.string = "屯田中...";
|
||||
} else {
|
||||
this.tipNode.active = false;
|
||||
}
|
||||
|
||||
this.headIcon.getComponent(GeneralHeadLogic).setHeadId(generals[0].cfgId);
|
||||
this.labelLv.string = generals[0].level + "";
|
||||
this.labelName.string = firstGeneralCfg.name;
|
||||
this.labelState.string = ArmyCommand.getInstance().getArmyStateDes(this._data);
|
||||
this.labelSoldierCnt.string = curSoldierCnt + "/" + totalSoldierCnt;
|
||||
this.progressSoldier.progress = curSoldierCnt / totalSoldierCnt;
|
||||
|
||||
if (generals[1]) {
|
||||
let sencondGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[1].cfgId);
|
||||
this.labelVice1.string = sencondGeneralCfg.name;
|
||||
} else {
|
||||
this.labelVice1.string = "";
|
||||
}
|
||||
|
||||
if (generals[2]) {
|
||||
let thirdGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[2].cfgId);
|
||||
this.labelVice2.string = thirdGeneralCfg.name;
|
||||
} else {
|
||||
this.labelVice2.string = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setArmyData(data: ArmyData, cmd: number, x: number, y: number): void {
|
||||
this._data = data;
|
||||
this._cmd = cmd;
|
||||
this._toX = x;
|
||||
this._toY = y;
|
||||
// console.log("setArmyData", arguments);
|
||||
this.updateItem();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/ArmySelectItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/ArmySelectItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "6319e0b2-db18-4371-97ff-fda2ca7f92dd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
42
assets/scripts/map/ui/ArmySelectNodeLogic.ts
Normal file
42
assets/scripts/map/ui/ArmySelectNodeLogic.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { _decorator, Component, Node, Prefab, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { ArmyData } from "../../general/ArmyProxy";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import MapCommand from "../MapCommand";
|
||||
import ArmySelectItemLogic from "./ArmySelectItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('ArmySelectNodeLogic')
|
||||
export default class ArmySelectNodeLogic extends Component {
|
||||
@property(Node)
|
||||
armyContainer: Node = null;
|
||||
@property(Prefab)
|
||||
itemPrefab: Prefab = null;
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("close_army_select_ui", this.onClickBack, this);
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickBack(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public setData(cmd: number, x: number, y: number): void {
|
||||
this.armyContainer.removeAllChildren();
|
||||
let myCity: MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let armyList: ArmyData[] = ArmyCommand.getInstance().proxy.getArmyList(myCity.cityId);
|
||||
for (let i: number = 0; i < armyList.length; i++) {
|
||||
if (armyList[i] && armyList[i].generals[0] > 0) {
|
||||
let item: Node = instantiate(this.itemPrefab);
|
||||
item.parent = this.armyContainer;
|
||||
item.getComponent(ArmySelectItemLogic).setArmyData(armyList[i], cmd, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/ArmySelectNodeLogic.ts.meta
Normal file
11
assets/scripts/map/ui/ArmySelectNodeLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "34c19263-312a-43f7-ace3-113afe0500d6",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
82
assets/scripts/map/ui/CityAboutLogic.ts
Normal file
82
assets/scripts/map/ui/CityAboutLogic.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { _decorator, Component, Node, Prefab, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { ArmyData } from "../../general/ArmyProxy";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import CityArmyItemLogic from "./CityArmyItemLogic";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { CityAddition } from "./MapUIProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('CityAboutLogic')
|
||||
export default class CityAboutLogic extends Component {
|
||||
@property(Node)
|
||||
armyLayer: Node = null;
|
||||
@property(Prefab)
|
||||
armyItem: Prefab = null;
|
||||
|
||||
protected _armyCnt: number = 5;//队伍数量 固定值
|
||||
protected _cityData: MapCityData = null;
|
||||
protected _armyComps: CityArmyItemLogic[] = [];
|
||||
|
||||
protected onEnable(): void {
|
||||
this.initView();
|
||||
EventMgr.on("update_city_addition", this.onUpdateCityAdditon, this);
|
||||
}
|
||||
|
||||
protected onDisable(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected initView(): void {
|
||||
for (let i: number = 0; i < this._armyCnt; i++) {
|
||||
let item = instantiate(this.armyItem);
|
||||
item.parent = this.armyLayer;
|
||||
let comp: CityArmyItemLogic = item.getComponent(CityArmyItemLogic);
|
||||
comp.order = i + 1;
|
||||
this._armyComps.push(comp);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateCityAdditon(cityId: number): void {
|
||||
if (this._cityData.cityId == cityId) {
|
||||
this.updateArmyList();
|
||||
}
|
||||
}
|
||||
|
||||
protected updateArmyList(): void {
|
||||
let additon: CityAddition = MapUICommand.getInstance().proxy.getMyCityAddition(this._cityData.cityId);
|
||||
let armyList: ArmyData[] = ArmyCommand.getInstance().proxy.getArmyList(this._cityData.cityId);
|
||||
for (let i: number = 0; i < this._armyComps.length; i++) {
|
||||
if (i >= additon.armyCnt) {
|
||||
//未开启
|
||||
this._armyComps[i].isOpenedArmy(false, false);
|
||||
} else {
|
||||
//已开启
|
||||
this._armyComps[i].isOpenedArmy(true, false);
|
||||
this._armyComps[i].setArmyData(this._cityData.cityId, armyList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setData(data: MapCityData): void {
|
||||
this._cityData = data;
|
||||
this.updateArmyList();
|
||||
MapUICommand.getInstance().qryCityFacilities(this._cityData.cityId);
|
||||
}
|
||||
|
||||
|
||||
protected onClickFacility(): void {
|
||||
//设施
|
||||
EventMgr.emit("open_facility", this._cityData);
|
||||
}
|
||||
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
|
||||
EventMgr.emit("close_city_about", this._cityData);
|
||||
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/CityAboutLogic.ts.meta
Normal file
11
assets/scripts/map/ui/CityAboutLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "01d02052-cf3e-436a-8c3a-401ab77e916b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
155
assets/scripts/map/ui/CityArmyItemLogic.ts
Normal file
155
assets/scripts/map/ui/CityArmyItemLogic.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import { _decorator, Component, Node, Label, Sprite } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { ArmyCmd, ArmyData } from "../../general/ArmyProxy";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('CityArmyItemLogic')
|
||||
export default class CityArmyItemLogic extends Component {
|
||||
@property(Node)
|
||||
infoNode: Node = null;
|
||||
@property(Node)
|
||||
maskNode: Node = null;
|
||||
@property(Node)
|
||||
tipNode: Node = null;
|
||||
@property(Label)
|
||||
labelTip: Label = null;
|
||||
@property(Sprite)
|
||||
headIcon: Sprite = null;
|
||||
@property(Label)
|
||||
labelId: Label = null;
|
||||
@property(Label)
|
||||
labelState: Label = null;
|
||||
@property(Label)
|
||||
labelLv: Label = null;
|
||||
@property(Label)
|
||||
labelName: Label = null;
|
||||
@property(Label)
|
||||
labelArms: Label = null;
|
||||
@property(Label)
|
||||
labelSoldierCnt: Label = null;
|
||||
@property(Label)
|
||||
labelVice1: Label = null;
|
||||
@property(Label)
|
||||
labelVice2: Label = null;
|
||||
|
||||
public order: number = 0;
|
||||
protected _cityId: number = 0;
|
||||
protected _data: ArmyData = null;
|
||||
protected _isOpened: boolean = true;
|
||||
protected _isOut: boolean = true;
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("update_army", this.onUpdateArmy, this);
|
||||
this.tipNode.active = false;
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected onUpdateArmy(armyData: ArmyData): void {
|
||||
if (this._data && armyData.id == this._data.id) {
|
||||
this.setArmyData(this._cityId, armyData);
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickItem(): void {
|
||||
if (this.maskNode.active == false) {
|
||||
if(this._isOut){
|
||||
if(this._data){
|
||||
EventMgr.emit("open_army_setting", this._cityId, this._data.order);
|
||||
}
|
||||
}else{
|
||||
EventMgr.emit("open_army_setting", this._cityId, this.order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected updateItem(): void {
|
||||
|
||||
console.log("cityarmyitem:", this._data);
|
||||
|
||||
if(this._isOpened == false){
|
||||
return
|
||||
}
|
||||
|
||||
if (this._data && this._data.generals[0] != 0) {
|
||||
//有数据 并且配置了第一个将
|
||||
this.tipNode.active = false;
|
||||
this.infoNode.active = true;
|
||||
let generals: GeneralData[] = ArmyCommand.getInstance().getArmyGenerals(this._data);
|
||||
let firstGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[0].cfgId);
|
||||
let curSoldierCnt: number = ArmyCommand.getInstance().getArmyCurSoldierCnt(this._data);
|
||||
let totalSoldierCnt: number = ArmyCommand.getInstance().getArmyTotalSoldierCntByGenerals(generals);
|
||||
if (this._data.cmd == ArmyCmd.Reclaim) {
|
||||
//屯田中
|
||||
this.labelState.string = "屯田中...";
|
||||
} else if(this._data.cmd == ArmyCmd.Conscript){
|
||||
this.labelState.string = "征兵中...";
|
||||
} else if (this._data.cmd > 0) {
|
||||
this.labelState.string = "队伍外派中...";
|
||||
} else {
|
||||
this.labelState.string = "";
|
||||
}
|
||||
this.labelId.string = this.order + "";
|
||||
this.headIcon.getComponent(GeneralHeadLogic).setHeadId(generals[0].cfgId);
|
||||
this.labelLv.string = generals[0].level + "";
|
||||
this.labelName.string = firstGeneralCfg.name;
|
||||
this.labelSoldierCnt.string = curSoldierCnt + "/" + totalSoldierCnt;
|
||||
// this.labelArms.string = "";
|
||||
|
||||
if (generals[1]) {
|
||||
let sencondGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[1].cfgId);
|
||||
this.labelVice1.string = sencondGeneralCfg.name;
|
||||
} else {
|
||||
this.labelVice1.string = "无";
|
||||
}
|
||||
|
||||
if (generals[2]) {
|
||||
let thirdGeneralCfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(generals[2].cfgId);
|
||||
this.labelVice2.string = thirdGeneralCfg.name;
|
||||
} else {
|
||||
this.labelVice2.string = "无";
|
||||
}
|
||||
} else {
|
||||
if(this._isOut){
|
||||
this.tipNode.active = true;
|
||||
this.infoNode.active = false;
|
||||
this.labelTip.string = "暂无队伍";
|
||||
}else{
|
||||
this.tipNode.active = true;
|
||||
this.infoNode.active = false;
|
||||
this.labelTip.string = "点击编制队伍";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public isOpenedArmy(bool: boolean, isOut: boolean): void {
|
||||
this._isOpened = bool;
|
||||
this.infoNode.active = false;
|
||||
this.maskNode.active = !this._isOpened;
|
||||
this.tipNode.active = !this._isOpened;
|
||||
this._isOut = isOut;
|
||||
if (this._isOpened == false) {
|
||||
if (this._isOut){
|
||||
this.labelTip.string = " 等级" + this.order + "开启";
|
||||
}else{
|
||||
let desName: string = MapUICommand.getInstance().proxy.getFacilityCfgByType(13).name;
|
||||
this.labelTip.string = desName + " 等级" + this.order + "开启";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setArmyData(cityId: number, data: ArmyData): void {
|
||||
this._cityId = cityId;
|
||||
this._data = data;
|
||||
this.updateItem();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/CityArmyItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/CityArmyItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "ac85ee91-ac2f-46b3-b530-9160e9b5eb3a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
358
assets/scripts/map/ui/CityArmySettingLogic.ts
Normal file
358
assets/scripts/map/ui/CityArmySettingLogic.ts
Normal file
@@ -0,0 +1,358 @@
|
||||
import { _decorator, Component, Label, Node, Prefab, EditBox, Slider, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { ArmyCmd, ArmyData } from "../../general/ArmyProxy";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { GeneralCampType, GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import MapCommand from "../MapCommand";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import { CityAddition, CityAdditionType, Facility } from "./MapUIProxy";
|
||||
import CityGeneralItemLogic from "./CityGeneralItemLogic";
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import { Conscript } from "../../config/Basci";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('CityArmySettingLogic')
|
||||
export default class CityArmySettingLogic extends Component {
|
||||
@property(Label)
|
||||
labelId: Label = null;
|
||||
@property(Label)
|
||||
labelCost: Label = null;
|
||||
@property(Label)
|
||||
labelSoldierCnt: Label = null;
|
||||
@property(Label)
|
||||
labelSpeed: Label = null;
|
||||
@property(Label)
|
||||
labelAtkCity: Label = null;
|
||||
@property(Label)
|
||||
labelAddition: Label = null;
|
||||
@property(Label)
|
||||
labelAdditionTip: Label = null;
|
||||
@property(Node)
|
||||
additionTouchNode: Node = null;
|
||||
@property(Node)
|
||||
additionTipNode: Node = null;
|
||||
@property(Label)
|
||||
labelResCost: Label = null;
|
||||
@property(Node)
|
||||
generalLayer: Node = null;
|
||||
@property(Prefab)
|
||||
generalPrefab: Prefab = null;
|
||||
@property([EditBox])
|
||||
editBoxs: EditBox[] = [];
|
||||
@property([Slider])
|
||||
sliders: Slider[] = [];
|
||||
@property([Node])
|
||||
tipNodes: Node[] = [];
|
||||
|
||||
protected _generalCnt: number = 3;
|
||||
protected _order: number = 0;
|
||||
protected _cityId: number = 0;
|
||||
protected _cityData: MapCityData = null;
|
||||
protected _isUnlock: boolean = false;
|
||||
protected _data: ArmyData = null;
|
||||
protected _addition: CityAddition = null;
|
||||
protected _gengeralLogics: CityGeneralItemLogic[] = [];
|
||||
protected _soldiers: number[] = null;
|
||||
protected _totalSoldiers: number[] = null;
|
||||
protected _curConscripts: number[] = null;//当前征兵数
|
||||
|
||||
protected _conTimes: number[] = null;
|
||||
protected _conCnts: number[] = null;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.initView();
|
||||
this.additionTipNode.active = false;
|
||||
this.additionTouchNode.on(Node.EventType.TOUCH_START, this.onShowAdditionTip, this);
|
||||
this.additionTouchNode.on(Node.EventType.TOUCH_END, this.onHideAdditionTip, this);
|
||||
this.additionTouchNode.on(Node.EventType.TOUCH_CANCEL, this.onHideAdditionTip, this);
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this._gengeralLogics.length = 0;
|
||||
}
|
||||
|
||||
protected onEnable(): void {
|
||||
this._soldiers = [0, 0, 0];
|
||||
this._totalSoldiers = [0, 0, 0];
|
||||
this._curConscripts = [0, 0, 0];
|
||||
this._conTimes = [0, 0, 0];
|
||||
this._conCnts = [0, 0, 0];
|
||||
|
||||
EventMgr.on("update_army", this.onUpdateArmy, this);
|
||||
EventMgr.on("chosed_general", this.onChooseGeneral, this);
|
||||
EventMgr.on("update_city_addition", this.onUpdateAddition, this);
|
||||
}
|
||||
|
||||
protected onDisable(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._data = null;
|
||||
this._addition = null;
|
||||
this._cityData = null;
|
||||
}
|
||||
|
||||
protected initView(): void {
|
||||
for (let i: number = 0; i < this._generalCnt; i++) {
|
||||
let item: Node = instantiate(this.generalPrefab);
|
||||
item.parent = this.generalLayer;
|
||||
let comp: CityGeneralItemLogic = item.getComponent(CityGeneralItemLogic);
|
||||
comp.index = i;
|
||||
this._gengeralLogics.push(comp);
|
||||
}
|
||||
}
|
||||
|
||||
protected onShowAdditionTip(): void {
|
||||
if (this._data && this.labelAddition.string != "无") {
|
||||
this.additionTipNode.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected onHideAdditionTip(): void {
|
||||
this.additionTipNode.active = false;
|
||||
}
|
||||
|
||||
protected clearSoldiers(): void {
|
||||
for (let i: number = 0; i < this._generalCnt; i++) {
|
||||
this._soldiers[i] = 0;
|
||||
this._totalSoldiers[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateArmy(armyData: ArmyData): void {
|
||||
if (armyData.cityId == this._cityId && armyData.order == this._order) {
|
||||
this.setData(this._cityId, this._order);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateAddition(cityId: number): void {
|
||||
if (this._cityId == cityId) {
|
||||
this.setData(this._cityId, this._order);
|
||||
}
|
||||
}
|
||||
|
||||
protected onChooseGeneral(cfgData: any, curData: any, position: any): void {
|
||||
ArmyCommand.getInstance().generalDispose(this._cityData.cityId, curData.id, this._order, Number(position), this._cityData);
|
||||
}
|
||||
|
||||
protected updateView(): void {
|
||||
let comp: CityGeneralItemLogic = null;
|
||||
let generalData: GeneralData = null;
|
||||
let generalCfg: GeneralConfig = null;
|
||||
let isUnlock: boolean = false;
|
||||
let totalCost: number = 0;
|
||||
let soldierCnt: number = 0;
|
||||
let totalSoldierCnt: number = 0;
|
||||
this.clearSoldiers();
|
||||
if (this._isUnlock) {
|
||||
for (let i: number = 0; i < this._gengeralLogics.length; i++) {
|
||||
comp = this._gengeralLogics[i];
|
||||
generalData = null;
|
||||
isUnlock = true;
|
||||
if (i == 2) {
|
||||
//只有第二个副将才需要判断是否解锁
|
||||
isUnlock = this._addition.vanguardCnt >= this._order;
|
||||
}
|
||||
if (this._data && this._data.generals[i] > 0) {
|
||||
generalData = GeneralCommand.getInstance().proxy.getMyGeneral(this._data.generals[i]);
|
||||
generalCfg = GeneralCommand.getInstance().proxy.getGeneralCfg(generalData.cfgId);
|
||||
totalCost += generalCfg.cost;
|
||||
this._soldiers[i] = this._data.soldiers[i];
|
||||
this._totalSoldiers[i] = generalData.level * 100 + this._addition.soldierCnt;
|
||||
soldierCnt += this._soldiers[i];
|
||||
totalSoldierCnt += this._totalSoldiers[i];
|
||||
this._conTimes[i] = this._data.conTimes[i];
|
||||
this._conCnts[i] = this._data.conCnts[i];
|
||||
|
||||
}
|
||||
if (isUnlock == false || generalData == null) {
|
||||
this.tipNodes[i].active = true;
|
||||
this.editBoxs[i].node.active = false;
|
||||
this.sliders[i].node.active = false;
|
||||
} else {
|
||||
this.tipNodes[i].active = false;
|
||||
this.editBoxs[i].node.active = true;
|
||||
this.sliders[i].node.active = true;
|
||||
|
||||
let totalValue: number = this._totalSoldiers[i] - this._soldiers[i];
|
||||
if(this._data && this._data.cmd == ArmyCmd.Conscript){
|
||||
var can = this._conCnts[i] == 0
|
||||
this.sliders[i].enabled = can;
|
||||
this.editBoxs[i].string = "0";
|
||||
this.sliders[i].progress = 0;
|
||||
this.editBoxs[i].enabled = can;
|
||||
}else if(this._data && this._data.cmd > ArmyCmd.Idle || totalValue <= 0) {
|
||||
//不可征兵
|
||||
this.editBoxs[i].string = "0";
|
||||
this.sliders[i].progress = 0;
|
||||
this.editBoxs[i].enabled = false;
|
||||
this.sliders[i].enabled = false;
|
||||
this.setCurConscriptForIndex(i, 0);
|
||||
} else {
|
||||
this.editBoxs[i].enabled = true;
|
||||
this.sliders[i].enabled = true;
|
||||
let curValue: number = 0;
|
||||
if (this.editBoxs[i].string != "") {
|
||||
curValue = Math.max(0, Math.min(parseInt(this.editBoxs[i].string), totalValue));
|
||||
}
|
||||
this.setCurConscriptForIndex(i, curValue);
|
||||
}
|
||||
|
||||
}
|
||||
comp.setData(this._cityId, this._order, generalData, this._soldiers[i], this._totalSoldiers[i], this._conCnts[i], this._conTimes[i], isUnlock);
|
||||
}
|
||||
}
|
||||
this.labelId.string = "部队" + this._order;
|
||||
this.labelCost.string = totalCost + "/" + MapUICommand.getInstance().proxy.getMyCityCost(this._cityId);
|
||||
this.labelSoldierCnt.string = soldierCnt + "/" + totalSoldierCnt;
|
||||
this.labelAddition.string = "无";
|
||||
if (this._data) {
|
||||
let generals: GeneralData[] = ArmyCommand.getInstance().getArmyGenerals(this._data);
|
||||
let speed: number = ArmyCommand.getInstance().getArmySpeed(generals);
|
||||
this.labelSpeed.string = speed.toFixed(2);
|
||||
|
||||
let destroy: number = ArmyCommand.getInstance().getArmyDestroy(generals);
|
||||
this.labelAtkCity.string = destroy.toFixed(2);
|
||||
|
||||
let camp: number = ArmyCommand.getInstance().getArmyCamp(generals);
|
||||
if (camp > 0) {
|
||||
if (camp == GeneralCampType.Han && this._addition.han > 0) {
|
||||
this.labelAdditionTip.string = "汉阵营加成:" + this._addition.han;
|
||||
this.labelAddition.string = "阵营";
|
||||
} else if (camp == GeneralCampType.Qun && this._addition.han > 0) {
|
||||
this.labelAdditionTip.string = "群阵营加成:" + this._addition.qun;
|
||||
this.labelAddition.string = "阵营";
|
||||
} else if (camp == GeneralCampType.Wei && this._addition.han > 0) {
|
||||
this.labelAdditionTip.string = "魏阵营加成:" + this._addition.wei;
|
||||
this.labelAddition.string = "阵营";
|
||||
} else if (camp == GeneralCampType.Shu && this._addition.han > 0) {
|
||||
this.labelAdditionTip.string = "蜀阵营加成:" + this._addition.shu;
|
||||
this.labelAddition.string = "阵营";
|
||||
} else if (camp == GeneralCampType.Wu && this._addition.han > 0) {
|
||||
this.labelAdditionTip.string = "吴阵营加成:" + this._addition.wu;
|
||||
this.labelAddition.string = "阵营";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.labelSpeed.string = "0";
|
||||
}
|
||||
|
||||
this.updateResCost();
|
||||
}
|
||||
|
||||
protected setCurConscriptForIndex(index: number, cnt: number = 0): void {
|
||||
let maxCnt: number = this._totalSoldiers[index] - this._soldiers[index];
|
||||
cnt = Math.min(cnt, maxCnt);
|
||||
let percent: number = cnt / maxCnt;
|
||||
this.editBoxs[index].string = cnt + "";
|
||||
this.sliders[index].progress = percent;
|
||||
this._curConscripts[index] = cnt;
|
||||
}
|
||||
|
||||
protected getTotalConscriptCnt(): number {
|
||||
let totalCnt: number = 0;
|
||||
for (let i = 0; i < this._curConscripts.length; i++) {
|
||||
totalCnt += this._curConscripts[i];
|
||||
}
|
||||
return totalCnt;
|
||||
}
|
||||
|
||||
protected updateResCost(): void {
|
||||
let totalCnt: number = this.getTotalConscriptCnt();
|
||||
if (totalCnt > 0) {
|
||||
var myRoleRes = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
var baseCost: Conscript = MapUICommand.getInstance().proxy.getConscriptBaseCost();
|
||||
let str: string = "消耗: " + "金币:" + totalCnt * baseCost.cost_gold + "/" + myRoleRes.gold;
|
||||
str += " 木材:" + totalCnt * baseCost.cost_wood + "/" + myRoleRes.wood;
|
||||
str += " 金属:" + totalCnt * baseCost.cost_iron + "/" + myRoleRes.iron;
|
||||
str += " 谷物:" + totalCnt * baseCost.cost_grain + "/" + myRoleRes.grain;
|
||||
this.labelResCost.string = str;
|
||||
} else {
|
||||
this.labelResCost.string = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected onChangeEditBox(editBox: EditBox): void {
|
||||
let index: number = this.editBoxs.indexOf(editBox);
|
||||
if (index >= 0) {
|
||||
this.setCurConscriptForIndex(index, parseInt(this.editBoxs[index].string));
|
||||
this.updateResCost();
|
||||
}
|
||||
}
|
||||
|
||||
protected onChangeSlider(slider: Slider): void {
|
||||
let index: number = this.sliders.indexOf(slider);
|
||||
if (index >= 0) {
|
||||
let maxCnt: number = this._totalSoldiers[index] - this._soldiers[index];
|
||||
this.setCurConscriptForIndex(index, Math.floor(this.sliders[index].progress * maxCnt));
|
||||
this.updateResCost();
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickQuick(): void {
|
||||
if (this._data && this._data.cmd == ArmyCmd.Idle || this._data.cmd == ArmyCmd.Conscript) {
|
||||
for (let i: number = 0; i < this._totalSoldiers.length; i++) {
|
||||
if(this._conCnts[i] > 0){
|
||||
//正在征兵的不能重复征兵
|
||||
this.setCurConscriptForIndex(i, 0);
|
||||
}else{
|
||||
let maxCnt: number = this._totalSoldiers[i] - this._soldiers[i];
|
||||
if (maxCnt > 0) {
|
||||
this.setCurConscriptForIndex(i, maxCnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateResCost();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onClickSure(): void {
|
||||
if (this._data && this._data.cmd == ArmyCmd.Idle || this._data.cmd == ArmyCmd.Conscript) {
|
||||
let totalCnt: number = this.getTotalConscriptCnt();
|
||||
if (totalCnt > 0) {
|
||||
ArmyCommand.getInstance().generalConscript(this._data.id, this._curConscripts, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickPrev(): void {
|
||||
this._curConscripts = [0, 0, 0];
|
||||
if (this._order == 1) {
|
||||
//第一个就跳到最后一个
|
||||
this.setData(this._cityId, this._addition.armyCnt);
|
||||
} else {
|
||||
this.setData(this._cityId, this._order - 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickNext(): void {
|
||||
this._curConscripts = [0, 0, 0];
|
||||
if (this._order == this._addition.armyCnt) {
|
||||
//最后一个就跳到第一个
|
||||
this.setData(this._cityId, 1);
|
||||
} else {
|
||||
this.setData(this._cityId, this._order + 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public setData(cityId: number, order: number = 1): void {
|
||||
this._curConscripts = [0, 0, 0];
|
||||
this._cityId = cityId;
|
||||
this._order = order;
|
||||
this._cityData = MapCommand.getInstance().cityProxy.getMyCityById(this._cityId);
|
||||
this._data = ArmyCommand.getInstance().proxy.getArmyByOrder(order, cityId);
|
||||
this._addition = MapUICommand.getInstance().proxy.getMyCityAddition(cityId);
|
||||
this._isUnlock = this._addition.armyCnt >= this._order;
|
||||
let facility: Map<number, Facility> = MapUICommand.getInstance().proxy.getMyFacilitys(this._cityId);
|
||||
if (facility == null) {
|
||||
MapUICommand.getInstance().qryCityFacilities(this._cityId);
|
||||
}
|
||||
this.updateView();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/CityArmySettingLogic.ts.meta
Normal file
11
assets/scripts/map/ui/CityArmySettingLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fa97f626-3fc1-46be-9108-d756122cc651",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
196
assets/scripts/map/ui/CityGeneralItemLogic.ts
Normal file
196
assets/scripts/map/ui/CityGeneralItemLogic.ts
Normal file
@@ -0,0 +1,196 @@
|
||||
import { _decorator, Component, Node, Label, Sprite, ProgressBar } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { ArmyData } from "../../general/ArmyProxy";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralCampType, GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('CityGeneralItemLogic')
|
||||
export default class CityGeneralItemLogic extends Component {
|
||||
@property(Node)
|
||||
infoNode: Node = null;
|
||||
@property(Node)
|
||||
addNode: Node = null;
|
||||
@property(Node)
|
||||
lockNode: Node = null;
|
||||
@property(Node)
|
||||
btnDown: Node = null;
|
||||
@property(Label)
|
||||
labelTitle: Label = null;
|
||||
@property(Sprite)
|
||||
headIcon: Sprite = null;
|
||||
@property(Label)
|
||||
labelLv: Label = null;
|
||||
@property(Label)
|
||||
labelName: Label = null;
|
||||
@property(Label)
|
||||
labelArms: Label = null;
|
||||
@property(Label)
|
||||
labelSoldierCnt: Label = null;
|
||||
@property(Label)
|
||||
labelCost: Label = null;
|
||||
@property(Label)
|
||||
labelCamp: Label = null;
|
||||
@property(Label)
|
||||
labelTip: Label = null;
|
||||
@property(Label)
|
||||
labelConTime: Label = null;
|
||||
@property(Label)
|
||||
labelConCnt: Label = null;
|
||||
@property(ProgressBar)
|
||||
progressBar: ProgressBar = null;
|
||||
@property(Node)
|
||||
conBg: Node = null;
|
||||
|
||||
public index: number = 0;
|
||||
protected _order: number = 0;
|
||||
protected _cityId: number = 0;
|
||||
protected _data: GeneralData = null;
|
||||
protected _soldierCnt: number = 0;
|
||||
protected _totalSoldierCnt: number = 0;
|
||||
protected _conCnt: number = 0;
|
||||
protected _conTime: number = 0;
|
||||
protected _isUnlock: boolean = false;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.schedule(this.updateCon, 1.0);
|
||||
}
|
||||
|
||||
protected onEnable(): void{
|
||||
this.conBg.active = false;
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected onClickDown(): void {
|
||||
ArmyCommand.getInstance().generalDispose(this._cityId, this._data.id, this._data.order, -1, null);
|
||||
}
|
||||
|
||||
protected onClickItem(): void {
|
||||
if (this._data) {
|
||||
//点击展示武将信息
|
||||
let cfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(this._data.cfgId);
|
||||
EventMgr.emit("open_general_des", cfg, this._data);
|
||||
} else if (this.addNode.active) {
|
||||
//上阵武将
|
||||
var generalArr: number[] = this.getAllGenerals();
|
||||
EventMgr.emit("open_general_choose", generalArr, this.index);
|
||||
}
|
||||
}
|
||||
|
||||
protected getAllGenerals(): number[] {
|
||||
let cityArmyData: ArmyData[] = ArmyCommand.getInstance().proxy.getArmyList(this._cityId);
|
||||
let general: GeneralData = null;
|
||||
var arr = [];
|
||||
for (var i = 0; i < cityArmyData.length; i++) {
|
||||
if (cityArmyData[i]) {
|
||||
arr = arr.concat(cityArmyData[i].generals);
|
||||
for (let j: number = 0; j < cityArmyData[i].generals.length; j++) {
|
||||
if (cityArmyData[i].generals[j] > 0) {
|
||||
general = GeneralCommand.getInstance().proxy.getMyGeneral(cityArmyData[i].generals[j]);
|
||||
if (general) {
|
||||
arr = arr.concat(GeneralCommand.getInstance().proxy.getGeneralIds(general.cfgId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
protected updateItem(): void {
|
||||
if (this.index == 0) {
|
||||
this.labelTitle.string = "主将"
|
||||
} else {
|
||||
this.labelTitle.string = "副将"
|
||||
}
|
||||
if (this._isUnlock == false) {
|
||||
//未解锁
|
||||
this.infoNode.active = false;
|
||||
this.addNode.active = false;
|
||||
this.lockNode.active = true;
|
||||
this.btnDown.active = false;
|
||||
let desName: string = MapUICommand.getInstance().proxy.getFacilityCfgByType(14).name;
|
||||
this.labelTip.string = desName + " 等级" + this._order + "开启";
|
||||
this.conBg.active = false;
|
||||
} else if (this._data == null) {
|
||||
//未配置武将
|
||||
this.infoNode.active = false;
|
||||
this.addNode.active = true;
|
||||
this.lockNode.active = false;
|
||||
this.btnDown.active = false;
|
||||
this.conBg.active = false;
|
||||
|
||||
} else {
|
||||
//展示武将信息
|
||||
this.infoNode.active = true;
|
||||
this.addNode.active = false;
|
||||
this.lockNode.active = false;
|
||||
this.btnDown.active = true;
|
||||
|
||||
this.updateCon();
|
||||
|
||||
let cfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(this._data.cfgId);
|
||||
this.headIcon.getComponent(GeneralHeadLogic).setHeadId(this._data.cfgId);
|
||||
this.labelLv.string = this._data.level + "";
|
||||
this.labelName.string = cfg.name;
|
||||
this.labelSoldierCnt.string = this._soldierCnt + "/" + this._totalSoldierCnt;
|
||||
this.progressBar.progress = this._soldierCnt / this._totalSoldierCnt;
|
||||
this.labelCost.string = "Cost " + cfg.cost;
|
||||
switch (this._data.config.camp) {
|
||||
case GeneralCampType.Han:
|
||||
this.labelCamp.string = "汉";
|
||||
break;
|
||||
case GeneralCampType.Qun:
|
||||
this.labelCamp.string = "群";
|
||||
break;
|
||||
case GeneralCampType.Wei:
|
||||
this.labelCamp.string = "魏";
|
||||
break;
|
||||
case GeneralCampType.Shu:
|
||||
this.labelCamp.string = "蜀";
|
||||
break;
|
||||
case GeneralCampType.Wu:
|
||||
this.labelCamp.string = "吴";
|
||||
break;
|
||||
default:
|
||||
this.labelCamp.string = "无";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected updateCon(){
|
||||
if (DateUtil.isAfterServerTime(this._conTime*1000)){
|
||||
this.conBg.active = false;
|
||||
this.labelConTime.string = "";
|
||||
this.labelConCnt.string = "";
|
||||
}else{
|
||||
this.conBg.active = true;
|
||||
this.labelConTime.string = DateUtil.leftTimeStr(this._conTime*1000);
|
||||
this.labelConCnt.string = "+" + this._conCnt;
|
||||
}
|
||||
}
|
||||
|
||||
public setData(cityId: number, order: number, data: GeneralData,
|
||||
soldierCnt: number, totalSoldierCnt: number, conCnt:number,
|
||||
conTime:number, isUnlock: boolean): void {
|
||||
this._cityId = cityId;
|
||||
this._order = order;
|
||||
this._data = data;
|
||||
this._soldierCnt = soldierCnt;
|
||||
this._totalSoldierCnt = totalSoldierCnt;
|
||||
this._conCnt = conCnt;
|
||||
this._conTime = conTime;
|
||||
this._isUnlock = isUnlock;
|
||||
this.updateItem();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/CityGeneralItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/CityGeneralItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9d98dfbb-5f5f-4d46-a5e7-5b3a695c25bb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
92
assets/scripts/map/ui/CollectLogic.ts
Normal file
92
assets/scripts/map/ui/CollectLogic.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
// // Learn TypeScript:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
||||
// // Learn Attribute:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
||||
// // Learn life-cycle callbacks:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
import { _decorator, Component, Label, Button } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import { Tools } from "../../utils/Tools";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('CollectLogic')
|
||||
export default class CollectLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
cdLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
timesLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
goldLab: Label = null;
|
||||
|
||||
@property(Button)
|
||||
collectBtn: Button = null;
|
||||
|
||||
_data: any = null;
|
||||
|
||||
protected onEnable():void{
|
||||
console.log("add interior_openCollect");
|
||||
EventMgr.on("interior_openCollect", this.onOpenCollect, this);
|
||||
EventMgr.on("interior_collect", this.onCollect, this);
|
||||
|
||||
var roleRes = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
this.goldLab.string = Tools.numberToShow(roleRes.gold_yield);
|
||||
|
||||
MapUICommand.getInstance().interiorOpenCollect();
|
||||
}
|
||||
|
||||
|
||||
protected onDisable():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onOpenCollect(msg:any):void{
|
||||
console.log("onOpenCollect:", msg);
|
||||
this._data = msg;
|
||||
this.startCountDown();
|
||||
}
|
||||
|
||||
protected onCollect(msg:any):void{
|
||||
console.log("onOpenCollect:", msg);
|
||||
this._data = msg;
|
||||
this.startCountDown();
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected onClickCollect(): void{
|
||||
MapUICommand.getInstance().interiorCollect();
|
||||
}
|
||||
|
||||
protected startCountDown(){
|
||||
this.stopCountDown();
|
||||
this.schedule(this.countDown, 1.0);
|
||||
this.countDown();
|
||||
}
|
||||
|
||||
public countDown() {
|
||||
this.timesLab.string = this._data.cur_times + "/" + this._data.limit;
|
||||
var diff = DateUtil.leftTime(this._data.next_time);
|
||||
if (diff>0){
|
||||
this.cdLab.string = DateUtil.leftTimeStr(this._data.next_time);
|
||||
this.collectBtn.interactable = false;
|
||||
}else{
|
||||
this.cdLab.string = "目前可以征收";
|
||||
this.collectBtn.interactable = true;
|
||||
}
|
||||
}
|
||||
|
||||
public stopCountDown() {
|
||||
this.unschedule(this.countDown);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/CollectLogic.ts.meta
Normal file
11
assets/scripts/map/ui/CollectLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "27056b00-731c-4bc0-ae3e-7bd3e9f3b15b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
35
assets/scripts/map/ui/Dialog.ts
Normal file
35
assets/scripts/map/ui/Dialog.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// // Learn TypeScript:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
||||
// // Learn Attribute:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
||||
// // Learn life-cycle callbacks:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
@ccclass('Dialog')
|
||||
export default class Dialog extends Component {
|
||||
|
||||
@property(Label)
|
||||
label: Label = null;
|
||||
|
||||
protected closeCallBack: Function = null;
|
||||
|
||||
protected onClickClose(): void {
|
||||
if (this.closeCallBack){
|
||||
this.closeCallBack()
|
||||
}
|
||||
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public text(text: any): void {
|
||||
this.label.string = text
|
||||
}
|
||||
|
||||
public setClose(close :Function){
|
||||
this.closeCallBack = close
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/Dialog.ts.meta
Normal file
11
assets/scripts/map/ui/Dialog.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "28245652-c17c-4533-b0e6-80e01c76736b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
64
assets/scripts/map/ui/DrawLogic.ts
Normal file
64
assets/scripts/map/ui/DrawLogic.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralCommonConfig } from "../../general/GeneralProxy";
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('DrawLogic')
|
||||
export default class DrawLogic extends Component {
|
||||
|
||||
|
||||
@property(Label)
|
||||
labelOnce: Label = null;
|
||||
|
||||
@property(Label)
|
||||
labelTen: Label = null;
|
||||
|
||||
@property(Label)
|
||||
cntLab: Label = null;
|
||||
|
||||
|
||||
protected onEnable():void{
|
||||
EventMgr.on("upate_my_roleRes", this.updateRoleRes, this);
|
||||
EventMgr.on("update_my_generals", this.updateRoleRes, this);
|
||||
this.updateRoleRes();
|
||||
}
|
||||
|
||||
|
||||
protected onDisable():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
protected updateRoleRes():void{
|
||||
let commonCfg: GeneralCommonConfig = GeneralCommand.getInstance().proxy.getCommonCfg();
|
||||
var roleResData = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
this.labelOnce.string = "消耗:"+commonCfg.draw_general_cost +"/"+ roleResData.gold;
|
||||
this.labelTen.string = "消耗:"+commonCfg.draw_general_cost * 10 +"/"+ roleResData.gold;
|
||||
|
||||
var basic = MapUICommand.getInstance().proxy.getBasicGeneral();
|
||||
var cnt = GeneralCommand.getInstance().proxy.getMyActiveGeneralCnt();
|
||||
this.cntLab.string = "(" + cnt + "/" + basic.limit + ")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected drawGeneralOnce():void{
|
||||
GeneralCommand.getInstance().drawGenerals();
|
||||
}
|
||||
|
||||
protected drawGeneralTen():void{
|
||||
GeneralCommand.getInstance().drawGenerals(10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/DrawLogic.ts.meta
Normal file
11
assets/scripts/map/ui/DrawLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2928eb4a-fe99-4700-9421-4031994b843a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
82
assets/scripts/map/ui/DrawRLogic.ts
Normal file
82
assets/scripts/map/ui/DrawRLogic.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { _decorator, Component, Prefab, Layout, instantiate, Vec3 } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralItemLogic, { GeneralItemType } from "./GeneralItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('DrawRLogic')
|
||||
export default class DrawRLogic extends Component {
|
||||
|
||||
|
||||
@property(Prefab)
|
||||
generalItemPrefab: Prefab = null;
|
||||
|
||||
@property(Layout)
|
||||
tenLayout:Layout = null;
|
||||
|
||||
@property(Layout)
|
||||
oneLayout:Layout = null;
|
||||
|
||||
private _maxSize:number = 10;
|
||||
private _scale:number = 0.4;
|
||||
|
||||
protected onLoad():void{
|
||||
|
||||
for(var i = 0; i < this._maxSize;i++){
|
||||
let _generalNode = instantiate(this.generalItemPrefab);
|
||||
_generalNode.parent = this.tenLayout.node;
|
||||
_generalNode.scale = new Vec3(this._scale, this._scale, this._scale);
|
||||
_generalNode.active = false;
|
||||
}
|
||||
|
||||
|
||||
let _generalNode = instantiate(this.generalItemPrefab);
|
||||
_generalNode.parent = this.oneLayout.node;
|
||||
_generalNode.scale = new Vec3(this._scale, this._scale, this._scale);
|
||||
_generalNode.active = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public setData(data:any):void{
|
||||
this.tenLayout.node.active = this.oneLayout.node.active = false;
|
||||
if(data.length == 1){
|
||||
this.oneLayout.node.active = true;
|
||||
var children = this.oneLayout.node.children;
|
||||
let com = children[0].getComponent(GeneralItemLogic);
|
||||
children[0].active = true;
|
||||
if(com){
|
||||
com.setData(data[0],GeneralItemType.GeneralNoThing);
|
||||
}
|
||||
|
||||
}else{
|
||||
this.tenLayout.node.active = true;
|
||||
var children = this.tenLayout.node.children;
|
||||
for(var i = 0; i < this._maxSize;i++){
|
||||
var child = children[i];
|
||||
if(data[i]){
|
||||
child.active = true;
|
||||
let com = child.getComponent(GeneralItemLogic);
|
||||
if(com){
|
||||
com.setData(data[i],GeneralItemType.GeneralNoThing);
|
||||
}
|
||||
}
|
||||
else{
|
||||
child.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/DrawRLogic.ts.meta
Normal file
11
assets/scripts/map/ui/DrawRLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "64665783-4486-4d93-b93f-4a23114a2544",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
60
assets/scripts/map/ui/FacilityAdditionItemLogic.ts
Normal file
60
assets/scripts/map/ui/FacilityAdditionItemLogic.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { _decorator, Component, Label, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { Facility, FacilityAdditionCfg, FacilityConfig, CityAdditionType } from "./MapUIProxy";
|
||||
|
||||
@ccclass('FacilityAdditionItemLogic')
|
||||
export default class FacilityAdditionItemLogic extends Component {
|
||||
@property(Label)
|
||||
labelName: Label = null;
|
||||
@property(Node)
|
||||
upNode: Node = null;
|
||||
@property(Node)
|
||||
maxNode: Node = null;
|
||||
@property(Label)
|
||||
labelOld: Label = null;
|
||||
@property(Label)
|
||||
labelNew: Label = null;
|
||||
@property(Label)
|
||||
labeMax: Label = null;
|
||||
|
||||
public setData(data:Facility, cfg:FacilityConfig, index:number): void {
|
||||
let additionType:number = cfg.additions[index];
|
||||
let additionCfg: FacilityAdditionCfg = MapUICommand.getInstance().proxy.getFacilityAdditionCfgByType(additionType);
|
||||
this.labelName.string = additionCfg.des;
|
||||
if (data.level >= cfg.upLevels.length) {
|
||||
//达到最大等级
|
||||
this.upNode.active = false;
|
||||
this.maxNode.active = true;
|
||||
|
||||
var v = cfg.upLevels[data.level - 1].values[index];
|
||||
if(additionType == CityAdditionType.Durable){
|
||||
v = v/100
|
||||
}
|
||||
this.labeMax.string = additionCfg.value.replace("%n%", v+ "");
|
||||
} else {
|
||||
this.upNode.active = true;
|
||||
this.maxNode.active = false;
|
||||
if (data.level == 0) {
|
||||
//代表未升级过
|
||||
this.labelOld.string = "---";
|
||||
} else {
|
||||
|
||||
var v = cfg.upLevels[data.level - 1].values[index];
|
||||
if(additionType == CityAdditionType.Durable){
|
||||
v = v/100
|
||||
}
|
||||
|
||||
this.labelOld.string = additionCfg.value.replace("%n%", v + "");
|
||||
}
|
||||
|
||||
var v = cfg.upLevels[data.level].values[index];
|
||||
if(additionType == CityAdditionType.Durable){
|
||||
v = v/100
|
||||
}
|
||||
|
||||
this.labelNew.string = additionCfg.value.replace("%n%", v + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/FacilityAdditionItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/FacilityAdditionItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "153121a9-12ea-4e64-a654-a2d2ef1a4b8e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
219
assets/scripts/map/ui/FacilityDesLogic.ts
Normal file
219
assets/scripts/map/ui/FacilityDesLogic.ts
Normal file
@@ -0,0 +1,219 @@
|
||||
import { _decorator, Component, Label, RichText, Button, Node, Prefab, NodePool, instantiate, UITransform } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import FacilityAdditionItemLogic from "./FacilityAdditionItemLogic";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { Facility, FacilityAdditionCfg, FacilityConfig, FacilityUpLevel } from "./MapUIProxy";
|
||||
|
||||
@ccclass('FacilityDesLogic')
|
||||
export default class FacilityDesLogic extends Component {
|
||||
@property(Label)
|
||||
labelTitle: Label = null;
|
||||
@property(Label)
|
||||
labelDes: Label = null;
|
||||
@property(RichText)
|
||||
labelConditions: RichText = null;
|
||||
@property(RichText)
|
||||
labelNeed: RichText = null;
|
||||
@property(Button)
|
||||
btnUp: Button = null;
|
||||
@property(Label)
|
||||
labelUp: Label = null;
|
||||
|
||||
@property(Label)
|
||||
labelNeedTime: Label = null;
|
||||
|
||||
@property(Node)
|
||||
additionNode: Node = null;
|
||||
@property(Prefab)
|
||||
additionItemPrefab: Prefab = null;
|
||||
|
||||
protected _cityId: number = 0;
|
||||
protected _data: Facility = null;
|
||||
protected _cfg: FacilityConfig = null;
|
||||
protected _additonCfg: FacilityAdditionCfg = null;
|
||||
protected _isUnLock: boolean = false;//是否解锁
|
||||
protected _isNeedComplete: boolean = false;//是否满足升级需求
|
||||
protected _isLevelMax: boolean = false;//是否已达最高等级
|
||||
protected _additionPool: NodePool = new NodePool();
|
||||
|
||||
protected onLoad(): void {
|
||||
this.schedule(this.updateNeedTime);
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
|
||||
}
|
||||
|
||||
protected removeAllAdditionItems(): void {
|
||||
let children: Node[] = this.additionNode.children.concat();
|
||||
this.additionNode.removeAllChildren();
|
||||
for (let i: number = 0; i < children.length; i++) {
|
||||
this._additionPool.put(children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected getAdditionItem(): Node {
|
||||
if (this._additionPool.size() > 0) {
|
||||
return this._additionPool.get();
|
||||
} else {
|
||||
return instantiate(this.additionItemPrefab);
|
||||
}
|
||||
}
|
||||
|
||||
//更新加成描述界面
|
||||
public updateAdditionView() {
|
||||
this.removeAllAdditionItems();
|
||||
for (let i: number = 0; i < this._cfg.additions.length; i++) {
|
||||
let item: Node = this.getAdditionItem();
|
||||
item.parent = this.additionNode;
|
||||
item.getComponent(FacilityAdditionItemLogic).setData(this._data, this._cfg, i);
|
||||
}
|
||||
}
|
||||
|
||||
//更新解锁条件
|
||||
public updateContidionView() {
|
||||
this._isUnLock = true;
|
||||
if (this._cfg.conditions.length > 0) {
|
||||
//有解锁条件
|
||||
let contidionList: string[] = [];
|
||||
for (let i: number = 0; i < this._cfg.conditions.length; i++) {
|
||||
let data: Facility = MapUICommand.getInstance().proxy.getMyFacilityByType(this._cityId, this._cfg.conditions[i].type);
|
||||
let cfg: FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(this._cfg.conditions[i].type);
|
||||
if (data == null || data.level < this._cfg.conditions[i].level) {
|
||||
//不满足条件
|
||||
contidionList.push("<color=#ff0000>" + cfg.name + this._cfg.conditions[i].level + "级</color>");
|
||||
this._isUnLock = false;
|
||||
} else {
|
||||
//满足条件
|
||||
contidionList.push("<color=#00ff00>" + cfg.name + this._cfg.conditions[i].level + "级</color>");
|
||||
}
|
||||
}
|
||||
this.labelConditions.node.parent.active = true;
|
||||
this.labelConditions.string = contidionList.join("<br/>");
|
||||
this.labelConditions.node.parent.getComponent(UITransform).height = this.labelConditions.node.getComponent(UITransform).height + 30;
|
||||
} else {
|
||||
this.labelConditions.node.parent.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
//更新资源需求
|
||||
public updateNeedView(): void {
|
||||
this._isNeedComplete = true;
|
||||
|
||||
let curLevel: number = this._data.level;
|
||||
if (curLevel >= 0 && curLevel < this._cfg.upLevels.length) {
|
||||
//未达到最高级时
|
||||
let roleRes: any = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
let upLevel: FacilityUpLevel = this._cfg.upLevels[curLevel];
|
||||
let needStrList: string[] = [];
|
||||
if (upLevel.grain > 0) {
|
||||
if (roleRes.grain < upLevel.grain) {
|
||||
this._isNeedComplete = false;
|
||||
needStrList.push("粮食:<color=#ff0000>" + upLevel.grain + "/" + roleRes.grain + "</color>");
|
||||
} else {
|
||||
needStrList.push("粮食:<color=#00ff00>" + upLevel.grain + "/" + roleRes.grain + "</color>");
|
||||
}
|
||||
}
|
||||
if (upLevel.wood > 0) {
|
||||
if (roleRes.wood < upLevel.wood) {
|
||||
this._isNeedComplete = false;
|
||||
needStrList.push("木材:<color=#ff0000>" + upLevel.wood + "/" + roleRes.wood + "</color>");
|
||||
} else {
|
||||
needStrList.push("木材:<color=#00ff00>" + upLevel.wood + "/" + roleRes.wood + "</color>");
|
||||
}
|
||||
}
|
||||
if (upLevel.iron > 0) {
|
||||
if (roleRes.iron < upLevel.iron) {
|
||||
this._isNeedComplete = false;
|
||||
needStrList.push("铁矿:<color=#ff0000>" + upLevel.iron + "/" + roleRes.iron + "</color>");
|
||||
} else {
|
||||
needStrList.push("铁矿:<color=#00ff00>" + upLevel.iron + "/" + roleRes.iron + "</color>");
|
||||
}
|
||||
}
|
||||
if (upLevel.stone > 0) {
|
||||
if (roleRes.stone < upLevel.stone) {
|
||||
this._isNeedComplete = false;
|
||||
needStrList.push("石头:<color=#ff0000>" + upLevel.stone + "/" + roleRes.stone + "</color>");
|
||||
} else {
|
||||
needStrList.push("石头:<color=#00ff00>" + upLevel.stone + "/" + roleRes.stone + "</color>");
|
||||
}
|
||||
}
|
||||
if (upLevel.decree > 0) {
|
||||
if (roleRes.decree < upLevel.decree) {
|
||||
this._isNeedComplete = false;
|
||||
needStrList.push("政令:<color=#ff0000>" + upLevel.decree + "/" + roleRes.decree + "</color>");
|
||||
} else {
|
||||
needStrList.push("政令:<color=#00ff00>" + upLevel.decree + "/" + roleRes.decree + "</color>");
|
||||
}
|
||||
}
|
||||
this.labelNeed.node.parent.active = true;
|
||||
this.labelNeed.string = needStrList.join("<br/>");
|
||||
this.labelNeed.node.parent.getComponent(UITransform).height = this.labelNeed.node.getComponent(UITransform).height + 30;
|
||||
this._isLevelMax = false;
|
||||
} else {
|
||||
this.labelNeed.node.parent.active = false;
|
||||
this._isLevelMax = true;
|
||||
}
|
||||
}
|
||||
|
||||
public updateNeedTime(): void {
|
||||
if(this._isLevelMax == false){
|
||||
var level = this._cfg.upLevels[this._data.level];
|
||||
if (this._data.isUping() == false){
|
||||
this.labelNeedTime.string = DateUtil.converSecondStr(level.time*1000);
|
||||
}else{
|
||||
this.labelNeedTime.string = DateUtil.converSecondStr(this._data.upLastTime());
|
||||
}
|
||||
}else{
|
||||
this.labelNeedTime.string = "等级已满";
|
||||
}
|
||||
}
|
||||
|
||||
//更新升级按钮
|
||||
public updateUpBtn(): void {
|
||||
if (this._isLevelMax) {
|
||||
//升满级了
|
||||
this.btnUp.node.active = false;
|
||||
} else {
|
||||
this.btnUp.node.active = true;
|
||||
if (this._isUnLock == false) {
|
||||
//未解锁
|
||||
this.btnUp.interactable = false;
|
||||
this.labelUp.string = "未解锁";
|
||||
} else if (this._isNeedComplete == false) {
|
||||
//资源不足
|
||||
this.btnUp.interactable = false;
|
||||
this.labelUp.string = "升级";
|
||||
} else if(this._data.isUping()){
|
||||
//正在升级中
|
||||
this.btnUp.interactable = false;
|
||||
this.labelUp.string = "升级中";
|
||||
}
|
||||
else {
|
||||
this.btnUp.interactable = true;
|
||||
this.labelUp.string = "升级";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setData(cityId: number, data: Facility, cfg: FacilityConfig): void {
|
||||
this._cityId = cityId;
|
||||
this._data = data;
|
||||
this._cfg = cfg;
|
||||
this.labelTitle.string = cfg.name;
|
||||
this.labelDes.string = cfg.des;
|
||||
this.updateAdditionView();
|
||||
this.updateContidionView();
|
||||
this.updateNeedView();
|
||||
this.updateNeedTime();
|
||||
this.updateUpBtn();
|
||||
}
|
||||
|
||||
protected onClickUp(): void {
|
||||
MapUICommand.getInstance().upFacility(this._cityId, this._data.type);
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/FacilityDesLogic.ts.meta
Normal file
11
assets/scripts/map/ui/FacilityDesLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "dfb4e119-6064-407a-9336-80ce4bd8661a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
81
assets/scripts/map/ui/FacilityItemLogic.ts
Normal file
81
assets/scripts/map/ui/FacilityItemLogic.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { _decorator, Component, Label, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import { Facility, FacilityConfig } from "./MapUIProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('FacilityItemLogic')
|
||||
export default class FacilityItemLogic extends Component {
|
||||
@property(Label)
|
||||
labelRate: Label = null;
|
||||
@property(Label)
|
||||
labelName: Label = null;
|
||||
|
||||
@property(Label)
|
||||
labelTime: Label = null;
|
||||
|
||||
@property(Node)
|
||||
lockNode: Node = null;
|
||||
|
||||
public type: number = 0;
|
||||
public isUnlock: boolean = false;
|
||||
public cityId: number = 0;
|
||||
public data: Facility = null;
|
||||
public cfg: FacilityConfig = null;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.node.on(Node.EventType.TOUCH_END, this.onTouchItem, this);
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this.node.off(Node.EventType.TOUCH_END, this.onTouchItem, this);
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected updateItem(): void {
|
||||
this.labelRate.string = this.data.level + "/" + this.cfg.upLevels.length;
|
||||
this.labelName.string = this.cfg.name;
|
||||
this.lockNode.active = !this.isUnlock;
|
||||
}
|
||||
|
||||
protected onTouchItem() {
|
||||
EventMgr.emit("select_facility_item", this.cityId, this.data.type);
|
||||
}
|
||||
|
||||
public setData(cityId: number, data: Facility, cfg:FacilityConfig, isUnlock:boolean): void {
|
||||
// console.log("setData:", data);
|
||||
|
||||
this.cityId = cityId;
|
||||
this.data = data;
|
||||
this.cfg = cfg;
|
||||
this.isUnlock = isUnlock;
|
||||
|
||||
if(this.data.isUping()){
|
||||
this.startUpTime();
|
||||
}else{
|
||||
this.stopCountDown();
|
||||
}
|
||||
|
||||
this.updateItem();
|
||||
}
|
||||
|
||||
protected countDown(){
|
||||
if (this.data.isUping()){
|
||||
this.labelTime.string = DateUtil.converSecondStr(this.data.upLastTime());
|
||||
}else{
|
||||
this.stopCountDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected stopCountDown(){
|
||||
this.unscheduleAllCallbacks();
|
||||
this.labelTime.string = "";
|
||||
}
|
||||
|
||||
protected startUpTime(){
|
||||
this.stopCountDown();
|
||||
this.schedule(this.countDown, 1.0);
|
||||
this.countDown();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/FacilityItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/FacilityItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3f5e7cea-6be6-4faf-b4b6-039ab258473d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
130
assets/scripts/map/ui/FacilityListLogic.ts
Normal file
130
assets/scripts/map/ui/FacilityListLogic.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { _decorator, Component, ScrollView, Node, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import FacilityDesLogic from "./FacilityDesLogic";
|
||||
import FacilityItemLogic from "./FacilityItemLogic";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { Facility, FacilityConfig } from "./MapUIProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('FacilityListLogic')
|
||||
export default class FacilityListLogic extends Component {
|
||||
@property(ScrollView)
|
||||
scrollView: ScrollView = null;
|
||||
|
||||
protected _curCityId: number = 0;
|
||||
protected _curSelectType: number = -1;
|
||||
protected _itemLogics: Map<number, FacilityItemLogic> = new Map<number, FacilityItemLogic>();
|
||||
|
||||
protected onLoad(): void {
|
||||
this.initView();
|
||||
EventMgr.on("update_my_facilities", this.updateView, this);
|
||||
EventMgr.on("update_my_facility", this.updateFacility, this);
|
||||
EventMgr.on("select_facility_item", this.onSelectItem, this);
|
||||
EventMgr.on("upate_my_roleRes", this.onUpdateMyRoleRes, this);
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._itemLogics.clear();
|
||||
this._itemLogics = null;
|
||||
}
|
||||
|
||||
protected initView(): void {
|
||||
let children: Node[] = this.scrollView.content.children;
|
||||
for (let i: number = 0; i < children.length; i++) {
|
||||
let subChildren: Node[] = children[i].children;
|
||||
for (let j: number = 0; j < subChildren.length; j++) {
|
||||
let item: Node = subChildren[j];
|
||||
if (item.name.indexOf("CityFacilityItem") == 0) {
|
||||
let type: number = parseInt(item.name.substring(16));
|
||||
let comp: FacilityItemLogic = item.addComponent(FacilityItemLogic);
|
||||
comp.labelRate = item.getChildByName("labelRate").getComponent(Label);
|
||||
comp.labelName = item.getChildByName("labelName").getComponent(Label);
|
||||
comp.labelTime = item.getChildByName("labelTime").getComponent(Label);
|
||||
comp.lockNode = item.getChildByName("lockNode");
|
||||
comp.labelTime.string = "";
|
||||
comp.type = type;
|
||||
this._itemLogics.set(type, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected updateView(): void {
|
||||
let dataList: Map<number, Facility> = MapUICommand.getInstance().proxy.getMyFacilitys(this._curCityId);
|
||||
if (dataList && dataList.size > 0) {
|
||||
dataList.forEach((data: Facility, type: number) => {
|
||||
if (this._itemLogics.has(type)) {
|
||||
//有数据就更新
|
||||
let logic: FacilityItemLogic = this._itemLogics.get(type);
|
||||
let cfg: FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(type);
|
||||
let isUnlock: boolean = MapUICommand.getInstance().proxy.isFacilityUnlock(this._curCityId, type);
|
||||
logic.setData(this._curCityId, data, cfg, isUnlock);
|
||||
}
|
||||
});
|
||||
if (this._curSelectType == -1) {
|
||||
this.setCurSelectType(0);//默认选中主城
|
||||
}
|
||||
}
|
||||
|
||||
this.updateDesView();
|
||||
}
|
||||
|
||||
protected updateFacility(cityId: number, data: Facility): void {
|
||||
if (this._curCityId == cityId) {
|
||||
if (this._itemLogics.has(data.type)) {
|
||||
//有数据就更新
|
||||
let logic: FacilityItemLogic = this._itemLogics.get(data.type);
|
||||
let cfg: FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(data.type);
|
||||
let isUnlock: boolean = MapUICommand.getInstance().proxy.isFacilityUnlock(this._curCityId, data.type);
|
||||
logic.setData(this._curCityId, data, cfg, isUnlock);
|
||||
}
|
||||
this._itemLogics.forEach((logic: FacilityItemLogic, type: number) => {
|
||||
let cfg: FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(logic.data.type);
|
||||
for (let i: number = 0; i < cfg.conditions.length; i++) {
|
||||
if (cfg.conditions[i].type == data.type) {
|
||||
//涉及到了解锁条件
|
||||
let data: Facility = MapUICommand.getInstance().proxy.getMyFacilityByType(this._curCityId, logic.data.type);
|
||||
let isUnlock: boolean = MapUICommand.getInstance().proxy.isFacilityUnlock(this._curCityId, logic.data.type);
|
||||
logic.setData(this._curCityId, data, cfg, isUnlock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.updateDesView();
|
||||
}
|
||||
|
||||
protected onUpdateMyRoleRes(): void {
|
||||
this.updateDesView();
|
||||
}
|
||||
|
||||
protected onSelectItem(cityId: number, type: number): void {
|
||||
if (this._curCityId == cityId) {
|
||||
this.setCurSelectType(type);
|
||||
}
|
||||
}
|
||||
|
||||
protected updateDesView(): void {
|
||||
let data: Facility = MapUICommand.getInstance().proxy.getMyFacilityByType(this._curCityId, this._curSelectType);
|
||||
let cfg: FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(this._curSelectType);
|
||||
this.node.getComponent(FacilityDesLogic).setData(this._curCityId, data, cfg);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public setCurSelectType(type: number): void {
|
||||
if (this._curSelectType != type) {
|
||||
this._curSelectType = type;
|
||||
this.updateDesView();
|
||||
}
|
||||
}
|
||||
|
||||
public setData(data: any): void {
|
||||
this._curCityId = data.cityId;
|
||||
this.updateView();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/FacilityListLogic.ts.meta
Normal file
11
assets/scripts/map/ui/FacilityListLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c3bc233e-cb57-4c5b-b2aa-0cff964a8fb3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
174
assets/scripts/map/ui/FortressAbout.ts
Normal file
174
assets/scripts/map/ui/FortressAbout.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
import { _decorator, Component, Node, Label, Button, Prefab, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { ArmyData } from "../../general/ArmyProxy";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import { MapBuildData } from "../MapBuildProxy";
|
||||
import MapCommand from "../MapCommand";
|
||||
import { MapResType } from "../MapProxy";
|
||||
import CityArmyItemLogic from "./CityArmyItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('FortressAbout')
|
||||
export default class FortressAbout extends Component {
|
||||
@property(Node)
|
||||
armyLayer: Node = null;
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
@property(Label)
|
||||
lvLab: Label = null;
|
||||
@property(Label)
|
||||
timeLab: Label = null;
|
||||
|
||||
|
||||
@property(Button)
|
||||
upBtn: Button = null;
|
||||
|
||||
@property(Button)
|
||||
destroyBtn: Button = null;
|
||||
|
||||
@property(Prefab)
|
||||
armyItem: Prefab = null;
|
||||
|
||||
protected _armyCnt: number = 5;//队伍数量 固定值
|
||||
protected _data: MapBuildData = null;
|
||||
protected _armyComps: CityArmyItemLogic[] = [];
|
||||
protected _cmd: MapCommand;
|
||||
|
||||
protected onLoad(): void {
|
||||
|
||||
this._cmd = MapCommand.getInstance();
|
||||
|
||||
}
|
||||
|
||||
onEnable (): void{
|
||||
EventMgr.on("update_builds", this.onUpdateBuilds, this);
|
||||
EventMgr.on("update_build", this.onUpdateBuild, this);
|
||||
EventMgr.on("delete_build", this.onDeleteBuild, this);
|
||||
|
||||
this.initView();
|
||||
}
|
||||
|
||||
protected onDisable(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected initView(): void {
|
||||
for (let i: number = 0; i < this._armyCnt; i++) {
|
||||
let item = instantiate(this.armyItem);
|
||||
item.parent = this.armyLayer;
|
||||
let comp: CityArmyItemLogic = item.getComponent(CityArmyItemLogic);
|
||||
comp.order = i + 1;
|
||||
this._armyComps.push(comp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected updateArmyList(): void {
|
||||
let armyList: ArmyData[] = ArmyCommand.getInstance().proxy.getArmysByPos(this._data.x, this._data.y);
|
||||
console.log("updateArmyList:", armyList, this._data);
|
||||
for (let i: number = 0; i < this._armyComps.length; i++) {
|
||||
if (this._data.level > i){
|
||||
this._armyComps[i].isOpenedArmy(true, true);
|
||||
}else{
|
||||
this._armyComps[i].isOpenedArmy(false, true);
|
||||
}
|
||||
|
||||
this._armyComps[i].setArmyData(0, null);
|
||||
if (armyList.length > i){
|
||||
this._armyComps[i].setArmyData(armyList[i].cityId, armyList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setData(data: MapBuildData): void {
|
||||
this._data = data;
|
||||
this.nameLab.string = data.name;
|
||||
this.lvLab.string = "lv:" + data.level;
|
||||
this.startCountDownTime();
|
||||
this.updateArmyList();
|
||||
|
||||
if (this._data.type == MapResType.SYS_FORTRESS){
|
||||
this.upBtn.node.active = false;
|
||||
this.destroyBtn.node.active = false;
|
||||
}else if(this._data.type == MapResType.FORTRESS){
|
||||
this.upBtn.node.active = true;
|
||||
this.destroyBtn.node.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateBuilds(areaIndex: number, addIds: number[], removeIds: number[], updateIds: number[]): void {
|
||||
console.log("onUpdateBuilds:", removeIds);
|
||||
|
||||
for (let i: number = 0; i < addIds.length; i++) {
|
||||
let data = this._cmd.buildProxy.getBuild(addIds[i]);
|
||||
if (data.x == this._data.x && data.y == this._data.y){
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i: number = 0; i < removeIds.length; i++) {
|
||||
console.log("data:", this._data);
|
||||
if(this._data.rid == 0){
|
||||
this.node.parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i: number = 0; i < updateIds.length; i++) {
|
||||
let data = this._cmd.buildProxy.getBuild(updateIds[i]);
|
||||
if (data.x == this._data.x && data.y == this._data.y){
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateBuild(data: MapBuildData): void {
|
||||
if(data.x == this._data.x && data.y == this._data.y){
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
protected onDeleteBuild(id: number, x: number, y: number): void {
|
||||
if(x == this._data.x && y == this._data.y){
|
||||
this.node.parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickUpBuild(): void {
|
||||
this._cmd.upBuild(this._data.x, this._data.y);
|
||||
}
|
||||
|
||||
protected onClickDestroyBuild(): void {
|
||||
this._cmd.delBuild(this._data.x, this._data.y);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
public startCountDownTime(){
|
||||
this.stopCountDownTime();
|
||||
this.schedule(this.countDownTime, 1.0);
|
||||
this.countDownTime();
|
||||
}
|
||||
|
||||
public countDownTime() {
|
||||
if (this._data.isBuilding()){
|
||||
this.timeLab.string = "建设中..." + DateUtil.leftTimeStr(this._data.endTime);
|
||||
} else if(this._data.isUping()){
|
||||
this.timeLab.string = "升级中..." + DateUtil.leftTimeStr(this._data.endTime);
|
||||
} else if(this._data.isDestroying()){
|
||||
this.timeLab.string = "拆除中..." + DateUtil.leftTimeStr(this._data.endTime);
|
||||
}else{
|
||||
this.timeLab.string = "";
|
||||
this.stopCountDownTime();
|
||||
}
|
||||
}
|
||||
|
||||
public stopCountDownTime() {
|
||||
this.unschedule(this.countDownTime);
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/FortressAbout.ts.meta
Normal file
11
assets/scripts/map/ui/FortressAbout.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "79f56279-7997-4a57-8064-5efeecf793ac",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
179
assets/scripts/map/ui/GeneralAddPrLogic.ts
Normal file
179
assets/scripts/map/ui/GeneralAddPrLogic.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
|
||||
import { _decorator, Component, Label, Prefab, Node, Layout, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import GeneralItemLogic, { GeneralItemType } from "./GeneralItemLogic";
|
||||
|
||||
@ccclass('GeneralAddPrLogic')
|
||||
export default class GeneralAddPrLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalItemPrefab: Prefab = null;
|
||||
|
||||
@property(Node)
|
||||
generalItemParent: Node = null;
|
||||
|
||||
@property(Layout)
|
||||
srollLayout:Layout = null;
|
||||
|
||||
@property(Label)
|
||||
prLabel: Label = null;
|
||||
|
||||
|
||||
@property(Node)
|
||||
addPr: Node = null;
|
||||
|
||||
|
||||
|
||||
private _currData:GeneralData = null;
|
||||
private _cfgData:GeneralConfig = null;
|
||||
|
||||
private _generalNode:Node = null;
|
||||
private _nameObj:any = {};
|
||||
private _addPrObj:any = {};
|
||||
private _addPrArr:string[] = [];
|
||||
private _canUsePr:number = -1;
|
||||
private _step:number = 100;
|
||||
protected _curAll:number = 0;
|
||||
|
||||
@property([Node])
|
||||
prItems: Node[] = [];
|
||||
|
||||
protected onLoad():void{
|
||||
this._generalNode = instantiate(this.generalItemPrefab);
|
||||
this._generalNode.parent = this.generalItemParent;
|
||||
|
||||
this._nameObj = {
|
||||
force:"武力",
|
||||
strategy:"战略",
|
||||
defense:"防御",
|
||||
speed:"速度",
|
||||
destroy:"破坏",
|
||||
};
|
||||
|
||||
this._addPrArr = ["force","strategy","defense","speed","destroy"]
|
||||
}
|
||||
|
||||
|
||||
public setData(cfgData:any,curData:any):void{
|
||||
console.log("curData:",curData)
|
||||
this._canUsePr =-1;
|
||||
this._currData = curData;
|
||||
this._cfgData = cfgData;
|
||||
this.nameLab.string = this._cfgData.name;
|
||||
|
||||
var com = this._generalNode.getComponent(GeneralItemLogic);
|
||||
if(com){
|
||||
com.updateItem(this._currData, GeneralItemType.GeneralNoThing);
|
||||
}
|
||||
|
||||
this._addPrObj = {
|
||||
force:this._currData.force_added,
|
||||
strategy:this._currData.strategy_added,
|
||||
defense:this._currData.defense_added,
|
||||
speed:this._currData.speed_added,
|
||||
destroy:this._currData.destroy_added,
|
||||
};
|
||||
|
||||
this._curAll = Math.abs(this._currData.hasPrPoint - this._currData.usePrPoint);
|
||||
this.updateView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected updateView():void{
|
||||
var children = this.srollLayout.node.children;
|
||||
var i = 0;
|
||||
for(var key in this._nameObj){
|
||||
children[i].getChildByName("New Label").getComponent(Label).string = this._nameObj[key] +":" +
|
||||
GeneralData.getPrStr(this._cfgData[key],this._addPrObj[key],this._currData.level,this._cfgData[key+"_grow"]);
|
||||
|
||||
var node:Label = children[i].getChildByName("New Sprite").getChildByName("change Label").getComponent(Label);
|
||||
node.string = this._addPrObj[key]/this._step +''
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(this._canUsePr == -1){
|
||||
this._canUsePr = Math.abs(this._currData.hasPrPoint - this._currData.usePrPoint);
|
||||
}
|
||||
this.prLabel.string = "可用属性点:" + this._canUsePr/this._step + "/" + this._currData.hasPrPoint/this._step;
|
||||
this.addPr.active = this._currData.hasPrPoint > 0?true:false;
|
||||
}
|
||||
|
||||
protected plus(target:any,index:number = 0):void{
|
||||
var num:number = this._addPrObj[this._addPrArr[index]]
|
||||
if(!this.isCanePlus() || num >= this._currData.hasPrPoint){
|
||||
return
|
||||
}
|
||||
|
||||
num = num + this._step;
|
||||
num = num > this._currData.hasPrPoint?this._currData.hasPrPoint:num;
|
||||
this._addPrObj[this._addPrArr[index]] = num;
|
||||
this._canUsePr -= this._step
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
|
||||
protected reduce(target:any,index:number = 0):void{
|
||||
var num:number = this._addPrObj[this._addPrArr[index]]
|
||||
if(!this.isCaneReduce() || num == 0){
|
||||
return
|
||||
}
|
||||
|
||||
num = num - this._step;
|
||||
num = num < 0?0:num;
|
||||
this._addPrObj[this._addPrArr[index]] = num;
|
||||
this._canUsePr += this._step
|
||||
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
|
||||
private getAllUse():number{
|
||||
var num:number = 0;
|
||||
for(var key in this._addPrObj){
|
||||
num +=this._addPrObj[key];
|
||||
}
|
||||
return num
|
||||
}
|
||||
|
||||
|
||||
private isCanePlus():boolean{
|
||||
var all:number = this.getAllUse();
|
||||
if(all + this._step > this._currData.hasPrPoint){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private isCaneReduce():boolean{
|
||||
var all:number = this.getAllUse();
|
||||
if(all - this._step < 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected onClickAddPr():void{
|
||||
GeneralCommand.getInstance().addPrGeneral(
|
||||
this._currData.id,
|
||||
this._addPrObj.force,
|
||||
this._addPrObj.strategy,
|
||||
this._addPrObj.defense,
|
||||
this._addPrObj.speed,
|
||||
this._addPrObj.destroy);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralAddPrLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralAddPrLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "53556fc9-1dce-4bdd-94b9-70704d738fe4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
100
assets/scripts/map/ui/GeneralComposeLogic.ts
Normal file
100
assets/scripts/map/ui/GeneralComposeLogic.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { _decorator, Component, Label, Prefab, Node, ScrollView, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import { GeneralItemType } from "./GeneralItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('GeneralComposeLogic')
|
||||
export default class GeneralComposeLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalItemPrefab: Prefab = null;
|
||||
|
||||
@property(Node)
|
||||
generalItemParent: Node = null;
|
||||
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
@property(Node)
|
||||
composeNode: Node = null;
|
||||
|
||||
private _currData:GeneralData = null;
|
||||
private _cfgData:GeneralConfig = null;
|
||||
|
||||
private _generalNode:Node = null;
|
||||
private _gIdsArr:number[] = [];
|
||||
|
||||
protected onLoad():void{
|
||||
this._generalNode = instantiate(this.generalItemPrefab);
|
||||
this._generalNode.parent = this.generalItemParent;
|
||||
}
|
||||
|
||||
protected onEnable():void{
|
||||
EventMgr.on("open_general_select", this.selectItem, this);
|
||||
this.updataView();
|
||||
}
|
||||
|
||||
protected onDisable():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
private selectItem(cfg:any,curData:any):void{
|
||||
var index = this._gIdsArr.indexOf(curData.id);
|
||||
if(index >= 0){
|
||||
|
||||
this._gIdsArr.splice(index,1)
|
||||
}else{
|
||||
this._gIdsArr.push(curData.id);
|
||||
}
|
||||
this.updataView();
|
||||
|
||||
}
|
||||
|
||||
public setData(cfgData:any,curData:any):void{
|
||||
this._currData = curData;
|
||||
this._cfgData = cfgData;
|
||||
this._gIdsArr = [];
|
||||
var com = this._generalNode.getComponent("GeneralItemLogic");
|
||||
if(com){
|
||||
com.updateItem(this._currData,GeneralItemType.GeneralNoThing);
|
||||
}
|
||||
|
||||
this.nameLab.string = this._cfgData.name;
|
||||
|
||||
this.updateGeneral();
|
||||
this.updataView();
|
||||
}
|
||||
|
||||
|
||||
protected updateGeneral():void{
|
||||
let list:any[] = GeneralCommand.getInstance().proxy.getComposeGenerals(this._cfgData.cfgId,this._currData.id);
|
||||
let listTemp = list.concat();
|
||||
|
||||
|
||||
listTemp.forEach(item => {
|
||||
item.type = GeneralItemType.GeneralSelect;
|
||||
})
|
||||
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
comp.setData(listTemp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private updataView():void{
|
||||
this.composeNode.active = ((this._gIdsArr.length > 0) && (this._currData.star_lv < this._cfgData.star));
|
||||
}
|
||||
|
||||
|
||||
protected onCompose(): void {
|
||||
GeneralCommand.getInstance().composeGeneral(this._currData.id,this._gIdsArr);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralComposeLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralComposeLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "146ed275-dc40-4cfd-97ad-fcd747dd8e45",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
118
assets/scripts/map/ui/GeneralConvertLogic.ts
Normal file
118
assets/scripts/map/ui/GeneralConvertLogic.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
|
||||
|
||||
import { _decorator, Component, ScrollView, Node, Prefab, instantiate, UITransform, Vec3 } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import GeneralItemLogic, { GeneralItemType } from "./GeneralItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('GeneralConvertLogic')
|
||||
export default class GeneralConvertLogic extends Component {
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
@property(Node)
|
||||
contentNode:Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalPrefab = null;
|
||||
|
||||
private _cunGeneral:number[] = [];
|
||||
|
||||
private _upMap:Map<number, Node> = new Map<number, Node>();
|
||||
|
||||
private _selectMap:Map<number, Node> = new Map<number, Node>();
|
||||
|
||||
protected onEnable():void{
|
||||
this.initGeneralCfg();
|
||||
EventMgr.on("open_general_select", this.onSelectGeneral, this);
|
||||
EventMgr.on("general_convert", this.onGeneralConvert, this);
|
||||
}
|
||||
|
||||
|
||||
protected onDisable():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
EventMgr.emit("open_general");
|
||||
}
|
||||
|
||||
protected initGeneralCfg():void{
|
||||
|
||||
let list:any[] = GeneralCommand.getInstance().proxy.getMyGeneralsNotUse();
|
||||
let listTemp = list.concat();
|
||||
|
||||
listTemp.forEach(item => {
|
||||
item.type = GeneralItemType.GeneralSelect;
|
||||
})
|
||||
|
||||
|
||||
for(var i = 0; i < listTemp.length ;i++){
|
||||
if(this._cunGeneral.indexOf(listTemp[i].id) >= 0 ){
|
||||
listTemp.splice(i,1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
comp.setData(listTemp);
|
||||
}
|
||||
|
||||
protected onSelectGeneral(cfgData: any, curData: any, node:Node): void {
|
||||
//console.log("curData:", curData, this._upMap.size);
|
||||
|
||||
var has = this._upMap.has(curData.id);
|
||||
if (has){
|
||||
var obj = this._upMap.get(curData.id);
|
||||
obj.parent = null;
|
||||
this._upMap.delete(curData.id);
|
||||
|
||||
var g = this._selectMap.get(curData.id);
|
||||
if (g){
|
||||
g.getComponent(GeneralItemLogic).select(false);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if (this._upMap.size >= 9){
|
||||
node.getComponent(GeneralItemLogic).select(false);
|
||||
return
|
||||
}
|
||||
|
||||
var g:Node = instantiate(this.generalPrefab);
|
||||
g.getComponent(GeneralItemLogic).setData(curData, GeneralItemType.GeneralSelect);
|
||||
g.getComponent(GeneralItemLogic).select(true);
|
||||
g.getComponent(UITransform).width *=0.5;
|
||||
g.getComponent(UITransform).height*=0.5;
|
||||
g.scale = new Vec3(0.5, 0.5, 0.5);
|
||||
g.parent = this.contentNode;
|
||||
this._upMap.set(curData.id, g);
|
||||
this._selectMap.set(curData.id, node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onGeneralConvert(msg:any):void{
|
||||
EventMgr.emit("show_toast", "获得金币:"+msg.add_gold);
|
||||
this._upMap.forEach((g:Node) => {
|
||||
g.parent = null;
|
||||
});
|
||||
|
||||
this._upMap.clear();
|
||||
this._selectMap.clear();
|
||||
|
||||
this.initGeneralCfg();
|
||||
}
|
||||
|
||||
protected onClickOK():void{
|
||||
var keys = this._upMap.keys();
|
||||
var ids = Array.from(keys);
|
||||
GeneralCommand.getInstance().convert(ids);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralConvertLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralConvertLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8c6e4078-04fd-4430-8f46-59b03888e083",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
172
assets/scripts/map/ui/GeneralDesLogic.ts
Normal file
172
assets/scripts/map/ui/GeneralDesLogic.ts
Normal file
@@ -0,0 +1,172 @@
|
||||
import { _decorator, Component, Label, Layout, Prefab, Node, EventTouch, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import {GeneralData } from "../../general/GeneralProxy";
|
||||
import SkillCommand from "../../skill/SkillCommand";
|
||||
import GeneralItemLogic, { GeneralItemType } from "./GeneralItemLogic";
|
||||
import SkillIconLogic from "./SkillIconLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('GeneralDesLogic')
|
||||
export default class GeneralDesLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
|
||||
@property(Layout)
|
||||
srollLayout:Layout = null;
|
||||
|
||||
@property(Label)
|
||||
lvLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
foreLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
defenseLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
speedLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
strategyLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
destroyLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
expLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
powerLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
costLabel: Label = null;
|
||||
|
||||
|
||||
@property(Prefab)
|
||||
generalItemPrefab: Prefab = null;
|
||||
|
||||
@property(Node)
|
||||
generalItemParent: Node = null;
|
||||
|
||||
@property([Node])
|
||||
skillIcons: Node[] = [];
|
||||
|
||||
@property([Label])
|
||||
skillNameLab: Label[] = [];
|
||||
|
||||
private _currData:GeneralData = null;
|
||||
private _cfgData:any = null;
|
||||
|
||||
|
||||
private _nameObj:any = {};
|
||||
private _addPrObj:any = {};
|
||||
private _generalNode:Node = null;
|
||||
|
||||
protected onEnable(){
|
||||
EventMgr.on("update_general", this.updateGeneral, this)
|
||||
}
|
||||
|
||||
protected onDisable(){
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onLoad():void{
|
||||
|
||||
this._nameObj = {
|
||||
force:"武力",
|
||||
strategy:"战略",
|
||||
defense:"防御",
|
||||
speed:"速度",
|
||||
destroy:"破坏",
|
||||
};
|
||||
|
||||
this._generalNode = instantiate(this.generalItemPrefab);
|
||||
this._generalNode.parent = this.generalItemParent;
|
||||
}
|
||||
|
||||
protected updateGeneral(){
|
||||
var data = GeneralCommand.getInstance().proxy.getMyGeneral(this._currData.id);
|
||||
if(data){
|
||||
this.setData(this._cfgData, data);
|
||||
}
|
||||
}
|
||||
|
||||
public setData(cfgData:any, curData:GeneralData):void{
|
||||
this._currData = curData;
|
||||
this._cfgData = cfgData;
|
||||
|
||||
var nextCfg = GeneralCommand.getInstance().proxy.getGeneralLevelCfg(this._currData.level + 1);
|
||||
var levelExp = nextCfg?nextCfg.exp:"MAX";
|
||||
var maxLevel: number = GeneralCommand.getInstance().proxy.getMaxLevel();
|
||||
this.lvLabel.string = '等级:' + this._currData.level + "/" + maxLevel;
|
||||
this.expLabel.string = "经验:" + curData.exp +"/" + levelExp;
|
||||
|
||||
this.nameLab.string = this._cfgData.name;
|
||||
|
||||
this._addPrObj = {
|
||||
force:this._currData.force_added,
|
||||
strategy:this._currData.strategy_added,
|
||||
defense:this._currData.defense_added,
|
||||
speed:this._currData.speed_added,
|
||||
destroy:this._currData.destroy_added,
|
||||
};
|
||||
|
||||
|
||||
this.foreLabel.string = this.getAttrStr("force");
|
||||
this.strategyLabel.string = this.getAttrStr("strategy");
|
||||
this.defenseLabel.string = this.getAttrStr("defense");
|
||||
this.speedLabel.string = this.getAttrStr("speed");
|
||||
this.destroyLabel.string = this.getAttrStr("destroy");
|
||||
|
||||
var com = this._generalNode.getComponent(GeneralItemLogic);
|
||||
if(com){
|
||||
com.updateItem(this._currData, GeneralItemType.GeneralNoThing);
|
||||
}
|
||||
|
||||
this.powerLabel.string = "体力:" + curData.physical_power + "/" + cfgData.physical_power_limit;
|
||||
this.costLabel.string = "cost:"+cfgData.cost;
|
||||
|
||||
for (let index = 0; index < curData.skills.length; index++) {
|
||||
let gSkill = curData.skills[index];
|
||||
let icon = this.skillIcons[index];
|
||||
let iconNameLab = this.skillNameLab[index];
|
||||
|
||||
if(gSkill == null){
|
||||
icon.getComponent(SkillIconLogic).setData(null, null);
|
||||
iconNameLab.string = "";
|
||||
}else{
|
||||
|
||||
let skillConf = SkillCommand.getInstance().proxy.getSkillCfg(gSkill.cfgId);
|
||||
let skill = SkillCommand.getInstance().proxy.getSkill(gSkill.cfgId);
|
||||
if(skillConf && skill){
|
||||
icon.getComponent(SkillIconLogic).setData(skill, gSkill);
|
||||
iconNameLab.string = skillConf.name;
|
||||
}else{
|
||||
icon.getComponent(SkillIconLogic).setData(null, null);
|
||||
iconNameLab.string = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getAttrStr(key: string) :string{
|
||||
var str = GeneralData.getPrStr(this._cfgData[key], this._addPrObj[key], this._currData.level, this._cfgData[key + "_grow"])
|
||||
return this._nameObj[key] + ":" + str;
|
||||
}
|
||||
|
||||
protected onClickSkill(event: EventTouch, pos){
|
||||
console.log("event", event, pos);
|
||||
var node: Node = event.target;
|
||||
var isEmpty = node.getComponent(SkillIconLogic).isEmpty();
|
||||
if(isEmpty){
|
||||
EventMgr.emit("open_skill", 1, this._currData, pos);
|
||||
}else{
|
||||
let skill = node.getComponent(SkillIconLogic).getSkill();
|
||||
EventMgr.emit("open_skillInfo", skill, 2, this._currData, pos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralDesLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralDesLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4986f436-70f5-4373-9813-61a448f35b77",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
39
assets/scripts/map/ui/GeneralHeadLogic.ts
Normal file
39
assets/scripts/map/ui/GeneralHeadLogic.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { _decorator, Component, Sprite, SpriteFrame, resources } from 'cc';
|
||||
const {ccclass} = _decorator;
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
|
||||
@ccclass('GeneralHeadLogic')
|
||||
export default class GeneralHeadLogic extends Component {
|
||||
|
||||
public setHeadId(id:number) {
|
||||
|
||||
// console.log("setHeadId:", id);
|
||||
var frame = GeneralCommand.getInstance().proxy.getGeneralTex(id);
|
||||
if(frame){
|
||||
var sp = this.node.getComponent(Sprite);
|
||||
if(sp){
|
||||
sp.spriteFrame = frame;
|
||||
}
|
||||
}else{
|
||||
|
||||
console.log("load setHeadId:", id);
|
||||
resources.load("./generalpic/card_" + id + "/spriteFrame", SpriteFrame,
|
||||
(finish: number, total: number) => {
|
||||
},
|
||||
(error: Error, asset: any) => {
|
||||
if (error != null) {
|
||||
console.log("setHeadId error:", error.message);
|
||||
}else{
|
||||
var frame = asset as SpriteFrame;
|
||||
var sp = this.node.getComponent(Sprite);
|
||||
if(sp){
|
||||
sp.spriteFrame = frame;
|
||||
}
|
||||
|
||||
GeneralCommand.getInstance().proxy.setGeneralTex(id, frame);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralHeadLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralHeadLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e558b072-202c-4577-9ca7-07e5ee9fef5b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
101
assets/scripts/map/ui/GeneralInfoLogic.ts
Normal file
101
assets/scripts/map/ui/GeneralInfoLogic.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
import { _decorator, Component, Prefab, ToggleContainer, Node, instantiate } from 'cc';
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('GeneralInfoLogic')
|
||||
export default class GeneralInfoLogic extends Component {
|
||||
|
||||
|
||||
@property(Prefab)
|
||||
generalDesPrefab: Prefab = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalComposePrefab: Prefab = null;
|
||||
|
||||
|
||||
@property(Prefab)
|
||||
generalAddPrefab: Prefab = null;
|
||||
|
||||
|
||||
@property(ToggleContainer)
|
||||
generalToggleContainer: ToggleContainer = null;
|
||||
|
||||
|
||||
private _currData:any = null;
|
||||
private _cfgData:any = null;
|
||||
|
||||
private _curIndex:number = 0;
|
||||
private _nodeList:Node[] = [];
|
||||
|
||||
protected onLoad():void{
|
||||
EventMgr.on("update_one_generals", this.updateOnce, this);
|
||||
|
||||
var des = instantiate(this.generalDesPrefab);
|
||||
des.parent = this.node;
|
||||
des.active = false;
|
||||
|
||||
|
||||
var comp = instantiate(this.generalComposePrefab);
|
||||
comp.parent = this.node;
|
||||
comp.active = false;
|
||||
|
||||
|
||||
var addd = instantiate(this.generalAddPrefab);
|
||||
addd.parent = this.node;
|
||||
addd.active = false;
|
||||
|
||||
this._nodeList[0] = des;
|
||||
this._nodeList[1] = comp;
|
||||
this._nodeList[2] = addd;
|
||||
}
|
||||
|
||||
protected updateOnce(curData:any):void{
|
||||
this.setData(this._cfgData,curData)
|
||||
}
|
||||
|
||||
|
||||
protected onDestroy():void{
|
||||
this._nodeList = []
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public setData(cfgData:any,curData:any):void{
|
||||
this._currData = curData;
|
||||
this._cfgData = cfgData;
|
||||
this.setIndex(this._curIndex);
|
||||
}
|
||||
|
||||
protected setIndex(index:number = 0):void{
|
||||
this._curIndex = index;
|
||||
this.allVisible();
|
||||
this._nodeList[index].active = true;
|
||||
this.generalToggleContainer.toggleItems[index].isChecked = true;
|
||||
|
||||
let logicNameArr:string[] = ["GeneralDesLogic","GeneralComposeLogic","GeneralAddPrLogic"]
|
||||
let com = this._nodeList[index].getComponent(logicNameArr[index]);
|
||||
if(com){
|
||||
com.setData(this._cfgData, this._currData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected allVisible():void{
|
||||
for(var i = 0; i < this._nodeList.length; i++){
|
||||
this._nodeList[i].active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected selectHandle(event:any,other:any):void{
|
||||
// console.log("event:",event,other)
|
||||
this.setIndex(other)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralInfoLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralInfoLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "96f821a7-11eb-4c5e-a507-83f8bf493b45",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
216
assets/scripts/map/ui/GeneralItemLogic.ts
Normal file
216
assets/scripts/map/ui/GeneralItemLogic.ts
Normal file
@@ -0,0 +1,216 @@
|
||||
|
||||
import { _decorator, Component, Label, Sprite, Layout, Node, color } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralCampType, GeneralData } from "../../general/GeneralProxy";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
// /**军队命令*/
|
||||
export class GeneralItemType {
|
||||
static GeneralInfo: number = 0;//武将详情
|
||||
static GeneralDispose: number = 1;//武将上阵
|
||||
static GeneralConScript: number = 2;//武将征兵
|
||||
static GeneralNoThing: number = 3;//无用
|
||||
static GeneralSelect: number = 4;//选择
|
||||
}
|
||||
|
||||
|
||||
@ccclass('GeneralItemLogic')
|
||||
export default class GeneralItemLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
lvLabel: Label = null;
|
||||
|
||||
@property(Sprite)
|
||||
spritePic:Sprite = null;
|
||||
|
||||
@property(Label)
|
||||
costLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
campLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
armLabel: Label = null;
|
||||
|
||||
@property(Layout)
|
||||
starLayout:Layout = null;
|
||||
|
||||
@property(Node)
|
||||
delNode:Node = null;
|
||||
|
||||
@property(Node)
|
||||
useNode:Node = null;
|
||||
|
||||
|
||||
@property(Node)
|
||||
selectNode:Node = null;
|
||||
|
||||
private _curData:any = null;
|
||||
private _type:number = -1;
|
||||
private _position:number = 0;
|
||||
private _cityData:any = null;
|
||||
private _orderId:number = 1;
|
||||
private _isSelect:boolean = false;
|
||||
|
||||
protected onLoad():void{
|
||||
this.delNode.active = false;
|
||||
this._isSelect = false;
|
||||
}
|
||||
|
||||
|
||||
public setData(curData:GeneralData,type:number = 0,position:number = 0):void{
|
||||
this.updateItem(curData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public updateItem(curData:any):void{
|
||||
this.updateView(curData);
|
||||
this._type = this._curData.type == undefined?-1:this._curData.type;
|
||||
this._position = this._curData.position == undefined?0:this._curData.position;
|
||||
}
|
||||
|
||||
|
||||
protected updateView(curData:any):void{
|
||||
this._curData = curData;
|
||||
|
||||
var cfgData = GeneralCommand.getInstance().proxy.getGeneralCfg(this._curData.cfgId);
|
||||
this.nameLabel.string = cfgData.name
|
||||
this.lvLabel.string = " Lv." + this._curData.level ;
|
||||
this.spritePic.getComponent(GeneralHeadLogic).setHeadId(this._curData.cfgId);
|
||||
this.showStar(cfgData.star,this._curData.star_lv);
|
||||
this.delNode.active = false;
|
||||
|
||||
if(cfgData.camp == GeneralCampType.Han){
|
||||
this.campLabel.string = "汉";
|
||||
}else if(cfgData.camp == GeneralCampType.Qun){
|
||||
this.campLabel.string = "群";
|
||||
}else if(cfgData.camp == GeneralCampType.Wei){
|
||||
this.campLabel.string = "魏";
|
||||
}else if(cfgData.camp == GeneralCampType.Shu){
|
||||
this.campLabel.string = "蜀";
|
||||
}else if(cfgData.camp == GeneralCampType.Wu){
|
||||
this.campLabel.string = "吴";
|
||||
}
|
||||
|
||||
this.armLabel.string = this.armstr(cfgData.arms);
|
||||
|
||||
if(this.useNode){
|
||||
if(this._type == GeneralItemType.GeneralInfo && this._curData.order > 0){
|
||||
this.useNode.active = true;
|
||||
}else{
|
||||
this.useNode.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.costLabel){
|
||||
this.costLabel.string = cfgData.cost + "";
|
||||
}
|
||||
this.select(false);
|
||||
}
|
||||
|
||||
protected armstr(arms:number []): string{
|
||||
// console.log("armstr:", arms);
|
||||
|
||||
var str = ""
|
||||
if(arms.indexOf(1)>=0 || arms.indexOf(4)>=0 || arms.indexOf(7)>=0){
|
||||
str += "步"
|
||||
}else if(arms.indexOf(2)>=0 || arms.indexOf(5)>=0 || arms.indexOf(8)>=0){
|
||||
str += "弓"
|
||||
}else if(arms.indexOf(3)>=0 || arms.indexOf(6)>=0 || arms.indexOf(9)>=0){
|
||||
str += "骑"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
public select(flag:boolean):void{
|
||||
if(this.selectNode){
|
||||
this.selectNode.active = flag;
|
||||
}
|
||||
this._isSelect = flag;
|
||||
}
|
||||
|
||||
|
||||
protected showStar(star:number = 3,star_lv:number = 0):void{
|
||||
var childen = this.starLayout.node.children;
|
||||
for(var i = 0;i<childen.length;i++){
|
||||
if(i < star){
|
||||
childen[i].active = true;
|
||||
if(i < star_lv){
|
||||
childen[i].getComponent(Sprite).color = color(255,0,0);
|
||||
}else{
|
||||
childen[i].getComponent(Sprite).color = color(255,255,255);
|
||||
}
|
||||
}else{
|
||||
childen[i].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected setOtherData(cityData:any,orderId:number = 1):void{
|
||||
this._cityData = cityData;
|
||||
this._orderId = orderId
|
||||
this.delNode.active = true;
|
||||
}
|
||||
|
||||
|
||||
protected onClickGeneral(event:any): void {
|
||||
if(this._curData){
|
||||
var cfgData = this._curData.config;
|
||||
console.log("onClickGeneral:", this._type);
|
||||
|
||||
//武将详情
|
||||
if(this._type == GeneralItemType.GeneralInfo){
|
||||
EventMgr.emit("open_general_des",cfgData, this._curData);
|
||||
}
|
||||
|
||||
//上阵
|
||||
else if(this._type == GeneralItemType.GeneralDispose){
|
||||
EventMgr.emit("chosed_general", cfgData, this._curData, this._position);
|
||||
}
|
||||
|
||||
//征兵
|
||||
else if(this._type == GeneralItemType.GeneralConScript){
|
||||
EventMgr.emit("open_army_conscript", this._orderId, this._cityData);
|
||||
}
|
||||
|
||||
else if(this._type == GeneralItemType.GeneralSelect){
|
||||
this._isSelect = !this._isSelect;
|
||||
this.select(this._isSelect);
|
||||
EventMgr.emit("open_general_select", cfgData, this._curData, this.node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 下阵
|
||||
*/
|
||||
protected onDelete():void{
|
||||
var cfgData = this._curData.config;
|
||||
EventMgr.emit("chosed_general",cfgData,this._curData,-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 战报的
|
||||
* @param curData
|
||||
*/
|
||||
public setWarReportData(curData:any):void{
|
||||
this.updateView(curData)
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "96e83c2a-c652-46c2-9ae9-5fc532a302b7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
89
assets/scripts/map/ui/GeneralListLogic.ts
Normal file
89
assets/scripts/map/ui/GeneralListLogic.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
import { _decorator, Component, ScrollView, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('GeneralListLogic')
|
||||
export default class GeneralListLogic extends Component {
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
@property(Label)
|
||||
cntLab:Label = null;
|
||||
|
||||
private _cunGeneral:number[] = [];
|
||||
private _type:number = 0;
|
||||
private _position:number = 0;
|
||||
|
||||
protected onEnable():void{
|
||||
EventMgr.on("update_my_generals", this.initGeneralCfg, this);
|
||||
EventMgr.on("general_convert", this.initGeneralCfg, this);
|
||||
EventMgr.on("chosed_general", this.onClickClose, this);
|
||||
}
|
||||
|
||||
|
||||
protected onDisable():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected onClickConvert(): void {
|
||||
EventMgr.emit("open_general_convert");
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected onTuJianConvert(): void {
|
||||
EventMgr.emit("open_general_roster");
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected initGeneralCfg():void{
|
||||
|
||||
var basic = MapUICommand.getInstance().proxy.getBasicGeneral();
|
||||
var cnt = GeneralCommand.getInstance().proxy.getMyActiveGeneralCnt();
|
||||
this.cntLab.string = "(" + cnt + "/" + basic.limit + ")";
|
||||
|
||||
let list:any[] = GeneralCommand.getInstance().proxy.getUseGenerals();
|
||||
let listTemp = list.concat();
|
||||
|
||||
|
||||
listTemp.forEach(item => {
|
||||
item.type = this._type;
|
||||
item.position = this._position;
|
||||
})
|
||||
|
||||
|
||||
for(var i = 0; i < listTemp.length ;i++){
|
||||
if(this._cunGeneral.indexOf(listTemp[i].id) >= 0 ){
|
||||
listTemp.splice(i,1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
comp.setData(listTemp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public setData(data:number[],type:number = 0,position:number = 0):void{
|
||||
this._cunGeneral = [];
|
||||
if(data && data.length > 0){
|
||||
this._cunGeneral = data;
|
||||
}
|
||||
|
||||
this._type = type;
|
||||
this._position = position;
|
||||
|
||||
this.initGeneralCfg();
|
||||
GeneralCommand.getInstance().qryMyGenerals();
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralListLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralListLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4a20faad-c58f-419c-9ce2-600a2db74d34",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
47
assets/scripts/map/ui/GeneralRosterListLogic.ts
Normal file
47
assets/scripts/map/ui/GeneralRosterListLogic.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralConfig } from "../../general/GeneralProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('GeneralRosterListLogic')
|
||||
export default class GeneralRosterListLogic extends Component {
|
||||
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
protected onEnable(): void {
|
||||
this.initGeneralCfg();
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
EventMgr.emit("open_general");
|
||||
}
|
||||
|
||||
|
||||
protected initGeneralCfg():void{
|
||||
|
||||
let cfgs = GeneralCommand.getInstance().proxy.getGeneralAllCfg();
|
||||
var arr = Array.from(cfgs.values());
|
||||
arr.sort(this.sortStar);
|
||||
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
comp.setData(arr);
|
||||
|
||||
}
|
||||
|
||||
protected sortStar(a: GeneralConfig, b: GeneralConfig): number {
|
||||
|
||||
if(a.star < b.star){
|
||||
return 1;
|
||||
}else if(a.star == b.star){
|
||||
return a.cfgId - b.cfgId;
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralRosterListLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralRosterListLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cd7a369e-5a03-44d0-ab87-294694e4241f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
108
assets/scripts/map/ui/GeneralRosterLogic.ts
Normal file
108
assets/scripts/map/ui/GeneralRosterLogic.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { _decorator, Component, Label, Sprite, Layout, color } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { GeneralCampType, GeneralConfig } from "../../general/GeneralProxy";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
|
||||
|
||||
// /**军队命令*/
|
||||
export class GeneralItemType {
|
||||
static GeneralInfo: number = 0;//武将详情
|
||||
static GeneralDispose: number = 1;//武将上阵
|
||||
static GeneralConScript: number = 2;//武将征兵
|
||||
static GeneralNoThing: number = 3;//无用
|
||||
static GeneralSelect: number = 4;//选择
|
||||
}
|
||||
|
||||
|
||||
@ccclass('GeneralRosterLogic')
|
||||
export default class GeneralRosterLogic extends Component {
|
||||
|
||||
|
||||
@property(Label)
|
||||
nameLabel: Label = null;
|
||||
|
||||
|
||||
@property(Sprite)
|
||||
spritePic:Sprite = null;
|
||||
|
||||
@property(Label)
|
||||
costLabel: Label = null;
|
||||
|
||||
|
||||
@property(Layout)
|
||||
starLayout:Layout = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
campLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
armLabel: Label = null;
|
||||
|
||||
_cfg:GeneralConfig = null;
|
||||
|
||||
public setData(cfg:GeneralConfig): void{
|
||||
this.updateItem(cfg);
|
||||
}
|
||||
|
||||
protected updateItem(cfg:GeneralConfig):void{
|
||||
// console.log("updateItem");
|
||||
this._cfg = cfg;
|
||||
this.nameLabel.string = this._cfg.name
|
||||
this.spritePic.getComponent(GeneralHeadLogic).setHeadId(this._cfg.cfgId);
|
||||
this.showStar(this._cfg.star, 0);
|
||||
|
||||
if(this.costLabel){
|
||||
this.costLabel.string = this._cfg.cost + "";
|
||||
}
|
||||
|
||||
if(this._cfg.camp == GeneralCampType.Han){
|
||||
this.campLabel.string = "汉";
|
||||
}else if(this._cfg.camp == GeneralCampType.Qun){
|
||||
this.campLabel.string = "群";
|
||||
}else if(this._cfg.camp == GeneralCampType.Wei){
|
||||
this.campLabel.string = "魏";
|
||||
}else if(this._cfg.camp == GeneralCampType.Shu){
|
||||
this.campLabel.string = "蜀";
|
||||
}else if(this._cfg.camp == GeneralCampType.Wu){
|
||||
this.campLabel.string = "吴";
|
||||
}
|
||||
|
||||
this.armLabel.string = this.armstr(this._cfg.arms);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected showStar(star:number = 3,star_lv:number = 0):void{
|
||||
var childen = this.starLayout.node.children;
|
||||
for(var i = 0;i<childen.length;i++){
|
||||
if(i < star){
|
||||
childen[i].active = true;
|
||||
if(i < star_lv){
|
||||
childen[i].getComponent(Sprite).color = color(255,0,0);
|
||||
}else{
|
||||
childen[i].getComponent(Sprite).color = color(255,255,255);
|
||||
}
|
||||
}else{
|
||||
childen[i].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected armstr(arms:number []): string{
|
||||
// console.log("armstr:", arms);
|
||||
|
||||
var str = ""
|
||||
if(arms.indexOf(1)>=0 || arms.indexOf(4)>=0 || arms.indexOf(7)>=0){
|
||||
str += "步"
|
||||
}else if(arms.indexOf(2)>=0 || arms.indexOf(5)>=0 || arms.indexOf(8)>=0){
|
||||
str += "弓"
|
||||
}else if(arms.indexOf(3)>=0 || arms.indexOf(6)>=0 || arms.indexOf(9)>=0){
|
||||
str += "骑"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/GeneralRosterLogic.ts.meta
Normal file
11
assets/scripts/map/ui/GeneralRosterLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "796acf32-d118-422c-be0e-f94255cb5387",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
276
assets/scripts/map/ui/MapUICommand.ts
Normal file
276
assets/scripts/map/ui/MapUICommand.ts
Normal file
@@ -0,0 +1,276 @@
|
||||
import { _decorator } from 'cc';
|
||||
import { ServerConfig } from "../../config/ServerConfig";
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import { NetManager } from "../../network/socket/NetManager";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import MapCommand from "../MapCommand";
|
||||
import MapUIProxy, { CityAddition, Facility } from "./MapUIProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
export default class MapUICommand {
|
||||
//单例
|
||||
protected static _instance: MapUICommand;
|
||||
public static getInstance(): MapUICommand {
|
||||
if (this._instance == null) {
|
||||
this._instance = new MapUICommand();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
public static destory(): boolean {
|
||||
if (this._instance) {
|
||||
this._instance.onDestory();
|
||||
this._instance = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//数据model
|
||||
protected _proxy: MapUIProxy = new MapUIProxy();
|
||||
|
||||
constructor() {
|
||||
EventMgr.on(ServerConfig.city_facilities, this.onCityFacilities, this);
|
||||
EventMgr.on(ServerConfig.city_upFacility, this.onCityUpFacility, this);
|
||||
EventMgr.on(ServerConfig.role_myRoleRes, this.onRoleMyRoleRes, this);
|
||||
EventMgr.on(ServerConfig.war_report, this.onUpdataWarReports, this);
|
||||
EventMgr.on(ServerConfig.war_reportPush, this.onUpdataWarReport, this);
|
||||
EventMgr.on(ServerConfig.war_read, this.onUpdataWarRead, this);
|
||||
EventMgr.on(ServerConfig.interior_collect, this.onCollect, this);
|
||||
EventMgr.on(ServerConfig.interior_openCollect, this.onOpenCollect, this);
|
||||
|
||||
EventMgr.on(ServerConfig.roleRes_push, this.updataRoleRes, this);
|
||||
|
||||
|
||||
setInterval(() => {
|
||||
let list: Map<number, Map<number, Facility>> = this._proxy.getMyAllFacilitys();
|
||||
list.forEach((fs, key) => {
|
||||
fs.forEach(f => {
|
||||
if(f.isNeedUpdateLevel()){
|
||||
//倒计时完,请求最新的等级
|
||||
console.log("有设施升级完了,需要刷新");
|
||||
this.qryCityFacilities(key);
|
||||
return
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
protected onCityFacilities(data: any): void {
|
||||
console.log("onCityFacilities :", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateMyFacilityList(data.msg.cityId, data.msg.facilities);
|
||||
EventMgr.emit("update_my_facilities");
|
||||
|
||||
//刷新城池附加加成
|
||||
let cityData: MapCityData = MapCommand.getInstance().cityProxy.getMyCityById(data.msg.cityId);
|
||||
let addition: CityAddition = this._proxy.updateMyCityAdditions(cityData.cityId);
|
||||
cityData.maxDurable = this._proxy.getMyCityMaxDurable(data.msg.cityId);
|
||||
EventMgr.emit("update_city_addition", data.msg.cityId, addition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onCityUpFacility(data: any): void {
|
||||
console.log("onCityUpFacility :", data);
|
||||
if (data.code == 0) {
|
||||
let facilityData: Facility = this._proxy.updateMyFacility(data.msg.cityId, data.msg.facility);
|
||||
EventMgr.emit("update_my_facility", data.msg.cityId, facilityData);
|
||||
LoginCommand.getInstance().proxy.saveEnterData(data.msg);
|
||||
EventMgr.emit("upate_my_roleRes");
|
||||
|
||||
//刷新城池附加加成
|
||||
let cityData: MapCityData = MapCommand.getInstance().cityProxy.getMyCityById(data.msg.cityId);
|
||||
let addition: CityAddition = this._proxy.updateMyCityAdditions(data.msg.cityId);
|
||||
cityData.maxDurable = this._proxy.getMyCityMaxDurable(data.msg.cityId);
|
||||
EventMgr.emit("update_city_addition", data.msg.cityId, addition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onRoleMyRoleRes(data: any): void {
|
||||
console.log("onRoleMyProperty :", data);
|
||||
if (data.code == 0) {
|
||||
LoginCommand.getInstance().proxy.saveEnterData(data.msg);
|
||||
EventMgr.emit("upate_my_roleRes");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected updataRoleRes(data: any): void {
|
||||
if (data.code == 0) {
|
||||
LoginCommand.getInstance().proxy.setRoleResData(data.msg);
|
||||
EventMgr.emit("upate_my_roleRes");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected onUpdataWarReports(data: any): void {
|
||||
console.log("onUpdataWarReport :", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateWarReports(data.msg);
|
||||
EventMgr.emit("upate_war_report");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected onUpdataWarReport(data: any): void {
|
||||
console.log("onUpdataWarReport :", data);
|
||||
if (data.code == 0) {
|
||||
this._proxy.updateWarReport(data.msg);
|
||||
EventMgr.emit("upate_war_report");
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdataWarRead(data: any): void {
|
||||
console.log("onUpdataWarRead :", data);
|
||||
if (data.code == 0) {
|
||||
var id = data.msg.id;
|
||||
if (id == 0) {
|
||||
this._proxy.updateAllWarRead(true);
|
||||
}else{
|
||||
this._proxy.updateWarRead(id, true);
|
||||
}
|
||||
|
||||
EventMgr.emit("upate_war_report");
|
||||
}
|
||||
}
|
||||
|
||||
protected onCollect(data:any):void {
|
||||
console.log("onCollect :", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("interior_collect", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected onOpenCollect(data:any):void{
|
||||
console.log("onOpenCollect :", data);
|
||||
if (data.code == 0) {
|
||||
EventMgr.emit("interior_openCollect", data.msg);
|
||||
}
|
||||
}
|
||||
|
||||
public onDestory(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
public get proxy(): MapUIProxy {
|
||||
return this._proxy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设施
|
||||
* @param cityId
|
||||
*/
|
||||
public qryCityFacilities(cityId: number = 0): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.city_facilities,
|
||||
msg: {
|
||||
cityId: cityId,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 升级设施
|
||||
* @param cityId
|
||||
* @param ftype
|
||||
*/
|
||||
public upFacility(cityId: number = 0, ftype: number = 0): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.city_upFacility,
|
||||
msg: {
|
||||
cityId: cityId,
|
||||
fType: ftype,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的角色资源属性
|
||||
* @param cityId
|
||||
*/
|
||||
public qryMyRoleRes(): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.role_myRoleRes,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 我的角色资源属性(全)
|
||||
* @param
|
||||
*/
|
||||
public updateMyProperty(data: any): void {
|
||||
LoginCommand.getInstance().proxy.saveEnterData(data.msg);
|
||||
EventMgr.emit("upate_my_roleRes");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 战报查询
|
||||
*/
|
||||
public qryWarReport(): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.war_report,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 读取
|
||||
*/
|
||||
public warRead(id: number = 0): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.war_read,
|
||||
msg: {
|
||||
id: id,
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public interiorCollect(): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.interior_collect,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public interiorOpenCollect(): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.interior_openCollect,
|
||||
msg: {
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
public interiorTransform(from:number[],to:number[]): void {
|
||||
let sendData: any = {
|
||||
name: ServerConfig.interior_transform,
|
||||
msg: {
|
||||
from:from,
|
||||
to:to
|
||||
}
|
||||
};
|
||||
NetManager.getInstance().send(sendData);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/MapUICommand.ts.meta
Normal file
11
assets/scripts/map/ui/MapUICommand.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c642be40-fa7a-4288-ae34-e8d040dd607d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
532
assets/scripts/map/ui/MapUILogic.ts
Normal file
532
assets/scripts/map/ui/MapUILogic.ts
Normal file
@@ -0,0 +1,532 @@
|
||||
import { _decorator, Component, Prefab, Node, Layout, Label, instantiate, UITransform } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import ArmySelectNodeLogic from "./ArmySelectNodeLogic";
|
||||
import CityArmySettingLogic from "./CityArmySettingLogic";
|
||||
import FacilityListLogic from "./FacilityListLogic";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import Dialog from "./Dialog";
|
||||
import UnionCommand from "../../union/UnionCommand";
|
||||
import MapCommand from "../MapCommand";
|
||||
import FortressAbout from "./FortressAbout";
|
||||
import CityAboutLogic from "./CityAboutLogic";
|
||||
import GeneralListLogic from "./GeneralListLogic";
|
||||
import TransformLogic from "./TransformLogic";
|
||||
import { Tools } from "../../utils/Tools";
|
||||
import GeneralInfoLogic from "./GeneralInfoLogic";
|
||||
import WarReportLogic from "./WarReportLogic";
|
||||
import DrawRLogic from "./DrawRLogic";
|
||||
import { GeneralData } from "../../general/GeneralProxy";
|
||||
import SkillLogic from "./SkillLogic";
|
||||
import { SkillConf } from "../../config/skill/Skill";
|
||||
import SkillInfoLogic from "./SkillInfoLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
|
||||
|
||||
@ccclass('MapUILogic')
|
||||
export default class MapUILogic extends Component {
|
||||
|
||||
@property(Node)
|
||||
contentNode:Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
facilityPrefab: Prefab = null;
|
||||
protected _facilityNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
armySettingPrefab: Prefab = null;
|
||||
protected _armySettingNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
dialog: Prefab = null;
|
||||
protected _dialogNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalPrefab: Prefab = null;
|
||||
protected _generalNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalDesPrefab: Prefab = null;
|
||||
protected _generalDesNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
cityAboutPrefab: Prefab = null;
|
||||
protected _cityAboutNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
fortressAboutPrefab: Prefab = null;
|
||||
protected _fortressAboutNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
warReportPrefab: Prefab = null;
|
||||
protected _warReportNode: Node = null;
|
||||
@property(Prefab)
|
||||
armySelectPrefab: Prefab = null;
|
||||
protected _armySelectNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
drawPrefab: Prefab = null;
|
||||
protected _drawNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
drawResultrefab: Prefab = null;
|
||||
protected _drawResultNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
unionPrefab: Prefab = null;
|
||||
protected _unionNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
chatPrefab: Prefab = null;
|
||||
protected _chatNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
collectPrefab: Prefab = null;
|
||||
protected _collectNode: Node = null;
|
||||
|
||||
|
||||
@property(Prefab)
|
||||
transFormPrefab: Prefab = null;
|
||||
protected _transFormNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalConvertPrefab: Prefab = null;
|
||||
protected _generalConvertNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
generalRosterPrefab: Prefab = null;
|
||||
protected _generalRosterNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
skillPrefab: Prefab = null;
|
||||
protected _skillNode: Node = null;
|
||||
|
||||
@property(Prefab)
|
||||
skillInfoPrefab: Prefab = null;
|
||||
protected _skillInfoNode: Node = null;
|
||||
|
||||
@property(Node)
|
||||
widgetNode: Node = null;
|
||||
|
||||
@property(Layout)
|
||||
srollLayout: Layout = null;
|
||||
|
||||
@property(Label)
|
||||
nameLabel: Label = null;
|
||||
|
||||
@property(Label)
|
||||
ridLabel: Label = null;
|
||||
|
||||
protected _resArray: any = [];
|
||||
protected _yieldArray: any = [];
|
||||
|
||||
protected onLoad(): void {
|
||||
|
||||
this._resArray.push({key:"grain", name:"谷:"});
|
||||
this._resArray.push({key:"wood", name:"木:"});
|
||||
this._resArray.push({key:"iron", name:"铁:"});
|
||||
this._resArray.push({key:"stone", name:"石:"});
|
||||
this._resArray.push({key:"gold", name:"钱:"});
|
||||
|
||||
this._yieldArray.push({key:"wood_yield", name:"木+"});
|
||||
this._yieldArray.push({key:"iron_yield", name:"铁+"});
|
||||
this._yieldArray.push({key:"stone_yield", name:"石+"});
|
||||
this._yieldArray.push({key:"grain_yield", name:"谷+"});
|
||||
|
||||
|
||||
EventMgr.on("open_city_about", this.openCityAbout, this);
|
||||
EventMgr.on("close_city_about", this.closeCityAbout, this);
|
||||
|
||||
EventMgr.on("open_fortress_about", this.openFortressAbout, this);
|
||||
EventMgr.on("open_facility", this.openFacility, this);
|
||||
|
||||
|
||||
EventMgr.on("open_army_setting", this.openArmySetting, this);
|
||||
EventMgr.on("upate_my_roleRes", this.updateRoleRes, this);
|
||||
EventMgr.on("open_general_des", this.openGeneralDes, this);
|
||||
EventMgr.on("open_general_choose", this.openGeneralChoose, this);
|
||||
EventMgr.on("open_army_select_ui", this.onOpenArmySelectUI, this);
|
||||
EventMgr.on("open_draw_result", this.openDrawR, this);
|
||||
EventMgr.on("robLoginUI", this.robLoginUI, this);
|
||||
EventMgr.on("interior_collect", this.onCollection, this);
|
||||
EventMgr.on("open_general_convert", this.onOpenGeneralConvert, this);
|
||||
EventMgr.on("open_general_roster", this.onOpenGeneralRoster, this);
|
||||
EventMgr.on("open_general", this.openGeneral, this);
|
||||
EventMgr.on("open_skill", this.onOpenSkill, this);
|
||||
EventMgr.on("close_skill", this.onCloseSkill, this);
|
||||
EventMgr.on("open_skillInfo", this.onOpenSkillInfo, this);
|
||||
|
||||
|
||||
|
||||
this.updateRoleRes();
|
||||
this.updateRole();
|
||||
let unionId = MapCommand.getInstance().cityProxy.myUnionId;
|
||||
if (unionId > 0) {
|
||||
UnionCommand.getInstance().unionApplyList(unionId);
|
||||
}
|
||||
}
|
||||
|
||||
protected robLoginUI(): void {
|
||||
this.showTip("账号在其他地方登录",function () {
|
||||
EventMgr.emit("enter_login");
|
||||
});
|
||||
}
|
||||
|
||||
protected showTip(text:string, close:Function):void {
|
||||
if (this._dialogNode == null){
|
||||
this._dialogNode = instantiate(this.dialog)
|
||||
this._dialogNode.parent = this.contentNode;
|
||||
}else{
|
||||
this._dialogNode.active = true;
|
||||
}
|
||||
this._dialogNode.setSiblingIndex(this.topLayer());
|
||||
this._dialogNode.getComponent(Dialog).text(text);
|
||||
this._dialogNode.getComponent(Dialog).setClose(close)
|
||||
}
|
||||
|
||||
|
||||
protected onDestroy(): void {
|
||||
this.clearAllNode();
|
||||
MapUICommand.getInstance().proxy.clearData();
|
||||
EventMgr.targetOff(this);
|
||||
|
||||
console.log("MapUILogic onDestroy")
|
||||
}
|
||||
|
||||
protected onBack(): void {
|
||||
LoginCommand.getInstance().account_logout();
|
||||
}
|
||||
|
||||
|
||||
protected clearAllNode(): void {
|
||||
this._facilityNode = null;
|
||||
this._generalNode = null;
|
||||
this._cityAboutNode = null;
|
||||
this._fortressAboutNode = null;
|
||||
this._armySelectNode = null;
|
||||
this._armySettingNode = null;
|
||||
this._drawNode = null;
|
||||
this._drawResultNode = null;
|
||||
this._generalDesNode = null;
|
||||
this._dialogNode = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
public topLayer():number {
|
||||
return this.contentNode.children.length+1;
|
||||
}
|
||||
/**
|
||||
* 设施
|
||||
*/
|
||||
protected openFacility(data: any): void {
|
||||
if (this._facilityNode == null) {
|
||||
this._facilityNode = instantiate(this.facilityPrefab);
|
||||
this._facilityNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._facilityNode.active = true;
|
||||
}
|
||||
this._facilityNode.setSiblingIndex(this.topLayer());
|
||||
this._facilityNode.getComponent(FacilityListLogic).setData(data);
|
||||
}
|
||||
|
||||
protected openArmySetting(cityId: number, order: number): void {
|
||||
if (this._armySettingNode == null) {
|
||||
this._armySettingNode = instantiate(this.armySettingPrefab);
|
||||
this._armySettingNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._armySettingNode.active = true;
|
||||
}
|
||||
this._armySettingNode.setSiblingIndex(this.topLayer());
|
||||
this._armySettingNode.getComponent(CityArmySettingLogic).setData(cityId, order);
|
||||
}
|
||||
/**
|
||||
* 武将
|
||||
*/
|
||||
protected openGeneral(data: number[], type: number = 0, position: number = 0, zIndex: number = 0): void {
|
||||
if (this._generalNode == null) {
|
||||
this._generalNode = instantiate(this.generalPrefab);
|
||||
this._generalNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._generalNode.active = true;
|
||||
}
|
||||
this._generalNode.setSiblingIndex(this.topLayer());
|
||||
this._generalNode.getComponent(GeneralListLogic).setData(data, type, position);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 武将选择
|
||||
* @param data
|
||||
* @param zIndex
|
||||
*/
|
||||
protected openGeneralChoose(data: number[], position: number = 0): void {
|
||||
this.openGeneral(data, 1, position, 1);
|
||||
}
|
||||
|
||||
/**打开军队选择界面*/
|
||||
protected onOpenArmySelectUI(cmd: number, x: number, y: number): void {
|
||||
if (this._armySelectNode == null) {
|
||||
this._armySelectNode = instantiate(this.armySelectPrefab);
|
||||
this._armySelectNode.parent = this.node;
|
||||
} else {
|
||||
this._armySelectNode.active = true;
|
||||
}
|
||||
this._armySelectNode.setSiblingIndex(this.topLayer());
|
||||
this._armySelectNode.getComponent(ArmySelectNodeLogic).setData(cmd, x, y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 武将详情
|
||||
*/
|
||||
protected openGeneralDes(cfgData: any, curData: any): void {
|
||||
if (this._generalDesNode == null) {
|
||||
this._generalDesNode = instantiate(this.generalDesPrefab);
|
||||
this._generalDesNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._generalDesNode.active = true;
|
||||
}
|
||||
this._generalDesNode.setSiblingIndex(this.topLayer());
|
||||
this._generalDesNode.getComponent(GeneralInfoLogic).setData(cfgData, curData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
protected openCityAbout(data: any): void {
|
||||
if (this._cityAboutNode == null) {
|
||||
this._cityAboutNode = instantiate(this.cityAboutPrefab);
|
||||
this._cityAboutNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._cityAboutNode.active = true;
|
||||
}
|
||||
|
||||
this._cityAboutNode.setSiblingIndex(this.topLayer());
|
||||
this.widgetNode.active = false;
|
||||
EventMgr.emit("scroll_to_map", data.x, data.y);
|
||||
this._cityAboutNode.getComponent(CityAboutLogic).setData(data);
|
||||
}
|
||||
|
||||
protected closeCityAbout(): void {
|
||||
this.widgetNode.active = true;
|
||||
}
|
||||
|
||||
protected openFortressAbout(data: any): void {
|
||||
if (this._fortressAboutNode == null) {
|
||||
this._fortressAboutNode = instantiate(this.fortressAboutPrefab);
|
||||
this._fortressAboutNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._fortressAboutNode.active = true;
|
||||
}
|
||||
this._fortressAboutNode.setSiblingIndex(this.topLayer());
|
||||
this._fortressAboutNode.getComponent(FortressAbout).setData(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 战报
|
||||
*/
|
||||
protected openWarReport(): void {
|
||||
if (this._warReportNode == null) {
|
||||
this._warReportNode = instantiate(this.warReportPrefab);
|
||||
this._warReportNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._warReportNode.active = true;
|
||||
}
|
||||
this._warReportNode.setSiblingIndex(this.topLayer());
|
||||
this._warReportNode.getComponent(WarReportLogic).updateView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
protected updateRoleRes(): void {
|
||||
var children = this.srollLayout.node.children;
|
||||
var roleRes = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
|
||||
var i = 0;
|
||||
children[i].getChildByName("New Label").getComponent(Label).string = "令牌:" + Tools.numberToShow(roleRes["decree"]);
|
||||
i+=1;
|
||||
|
||||
|
||||
for (let index = 0; index < this._resArray.length; index++) {
|
||||
const obj = this._resArray[index];
|
||||
var label = children[i].getChildByName("New Label").getComponent(Label)
|
||||
|
||||
if(obj.key == "gold"){
|
||||
label.string = obj.name + Tools.numberToShow(roleRes[obj.key]);
|
||||
}else{
|
||||
label.string = obj.name + Tools.numberToShow(roleRes[obj.key]) + "/" + Tools.numberToShow(roleRes["depot_capacity"]);
|
||||
}
|
||||
|
||||
i+=1;
|
||||
}
|
||||
|
||||
for (let index = 0; index < this._yieldArray.length; index++) {
|
||||
const obj = this._yieldArray[index];
|
||||
var label = children[i].getChildByName("New Label").getComponent(Label)
|
||||
label.string = obj.name + Tools.numberToShow(roleRes[obj.key]);
|
||||
i+=1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 抽卡
|
||||
*/
|
||||
protected openDraw(): void {
|
||||
if (this._drawNode == null) {
|
||||
this._drawNode = instantiate(this.drawPrefab);
|
||||
this._drawNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._drawNode.active = true;
|
||||
}
|
||||
this._drawNode.setSiblingIndex(this.topLayer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 抽卡结果
|
||||
* @param data
|
||||
*/
|
||||
protected openDrawR(data: any): void {
|
||||
if (this._drawResultNode == null) {
|
||||
this._drawResultNode = instantiate(this.drawResultrefab);
|
||||
this._drawResultNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._drawResultNode.active = true;
|
||||
}
|
||||
this._drawResultNode.setSiblingIndex(this.topLayer());
|
||||
this._drawResultNode.getComponent(DrawRLogic).setData(data);
|
||||
|
||||
console.log("openDrawR:", this.contentNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected openUnion(): void {
|
||||
if (this._unionNode == null) {
|
||||
this._unionNode = instantiate(this.unionPrefab);
|
||||
this._unionNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._unionNode.active = true;
|
||||
}
|
||||
this._unionNode.setSiblingIndex(this.topLayer());
|
||||
}
|
||||
|
||||
|
||||
protected openChat(): void {
|
||||
if (this._chatNode == null) {
|
||||
this._chatNode = instantiate(this.chatPrefab);
|
||||
this._chatNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._chatNode.active = true;
|
||||
}
|
||||
this._chatNode.setSiblingIndex(this.topLayer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected openTr(): void {
|
||||
if (this._transFormNode == null) {
|
||||
this._transFormNode = instantiate(this.transFormPrefab);
|
||||
this._transFormNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._transFormNode.active = true;
|
||||
}
|
||||
this._transFormNode.setSiblingIndex(this.topLayer());
|
||||
this._transFormNode.getComponent(TransformLogic).initView();
|
||||
}
|
||||
|
||||
protected onOpenGeneralConvert(): void {
|
||||
console.log("onOpenGeneralConvert");
|
||||
if (this._generalConvertNode == null) {
|
||||
this._generalConvertNode = instantiate(this.generalConvertPrefab);
|
||||
this._generalConvertNode.parent = this.contentNode;
|
||||
|
||||
} else {
|
||||
this._generalConvertNode.active = true;
|
||||
}
|
||||
|
||||
this._generalConvertNode.setSiblingIndex(this.topLayer());
|
||||
|
||||
}
|
||||
|
||||
protected onOpenGeneralRoster(): void {
|
||||
console.log("onOpenGeneralRoster");
|
||||
if (this._generalRosterNode == null) {
|
||||
this._generalRosterNode = instantiate(this.generalRosterPrefab);
|
||||
this._generalRosterNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._generalRosterNode.active = true;
|
||||
}
|
||||
this._generalRosterNode.setSiblingIndex(this.topLayer());
|
||||
|
||||
}
|
||||
|
||||
onClickSkillBtn(): void{
|
||||
this.onOpenSkill(0);
|
||||
}
|
||||
|
||||
protected onOpenSkill(type:number=0, general:GeneralData = null, skillPos:number=-1): void {
|
||||
console.log("onOpenSkill", type, general, skillPos);
|
||||
if (this._skillNode == null) {
|
||||
this._skillNode = instantiate(this.skillPrefab);
|
||||
this._skillNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._skillNode.active = true;
|
||||
}
|
||||
this._skillNode.setSiblingIndex(this.topLayer());
|
||||
this._skillNode.getComponent(SkillLogic).setData(type, general, skillPos);
|
||||
}
|
||||
|
||||
protected onCloseSkill(){
|
||||
if (this._skillNode) {
|
||||
this._skillNode.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected onOpenSkillInfo(cfg:SkillConf, type:number=0, general:GeneralData = null, skillPos:number=-1){
|
||||
console.log("onOpenSkillInfo", cfg, type, general, skillPos);
|
||||
if (this._skillInfoNode == null) {
|
||||
this._skillInfoNode = instantiate(this.skillInfoPrefab);
|
||||
this._skillInfoNode.parent = this.contentNode;
|
||||
} else {
|
||||
this._skillInfoNode.active = true;
|
||||
}
|
||||
this._skillInfoNode.setSiblingIndex(this.topLayer());
|
||||
this._skillInfoNode.getComponent(SkillInfoLogic).setData(cfg, type, general, skillPos);
|
||||
}
|
||||
|
||||
|
||||
//征收
|
||||
protected onCollection(msg:any):void{
|
||||
this.showTip("成功征收到 "+msg.gold+" 金币", null);
|
||||
}
|
||||
|
||||
protected updateRole(): void {
|
||||
var roleData = LoginCommand.getInstance().proxy.getRoleData();
|
||||
this.nameLabel.string = "昵称: " + roleData.nickName;
|
||||
this.ridLabel.string = "角色ID: " + roleData.rid + "";
|
||||
}
|
||||
|
||||
protected onClickCollection():void {
|
||||
if(this._collectNode == null){
|
||||
this._collectNode = instantiate(this.collectPrefab);
|
||||
this._collectNode.parent = this.contentNode;
|
||||
}
|
||||
this._collectNode.active = true;
|
||||
this._collectNode.setSiblingIndex(this.topLayer());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/MapUILogic.ts.meta
Normal file
11
assets/scripts/map/ui/MapUILogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "db03d0c1-277f-4488-bf4b-7cb2b267e54a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
735
assets/scripts/map/ui/MapUIProxy.ts
Normal file
735
assets/scripts/map/ui/MapUIProxy.ts
Normal file
@@ -0,0 +1,735 @@
|
||||
import { _decorator } from 'cc';
|
||||
import { Basic, Conscript, General } from "../../config/Basci";
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
|
||||
export class CityAddition {
|
||||
cost: number = 0;
|
||||
armyCnt: number = 0;//军队数量
|
||||
vanguardCnt: 0;//军队前锋数量 默认每队只有两个位置 前锋数量影响第三个位置的开启
|
||||
soldierCnt: 0;//带兵数加成
|
||||
han: number = 0;//汉阵营加成
|
||||
qun: number = 0;//群阵营加成
|
||||
wei: number = 0;//魏阵营加成
|
||||
shu: number = 0;//蜀阵营加成
|
||||
wu: number = 0;//吴阵营加成
|
||||
taxRate:number = 0;//交换的税率
|
||||
durable:number = 0;//耐久
|
||||
|
||||
|
||||
public clear(): void {
|
||||
this.cost = 0;
|
||||
this.armyCnt = 0;
|
||||
this.vanguardCnt = 0;
|
||||
this.soldierCnt = 0;
|
||||
this.han = 0;
|
||||
this.qun = 0;
|
||||
this.wei = 0;
|
||||
this.shu = 0;
|
||||
this.wu = 0;
|
||||
this.durable = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**城池加成类型*/
|
||||
export class CityAdditionType {
|
||||
static Durable: number = 1;//耐久
|
||||
static Cost: number = 2;
|
||||
static ArmyTeams: number = 3;//队伍数量
|
||||
static Speed: number = 4;//速度
|
||||
static Defense: number = 5;//防御
|
||||
static Strategy: number = 6; //谋略
|
||||
static Force: number = 7; //攻击武力
|
||||
static ConscriptTime: number = 8;//征兵时间
|
||||
static ReserveLimit: number = 9;//预备役上限
|
||||
static Unkonw: number = 10;
|
||||
static HanAddition: number = 11;
|
||||
static QunAddition: number = 12;
|
||||
static WeiAddition: number = 13;
|
||||
static ShuAddition: number = 14;
|
||||
static WuAddition: number = 15;
|
||||
static DealTaxRate: number = 16;//交易税率
|
||||
static Wood: number = 17;
|
||||
static Iron: number = 18;
|
||||
static Grain: number = 19;
|
||||
static Stone: number = 20;
|
||||
static Tax: number = 21;//税收
|
||||
static ExtendTimes: number = 22;//扩建次数
|
||||
static WarehouseLimit: number = 23;//仓库容量
|
||||
static SoldierLimit: number = 24;//带兵数量
|
||||
static VanguardLimit: number = 25;//前锋数量
|
||||
}
|
||||
|
||||
/**设施*/
|
||||
export class Facility {
|
||||
level: number = 0;
|
||||
type: number = 0;
|
||||
upTime:number = 0; //升级的时间,0为该等级已经升级成功
|
||||
|
||||
public isUping(): boolean{
|
||||
return this.upLastTime() > 0
|
||||
}
|
||||
|
||||
public isNeedUpdateLevel(): boolean{
|
||||
return this.upLastTime() < 0
|
||||
}
|
||||
|
||||
public upLastTime(): number{
|
||||
if(this.upTime > 0){
|
||||
let cfg:FacilityConfig = MapUICommand.getInstance().proxy.getFacilityCfgByType(this.type);
|
||||
var costTime = cfg.upLevels[this.level].time;
|
||||
return DateUtil.leftTime((this.upTime+costTime)*1000);
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**设施(配置)*/
|
||||
export class FacilityConfig {
|
||||
name: string = "";
|
||||
type: number = 0;
|
||||
des: string = "";
|
||||
additions: number[] = [];
|
||||
conditions: FacilityOpenCondition[] = [];
|
||||
upLevels: FacilityUpLevel[] = [];
|
||||
}
|
||||
|
||||
/**设施加成类型配置*/
|
||||
export class FacilityAdditionCfg {
|
||||
type: number = 0;
|
||||
des: string = "";
|
||||
value: string = "";
|
||||
}
|
||||
|
||||
/**设施开启条件配置*/
|
||||
export class FacilityOpenCondition {
|
||||
type: number = 0;
|
||||
level: number = 0;
|
||||
}
|
||||
|
||||
/**设施升级配置*/
|
||||
export class FacilityUpLevel {
|
||||
level: number = 0;
|
||||
values: number[] = [];
|
||||
wood: number = 0;
|
||||
iron: number = 0;
|
||||
stone: number = 0;
|
||||
grain: number = 0;
|
||||
decree: number = 0;
|
||||
time:number = 0;
|
||||
}
|
||||
|
||||
export class BasicGeneral {
|
||||
limit: number = 0;
|
||||
}
|
||||
|
||||
|
||||
export class WarReport {
|
||||
id: number = 0;
|
||||
attack_rid: number = 0;
|
||||
defense_rid: number = 0;
|
||||
|
||||
beg_attack_army: any = {};
|
||||
beg_defense_army: any = {};
|
||||
end_attack_army: any = {};
|
||||
end_defense_army: any = {};
|
||||
|
||||
result: number = 0;
|
||||
rounds: any = {};
|
||||
attack_is_read: boolean = false;
|
||||
defense_is_read: boolean = false;
|
||||
destroy_durable: number = 0;
|
||||
occupy: number = 0;
|
||||
x: number = 0;
|
||||
y: number = 0;
|
||||
ctime: number = 0;
|
||||
beg_attack_general: any[] = [];
|
||||
beg_defense_general: any[] = [];
|
||||
|
||||
end_attack_general: any[] = [];
|
||||
end_defense_general: any[] = [];
|
||||
|
||||
is_read: boolean = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
export class WarReportRound {
|
||||
isAttack: boolean = false;
|
||||
attack: any = {};
|
||||
defense: any = {};
|
||||
attackLoss: number = 0;
|
||||
defenseLoss: number = 0;
|
||||
round: number = 0;
|
||||
turn: number = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default class MapUIProxy {
|
||||
protected _myFacility: Map<number, Map<number, Facility>> = new Map<number, Map<number, Facility>>();//城市设施
|
||||
protected _facilityCfg: Map<number, FacilityConfig> = new Map<number, FacilityConfig>();//设施配置
|
||||
protected _facilityAdditionCfg: Map<number, FacilityAdditionCfg> = new Map<number, FacilityAdditionCfg>();//升级加成配置
|
||||
protected _warReport: Map<number, WarReport> = new Map<number, WarReport>();
|
||||
protected _additions: Map<number, CityAddition> = new Map<number, CityAddition>();
|
||||
protected _basic: Basic
|
||||
|
||||
public clearData(): void {
|
||||
this._warReport.clear();
|
||||
this._myFacility.clear();
|
||||
this._additions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前城市的设施
|
||||
* @param data
|
||||
*/
|
||||
public updateMyFacilityList(cityId: number, datas: any[]): void {
|
||||
console.log("updateMyFacilityList:", datas);
|
||||
let list: Map<number, Facility> = new Map<number, Facility>();
|
||||
this._myFacility.set(cityId, list);
|
||||
for (var i = 0; i < datas.length; i++) {
|
||||
var obj = new Facility();
|
||||
obj.level = datas[i].level;
|
||||
obj.type = datas[i].type;
|
||||
obj.upTime = datas[i].up_time;
|
||||
list.set(obj.type, obj);
|
||||
}
|
||||
|
||||
console.log("list:", list);
|
||||
}
|
||||
|
||||
public updateMyFacility(cityId: number, data: any): Facility {
|
||||
console.log("updateMyFacility:", data);
|
||||
if (this._myFacility.has(cityId)) {
|
||||
let list: Map<number, Facility> = this._myFacility.get(cityId);
|
||||
let facilityData: Facility = list.get(data.type);
|
||||
if (facilityData == null) {
|
||||
facilityData = new Facility();
|
||||
list.set(data.type, facilityData);
|
||||
}
|
||||
facilityData.level = data.level;
|
||||
facilityData.type = data.type;
|
||||
facilityData.upTime = data.up_time;
|
||||
return facilityData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**更新设施加成数据*/
|
||||
public updateMyCityAdditions(cityId: number): CityAddition {
|
||||
if (this._myFacility.has(cityId)) {
|
||||
let addition: CityAddition = null;
|
||||
if (this._additions.has(cityId)) {
|
||||
addition = this._additions.get(cityId);
|
||||
} else {
|
||||
addition = new CityAddition();
|
||||
this._additions.set(cityId, addition);
|
||||
}
|
||||
addition.clear();//清除旧数据 重新计算
|
||||
let list: Map<number, Facility> = this._myFacility.get(cityId);
|
||||
list.forEach((data: Facility, type: number) => {
|
||||
if (data.level > 0) {
|
||||
let cfg: FacilityConfig = this.getFacilityCfgByType(data.type);
|
||||
if (cfg) {
|
||||
let addValue: number = 0;
|
||||
let index: number = -1;
|
||||
index = cfg.additions.indexOf(CityAdditionType.ArmyTeams);
|
||||
if (index != -1) {
|
||||
//军队数量加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.armyCnt += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.Cost);
|
||||
if (index != -1) {
|
||||
//cost加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.cost += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.SoldierLimit);
|
||||
if (index != -1) {
|
||||
//带兵数加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.soldierCnt += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.VanguardLimit);
|
||||
if (index != -1) {
|
||||
//带兵数加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.vanguardCnt += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.HanAddition);
|
||||
if (index != -1) {
|
||||
//汉阵营加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.han += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.QunAddition);
|
||||
if (index != -1) {
|
||||
//群阵营加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.qun += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.WeiAddition);
|
||||
if (index != -1) {
|
||||
//魏阵营加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.wei += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.ShuAddition);
|
||||
if (index != -1) {
|
||||
//蜀阵营加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.shu += addValue;
|
||||
}
|
||||
index = cfg.additions.indexOf(CityAdditionType.WuAddition);
|
||||
if (index != -1) {
|
||||
//吴阵营加成
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.wu += addValue;
|
||||
}
|
||||
|
||||
index = cfg.additions.indexOf(CityAdditionType.DealTaxRate);
|
||||
if (index != -1) {
|
||||
//交易税收
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.taxRate += addValue;
|
||||
}
|
||||
|
||||
index = cfg.additions.indexOf(CityAdditionType.Durable);
|
||||
if (index != -1) {
|
||||
//console.log("CityAdditionType.Durable:", cfg.upLevels, addValue, index);
|
||||
//耐久
|
||||
addValue = cfg.upLevels[data.level - 1].values[index];
|
||||
addition.durable += addValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("updateMyCityAdditions", cityId, addition);
|
||||
return addition;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前拥有的设施
|
||||
* @param cityId
|
||||
*/
|
||||
public getMyFacilitys(cityId: number = 0): Map<number, Facility> {
|
||||
return this._myFacility.get(cityId);
|
||||
}
|
||||
|
||||
public getMyAllFacilitys(): Map<number, Map<number, Facility>> {
|
||||
return this._myFacility;
|
||||
}
|
||||
|
||||
/**获取指定的设施数据*/
|
||||
public getMyFacilityByType(cityId: number = 0, type: number = 0): Facility {
|
||||
if (this._myFacility.has(cityId)) {
|
||||
let list: Map<number, Facility> = this._myFacility.get(cityId);
|
||||
if (list.has(type)) {
|
||||
return list.get(type);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**获取城池的加成数据*/
|
||||
public getMyCityAddition(cityId: number): CityAddition {
|
||||
let addition: CityAddition = null;
|
||||
if (this._additions.has(cityId)) {
|
||||
addition = this._additions.get(cityId);
|
||||
} else {
|
||||
addition = new CityAddition();
|
||||
this._additions.set(cityId, addition);
|
||||
}
|
||||
return addition;
|
||||
}
|
||||
|
||||
public getMyCityCost(cityId: number):number{
|
||||
let addition = this.getMyCityAddition(cityId);
|
||||
console.log("getMyCityCost:", cityId, addition, this._basic.city.cost);
|
||||
return addition.cost + this._basic.city.cost;
|
||||
}
|
||||
|
||||
//最大耐久
|
||||
public getMyCityMaxDurable(cityId: number):number{
|
||||
let addition = this.getMyCityAddition(cityId);
|
||||
console.log("getMyCityMaxDurable:", cityId, addition, this._basic.city.durable);
|
||||
return addition.durable + this._basic.city.durable;
|
||||
}
|
||||
|
||||
public getTransformRate():number {
|
||||
return this._basic.city.transform_rate
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部设施配置
|
||||
* @param jsonAsset
|
||||
*/
|
||||
public setAllFacilityCfg(jsonAssets: any[]): void {
|
||||
this._facilityCfg = new Map();
|
||||
|
||||
let mainJson: any = null;//设施类型配置
|
||||
let additionJson: any = null;//升级类型配置
|
||||
let otherJsons: any[] = [];//具体升级配置
|
||||
|
||||
for (let i: number = 0; i < jsonAssets.length; i++) {
|
||||
if (jsonAssets[i]._name == "facility") {
|
||||
mainJson = jsonAssets[i].json;
|
||||
} else if (jsonAssets[i]._name == "facility_addition") {
|
||||
additionJson = jsonAssets[i].json;
|
||||
} else {
|
||||
otherJsons.push(jsonAssets[i].json);
|
||||
}
|
||||
}
|
||||
console.log("mainJson", mainJson, additionJson);
|
||||
if (mainJson != null && additionJson != null) {
|
||||
//主配置存在才处理配置文件
|
||||
this._facilityCfg.clear();
|
||||
for (let i: number = 0; i < mainJson.list.length; i++) {
|
||||
let cfgData: FacilityConfig = new FacilityConfig();
|
||||
cfgData.type = mainJson.list[i].type;
|
||||
cfgData.name = mainJson.list[i].name;
|
||||
this._facilityCfg.set(cfgData.type, cfgData);
|
||||
}
|
||||
|
||||
this._facilityAdditionCfg.clear();
|
||||
for (let i: number = 0; i < additionJson.list.length; i++) {
|
||||
let cfgData: FacilityAdditionCfg = new FacilityAdditionCfg();
|
||||
cfgData.type = additionJson.list[i].type;
|
||||
cfgData.des = additionJson.list[i].des;
|
||||
cfgData.value = additionJson.list[i].value;
|
||||
this._facilityAdditionCfg.set(cfgData.type, cfgData);
|
||||
}
|
||||
|
||||
let jsonList: any[] = [];
|
||||
for (let i: number = 0; i < otherJsons.length; i++) {
|
||||
this.getFacilityUpLevelJsonList(otherJsons[i], jsonList);
|
||||
}
|
||||
console.log("jsonList", jsonList, otherJsons);
|
||||
|
||||
for (let i: number = 0; i < jsonList.length; i++) {
|
||||
let type: number = jsonList[i].type;
|
||||
let cfgData: FacilityConfig = this._facilityCfg.get(type);
|
||||
if (cfgData) {
|
||||
//存在主配置 才加入升级配置
|
||||
cfgData.des = jsonList[i].des;
|
||||
cfgData.additions = jsonList[i].additions;
|
||||
cfgData.conditions = [];
|
||||
for (let j: number = 0; j < jsonList[i].conditions.length; j++) {
|
||||
let conditionData: FacilityOpenCondition = new FacilityOpenCondition();
|
||||
conditionData.type = jsonList[i].conditions[j].type;
|
||||
conditionData.level = jsonList[i].conditions[j].level;
|
||||
cfgData.conditions.push(conditionData);
|
||||
}
|
||||
|
||||
cfgData.upLevels.length = jsonList[i].levels.length;
|
||||
for (let k: number = 0; k < jsonList[i].levels.length; k++) {
|
||||
let upLevelData: FacilityUpLevel = new FacilityUpLevel();
|
||||
upLevelData.level = jsonList[i].levels[k].level;
|
||||
upLevelData.values = jsonList[i].levels[k].values;
|
||||
upLevelData.wood = jsonList[i].levels[k].need.wood;
|
||||
upLevelData.iron = jsonList[i].levels[k].need.iron;
|
||||
upLevelData.grain = jsonList[i].levels[k].need.grain;
|
||||
upLevelData.wood = jsonList[i].levels[k].need.wood;
|
||||
upLevelData.stone = jsonList[i].levels[k].need.stone;
|
||||
upLevelData.time = jsonList[i].levels[k].time;
|
||||
cfgData.upLevels[upLevelData.level - 1] = upLevelData;
|
||||
|
||||
//console.log("upLevelData:", upLevelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this._facilityCfg.forEach((value: FacilityConfig, key: number) => {
|
||||
console.log("this._facilityCfg", key, value);
|
||||
});
|
||||
}
|
||||
|
||||
protected getFacilityUpLevelJsonList(data: any, list: any[]): void {
|
||||
if (typeof (data) == "string" || typeof (data) == "number") {
|
||||
return;
|
||||
}
|
||||
if (data.type != undefined && data.additions != undefined) {
|
||||
//代表是需要的数据
|
||||
list.push(data);
|
||||
} else {
|
||||
//代表有多条数据在更里层
|
||||
for (let key in data) {
|
||||
this.getFacilityUpLevelJsonList(data[key], list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getFacilityCfgByType(type: number = 0): FacilityConfig {
|
||||
return this._facilityCfg.get(type);
|
||||
}
|
||||
|
||||
public getFacilityAdditionCfgByType(type: number = 0): FacilityAdditionCfg {
|
||||
return this._facilityAdditionCfg.get(type);
|
||||
}
|
||||
|
||||
/**设施是否解锁*/
|
||||
public isFacilityUnlock(cityId: number, type: number): boolean {
|
||||
let isUnlock: boolean = true;
|
||||
let cfg: FacilityConfig = this.getFacilityCfgByType(type);
|
||||
for (let i: number = 0; i < cfg.conditions.length; i++) {
|
||||
let data: Facility = this.getMyFacilityByType(cityId, cfg.conditions[i].type);
|
||||
if (data && data.level < cfg.conditions[i].level) {
|
||||
isUnlock = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isUnlock;
|
||||
}
|
||||
|
||||
public setBasic(data: any): void {
|
||||
this._basic = data.json;
|
||||
console.log("setBasic:", this._basic);
|
||||
}
|
||||
|
||||
|
||||
public getConscriptBaseCost(): Conscript {
|
||||
return this._basic.conscript;
|
||||
}
|
||||
|
||||
public getDefenseSoldiers(level:number): number {
|
||||
console.log("getDefenseSoldiers:", level);
|
||||
return this._basic.npc.levels[level-1].soilders
|
||||
}
|
||||
|
||||
public getBasicGeneral(): General {
|
||||
return this._basic.general;
|
||||
}
|
||||
|
||||
|
||||
public updateWarReports(data: any): void {
|
||||
var list = data.list;
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var obj: WarReport = this.createWarReprot(list[i]);
|
||||
this._warReport.set(obj.id, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public updateWarReport(data: any): void {
|
||||
var obj: WarReport = this.createWarReprot(data);
|
||||
this._warReport.set(obj.id, obj);
|
||||
}
|
||||
|
||||
|
||||
protected createWarReprot(data: any): WarReport {
|
||||
var obj = new WarReport();
|
||||
obj.id = data.id;
|
||||
obj.attack_rid = data.a_rid;
|
||||
obj.defense_rid = data.d_rid;
|
||||
|
||||
obj.beg_attack_general = this.arrayToObject(JSON.parse(data.b_a_general));
|
||||
obj.end_attack_general = this.arrayToObject(JSON.parse(data.e_a_general));
|
||||
obj.end_attack_army = JSON.parse(data.e_a_army);
|
||||
obj.beg_attack_army = JSON.parse(data.b_a_army);
|
||||
|
||||
try {
|
||||
obj.beg_defense_army = JSON.parse(data.b_d_army);
|
||||
obj.end_defense_army = JSON.parse(data.e_d_army);
|
||||
obj.beg_defense_general = this.arrayToObject(JSON.parse(data.b_d_general));
|
||||
obj.end_defense_general = this.arrayToObject(JSON.parse(data.e_d_general));
|
||||
obj.rounds = this.createRoundsData(data.rounds, obj.beg_attack_general, obj.beg_defense_general)
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
obj.result = data.result;
|
||||
|
||||
obj.defense_is_read = data.d_is_read;
|
||||
obj.attack_is_read = data.a_is_read;
|
||||
|
||||
obj.is_read = this.isReadObj(obj);
|
||||
obj.destroy_durable = data.destroy;
|
||||
obj.occupy = data.occupy;
|
||||
obj.x = data.x;
|
||||
obj.y = data.y;
|
||||
obj.ctime = data.ctime;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
private createRoundsData(data: string, attack_generals: any[], defense_generals: any[]): any[] {
|
||||
var generals: any[] = attack_generals.concat(defense_generals);
|
||||
|
||||
var _list: any[] = [];
|
||||
var rounds: any[] = JSON.parse(data);
|
||||
for (var i = 0; i < rounds.length; i++) {
|
||||
var round: any[] = rounds[i].b;
|
||||
if(!round){
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = 0; j < round.length; j++) {
|
||||
var turn = round[j];
|
||||
var attack_id = turn[0];
|
||||
var defense_id = turn[1];
|
||||
var attack_loss = turn[2];
|
||||
var defense_loss = turn[3];
|
||||
|
||||
var obj = new WarReportRound();
|
||||
obj.attack = this.getMatchGeneral(generals, attack_id);
|
||||
obj.defense = this.getMatchGeneral(generals, defense_id);
|
||||
obj.isAttack = this.getMatchGeneral(attack_generals, attack_id) != null;
|
||||
obj.attackLoss = attack_loss;
|
||||
obj.defenseLoss = defense_loss;
|
||||
obj.round = i + 1;
|
||||
obj.turn = j + 1;
|
||||
_list.push(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return _list;
|
||||
}
|
||||
|
||||
|
||||
protected arrayToObject(arr: any): any {
|
||||
let temp: any = [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var data = arr[i];
|
||||
|
||||
var obj: any = {}
|
||||
obj.id = data[0];
|
||||
obj.cfgId = data[1];
|
||||
obj.physical_power = data[2];
|
||||
obj.order = data[3];
|
||||
obj.level = data[4];
|
||||
obj.exp = data[5];
|
||||
obj.cityId = data[6];
|
||||
obj.curArms = data[7];
|
||||
obj.hasPrPoint = data[8];
|
||||
obj.attack_distance = data[9];
|
||||
obj.force_added = data[10];
|
||||
obj.strategy_added = data[11];
|
||||
obj.defense_added = data[12];
|
||||
obj.speed_added = data[13];
|
||||
obj.destroy_added = data[14];
|
||||
obj.star_lv = data[15];
|
||||
obj.star = data[16];
|
||||
|
||||
|
||||
temp.push(obj);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
protected getMatchGeneral(generals: any[], id: number = 0): any {
|
||||
for (var i = 0; i < generals.length; i++) {
|
||||
if (generals[i].id == id) {
|
||||
return generals[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public updateWarRead(id: number = 0, isRead: boolean = true) {
|
||||
var data = this._warReport.get(id);
|
||||
var roleData = LoginCommand.getInstance().proxy.getRoleData();
|
||||
if (data) {
|
||||
if (data.defense_rid == roleData.rid) {
|
||||
data.defense_is_read = isRead;
|
||||
data.is_read = isRead;
|
||||
}
|
||||
|
||||
if (data.attack_rid == roleData.rid) {
|
||||
data.attack_is_read = isRead;
|
||||
data.is_read = isRead;
|
||||
}
|
||||
|
||||
|
||||
this._warReport.set(id, data);
|
||||
}
|
||||
}
|
||||
|
||||
public updateAllWarRead(isRead: boolean = true) {
|
||||
this._warReport.forEach(element => {
|
||||
this.updateWarRead(element.id, isRead)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public isRead(id: number = 0): boolean {
|
||||
var data = this._warReport.get(id);
|
||||
var roleData = LoginCommand.getInstance().proxy.getRoleData();
|
||||
if (data) {
|
||||
if (data.defense_rid == roleData.rid) {
|
||||
return data.defense_is_read;
|
||||
}
|
||||
|
||||
if (data.attack_rid == roleData.rid) {
|
||||
return data.attack_is_read;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public isReadObj(obj: any): boolean {
|
||||
var roleData = LoginCommand.getInstance().proxy.getRoleData();
|
||||
if (obj.defense_rid == roleData.rid) {
|
||||
return obj.defense_is_read;
|
||||
}
|
||||
|
||||
if (obj.attack_rid == roleData.rid) {
|
||||
return obj.attack_is_read;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public getWarReport(): WarReport[] {
|
||||
var arr: WarReport[] = Array.from(this._warReport.values());
|
||||
arr = arr.sort(this.sortIsRead);
|
||||
arr = arr.concat();
|
||||
|
||||
var backArr: WarReport[] = [];
|
||||
// for (var i = 0; i < arr.length; i++) {
|
||||
// if (arr[i].is_read == true) {
|
||||
// backArr.push(arr[i]);
|
||||
// arr.splice(i, 1);
|
||||
// i--;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
backArr = arr.concat(backArr);
|
||||
// backArr = backArr.reverse();
|
||||
return backArr;
|
||||
}
|
||||
|
||||
|
||||
public sortIsRead(a: any, b: any): number {
|
||||
if (a.id < b.id) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public isReadNum(): number {
|
||||
var num = 0;
|
||||
var arr = this.getWarReport();
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (!this.isRead(arr[i].id)) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/MapUIProxy.ts.meta
Normal file
11
assets/scripts/map/ui/MapUIProxy.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9db4d798-ac93-46c7-9479-de62b7bb156b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
155
assets/scripts/map/ui/RightArmyItemLogic.ts
Normal file
155
assets/scripts/map/ui/RightArmyItemLogic.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import { _decorator, Component, Label, Node, Sprite, UITransform } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { ArmyCmd, ArmyData } from "../../general/ArmyProxy";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import { GeneralConfig, GeneralData } from "../../general/GeneralProxy";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import MapCommand from "../MapCommand";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import GeneralHeadLogic from "./GeneralHeadLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('RightArmyItemLogic')
|
||||
export default class RightArmyItemLogic extends Component {
|
||||
@property(Label)
|
||||
labelInfo: Label = null;
|
||||
@property(Label)
|
||||
labelPos: Label = null;
|
||||
@property(Node)
|
||||
bottomNode: Node = null;
|
||||
@property(Sprite)
|
||||
headIcon: Sprite = null;
|
||||
@property(Label)
|
||||
labelSoldierCnt: Label = null;
|
||||
@property(Label)
|
||||
labelStrength: Label = null;
|
||||
@property(Label)
|
||||
labelMorale: Label = null;
|
||||
@property(Node)
|
||||
btnBack: Node = null;
|
||||
@property(Node)
|
||||
btnSetting: Node = null;
|
||||
|
||||
public order: number = 0;
|
||||
protected _data: ArmyData = null;
|
||||
protected _firstGeneral: GeneralData = null;
|
||||
protected _qryReturnTime: number = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("update_general", this.onUpdateGeneral, this);
|
||||
this.node.getComponent(UITransform).height -= this.bottomNode.getComponent(UITransform).height;
|
||||
this.bottomNode.active = false;
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected update(): void {
|
||||
if (this._data && (this._data.state > 0 || this._data.cmd == ArmyCmd.Reclaim)) {
|
||||
let nowTime: number = DateUtil.getServerTime();
|
||||
let time: number = 0;
|
||||
if (this._data.state > 0) {
|
||||
//行军或者撤退中
|
||||
time = Math.max(0, this._data.endTime - nowTime);
|
||||
} else {
|
||||
//屯田中
|
||||
time = Math.max(0, GeneralCommand.getInstance().proxy.getCommonCfg().reclamation_time * 1000 - (nowTime - this._data.endTime));
|
||||
// if (time == 0 && nowTime - this._qryReturnTime > 2000) {
|
||||
// //屯田结束 主动请求撤退
|
||||
// this._qryReturnTime = nowTime;
|
||||
// this.onClickBack();
|
||||
// }
|
||||
}
|
||||
this.labelPos.string = DateUtil.converSecondStr(time);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateGeneral(): void {
|
||||
|
||||
}
|
||||
|
||||
protected onClickTop(): void {
|
||||
this.bottomNode.active = !this.bottomNode.active;
|
||||
if(this.bottomNode.active){
|
||||
this.node.getComponent(UITransform).height += this.bottomNode.getComponent(UITransform).height;
|
||||
}else{
|
||||
this.node.getComponent(UITransform).height -= this.bottomNode.getComponent(UITransform).height;
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickBack(): void {
|
||||
if (this._data) {
|
||||
let cityData: MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
ArmyCommand.getInstance().generalAssignArmy(this._data.id, ArmyCmd.Return, cityData.x, cityData.y, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickSetting(): void {
|
||||
if (this._data) {
|
||||
let cityData: MapCityData = MapCommand.getInstance().cityProxy.getMyCityById(this._data.cityId);
|
||||
EventMgr.emit("open_army_setting", this._data.cityId, this.order);
|
||||
}
|
||||
}
|
||||
|
||||
protected updateGeneralByData(): void {
|
||||
let stateStr: string = ArmyCommand.getInstance().getArmyStateDes(this._data);
|
||||
var teamName = "";
|
||||
if (this._firstGeneral) {
|
||||
let cfg: GeneralConfig = GeneralCommand.getInstance().proxy.getGeneralCfg(this._firstGeneral.cfgId);
|
||||
teamName = cfg.name;
|
||||
this.headIcon.getComponent(GeneralHeadLogic).setHeadId(this._firstGeneral.cfgId);
|
||||
this.labelStrength.string = "体力 " + this._firstGeneral.physical_power + "/" + cfg.physical_power_limit;
|
||||
}
|
||||
this.labelInfo.string = stateStr + " " + teamName + "队";
|
||||
|
||||
}
|
||||
|
||||
protected updateItem(): void {
|
||||
if (this._data && this._data.generals[0] != 0) {
|
||||
// console.log("updateItem", this._data);
|
||||
this.node.active = true;
|
||||
this._firstGeneral = GeneralCommand.getInstance().proxy.getMyGeneral(this._data.generals[0]);
|
||||
this.updateGeneralByData();
|
||||
|
||||
this.labelPos.string = "(" + this._data.x + ", " + this._data.y + ")";
|
||||
|
||||
this.labelSoldierCnt.string = "骑兵 " + (this._data.soldiers[0] + this._data.soldiers[1] + this._data.soldiers[2]);
|
||||
|
||||
if (this._data.cmd == ArmyCmd.Idle) {
|
||||
|
||||
this.btnSetting.active = true;
|
||||
let cityData: MapCityData = MapCommand.getInstance().cityProxy.getMyCityById(this._data.cityId);
|
||||
if (cityData && cityData.x == this._data.fromX && cityData.y == this._data.fromY){
|
||||
//代表在城池里面
|
||||
this.btnBack.active = false;
|
||||
}else{
|
||||
//代表在城外据点待命
|
||||
this.btnBack.active = true;
|
||||
}
|
||||
|
||||
} else if (this._data.cmd == ArmyCmd.Conscript){
|
||||
this.btnSetting.active = false;
|
||||
this.btnBack.active = false;
|
||||
} else if (this._data.state == 0 && this._data.cmd != ArmyCmd.Reclaim) {
|
||||
//停留的时候才能配置队伍和撤退
|
||||
this.btnSetting.active = false;
|
||||
this.btnBack.active = true;
|
||||
} else {
|
||||
this.btnSetting.active = false;
|
||||
this.btnBack.active = false;
|
||||
}
|
||||
} else {
|
||||
this._firstGeneral = null;
|
||||
this.node.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
public setArmyData(data: ArmyData): void {
|
||||
this._data = data;
|
||||
this.updateItem();
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/RightArmyItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/RightArmyItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c3048e72-b3e0-4db7-b80b-34a06820fd10",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
38
assets/scripts/map/ui/RightCityItemLogic.ts
Normal file
38
assets/scripts/map/ui/RightCityItemLogic.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('RightCityItemLogic')
|
||||
export default class RightCityItemLogic extends Component {
|
||||
@property(Label)
|
||||
labelInfo: Label = null;
|
||||
@property(Label)
|
||||
labelPos: Label = null;
|
||||
|
||||
protected _data: MapCityData = null;
|
||||
|
||||
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected onClickBg(): void {
|
||||
if (this._data) {
|
||||
EventMgr.emit("scroll_to_map", this._data.x, this._data.y);
|
||||
}
|
||||
}
|
||||
|
||||
public setArmyData(data: MapCityData): void {
|
||||
this._data = data;
|
||||
if (this._data) {
|
||||
this.labelInfo.string = this._data.name;
|
||||
this.labelPos.string = "(" + this._data.x + ", " + this._data.y + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/RightCityItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/RightCityItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c94d5441-504e-48cf-996f-e5de8afe1aea",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
126
assets/scripts/map/ui/RightInfoNodeLogic.ts
Normal file
126
assets/scripts/map/ui/RightInfoNodeLogic.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import { _decorator, Component, Toggle, ScrollView, Prefab, Node, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { ArmyData } from "../../general/ArmyProxy";
|
||||
import ArmyCommand from "../../general/ArmyCommand";
|
||||
import MapCommand from "../MapCommand";
|
||||
import RightArmyItemLogic from "./RightArmyItemLogic";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import RightCityItemLogic from "./RightCityItemLogic";
|
||||
import RightTagItemLogic from "./RightTagItemLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('RightInfoNodeLogic')
|
||||
export default class RightInfoNodeLogic extends Component {
|
||||
@property([Toggle])
|
||||
toggles: Toggle[] = [];
|
||||
@property(ScrollView)
|
||||
armyScrollView: ScrollView = null;
|
||||
@property(ScrollView)
|
||||
cityScrollView: ScrollView = null;
|
||||
@property(ScrollView)
|
||||
tagsScrollView: ScrollView = null;
|
||||
|
||||
@property(Prefab)
|
||||
armyItemPrefabs: Prefab = null;
|
||||
@property(Prefab)
|
||||
cityItemPrefabs: Prefab = null;
|
||||
|
||||
@property(Prefab)
|
||||
tagItemPrefabs: Prefab = null;
|
||||
|
||||
protected _armys: Node[] = [];
|
||||
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("update_army_list", this.onUpdateArmyList, this);
|
||||
EventMgr.on("update_army", this.onUpdateArmy, this);
|
||||
EventMgr.on("update_tag", this.onUpdateTag, this);
|
||||
|
||||
this.armyScrollView.node.active = true;
|
||||
this.cityScrollView.node.active = false;
|
||||
this.tagsScrollView.node.active = false;
|
||||
this.initArmys();
|
||||
this.initCitys();
|
||||
this.initTags();
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
this._armys.length = 0;
|
||||
this._armys = null;
|
||||
}
|
||||
|
||||
protected initArmys(): void {
|
||||
let cityId: number = MapCommand.getInstance().cityProxy.getMyMainCity().cityId;
|
||||
let datas: ArmyData[] = ArmyCommand.getInstance().proxy.getArmyList(cityId);
|
||||
this.armyScrollView.content.removeAllChildren(true);
|
||||
console.log("datas", datas);
|
||||
if (datas) {
|
||||
this._armys.length = datas.length;
|
||||
for (let i: number = 0; i < datas.length; i++) {
|
||||
let item: Node = instantiate(this.armyItemPrefabs);
|
||||
item.parent = this.armyScrollView.content;
|
||||
this._armys[i] = item;
|
||||
item.getComponent(RightArmyItemLogic).order = i + 1;
|
||||
item.getComponent(RightArmyItemLogic).setArmyData(datas[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected initCitys():void {
|
||||
let citys: MapCityData[] = MapCommand.getInstance().cityProxy.getMyCitys();
|
||||
this.cityScrollView.content.removeAllChildren();
|
||||
if (citys && citys.length > 0) {
|
||||
for (let i: number = 0; i < citys.length; i++) {
|
||||
let item: Node = instantiate(this.cityItemPrefabs);
|
||||
item.parent = this.cityScrollView.content;
|
||||
item.getComponent(RightCityItemLogic).setArmyData(citys[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected initTags(): void {
|
||||
let tags = MapCommand.getInstance().proxy.getPosTags();
|
||||
this.tagsScrollView.content.removeAllChildren();
|
||||
for (let i: number = 0; i < tags.length; i++) {
|
||||
var tag = tags[i];
|
||||
|
||||
|
||||
let item: Node = instantiate(this.tagItemPrefabs);
|
||||
item.parent = this.tagsScrollView.content;
|
||||
item.getComponent(RightTagItemLogic).setData(tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateArmyList(datas: ArmyData[]): void {
|
||||
this.initArmys();
|
||||
}
|
||||
|
||||
protected onUpdateArmy(data: ArmyData): void {
|
||||
if (MapCommand.getInstance().cityProxy.getMyMainCity().cityId == data.cityId) {
|
||||
this._armys[data.order - 1].getComponent(RightArmyItemLogic).setArmyData(data);
|
||||
}
|
||||
}
|
||||
|
||||
protected onUpdateTag():void {
|
||||
this.initTags();
|
||||
}
|
||||
|
||||
onClockToggle(toggle: Toggle): void {
|
||||
let index: number = this.toggles.indexOf(toggle);
|
||||
if (index == 1) {
|
||||
this.armyScrollView.node.active = false;
|
||||
this.cityScrollView.node.active = true;
|
||||
this.tagsScrollView.node.active = false;
|
||||
} else if(index == 0){
|
||||
this.armyScrollView.node.active = true;
|
||||
this.cityScrollView.node.active = false;
|
||||
this.tagsScrollView.node.active = false;
|
||||
}else{
|
||||
this.armyScrollView.node.active = false;
|
||||
this.cityScrollView.node.active = false;
|
||||
this.tagsScrollView.node.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/RightInfoNodeLogic.ts.meta
Normal file
11
assets/scripts/map/ui/RightInfoNodeLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c999ef55-1c14-4a05-83f5-c9a413d283df",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
38
assets/scripts/map/ui/RightTagItemLogic.ts
Normal file
38
assets/scripts/map/ui/RightTagItemLogic.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { _decorator, Component, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('RightTagItemLogic')
|
||||
export default class RightTagItemLogic extends Component {
|
||||
@property(Label)
|
||||
labelInfo: Label = null;
|
||||
@property(Label)
|
||||
labelPos: Label = null;
|
||||
|
||||
protected _data: MapCityData = null;
|
||||
|
||||
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
protected onClickBg(): void {
|
||||
if (this._data) {
|
||||
EventMgr.emit("scroll_to_map", this._data.x, this._data.y);
|
||||
}
|
||||
}
|
||||
|
||||
public setData(data:any): void {
|
||||
this._data = data;
|
||||
if (this._data) {
|
||||
this.labelInfo.string = this._data.name;
|
||||
this.labelPos.string = "(" + this._data.x + ", " + this._data.y + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/RightTagItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/RightTagItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "46c1e328-5365-4a0c-a411-fd2f0995cbbd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
55
assets/scripts/map/ui/SkillIconLogic.ts
Normal file
55
assets/scripts/map/ui/SkillIconLogic.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { _decorator, Component, SpriteFrame, Label, Sprite } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
|
||||
import { gSkill } from "../../general/GeneralProxy";
|
||||
import SkillCommand from "../../skill/SkillCommand";
|
||||
import { Skill } from "../../skill/SkillProxy";
|
||||
|
||||
|
||||
@ccclass('SkillIconLogic')
|
||||
export default class SkillIconLogic extends Component {
|
||||
|
||||
@property([SpriteFrame])
|
||||
sps:SpriteFrame[] = [];
|
||||
|
||||
@property(Label)
|
||||
lvLab:Label = null;
|
||||
|
||||
_data: Skill = null;
|
||||
|
||||
public setData(data:Skill, gdata:gSkill):void{
|
||||
|
||||
this._data = data;
|
||||
if(this._data == null){
|
||||
this.getComponent(Sprite).spriteFrame = null;
|
||||
}else{
|
||||
var conf = SkillCommand.getInstance().proxy.getSkillCfg(data.cfgId);
|
||||
if(conf.trigger <= this.sps.length){
|
||||
this.getComponent(Sprite).spriteFrame = this.sps[conf.trigger-1];
|
||||
}else{
|
||||
this.getComponent(Sprite).spriteFrame = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(gdata){
|
||||
if(this.lvLab){
|
||||
this.lvLab.string = "lv:" + gdata.lv;
|
||||
}
|
||||
}else{
|
||||
if(this.lvLab){
|
||||
this.lvLab.string = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public isEmpty():boolean {
|
||||
return this._data == null;
|
||||
}
|
||||
|
||||
public getSkill():Skill {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/SkillIconLogic.ts.meta
Normal file
11
assets/scripts/map/ui/SkillIconLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "11559425-7c33-45f3-a920-e726b531c17d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
171
assets/scripts/map/ui/SkillInfoLogic.ts
Normal file
171
assets/scripts/map/ui/SkillInfoLogic.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import { _decorator, Component, Label, Node, Button } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import { SkillConf, SkillOutline } from "../../config/skill/Skill";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralData } from "../../general/GeneralProxy";
|
||||
import SkillCommand from "../../skill/SkillCommand";
|
||||
import { Skill } from "../../skill/SkillProxy";
|
||||
import SkillIconLogic from "./SkillIconLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('SkillInfoLogic')
|
||||
export default class SkillInfoLogic extends Component {
|
||||
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
|
||||
@property(Node)
|
||||
icon:Node = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
lvLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
triggerLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
targetLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
armLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
rateLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
curDesLab: Label = null;
|
||||
|
||||
@property(Label)
|
||||
nextDesLab: Label = null;
|
||||
|
||||
@property(Button)
|
||||
learnBtn: Button = null;
|
||||
|
||||
@property(Button)
|
||||
lvBtn: Button = null;
|
||||
|
||||
@property(Button)
|
||||
giveUpBtn: Button = null;
|
||||
|
||||
_data: Skill = null;
|
||||
_cfg: SkillConf = null;
|
||||
|
||||
_general: GeneralData = null;
|
||||
_type: number = 0;
|
||||
_skillPos : number = -1;
|
||||
|
||||
protected onEnable() {
|
||||
this.learnBtn.node.active = false;
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
public setData(data: Skill, type:number, general:GeneralData, skillPos: number) {
|
||||
|
||||
console.log("setData Skill:", data, general);
|
||||
|
||||
var conf = SkillCommand.getInstance().proxy.getSkillCfg(data.cfgId);
|
||||
this.icon.getComponent(SkillIconLogic).setData(data, null);
|
||||
var outLine: SkillOutline = SkillCommand.getInstance().proxy.outLine;
|
||||
|
||||
this._cfg = conf;
|
||||
this._data = data;
|
||||
this._type = type;
|
||||
this._general = general;
|
||||
this._skillPos = skillPos;
|
||||
|
||||
this.learnBtn.node.active = type == 1;
|
||||
this.giveUpBtn.node.active = type == 2;
|
||||
|
||||
this.nameLab.string = conf.name;
|
||||
|
||||
let isShowLv = false;
|
||||
let lv = 0;
|
||||
if(type == 2){
|
||||
for (let index = 0; index < general.skills.length; index++) {
|
||||
const gskill = general.skills[index];
|
||||
if (gskill && gskill.cfgId == data.cfgId && gskill.lv <= conf.levels.length){
|
||||
isShowLv = true;
|
||||
lv = gskill.lv;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.lvBtn.node.active = isShowLv;
|
||||
if(isShowLv){
|
||||
this.lvLab.string = "lv:" + lv;
|
||||
}else{
|
||||
this.lvLab.string = "";
|
||||
}
|
||||
|
||||
this.triggerLab.string = outLine.trigger_type.list[conf.trigger-1].des;
|
||||
this.rateLab.string = conf.levels[0].probability + "%";
|
||||
this.targetLab.string = outLine.target_type.list[conf.target-1].des;
|
||||
this.armLab.string = this.armstr(conf.arms);
|
||||
|
||||
var des1 = conf.des
|
||||
for (let index = 0; index < conf.levels[0].effect_value.length; index++) {
|
||||
var str = conf.levels[0].effect_value[index] + "";
|
||||
des1 = des1.replace("%n%", str);
|
||||
}
|
||||
|
||||
this.curDesLab.string = des1;
|
||||
|
||||
var des2 = conf.des
|
||||
for (let index = 0; index < conf.levels[1].effect_value.length; index++) {
|
||||
var str = conf.levels[1].effect_value[index] + "";
|
||||
des2 = des2.replace("%n%", str);
|
||||
}
|
||||
|
||||
this.nextDesLab.string = des2;
|
||||
|
||||
}
|
||||
|
||||
protected armstr(arms:number []): string{
|
||||
// console.log("armstr:", arms);
|
||||
|
||||
var str = ""
|
||||
if(arms.indexOf(1)>=0 || arms.indexOf(4)>=0 || arms.indexOf(7)>=0){
|
||||
str += "步"
|
||||
}
|
||||
|
||||
if(arms.indexOf(2)>=0 || arms.indexOf(5)>=0 || arms.indexOf(8)>=0){
|
||||
str += "弓"
|
||||
}
|
||||
|
||||
if(arms.indexOf(3)>=0 || arms.indexOf(6)>=0 || arms.indexOf(9)>=0){
|
||||
str += "骑"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
protected onClickLearn():void {
|
||||
if(this._general){
|
||||
GeneralCommand.getInstance().upSkill(this._general.id, this._cfg.cfgId, this._skillPos);
|
||||
this.node.active = false;
|
||||
EventMgr.emit("close_skill");
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickLv():void {
|
||||
if(this._general){
|
||||
GeneralCommand.getInstance().lvSkill(this._general.id, this._skillPos);
|
||||
this.node.active = false;
|
||||
EventMgr.emit("close_skill");
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickForget():void {
|
||||
if(this._general){
|
||||
GeneralCommand.getInstance().downSkill(this._general.id, this._cfg.cfgId, this._skillPos);
|
||||
this.node.active = false;
|
||||
EventMgr.emit("close_skill");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/SkillInfoLogic.ts.meta
Normal file
11
assets/scripts/map/ui/SkillInfoLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3f6b5c38-0203-4608-ba3b-9af983a98823",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
41
assets/scripts/map/ui/SkillItemLogic.ts
Normal file
41
assets/scripts/map/ui/SkillItemLogic.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { _decorator, Component, Label, Node, SpriteFrame } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
import SkillCommand from "../../skill/SkillCommand";
|
||||
import { Skill } from "../../skill/SkillProxy";
|
||||
import SkillIconLogic from "./SkillIconLogic";
|
||||
|
||||
@ccclass('SkillItemLogic')
|
||||
export default class SkillItemLogic extends Component {
|
||||
|
||||
|
||||
@property(Label)
|
||||
nameLab: Label = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
limitLab: Label = null;
|
||||
|
||||
@property(Node)
|
||||
icon:Node = null;
|
||||
|
||||
@property([SpriteFrame])
|
||||
sps:SpriteFrame[] = [];
|
||||
|
||||
_skill: Skill = null;
|
||||
|
||||
protected onEnable():void{
|
||||
|
||||
}
|
||||
|
||||
protected updateItem(skill:Skill):void{
|
||||
|
||||
var conf = SkillCommand.getInstance().proxy.getSkillCfg(skill.cfgId);
|
||||
this._skill = skill;
|
||||
this.nameLab.string = conf.name;
|
||||
|
||||
this.icon.getComponent(SkillIconLogic).setData(skill, null);
|
||||
|
||||
this.limitLab.string = this._skill.generals.length + "/" + conf.limit;
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/SkillItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/SkillItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9bc6d30a-a60d-4688-8b93-134a8b8b9a30",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
81
assets/scripts/map/ui/SkillLogic.ts
Normal file
81
assets/scripts/map/ui/SkillLogic.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
const {ccclass, property} = _decorator;
|
||||
|
||||
import { General } from "../../config/Basci";
|
||||
import { SkillConf } from "../../config/skill/Skill";
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { GeneralData } from "../../general/GeneralProxy";
|
||||
import SkillCommand from "../../skill/SkillCommand";
|
||||
import { Skill } from "../../skill/SkillProxy";
|
||||
import SkillInfoLogic from "./SkillInfoLogic";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('SkillLogic')
|
||||
export default class SkillLogic extends Component {
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView: ScrollView = null;
|
||||
|
||||
_general: GeneralData = null;
|
||||
_type: number = 0;
|
||||
_skillPos : number = -1;
|
||||
|
||||
|
||||
|
||||
protected onEnable():void{
|
||||
|
||||
EventMgr.on("skill_list_info", this.onSkillList, this);
|
||||
SkillCommand.getInstance().qrySkillList();
|
||||
}
|
||||
|
||||
protected onDisable():void {
|
||||
EventMgr.targetOff(this)
|
||||
}
|
||||
|
||||
protected onSkillList(){
|
||||
var skills = SkillCommand.getInstance().proxy.skills;
|
||||
var skillConfs = SkillCommand.getInstance().proxy.skillConfs;
|
||||
|
||||
var arr = [];
|
||||
for (let i = 0; i < skillConfs.length; i++) {
|
||||
var found = false;
|
||||
let cfg = skillConfs[i];
|
||||
|
||||
let dSkill = new Skill();
|
||||
dSkill.cfgId = cfg.cfgId;
|
||||
dSkill.generals = [];
|
||||
|
||||
for (let j = 0; j < skills.length; j++) {
|
||||
var skill = skills[j];
|
||||
if (skill.cfgId == cfg.cfgId){
|
||||
found = true;
|
||||
arr.push(skill);
|
||||
break
|
||||
}
|
||||
}
|
||||
if(found == false){
|
||||
arr.push(dSkill);
|
||||
}
|
||||
}
|
||||
|
||||
var comp = this.scrollView.node.getComponent("ListLogic");
|
||||
comp.setData(arr);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected onClickItem(data: Skill, target): void {
|
||||
EventMgr.emit("open_skillInfo", data, this._type, this._general, this._skillPos);
|
||||
}
|
||||
|
||||
|
||||
/** type:0普通展示、type:1 学习、2:武将查看 **/
|
||||
public setData(type:number, general:GeneralData, skillPos: number) {
|
||||
this._type = type;
|
||||
this._general = general;
|
||||
this._skillPos = skillPos;
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/SkillLogic.ts.meta
Normal file
11
assets/scripts/map/ui/SkillLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4147bbc1-add2-48ef-9c1d-26ab0a58797d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
56
assets/scripts/map/ui/SmallMapLogic.ts
Normal file
56
assets/scripts/map/ui/SmallMapLogic.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { _decorator, Component, EditBox, Node, Vec2 } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import MapCommand from "../MapCommand";
|
||||
import MapUtil from "../MapUtil";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('SmallMapLogic')
|
||||
export default class SmallMapLogic extends Component {
|
||||
@property(EditBox)
|
||||
editBoxX: EditBox = null;
|
||||
@property(EditBox)
|
||||
editBoxY: EditBox = null;
|
||||
|
||||
protected _armys: Node[] = [];
|
||||
protected _citys: Node[] = [];
|
||||
|
||||
protected onLoad(): void {
|
||||
EventMgr.on("map_center_change", this.onMapCenterChange, this);
|
||||
EventMgr.on("scroll_to_map", this.onScrollToMap, this);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected updateView() {
|
||||
let centerPoint:Vec2 = MapCommand.getInstance().proxy.getCurCenterPoint();
|
||||
if (centerPoint) {
|
||||
this.editBoxX.string = centerPoint.x.toString();
|
||||
this.editBoxY.string = centerPoint.y.toString();
|
||||
}
|
||||
}
|
||||
|
||||
protected onMapCenterChange(): void {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
protected onScrollToMap():void {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
onClickJump(): void {
|
||||
let x: number = Number(this.editBoxX.string);
|
||||
let y: number = Number(this.editBoxY.string);
|
||||
if (x >= 0
|
||||
&& y >= 0
|
||||
&& x < MapUtil.mapSize.width
|
||||
&& y < MapUtil.mapSize.height) {
|
||||
EventMgr.emit("scroll_to_map", x, y);
|
||||
} else {
|
||||
console.log("跳转无效位置", x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/SmallMapLogic.ts.meta
Normal file
11
assets/scripts/map/ui/SmallMapLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "36cb81dd-07b3-4126-b76e-93f6708d206d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
178
assets/scripts/map/ui/TransformLogic.ts
Normal file
178
assets/scripts/map/ui/TransformLogic.ts
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
import { _decorator, Component, Layout, Node, Label, Slider, Toggle } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import MapCommand from "../MapCommand";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('TransformLogic')
|
||||
export default class TransformLogic extends Component {
|
||||
|
||||
|
||||
@property(Layout)
|
||||
fromLayout:Layout = null;
|
||||
|
||||
|
||||
@property(Layout)
|
||||
toLayout:Layout = null;
|
||||
|
||||
|
||||
@property(Node)
|
||||
trNode:Node = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
trLabel:Label = null;
|
||||
|
||||
@property(Label)
|
||||
rateLabel:Label = null;
|
||||
|
||||
|
||||
@property(Slider)
|
||||
trSlider:Slider = null;
|
||||
|
||||
protected _nameObj: any = {};
|
||||
protected _keyArr:string[] = []
|
||||
protected _curFromIndex:number = -1;
|
||||
protected _curToIndex:number = -1;
|
||||
protected _fromChange:number = 0;
|
||||
protected _toChange:number = 0;
|
||||
|
||||
protected onLoad():void{
|
||||
|
||||
this._nameObj = {
|
||||
wood: "木材x",
|
||||
iron: "金属x",
|
||||
stone: "石材x",
|
||||
grain: "谷物x",
|
||||
};
|
||||
|
||||
this._keyArr = ["wood","iron","stone","grain"]
|
||||
|
||||
EventMgr.on("upate_my_roleRes", this.initView, this);
|
||||
}
|
||||
|
||||
private getRate() :number {
|
||||
var cityId = MapCommand.getInstance().cityProxy.getMyMainCity().cityId;
|
||||
var _addition = MapUICommand.getInstance().proxy.getMyCityAddition(cityId);
|
||||
var rate = MapUICommand.getInstance().proxy.getTransformRate() + _addition.taxRate;
|
||||
return rate
|
||||
}
|
||||
|
||||
public initView():void{
|
||||
this.updateView();
|
||||
this.updateBtn();
|
||||
|
||||
}
|
||||
|
||||
protected updateView():void{
|
||||
var roleRes = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
var i = 0;
|
||||
let children_from = this.fromLayout.node.children;
|
||||
for (var key in this._nameObj) {
|
||||
children_from[i].getChildByName("New Label").getComponent(Label).string = this._nameObj[key] + roleRes[key];
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
let children_to = this.toLayout.node.children;
|
||||
for (var key in this._nameObj) {
|
||||
children_to[i].getChildByName("New Label").getComponent(Label).string = this._nameObj[key] + roleRes[key];
|
||||
i++;
|
||||
}
|
||||
|
||||
var rate = this.getRate()
|
||||
this.rateLabel.string = "1 / " + (rate/100)
|
||||
|
||||
}
|
||||
|
||||
protected updateBtn():void{
|
||||
this.trSlider.progress = 0.0;
|
||||
this.trNode.active = this._curFromIndex == this._curToIndex?false:true;
|
||||
this.updateLable();
|
||||
}
|
||||
|
||||
|
||||
protected updateLable():void{
|
||||
var from_index = this.getFromSelectIndex();
|
||||
var to_index = this.getToSelectIndex();
|
||||
if (from_index < 0 || to_index < 0){
|
||||
this.trLabel.string = ""
|
||||
}else{
|
||||
var roleRes = LoginCommand.getInstance().proxy.getRoleResData();
|
||||
var from_key = this._keyArr[from_index];
|
||||
this._fromChange = Math.round(roleRes[from_key] * this.trSlider.progress)
|
||||
|
||||
var rate = this.getRate()
|
||||
this._toChange = Math.round(this._fromChange * rate / 100)
|
||||
this.trLabel.string = this._fromChange + "/" + this._toChange
|
||||
}
|
||||
}
|
||||
|
||||
protected getFromSelectIndex():number{
|
||||
let children_from = this.fromLayout.node.children;
|
||||
for(var i = 0;i < children_from.length;i++){
|
||||
if(children_from[i].getComponent(Toggle).isChecked){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
protected getToSelectIndex():number{
|
||||
let children_to = this.toLayout.node.children;
|
||||
for(var i = 0;i < children_to.length;i++){
|
||||
if(children_to[i].getComponent(Toggle).isChecked){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
protected fromToggleHandle(event:any):void{
|
||||
console.log("fromToggleHandle:",this.getFromSelectIndex())
|
||||
this._curFromIndex = this.getFromSelectIndex();
|
||||
this.updateBtn();
|
||||
}
|
||||
|
||||
protected toToggleHandle(event:any):void{
|
||||
console.log("toToggleHandle:",this.getToSelectIndex())
|
||||
this._curToIndex = this.getToSelectIndex()
|
||||
this.updateBtn();
|
||||
}
|
||||
|
||||
|
||||
protected slideHandle():void{
|
||||
this.updateLable();
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
protected onTransForm():void{
|
||||
let from:number[] = [0,0,0,0];
|
||||
let to:number[] = [0,0,0,0];
|
||||
|
||||
var from_index = this.getFromSelectIndex();
|
||||
var to_index = this.getToSelectIndex();
|
||||
|
||||
if(from_index < 0 || to_index < 0){
|
||||
return
|
||||
}
|
||||
|
||||
from[from_index] = this._fromChange;
|
||||
to[to_index] = this._toChange;
|
||||
|
||||
MapUICommand.getInstance().interiorTransform(from,to);
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/TransformLogic.ts.meta
Normal file
11
assets/scripts/map/ui/TransformLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fef59507-c1dd-452e-8d5e-d482009d3223",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
37
assets/scripts/map/ui/UnionButtonLogic.ts
Normal file
37
assets/scripts/map/ui/UnionButtonLogic.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import UnionCommand from "../../union/UnionCommand";
|
||||
import { MapCityData } from "../MapCityProxy";
|
||||
import MapCommand from "../MapCommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('UnionButtonLogic')
|
||||
export default class WarButtonLogic extends Component {
|
||||
|
||||
|
||||
@property(Node)
|
||||
tipsNode:Node = null;
|
||||
|
||||
protected onLoad():void{
|
||||
EventMgr.on("update_union_apply", this.updateView, this);
|
||||
this.tipsNode.active = false;
|
||||
}
|
||||
|
||||
|
||||
protected updateView():void{
|
||||
let city:MapCityData = MapCommand.getInstance().cityProxy.getMyMainCity();
|
||||
let cnt = UnionCommand.getInstance().proxy.getApplyCnt(city.unionId);
|
||||
this.tipsNode.active = cnt > 0;
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/UnionButtonLogic.ts.meta
Normal file
11
assets/scripts/map/ui/UnionButtonLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "600c36c9-5fb3-48c7-9b23-56896ecf47ed",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
33
assets/scripts/map/ui/WarButtonLogic.ts
Normal file
33
assets/scripts/map/ui/WarButtonLogic.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
|
||||
@ccclass('WarButtonLogic')
|
||||
export default class WarButtonLogic extends Component {
|
||||
|
||||
|
||||
@property(Node)
|
||||
tipsNode:Node = null;
|
||||
|
||||
protected onLoad():void{
|
||||
EventMgr.on("upate_war_report", this.updateView, this);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
|
||||
protected updateView():void{
|
||||
this.tipsNode.active = MapUICommand.getInstance().proxy.isReadNum()>0?true:false;
|
||||
}
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/WarButtonLogic.ts.meta
Normal file
11
assets/scripts/map/ui/WarButtonLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "4d3bf2b7-9ebf-4cfc-8adc-495107d4bf96",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
57
assets/scripts/map/ui/WarReportDesItemLogic.ts
Normal file
57
assets/scripts/map/ui/WarReportDesItemLogic.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { _decorator, Component, RichText, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import GeneralCommand from "../../general/GeneralCommand";
|
||||
import { WarReportRound } from "./MapUIProxy";
|
||||
|
||||
@ccclass('WarReportDesItemLogic')
|
||||
export default class WarReportDesItemLogic extends Component {
|
||||
|
||||
private _curData:WarReportRound = null;
|
||||
|
||||
@property(RichText)
|
||||
warLab1:RichText = null;
|
||||
|
||||
@property(RichText)
|
||||
warLab2:RichText = null;
|
||||
|
||||
@property(Label)
|
||||
roundsLabel:Label = null;
|
||||
|
||||
|
||||
protected onLoad():void{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected updateItem(data:WarReportRound):void{
|
||||
console.log("updateItem:", data);
|
||||
|
||||
this._curData = data;
|
||||
this.roundsLabel.string = "第" + this._curData.round + "轮/" + this._curData.turn+"回合";
|
||||
|
||||
var att_cfg = GeneralCommand.getInstance().proxy.getGeneralCfg(this._curData.attack.cfgId);
|
||||
var def_cfg = GeneralCommand.getInstance().proxy.getGeneralCfg(this._curData.defense.cfgId);
|
||||
|
||||
var title1 = ""
|
||||
var title2 = ""
|
||||
if(data.isAttack){
|
||||
title1 = "攻";
|
||||
title2 = "防";
|
||||
}else{
|
||||
title2 = "攻";
|
||||
title1 = "防";
|
||||
}
|
||||
this.warLab1.string = "<color=#ff0000>" + title1 + att_cfg.name + "</color>" + " 对 "
|
||||
+ "<color=#00ff00>" + title2 + def_cfg.name + "</color>" + " 发起攻击,"
|
||||
+ "<color=#00ff00>" + title2 + def_cfg.name + "</color>" + " 损失 " +
|
||||
"<color=#F2C420>" + this._curData.defenseLoss + "</color>" + " 士兵";
|
||||
|
||||
this.warLab2.string = "<color=#ff0000>" + title2 + def_cfg.name + "</color>" + " 对 "
|
||||
+ "<color=#00ff00>" + title1 + att_cfg.name + "</color>" + " 发起攻击,"
|
||||
+ "<color=#00ff00>" + title1 + att_cfg.name + "</color>" + " 损失 " +
|
||||
"<color=#F2C420>" + this._curData.attackLoss + "</color>" + " 士兵";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
assets/scripts/map/ui/WarReportDesItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/WarReportDesItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "15d17876-c754-46ae-b315-5bf72dab3f31",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
34
assets/scripts/map/ui/WarReportDesLogic.ts
Normal file
34
assets/scripts/map/ui/WarReportDesLogic.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { _decorator, Component, ScrollView } from 'cc';
|
||||
import ListLogic from '../../utils/ListLogic';
|
||||
const { ccclass, property } = _decorator;
|
||||
import { WarReport } from "./MapUIProxy";
|
||||
|
||||
@ccclass('WarReportDesLogic')
|
||||
export default class WarReportDesLogic extends Component {
|
||||
|
||||
|
||||
private _curData:WarReport = null;
|
||||
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
|
||||
protected onLoad():void{
|
||||
}
|
||||
|
||||
|
||||
public setData(data:any):void{
|
||||
|
||||
this._curData = data;
|
||||
console.log("WarReportDesLogic rounds:", this._curData.rounds);
|
||||
|
||||
var comp = this.scrollView.node.getComponent(ListLogic);
|
||||
comp.setData(this._curData.rounds);
|
||||
}
|
||||
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/WarReportDesLogic.ts.meta
Normal file
11
assets/scripts/map/ui/WarReportDesLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3afacdf8-3b35-4094-8d2e-b82cdb1dc730",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
130
assets/scripts/map/ui/WarReportItemLogic.ts
Normal file
130
assets/scripts/map/ui/WarReportItemLogic.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { _decorator, Component, Node, Label } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import LoginCommand from "../../login/LoginCommand";
|
||||
import { Role } from "../../login/LoginProxy";
|
||||
import DateUtil from "../../utils/DateUtil";
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { WarReport } from "./MapUIProxy";
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
import GeneralItemLogic from './GeneralItemLogic';
|
||||
|
||||
@ccclass('WarReportItemLogic')
|
||||
export default class WarReportItemLogic extends Component {
|
||||
|
||||
|
||||
private _curData:WarReport = null;
|
||||
|
||||
@property(Node)
|
||||
readBg:Node = null;
|
||||
|
||||
@property([Node])
|
||||
ackNode:Node[] = [];
|
||||
|
||||
|
||||
@property([Node])
|
||||
defNode:Node[] = [];
|
||||
|
||||
|
||||
@property(Node)
|
||||
winNode:Node = null;
|
||||
|
||||
|
||||
@property(Node)
|
||||
loseNode:Node = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
timeLabel: Label = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
leftLabel: Label = null;
|
||||
|
||||
|
||||
@property(Label)
|
||||
rightLabel: Label = null;
|
||||
|
||||
protected onLoad():void{
|
||||
this.winNode.active = this.loseNode.active = false;
|
||||
}
|
||||
|
||||
|
||||
protected updateItem(data:any):void{
|
||||
this._curData = data;
|
||||
|
||||
var isRead = MapUICommand.getInstance().proxy.isRead(this._curData.id);
|
||||
this.readBg.active = isRead;
|
||||
|
||||
|
||||
this.setTeams(this.ackNode,this._curData.beg_attack_general);
|
||||
this.setTeams(this.defNode,this._curData.beg_defense_general);
|
||||
|
||||
var roleData:Role = LoginCommand.getInstance().proxy.getRoleData();
|
||||
this.isMeWin(this._curData.attack_rid)
|
||||
|
||||
this.leftLabel.string = roleData.rid == this._curData.attack_rid?"我":"敌";
|
||||
this.rightLabel.string = roleData.rid == this._curData.defense_rid?"我":"敌"
|
||||
|
||||
this.timeLabel.string = DateUtil.converTimeStr(this._curData.ctime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected isMeWin(rid:number = 0):void{
|
||||
var roleData:Role = LoginCommand.getInstance().proxy.getRoleData();
|
||||
this.winNode.active = this.loseNode.active = false;
|
||||
|
||||
if(roleData.rid == rid){
|
||||
if(this._curData.result == 0){
|
||||
this.loseNode.active = true;
|
||||
}else if(this._curData.result == 1){
|
||||
|
||||
}else{
|
||||
this.winNode.active = true;
|
||||
}
|
||||
}else{
|
||||
if(this._curData.result == 0){
|
||||
this.winNode.active = true;
|
||||
}else if(this._curData.result == 1){
|
||||
|
||||
}else{
|
||||
this.loseNode.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected setTeams(node:Node[],generals:any[]){
|
||||
for(var i = 0; i < node.length ;i++){
|
||||
let item:Node = node[i];
|
||||
let com = item.getComponent(GeneralItemLogic);
|
||||
var general = generals[i];
|
||||
if(general){
|
||||
item.active = true;
|
||||
if(com){
|
||||
com.setWarReportData(general);
|
||||
}
|
||||
|
||||
}else{
|
||||
item.active = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected onClickItem():void{
|
||||
var isRead = MapUICommand.getInstance().proxy.isRead(this._curData.id);
|
||||
if(!isRead){
|
||||
MapUICommand.getInstance().warRead(this._curData.id);
|
||||
}
|
||||
|
||||
console.log("click_war_report:", this._curData);
|
||||
EventMgr.emit("click_war_report", this._curData);
|
||||
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/WarReportItemLogic.ts.meta
Normal file
11
assets/scripts/map/ui/WarReportItemLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3f022498-a996-4017-ad37-8790aac43273",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
69
assets/scripts/map/ui/WarReportLogic.ts
Normal file
69
assets/scripts/map/ui/WarReportLogic.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
// // Learn TypeScript:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
||||
// // Learn Attribute:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
||||
// // Learn life-cycle callbacks:
|
||||
// // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
import { _decorator, Component, ScrollView, Prefab, Node, instantiate } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
import MapUICommand from "./MapUICommand";
|
||||
import { WarReport } from "./MapUIProxy";
|
||||
import WarReportDesLogic from './WarReportDesLogic';
|
||||
import { EventMgr } from '../../utils/EventMgr';
|
||||
import ListLogic from '../../utils/ListLogic';
|
||||
|
||||
@ccclass('WarReportLogic')
|
||||
export default class WarReportLogic extends Component {
|
||||
|
||||
@property(ScrollView)
|
||||
scrollView:ScrollView = null;
|
||||
|
||||
@property(Prefab)
|
||||
warPortDesPrefab: Prefab = null;
|
||||
private _warPortDesNode:Node = null;
|
||||
|
||||
protected onLoad():void{
|
||||
EventMgr.on("upate_war_report", this.initView, this);
|
||||
EventMgr.on("click_war_report", this.openWarPortDes, this);
|
||||
}
|
||||
|
||||
|
||||
protected onDestroy():void{
|
||||
EventMgr.targetOff(this);
|
||||
}
|
||||
|
||||
protected onClickClose(): void {
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
|
||||
protected initView():void{
|
||||
var report:WarReport[] = MapUICommand.getInstance().proxy.getWarReport();
|
||||
|
||||
var comp = this.scrollView.node.getComponent(ListLogic);
|
||||
comp.setData(report);
|
||||
}
|
||||
|
||||
public updateView():void{
|
||||
this.initView();
|
||||
MapUICommand.getInstance().qryWarReport();
|
||||
}
|
||||
|
||||
protected openWarPortDes(data:WarReport):void{
|
||||
console.log("openWarPortDes");
|
||||
if (this._warPortDesNode == null) {
|
||||
this._warPortDesNode = instantiate(this.warPortDesPrefab);
|
||||
this._warPortDesNode.parent = this.node;
|
||||
} else {
|
||||
this._warPortDesNode.active = true;
|
||||
}
|
||||
|
||||
this._warPortDesNode.getComponent(WarReportDesLogic).setData(data);
|
||||
}
|
||||
|
||||
protected allRead():void{
|
||||
MapUICommand.getInstance().warRead(0);
|
||||
}
|
||||
}
|
||||
11
assets/scripts/map/ui/WarReportLogic.ts.meta
Normal file
11
assets/scripts/map/ui/WarReportLogic.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "92a94b82-51a9-4871-b7d9-615af878bb01",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user