| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- import towerManger from "./towerManger";
- import { TowerType } from "../../configData/Enum";
- import gameUI from "../UIFace/gameUI";
- import monsterManger from "../monster/monsterManger";
- import gameData from "../../configData/gameData";
- import TapNode from "../UIFace/TapNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class TowerHuan extends cc.Component {
- /**环点击区域 */
- @property(cc.Node)
- private tapSqrt: cc.Node = null;
- /**预警范围 */
- @property(cc.Sprite)
- private lanse: cc.Sprite = null;
- /**预警范围 */
- @property(cc.Sprite)
- private redquan: cc.Sprite = null;
- /** 圆环底座*/
- @property(cc.Sprite)
- private huan: cc.Sprite = null;
- /**不可升级标志 */
- @property(cc.Sprite)
- private nosele: cc.Sprite = null;
- /**升级金币数量 */
- @property(cc.Label)
- private sale: cc.Label = null;
- /**升级底座 */
- @property(cc.Sprite)
- private shengji: cc.Sprite = null;
- /**插旗底座 */
- @property(cc.Sprite)
- private chaqi: cc.Sprite = null;
- /**卖掉塔底座 */
- @property(cc.Sprite)
- private towerdestory: cc.Sprite = null;
- /**升级标志 */
- @property(cc.Sprite)
- private uptip: cc.Sprite = null;
- /**升级勾 */
- @property(cc.Sprite)
- private upgou: cc.Sprite = null;
- /**卖钱标志 */
- @property(cc.Sprite)
- private saletip: cc.Sprite = null;
- /**卖钱勾 */
- @property(cc.Sprite)
- private salegou: cc.Sprite = null;
- /**圆环是否打开 */
- public isOpen = false;
- /**是否可以插旗 */
- public isCanChaqi = false;
- /**升四级塔选项 */
- private upfor1: cc.Node = null;
- private upfor2: cc.Node = null;
- /**技能升级选项 */
- private skillupbg1: cc.Node = null;
- private skillupbg2: cc.Node = null;
- private skillupbg3: cc.Node = null;
- private skillLv = [0, 0, 0];
- private GoPos: cc.Vec3[] = [];
- private norMaterial: cc.Material = cc.Material.getBuiltinMaterial('2d-sprite');
- private grayMaterial: cc.Material = cc.Material.getBuiltinMaterial('2d-gray-sprite');
- private tower = null;
- private towerType: TowerType = 1;
- onLoad() {
- this.tapSqrt.on(cc.Node.EventType.TOUCH_START, this.touchNode, this);
- this.initSpr();
- this.GoPos = gameUI.instance.getGoPos();
- }
- private initSpr() {
- this.redquan.node.active = false;
- this.huan.node.active = false;
- this.chaqi.node.on(cc.Node.EventType.TOUCH_START, this.chaqiclick, this);
- this.towerdestory.node.on(cc.Node.EventType.TOUCH_START, this.destoryclick, this);
- }
- public setTowerType(type: TowerType) {
- this.towerType = type;
- this.chaqi.node.active = (type == TowerType.Enum_Barrack);
- if (type == TowerType.Enum_Barrack) {
- this.redquan.spriteFrame = this.lanse.spriteFrame;
- }
- }
- /**设置塔 */
- public setTower(tower) {
- this.tower = tower;
- this.sale.string = tower.myDataObj.TowerData.up_gold[0].toString();
- // console.log("------");
- this.initModel();
- }
- /**设置塔环类型 */
- private initModel() {
- let level = this.tower.myDataObj.TowerData.tower_level;
- this.shengji.node.active = false;
- this.upfor1 = this.huan.node.getChildByName('tower_upFour_1');
- this.upfor2 = this.huan.node.getChildByName('tower_upFour_2');
- this.skillupbg1 = this.huan.node.getChildByName('skillupbg1');
- this.skillupbg2 = this.huan.node.getChildByName('skillupbg2');
- this.skillupbg3 = this.huan.node.getChildByName('skillupbg3');
- this.upfor1.active = false;
- this.upfor2.active = false;
- this.skillupbg1.active = false;
- this.skillupbg2.active = false;
- this.skillupbg3.active = false;
- if (this.towerType == TowerType.Enum_Barrack) {
- this.skillupbg1.setPosition(-139, 16);
- this.skillupbg2.setPosition(-32, 134);
- this.skillupbg3.setPosition(124, 98);
- }
- if (level < 3) {
- this.shengji.node.active = true;
- this.shengji.node.on(cc.Node.EventType.TOUCH_START, () => {
- this.shengjiclick(0);
- }, this);
- }
- if (level == 3) {
- this.upfor1.active = true;
- this.upfor2.active = true;
- this.upfor1.on(cc.Node.EventType.TOUCH_START, this.seleTower1click, this);
- this.upfor2.on(cc.Node.EventType.TOUCH_START, this.seleTower2click, this);
- let sale1 = this.upfor1.getChildByName('sale').getComponent(cc.Label);
- let sale2 = this.upfor2.getChildByName('sale').getComponent(cc.Label);
- sale1.string = this.tower.myDataObj.TowerData.up_gold[0].toString();
- sale2.string = this.tower.myDataObj.TowerData.up_gold[0].toString();
- let self = this;
- cc.resources.load("game/skill/tower_icon_" + this.towerType+"_0", cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.upfor1.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- cc.resources.load("game/skill/tower_icon_" + this.towerType+"_1", cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.upfor2.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- if (level >= 4) {
- this.skillupbg1.active = true;
- this.skillupbg2.active = true;
- if (this.towerType == TowerType.Enum_Barrack) {
- this.skillupbg3.active = true;
- }
- this.skillupbg1.on(cc.Node.EventType.TOUCH_START, this.upSkill1click, this);
- this.skillupbg2.on(cc.Node.EventType.TOUCH_START, this.upSkill2click, this);
- this.skillupbg3.on(cc.Node.EventType.TOUCH_START, this.upSkill3click, this);
- this.resetSkillTap();
- }
- }
- /**设置技能升级按钮 金币数 和图片 */
- private resetSkillTap() {
- let sale1 = this.skillupbg1.getChildByName('sale').getComponent(cc.Label);
- let sale2 = this.skillupbg2.getChildByName('sale').getComponent(cc.Label);
- let sale3 = this.skillupbg3.getChildByName('sale').getComponent(cc.Label);
- let self = this;
- if (this.skillLv[0] == 0) {
- sale1.string = this.tower.myDataObj.TowerData.up_gold[0].toString();
- let idd = this.tower.myDataObj.TowerData.next_skill[0];
- this.tower.myDataObj.writeSkill_Config(idd);
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- else {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDL);
- sale1.string = this.tower.myDataObj.SkillData.up_gold.toString();
- for (let i = 1; i <= this.skillLv[0]; i++) {
- this.skillupbg1.getChildByName('skilllv' + i).opacity = 255;
- }
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- if (this.skillLv[1] == 0) {
- sale2.string = this.tower.myDataObj.TowerData.up_gold[1].toString();
- let idd = this.tower.myDataObj.TowerData.next_skill[1];
- this.tower.myDataObj.writeSkill_Config(idd);
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- else {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDR);
- sale2.string = this.tower.myDataObj.SkillData.up_gold.toString();
- for (let i = 1; i <= this.skillLv[1]; i++) {
- this.skillupbg2.getChildByName('skilllv' + i).opacity = 255;
- }
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- if (this.towerType == TowerType.Enum_Barrack) {
- if (this.skillLv[2] == 0) {
- sale3.string = this.tower.myDataObj.TowerData.up_gold[2].toString();
- let idd = this.tower.myDataObj.TowerData.next_skill[2];
- this.tower.myDataObj.writeSkill_Config(idd);
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- else {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDT);
- sale3.string = this.tower.myDataObj.SkillData.up_gold.toString();
- for (let i = 1; i <= this.skillLv[2]; i++) {
- this.skillupbg3.getChildByName('skilllv' + i).opacity = 255;
- }
- cc.resources.load("game/skill/" + this.tower.myDataObj.SkillData.skill_icon, cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- self.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).spriteFrame = myspriteFrame;
- });
- }
- }
- }
- /**设置环的大小 */
- public setRedHuanScale(scale: number) {
- this.redquan.node.scale = scale / 275;
- }
- /**选择左技能塔 */
- private seleTower1click() {
- this.shengjiclick(0);
- }
- /**选择右技能塔 */
- private seleTower2click() {
- this.shengjiclick(1);
- }
- /**升级左边技能 */
- private upSkill1click() {
- if (this.skillLv[0] < 3) {
- this.shengjiclick(0);
- }
- }
- /**升级右边技能 */
- private upSkill2click() {
- if (this.skillLv[1] < 3) {
- this.shengjiclick(1);
- }
- }
- /**升级3边技能 */
- private upSkill3click() {
- if (this.skillLv[2] < 3) {
- this.shengjiclick(2);
- }
- }
- /**升级塔 */
- private shengjiclick(dex: number) {
- let level = this.tower.myDataObj.TowerData.tower_level;
- let upgold = this.tower.myDataObj.TowerData.up_gold[dex];
- if (level == 3) {
- upgold = this.tower.myDataObj.TowerData.up_gold[0];
- }
- let isgoldMore = upgold <= gameUI.instance.getGold();
- if (level >= 4 && this.skillLv[dex] > 0) {
- if (dex == 0) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDL);
- isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- }
- if (dex == 1) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDR);
- isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- }
- if (dex == 2) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDT);
- isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- }
- }
- let canUpTower = gameUI.instance.getLevelLimit().indexOf(this.tower.myDataObj.TowerData.next_tower_id[dex]) < 0;
- let dagou = this.upgou;
- if (level == 3) {
- if (dex == 0) {
- dagou = this.upfor1.getChildByName('build_1').getComponent(cc.Sprite);
- }
- if (dex == 1) {
- dagou = this.upfor2.getChildByName('build_1').getComponent(cc.Sprite);
- }
- }
- if (level >= 4) {
- if (dex == 0) {
- dagou = this.skillupbg1.getChildByName('build_1').getComponent(cc.Sprite);
- }
- if (dex == 1) {
- dagou = this.skillupbg2.getChildByName('build_1').getComponent(cc.Sprite);
- }
- if (dex == 2) {
- dagou = this.skillupbg3.getChildByName('build_1').getComponent(cc.Sprite);
- }
- }
- if (isgoldMore && canUpTower) {
- if (dagou.node.opacity == 0) {
- dagou.node.opacity = 255;
- if (level < 3) {
- this.uptip.node.opacity = 0;
- }
- if (level == 3) {
- if (dex == 0) {
- this.upfor2.getChildByName('build_1').opacity = 0;
- }
- if (dex == 1) {
- this.upfor1.getChildByName('build_1').opacity = 0;
- }
- }
- if (level >= 4) {
- if (dex == 0) {
- this.skillupbg2.getChildByName('build_1').opacity = 0;
- this.skillupbg3.getChildByName('build_1').opacity = 0;
- }
- if (dex == 1) {
- this.skillupbg1.getChildByName('build_1').opacity = 0;
- this.skillupbg3.getChildByName('build_1').opacity = 0;
- }
- if (dex == 2) {
- this.skillupbg1.getChildByName('build_1').opacity = 0;
- this.skillupbg2.getChildByName('build_1').opacity = 0;
- }
- }
- }
- else {
- if (level <= 3) {
- towerManger.instance.delateTower(this.tower);
- towerManger.instance.UpTower(this.tower, this.tower.myDataObj.TowerData.next_tower_id[dex]);
- gameUI.instance.AddGold(-this.tower.myDataObj.TowerData.up_gold[0]);
- this.scheduleOnce(function () {
- this.tower.node.destroy();
- }, 0);
- }
- else {
- this.tower.setandUpSkillId(dex + 1);
- if (this.skillLv[dex] == 0) {
- gameUI.instance.AddGold(-this.tower.myDataObj.TowerData.up_gold[0]);
- }
- else {
- gameUI.instance.AddGold(-this.tower.myDataObj.SkillData.up_gold);
- }
- this.skillLv[dex]++;
- this.resetSkillTap();
- this.turnsmall();
- }
- }
- }
- }
- /**插旗 */
- private chaqiclick() {
- this.redquan.node.active = true;
- this.isCanChaqi = true;
- TapNode.instance.node.active = true;
- this.turnsmall();
- }
- /**插旗 */
- public chaqiTap(location: cc.Vec2) {
- if (this.isCanChaqi) {
- if (this.getIsInGopos(location) && this.tower.getIsInSqrt(location)) {
- this.isCanChaqi = false;
- this.redquan.node.active = false;
- TapNode.instance.node.active = false;
- this.tower.chaqiWalk(location);
- monsterManger.instance.chaqidian(location);
- }
- else {
- monsterManger.instance.updatest(location);
- }
- }
- }
- /**插旗位置判断 */
- private getIsInGopos(location: cc.Vec2): boolean {
- let leth = Number(gameData.instance().game_Const[7][2]);
- let laca = cc.v3(location.x, location.y);
- for (let i = 0; i < this.GoPos.length; i++) {
- const element = this.GoPos[i];
- if (element.sub(laca).mag() < leth) {
- return true;
- }
- }
- return false;
- }
- /**销毁塔卖钱*/
- private destoryclick() {
- if (this.salegou.node.opacity == 0) {
- this.salegou.node.opacity = 255;
- this.saletip.node.opacity = 0;
- }
- else {
- this.tower._taside.openTouchOn();
- towerManger.instance.delateTower(this.tower);
- let value_gold = this.tower.myDataObj.TowerData.value_gold;
- if (this.tower.SkillIDL > 0) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDL);
- value_gold += this.tower.myDataObj.SkillData.up_gold;
- this.tower._taside.addtowerGold(this.tower.myDataObj.SkillData.up_gold);
- }
- if (this.tower.SkillIDR > 0) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDR);
- value_gold += this.tower.myDataObj.SkillData.up_gold;
- this.tower._taside.addtowerGold(this.tower.myDataObj.SkillData.up_gold);
- }
- if (this.towerType == TowerType.Enum_Barrack) {
- if (this.tower.SkillIDT > 0) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDT);
- value_gold += this.tower.myDataObj.SkillData.up_gold;
- this.tower._taside.addtowerGold(this.tower.myDataObj.SkillData.up_gold);
- }
- }
- if (towerManger.instance.talantData[0].length > 0 && this.towerType == TowerType.Enum_Arrow) {
- value_gold = this.tower._taside.gettowerGold() * towerManger.instance.talantData[0][0];
- this.tower._taside.settowerGold(0);
- }
- gameUI.instance.AddGold(value_gold);
- this.tower.node.destroy();
- }
- }
- //iconspr
- /**显示金币不足时状态 */
- private showNosele() {
- let isgoldMore = this.tower.myDataObj.TowerData.up_gold[0] <= gameUI.instance.getGold();
- let canUpTower = gameUI.instance.getLevelLimit().indexOf(this.tower.myDataObj.TowerData.next_tower_id[0]) < 0;
- let level = this.tower.myDataObj.TowerData.tower_level;
- if (level < 3) {
- this.uptip.node.opacity = 255;
- if (canUpTower) {
- this.nosele.node.opacity = 0;
- this.shengji.node.getChildByName('skillupbg3').opacity = 255;
- this.shengji.node.getChildByName('iconspr').opacity = 255;
- this.sale.node.opacity = 255;
- }
- else {
- this.nosele.node.opacity = 255;
- this.shengji.node.getChildByName('iconspr').opacity = 0;
- this.sale.node.opacity = 0;
- this.shengji.node.getChildByName('skillupbg3').opacity = 0;
- }
- if (isgoldMore) {
- this.shengji.node.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.sale.node.color = cc.color(235, 255, 6);
- }
- else {
- this.shengji.node.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.sale.node.color = cc.color(102, 91, 91);
- }
- }
- if (level == 3) {
-
- if (canUpTower) {
- this.upfor1.getChildByName('build_2').opacity = 0;
- this.upfor1.getChildByName('iconspr').opacity = 255;
- this.upfor1.getChildByName('sale').opacity = 255;
- this.upfor1.getChildByName('skillupbg3').opacity = 255;
- }
- else {
- this.upfor1.getChildByName('build_2').opacity = 255;
- this.upfor1.getChildByName('iconspr').opacity = 0;
- this.upfor1.getChildByName('sale').opacity = 0;
- this.upfor1.getChildByName('skillupbg3').opacity = 0;
- }
- let canUpTower1 = gameUI.instance.getLevelLimit().indexOf(this.tower.myDataObj.TowerData.next_tower_id[1]) < 0;
- if (canUpTower1) {
- this.upfor2.getChildByName('build_2').opacity = 0;
- this.upfor2.getChildByName('iconspr').opacity = 255;
- this.upfor2.getChildByName('sale').opacity = 255;
- this.upfor2.getChildByName('skillupbg3').opacity = 255;
- }
- else {
- this.upfor2.getChildByName('build_2').opacity = 255;
- this.upfor2.getChildByName('iconspr').opacity = 0;
- this.upfor2.getChildByName('sale').opacity = 0;
- this.upfor2.getChildByName('skillupbg3').opacity = 0;
- }
- if (isgoldMore) {
- this.upfor1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.upfor2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.upfor1.getChildByName('sale').color = cc.color(235, 255, 6);
- this.upfor2.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.upfor1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.upfor2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.upfor1.getChildByName('sale').color = cc.color(102, 91, 91);
- this.upfor2.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- if (level >= 4) {
- if (this.tower.SkillIDL == 0) {
- let isgoldMore = this.tower.myDataObj.TowerData.up_gold[0] <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg1.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg1.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- if (this.skillLv[0] < 3) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDL);
- let isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg1.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg1.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg1.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- this.skillupbg1.getChildByName('sale').opacity = 0;
- this.skillupbg1.getChildByName('skillupbg3').opacity = 0;
- }
- }
- if (this.tower.SkillIDR == 0) {
- let isgoldMore = this.tower.myDataObj.TowerData.up_gold[1] <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg2.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg2.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- if (this.skillLv[1] < 3) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDR);
- let isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg2.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg2.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg2.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- this.skillupbg2.getChildByName('sale').opacity = 0;
- this.skillupbg2.getChildByName('skillupbg3').opacity = 0;
- }
- }
- if (this.towerType == TowerType.Enum_Barrack) {
- if (this.tower.SkillIDT == 0) {
- let isgoldMore = this.tower.myDataObj.TowerData.up_gold[2] <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg3.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg3.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- if (this.skillLv[2] < 3) {
- this.tower.myDataObj.writeSkill_Config(this.tower.SkillIDT);
- let isgoldMore = this.tower.myDataObj.SkillData.up_gold <= gameUI.instance.getGold();
- if (isgoldMore) {
- this.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.norMaterial);
- this.skillupbg3.getChildByName('sale').color = cc.color(235, 255, 6);
- }
- else {
- this.skillupbg3.getChildByName('iconspr').getComponent(cc.Sprite).setMaterial(0, this.grayMaterial);
- this.skillupbg3.getChildByName('sale').color = cc.color(102, 91, 91);
- }
- }
- else {
- this.skillupbg3.getChildByName('sale').opacity = 0;
- this.skillupbg3.getChildByName('skillupbg3').opacity = 0;
- }
- }
- }
- }
- }
- /**打开圆环 */
- private turnbig() {
- this.showNosele();
- towerManger.instance.closedHuan();
- this.huan.node.scale = 0.5;
- this.huan.node.opacity = 0;
- this.huan.node.active = true;
- this.redquan.node.active = true;
- this.huan.node.stopAllActions();
- this.node.zIndex = 1007;
- cc.tween(this.huan.node)
- .to(0.1, { scale: 1, opacity: 255 })
- .call(() => {
- this.isOpen = true;
- })
- .start();
- }
- /**关闭圆环 */
- public turnsmall() {
- if (this.isOpen) {
- this.node.zIndex = 1006;
- this.huan.node.stopAllActions();
- cc.tween(this.huan.node)
- .to(0.1, { scale: 0.5, opacity: 0 })
- .call(() => {
- this.huan.node.active = false;
- this.isOpen = false;
- if (!this.isCanChaqi) {
- this.redquan.node.active = false;
- }
- this.upgou.node.opacity = 0;
- this.salegou.node.opacity = 0;
- this.saletip.node.opacity = 255;
- this.upfor1.getChildByName('build_1').opacity = 0;
- this.upfor2.getChildByName('build_1').opacity = 0;
- this.skillupbg1.getChildByName('build_1').opacity = 0;
- this.skillupbg2.getChildByName('build_1').opacity = 0;
- this.skillupbg3.getChildByName('build_1').opacity = 0;
- })
- .start();
- }
- }
- /**点击泥土 */
- private touchNode() {
- this.turnbig();
- }
- }
|