WealthMng.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. import { HTTP_TYPE } from "../datas/CommonData";
  2. import { RichData } from "../datas/RichData";
  3. import { WealthData } from "../datas/WealthData";
  4. import Main from "../Main";
  5. import Wealth from "../other/control/Wealth";
  6. import Bullet from "../other/item/Bullet";
  7. import CarSpace from "../prefabs/CarSpace";
  8. import MyExtends from "../tools/MyExtends";
  9. import Time from "../tools/Time";
  10. import UIMng, { PanelType } from "../uiFrames/UIMng";
  11. import Sciencen_M from "../utils/Sciencen_M";
  12. import AdM from "./AdM";
  13. import { GameController } from "./GameController";
  14. import GameM, { AUDIO_TYPE } from "./GameM";
  15. import GuideMng from "./GuideMng";
  16. import HttpM from "./HttpM";
  17. import UiM from "./UiM";
  18. const { ccclass, property } = cc._decorator;
  19. export enum WealthState {
  20. Cooling = 0,
  21. ReadyFight = 1,
  22. Fighting = 2,
  23. End = 3,
  24. }
  25. @ccclass
  26. export default class WealthMng extends cc.Component {
  27. private static ins: WealthMng = null
  28. static get Ins(): WealthMng {
  29. if (!this.ins) {
  30. this.ins = new WealthMng();
  31. }
  32. return this.ins;
  33. }
  34. Destroy() {
  35. this.node.destroy();
  36. WealthMng.ins = null;
  37. }
  38. @property(cc.Node)
  39. private gameView: cc.Node = null;
  40. @property(cc.Node)
  41. private posNodeAry: cc.Node[] = [];
  42. @property(cc.Node)
  43. private wealth: cc.Node = null;
  44. @property(cc.Node)
  45. private bullet: cc.Node = null;
  46. @property(cc.Node)
  47. private bulletEft: cc.Node = null;
  48. @property(sp.Skeleton)
  49. private groundDeftSpine: sp.Skeleton = null;
  50. @property(sp.Skeleton)
  51. private titleSpine: sp.Skeleton = null;
  52. //@property(cc.Node)
  53. //private bg1: cc.Node = null;
  54. //@property(cc.Node)
  55. //private bg2: cc.Node = null;
  56. //@property(cc.Node)
  57. //private tip: cc.Node = null;
  58. @property(cc.Node)
  59. private coinEft: cc.Node = null;
  60. @property(cc.Label)
  61. private coinEftTxt: cc.Label = null;
  62. @property(sp.Skeleton)
  63. private pointSpine: sp.Skeleton = null;
  64. @property(cc.Node)
  65. uiWealthNode: cc.Node = null;
  66. @property(cc.Node)
  67. mask: cc.Node = null;
  68. @property(cc.Node)
  69. inputBlock: cc.Node = null;
  70. private bulletParent: cc.Node = null;
  71. private wealthScr: Wealth = null;
  72. private mainScr: Main = null;
  73. private carSpaceAry: CarSpace[] = [];
  74. private timer: number = 0;
  75. isWealthing: boolean = false;
  76. isUsingSkill: boolean = false;
  77. private changeStateTime: number = 5;
  78. private curPosNodeIndex: number = 0;
  79. /**是否在冷却中*/
  80. isCooling: boolean = false;
  81. blood: number = 200;
  82. bloodValue: number = 200;
  83. private triggerTimer: number = 0;
  84. private triggerTime: number = 5;
  85. private triggerCheck: boolean = false;
  86. private titleNodePos: cc.Vec2 = null;
  87. wealthState: WealthState = WealthState.ReadyFight;
  88. isJumping: boolean = false;
  89. onLoad() {
  90. WealthMng.ins = this;
  91. WealthData.Ins.wealthMng = this;
  92. //WealthData.Ins.WealthInit();
  93. this.mainScr = UiM.Instance.hallNode.getComponent(Main);
  94. this.wealthScr = this.wealth.getComponent(Wealth);
  95. this.wealthScr.onLoad();
  96. //this.carSpaceAry = this.mainScr.carSpaceArr;
  97. this.wealth.active = false;
  98. this.mainScr.carSpaceArr.forEach(element => {
  99. this.carSpaceAry.push(element.getComponent(CarSpace));
  100. });
  101. //cc.director.getCollisionManager().enabled = true;
  102. cc.director.getPhysicsManager().enabled = true;
  103. //console.log("WealthData1:", WealthData.Ins.wealthMng);
  104. //console.log("++++++++++++", this.wealthScr);
  105. this.titleNodePos = this.titleSpine.node.getPosition();
  106. this.Init();
  107. //console.log("Wealth WorldPos:",MyExtends.localConvertWorldPointAR(this.node));
  108. //let worldpos = MyExtends.localConvertWorldPointAR(this.uiWealthNode);// this.node.parent.parent.convertToWorldSpaceAR(cc.v2(0, -162)); //MyExtends.localConvertWorldPointAR(this.node.parent.parent,cc.v2(0, -162));
  109. //worldpos = MyExtends.worldConvertLocalPointAR2D(this.gameView, worldpos);
  110. //console.log("WorldPos:(" + worldpos.x + "," + worldpos.y + ")");
  111. this.schedule(() => { WealthData.Ins.UpdateWealthState(); }, 5);
  112. //console.log("+++++++++++++++++: " + Sciencen_M.instance.subtraction("100", "150"));
  113. }
  114. start() {
  115. }
  116. update(dt) {
  117. this.CheckWealth(dt);
  118. //this.TimerCheckTriggerWealth(dt);
  119. this.TimerCooling(dt);
  120. this.TimerLife(dt);
  121. }
  122. GetUiWealthPos() {
  123. let worldpos = MyExtends.localConvertWorldPointAR(this.uiWealthNode);
  124. worldpos = MyExtends.worldConvertLocalPointAR2D(this.gameView, worldpos);
  125. return worldpos;
  126. }
  127. Init() {
  128. //console.log("WealthOpenResRequest-------------------1:");
  129. //HttpM.Instance.SendData(HTTP_TYPE.wealthGodOpen, {}, (res) => {
  130. // console.log("WealthOpenRes------------:", res);
  131. // if (res.data != null) {
  132. // console.log("WealthOpen:", res.data);
  133. // }
  134. //});
  135. //WealthData.Ins.CheckUnLockWealth();
  136. WealthData.Ins.WealthStatusInit();
  137. this.scheduleOnce(() => {
  138. if (WealthData.Ins.lifeTimer > 0 && WealthData.Ins.wealthInfo.wealthGodStatus == 3) {
  139. this.SwitchFightingState();
  140. GameM.audioM.setPauseMusic();
  141. GameM.audioM.playMateEffect(AUDIO_TYPE.wealthbgm, true);
  142. } else {
  143. //this.CheckTriggerWealth();
  144. }
  145. }, 2);
  146. }
  147. /**切换为战斗状态*/
  148. async SwitchFightingState() {
  149. this.triggerCheck = false;
  150. WealthData.Ins.WealthFightInit();
  151. this.inputBlock.active = true;
  152. this.mask.opacity = 0;
  153. this.mask.active = true;
  154. this.mask.runAction(cc.fadeTo(0.3, 130));
  155. await Time.WaitForSeconds(0.3);
  156. this.titleSpine.node.setPosition(this.titleNodePos);
  157. this.titleSpine.node.opacity = 255;
  158. this.titleSpine.node.active = true;
  159. this.titleSpine.setAnimation(0, "animation", false);
  160. await Time.WaitForSeconds(this.titleSpine.findAnimation("animation").duration + 0.5);
  161. let b1 = cc.delayTime(0.2);
  162. let b2 = cc.spawn(cc.moveTo(0.5, cc.v2(0, this.titleNodePos.y + 100)), cc.fadeOut(0.5));
  163. let b3 = cc.callFunc(() => { this.titleSpine.node.active = false; });
  164. this.titleSpine.node.runAction(cc.sequence(b1, b2, b3));
  165. await Time.WaitForSeconds(0.5);
  166. //let wealthbtn = UiM.Instance.hallNode.getComponent(Main).wealthBtn;
  167. //wealthbtn.runAction(cc.sequence(cc.fadeOut(0.3), cc.callFunc(() => wealthbtn.active = false)));
  168. this.curPosNodeIndex = 3;
  169. this.wealthScr.SwitchFightingState(this.posNodeAry[this.curPosNodeIndex].getPosition(), () => {
  170. this.triggerTimer = 0;
  171. //WealthData.Ins.blood = WealthData.Ins.bloodValue;
  172. this.timer = 0;
  173. this.isJumping = false;
  174. this.isUsingSkill = false;
  175. //this.wealth.setPosition(500, -140);
  176. //this.wealth.scale = 1;
  177. //this.wealth.active = true;
  178. //this.curPosNodeIndex = MyExtends.GetIndexByAry(this.posNodeAry, this.curPosNodeIndex);
  179. //let a1 = cc.jumpTo(0.7, this.posNodeAry[this.curPosNodeIndex].getPosition(), 800, 1);
  180. //let a2 = cc.callFunc(() => { this.CheckAttack(); });
  181. //this.wealth.runAction(cc.sequence(a1, a2));
  182. this.wealthScr.UpdateTxt(WealthData.Ins.blood, WealthData.Ins.bloodValue);
  183. this.isWealthing = true;
  184. this.wealthState = WealthState.Fighting;
  185. this.CheckAttack();
  186. this.mainScr.ChangeNormalGuideState(0);
  187. this.mask.active = false;
  188. this.inputBlock.active = false;
  189. WealthData.Ins.SwitchFightingState();
  190. });
  191. if (UIMng.Ins.IsExistPanel(PanelType.WealthPanel)) {
  192. UIMng.Ins.GetPanel(PanelType.WealthPanel).OnExit();
  193. }
  194. }
  195. /**触发财神降临*/
  196. CheckTriggerWealth(isunlocktrigger: boolean = false) {
  197. if (!this.isWealthing) {
  198. WealthData.Ins.CheckTriggerWealth(isunlocktrigger, () => {
  199. this.CreatWealth();
  200. GameM.audioM.setPauseMusic();
  201. GameM.audioM.playMateEffect(AUDIO_TYPE.wealthbgm, true);
  202. });
  203. }
  204. }
  205. async CreatWealth() {
  206. this.triggerCheck = false;
  207. WealthData.Ins.WealthFightInit();
  208. this.inputBlock.active = true;
  209. this.mask.opacity = 0;
  210. this.mask.active = true;
  211. this.mask.runAction(cc.fadeTo(0.3, 130));
  212. await Time.WaitForSeconds(0.3);
  213. this.titleSpine.node.setPosition(this.titleNodePos);
  214. this.titleSpine.node.opacity = 255;
  215. this.titleSpine.node.active = true;
  216. this.titleSpine.setAnimation(0, "animation", false);
  217. await Time.WaitForSeconds(this.titleSpine.findAnimation("animation").duration + 0.5);
  218. let b1 = cc.delayTime(0.2);
  219. let b2 = cc.spawn(cc.moveTo(0.5, cc.v2(0, this.titleNodePos.y + 100)), cc.fadeOut(0.5));
  220. let b3 = cc.callFunc(() => { this.titleSpine.node.active = false; });
  221. this.titleSpine.node.runAction(cc.sequence(b1, b2, b3));
  222. await Time.WaitForSeconds(0.5);
  223. //let wealthbtn = UiM.Instance.hallNode.getComponent(Main).wealthBtn;
  224. //wealthbtn.runAction(cc.sequence(cc.fadeOut(0.3), cc.callFunc(() => wealthbtn.active = false)));
  225. this.curPosNodeIndex = 3;
  226. this.wealthScr.TriggerWealth(this.posNodeAry[this.curPosNodeIndex].getPosition(), () => {
  227. this.triggerTimer = 0;
  228. WealthData.Ins.blood = WealthData.Ins.bloodValue;
  229. this.timer = 0;
  230. this.isJumping = false;
  231. this.isUsingSkill = false;
  232. //this.wealth.setPosition(500, -140);
  233. //this.wealth.scale = 1;
  234. //this.wealth.active = true;
  235. //this.curPosNodeIndex = MyExtends.GetIndexByAry(this.posNodeAry, this.curPosNodeIndex);
  236. //let a1 = cc.jumpTo(0.7, this.posNodeAry[this.curPosNodeIndex].getPosition(), 800, 1);
  237. //let a2 = cc.callFunc(() => { this.CheckAttack(); });
  238. //this.wealth.runAction(cc.sequence(a1, a2));
  239. this.wealthScr.UpdateTxt(WealthData.Ins.blood, WealthData.Ins.bloodValue);
  240. this.isWealthing = true;
  241. this.wealthState = WealthState.Fighting;
  242. this.CheckAttack();
  243. this.mainScr.ChangeNormalGuideState(0);
  244. this.mask.active = false;
  245. this.inputBlock.active = false;
  246. //没有进入大富翁界面才允许引导
  247. if (!RichData.Ins.isOpenRichPanel)
  248. GuideMng.Ins.CheckWealthGuide17();
  249. });
  250. if (UIMng.Ins.IsExistPanel(PanelType.WealthPanel)) {
  251. UIMng.Ins.GetPanel(PanelType.WealthPanel).OnExit();
  252. }
  253. }
  254. CheckWealth(dt) {
  255. //if (this.isWealthing && !this.isUsingSkill) {
  256. // this.timer += dt;
  257. // if (this.timer >= this.changeStateTime) {
  258. // this.timer = 0;
  259. // this.curPosNodeIndex = MyExtends.GetIndexByAry(this.posNodeAry, this.curPosNodeIndex);
  260. // this.isJumping = true;
  261. // let a1 = cc.jumpTo(0.7, this.posNodeAry[this.curPosNodeIndex].getPosition(), 800, 1);
  262. // let a2 = cc.callFunc(() => { this.CheckAttack(); });
  263. // this.wealth.runAction(cc.sequence(a1, a2));
  264. // }
  265. //}
  266. }
  267. /**触发 改为购买武将触发*/
  268. TimerCheckTriggerWealth(dt) {
  269. return;
  270. if (this.triggerCheck) {
  271. this.triggerTimer += dt;
  272. if (this.triggerTimer >= this.triggerTime) {
  273. //this.triggerCheck = false;
  274. this.CheckTriggerWealth();
  275. }
  276. }
  277. }
  278. /**财神挑战冷却计时器*/
  279. TimerCooling(dt) {
  280. if (this.isCooling) {
  281. WealthData.Ins.coolingTimer -= dt;
  282. if (WealthData.Ins.coolingTimer <= 0) {
  283. WealthData.Ins.WealthReady();
  284. // WealthData.Ins.coolingTimer = 0;
  285. // this.isCooling = false;
  286. // WealthData.Ins.isCooling = false;
  287. console.log("trigger cooling end");
  288. }
  289. }
  290. }
  291. TimerLife(dt) {
  292. if (this.isWealthing) {
  293. WealthData.Ins.lifeTimer -= dt;
  294. if (WealthData.Ins.lifeTimer <= 0) {
  295. this.CheckAttackEnd(false);
  296. }
  297. }
  298. }
  299. CheckAttack() {
  300. this.isJumping = false;
  301. if (!this.isWealthing) return;
  302. let carindexs: number[] = [];
  303. if (this.curPosNodeIndex < 4) {
  304. carindexs.push(this.curPosNodeIndex);
  305. carindexs.push(this.curPosNodeIndex + 1);
  306. carindexs.push(this.curPosNodeIndex + 5);
  307. carindexs.push(this.curPosNodeIndex + 6);
  308. } else {
  309. carindexs.push(this.curPosNodeIndex - 4 + 5);
  310. carindexs.push(this.curPosNodeIndex - 4 + 6);
  311. carindexs.push(this.curPosNodeIndex - 4 + 10);
  312. carindexs.push(this.curPosNodeIndex - 4 + 11);
  313. }
  314. for (let i = 0; i < this.carSpaceAry.length; i++) {
  315. //if (!this.isWealthing) break;
  316. if (carindexs.includes(i)) {
  317. this.carSpaceAry[i].CheckSpaceState(false);
  318. //console.log("====1 index:"+this.curPosNodeIndex);
  319. }
  320. else {
  321. this.carSpaceAry[i].CheckSpaceState(true);
  322. }
  323. this.carSpaceAry[i].CheckAttack();
  324. }
  325. }
  326. MasterEffect() {
  327. for (let i = 0; i < this.carSpaceAry.length; i++) {
  328. this.carSpaceAry[i].MasterEffect();
  329. }
  330. //this.carSpaceAry.forEach(element => {
  331. // element.MasterEffect();
  332. //});
  333. this.isUsingSkill = false;
  334. if (this.bulletParent != null) {
  335. this.bulletParent.destroy();
  336. this.bulletParent = null;
  337. }
  338. this.PlayGroundAni();
  339. MyExtends.ScreenShock(UiM.Instance.hallNode, 0.3);
  340. }
  341. async PlayGroundAni() {
  342. this.groundDeftSpine.node.setPosition(this.posNodeAry[this.curPosNodeIndex].x, this.posNodeAry[this.curPosNodeIndex].y - 170);
  343. this.groundDeftSpine.node.active = true;
  344. this.groundDeftSpine.setAnimation(0, "animation", false);
  345. await Time.WaitForSeconds(1);
  346. this.groundDeftSpine.node.active = false;
  347. }
  348. Shoot(carspace: cc.Node, masterlv: number) {
  349. if (this.isWealthing) {
  350. if (this.bulletParent == null) {
  351. this.bulletParent = new cc.Node("BulletParent");
  352. this.bulletParent.parent = this.gameView;
  353. }
  354. let bulletcopy = cc.instantiate(this.bullet);
  355. //bulletcopy.parent = this.gameView;
  356. bulletcopy.parent = this.bulletParent;
  357. bulletcopy.setPosition(MyExtends.convetOtherNodeSpaceAR(carspace, this.gameView));
  358. bulletcopy.active = true;
  359. bulletcopy.getComponent(Bullet).Shoot(this.wealth, masterlv);
  360. }
  361. }
  362. async ShootEft(pos: cc.Vec2) {
  363. let bulleteftc = cc.instantiate(this.bulletEft);
  364. bulleteftc.parent = this.gameView;
  365. bulleteftc.setPosition(pos);
  366. bulleteftc.active = true;
  367. await Time.WaitForSeconds(1);
  368. bulleteftc.destroy();
  369. }
  370. /**受到伤害
  371. * @param damageType 伤害类型 1 武将攻击伤害 2 玩家攻击伤害
  372. * @param masterlv 武将等级
  373. */
  374. GetDamage(damageType = 1, masterlv: number = 1) {
  375. if (this.isWealthing && WealthData.Ins.blood != "0" && WealthData.Ins.blood[0] != "-") {
  376. let damage = damageType == 1 ? WealthData.Ins.GetMasterDamageCoin(masterlv) : WealthData.Ins.GetPlayDamageCoin();
  377. WealthData.Ins.blood = Sciencen_M.instance.subtraction(WealthData.Ins.blood, damage);
  378. //WealthData.Ins.blood--;
  379. if (WealthData.Ins.blood[0] == "0" || WealthData.Ins.blood[0] == "-") {
  380. WealthData.Ins.blood = "0";
  381. this.CheckAttackEnd(true);
  382. } else {
  383. if (damageType == 1)
  384. this.CheckUseSkill1();
  385. this.wealthScr.UpdateTxt(WealthData.Ins.blood, WealthData.Ins.bloodValue);
  386. if (!this.isUsingSkill && damageType == 2)
  387. this.wealthScr.GetDamage();
  388. }
  389. if (damageType == 2)
  390. GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
  391. this.PlayCoinAni(damage, damageType);
  392. GameM.commonData.updateGold(damage);
  393. //GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold });
  394. }
  395. }
  396. /**使用眩晕技能*/
  397. async CheckUseSkill1() {
  398. if (GuideMng.Ins.CurGuideId == 17) return;
  399. if (!this.isUsingSkill && !this.isJumping && WealthData.Ins.CheckTriggerSkill1()) {
  400. //console.log("--->2", this.carSpaceAry);
  401. this.isUsingSkill = true;
  402. this.curPosNodeIndex = MyExtends.GetIndexByAry(this.posNodeAry, this.curPosNodeIndex);
  403. this.pointSpine.node.setPosition(this.posNodeAry[this.curPosNodeIndex].getPosition().x, this.posNodeAry[this.curPosNodeIndex].getPosition().y - 140);
  404. this.pointSpine.node.active = true;
  405. this.pointSpine.setAnimation(0, "animation", true);
  406. //this.posNodeAry[this.curPosNodeIndex].active = true;
  407. await Time.WaitForSeconds(0.5);
  408. //this.posNodeAry[this.curPosNodeIndex].active = false;
  409. this.wealthScr.UseSkill1(this.posNodeAry[this.curPosNodeIndex].getPosition(), () => {
  410. this.MasterSkill1Effect();
  411. if (!RichData.Ins.isOpenRichPanel)
  412. GameM.audioM.playEffect(AUDIO_TYPE.wealthswim, false);
  413. this.pointSpine.clearTrack(0);
  414. this.pointSpine.node.active = false;
  415. });
  416. }
  417. }
  418. MasterSkill1Effect() {
  419. this.isJumping = false;
  420. if (!this.isWealthing) return;
  421. let carindexs: number[] = [];
  422. if (this.curPosNodeIndex < 4) {
  423. carindexs.push(this.curPosNodeIndex);
  424. carindexs.push(this.curPosNodeIndex + 1);
  425. carindexs.push(this.curPosNodeIndex + 5);
  426. carindexs.push(this.curPosNodeIndex + 6);
  427. } else {
  428. carindexs.push(this.curPosNodeIndex - 4 + 5);
  429. carindexs.push(this.curPosNodeIndex - 4 + 6);
  430. carindexs.push(this.curPosNodeIndex - 4 + 10);
  431. carindexs.push(this.curPosNodeIndex - 4 + 11);
  432. }
  433. for (let i = 0; i < this.carSpaceAry.length; i++) {
  434. if (carindexs.includes(i)) {
  435. this.carSpaceAry[i].CheckSpaceState(false);
  436. }
  437. else {
  438. this.carSpaceAry[i].CheckSpaceState(true);
  439. }
  440. this.carSpaceAry[i].MasterEffect();
  441. }
  442. //for (let i = 0; i < this.carSpaceAry.length; i++) {
  443. // this.carSpaceAry[i].MasterEffect();
  444. //}
  445. //this.carSpaceAry.forEach(element => {
  446. // element.MasterEffect();
  447. //});
  448. this.isUsingSkill = false;
  449. if (this.bulletParent != null) {
  450. this.bulletParent.destroy();
  451. this.bulletParent = null;
  452. }
  453. this.PlayGroundAni();
  454. MyExtends.ScreenShock(UiM.Instance.hallNode, 0.3);
  455. }
  456. /**播放金币动画
  457. * @param coinStr 金币
  458. * @param roletype 角色类型 1 武将 2 玩家
  459. */
  460. PlayCoinAni(coinStr: string, roletype: number) {
  461. //this.coinEft.active = true;
  462. //this.coinEft.stopAllActions();
  463. this.coinEft.opacity = 255;
  464. this.coinEft.setPosition(0, 0);
  465. this.coinEftTxt.string = Sciencen_M.instance.format(coinStr);
  466. this.coinEftTxt.node.color = roletype == 1 ? cc.color(255, 255, 255, 255) : cc.color(254, 241, 65, 255);
  467. let copy = cc.instantiate(this.coinEft);
  468. copy.parent = this.coinEft.parent;
  469. copy.setPosition(this.wealth.x, this.wealth.y + 150);
  470. copy.active = true;
  471. let a, c;
  472. if (roletype == 1) {
  473. copy.scale = 0.5;
  474. a = cc.moveBy(0.5, cc.v2(0, 150));
  475. c = cc.scaleTo(0.5, 1);
  476. } else {
  477. copy.scale = 0.7;
  478. a = cc.moveBy(0.5, cc.v2(-40, 150));
  479. c = cc.scaleTo(0.5, 1.2);
  480. }
  481. //let a = cc.moveBy(0.5, cc.v2(0, 100));
  482. let b1 = cc.delayTime(0.4);
  483. let b2 = cc.fadeOut(0.1);
  484. let b3 = cc.callFunc(() => { copy.destroy(); });
  485. let b = cc.sequence(b1, b2, b3);
  486. //let c = cc.scaleTo(0.5, 1);
  487. copy.runAction(cc.spawn(a, b, c));
  488. }
  489. CheckAttackEnd(isSuccess: boolean) {
  490. if (this.isWealthing) {
  491. this.isWealthing = false;
  492. WealthData.Ins.WealthCooling();
  493. this.curPosNodeIndex = 0;
  494. this.timer = 0;
  495. this.wealthState = WealthState.ReadyFight;
  496. if (this.pointSpine.node.active == true) {
  497. this.pointSpine.clearTrack(0);
  498. this.pointSpine.node.active = false;
  499. }
  500. this.wealth.stopAllActions();
  501. this.wealthScr.WealthEnd(isSuccess);
  502. for (let i = 0; i < this.carSpaceAry.length; i++) {
  503. this.carSpaceAry[i].AttackEnd();
  504. this.carSpaceAry[i].CheckSpaceState(true);
  505. }
  506. this.mainScr.ChangeNormalGuideState(1);
  507. this.triggerCheck = true;
  508. if (UIMng.Ins.IsExistPanel(PanelType.WealthPanel)) {
  509. UIMng.Ins.GetPanel(PanelType.WealthPanel).OnExit();
  510. }
  511. console.log("WealthInfo: Challenge have times:" + (WealthData.Ins.challengeTimes - WealthData.Ins.challengedTimes) + " Cooling Time:" + WealthData.Ins.coolingTimer);
  512. //不在每日五福界面则关闭音效
  513. GameController.Ins.SwitchAudio(2);
  514. WealthData.Ins.WealthFightEnd();
  515. }
  516. }
  517. GetOccupyCarSpaces() {
  518. let carindexs: number[] = [];
  519. if (this.curPosNodeIndex < 4) {
  520. carindexs.push(this.curPosNodeIndex);
  521. carindexs.push(this.curPosNodeIndex + 1);
  522. carindexs.push(this.curPosNodeIndex + 5);
  523. carindexs.push(this.curPosNodeIndex + 6);
  524. } else {
  525. carindexs.push(this.curPosNodeIndex - 4 + 5);
  526. carindexs.push(this.curPosNodeIndex - 4 + 6);
  527. carindexs.push(this.curPosNodeIndex - 4 + 10);
  528. carindexs.push(this.curPosNodeIndex - 4 + 11);
  529. }
  530. }
  531. ClearShield() {
  532. this.wealthScr.UnUseShield();
  533. }
  534. }