| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- import DataObj from "../../configData/DataObj";
- import GameConfig from "../../configData/GameConfig";
- import monsterManger from "../monster/monsterManger";
- import towerManger from "./towerManger";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class skillManger extends cc.Component {
- @property(cc.Sprite)
- private tapQuan: cc.Sprite = null;
-
- public static instance: skillManger = null;
- public myDataObj: DataObj = null;
- private yunshiArr: cc.Node[] = [];
- private yunshiPosArr: cc.Vec3[] = [];
- /**燃烧半径 */
- private lenthR = 0;
- protected onLoad() {
- skillManger.instance = this;
- this.myDataObj = new DataObj();
- }
- /** 陨石创建*/
- public yunshiBuild(loca: cc.Vec2) {
- this.myDataObj.writeSkill_Config(60);
- let num = this.myDataObj.SkillData.parameter_1;
- if (towerManger.instance.talantData[20].length > 0) {
- num += towerManger.instance.talantData[20][0];
- }
- this.lenthR = this.myDataObj.getArr(this.myDataObj.SkillData.parameter_2)[1];
- if (towerManger.instance.talantData[22].length > 0) {
- this.lenthR *=1+ towerManger.instance.talantData[22][1];
- }
- let lethShow = this.lenthR - 20;
- this.yunshiArr = [];
- this.yunshiPosArr = [];
- let self = this;
- cc.resources.load("skill/yunshi", cc.SpriteFrame, function (err, myspriteFrame: cc.SpriteFrame) {
- for (let i = 0; i < num; i++) {
- let suijix = Math.floor((-lethShow + 2 * lethShow * Math.random()) / 20) * 20;
- let yyLenth = Math.sqrt(lethShow * lethShow - suijix * suijix);
- let suijiY = Math.floor((-yyLenth + 2 * yyLenth * Math.random()) / 20) * 20;
- if (i == 0) {
- suijix = 0;
- }
- let mynode = new cc.Node();
- let spr = mynode.addComponent(cc.Sprite);
- spr.spriteFrame = myspriteFrame;
- mynode.setPosition(cc.v2(loca.x + suijix, 550));
- mynode.setAnchorPoint(cc.v2(0.5, 0));
- self.node.addChild(mynode, 1009);
- if (i == 0) {
- self.yunshiPosArr.push(cc.v3(loca));
- mynode.scale = 0.8;
- }
- else {
- mynode.scale = 0.4;
- self.yunshiPosArr.push(cc.v3(loca).add(cc.v3(suijix, suijiY)));
- }
- self.yunshiArr.push(mynode);
- }
- self.yunshiAct();
- });
- }
- /**陨石掉落动画 */
- private yunshiAct() {
- for (let i = 0; i < this.yunshiArr.length; i++) {
- const element = this.yunshiArr[i];
- let tt = 0.1 + Math.random() / 2;
- if (i == 0) {
- tt = 0;
- }
- let leth = 550 - this.yunshiPosArr[i].y;
- cc.tween(element)
- .delay(tt)
- .to(leth / Number(this.myDataObj.SkillData.parameter_5), { position: this.yunshiPosArr[i] })
- .call(() => {
- let hurt = this.myDataObj.getRanm(1, this.myDataObj.SkillData.parameter_3);
- if (towerManger.instance.talantData[24].length > 0) {
- hurt *= 1+ towerManger.instance.talantData[20][1]+towerManger.instance.talantData[22][0] + towerManger.instance.talantData[24][0];
- }
- else
- {
- if (towerManger.instance.talantData[22].length > 0) {
- hurt *= 1 + towerManger.instance.talantData[20][1]+towerManger.instance.talantData[22][0];
- }
- else
- {
- if (towerManger.instance.talantData[20].length > 0) {
- hurt *= 1 + towerManger.instance.talantData[20][1];
- }
- }
- }
-
-
- let lethR = this.myDataObj.getArr(this.myDataObj.SkillData.parameter_2)[0];
- if (towerManger.instance.talantData[22].length > 0) {
- lethR *= 1+ towerManger.instance.talantData[22][1];
- }
- this.hurtMonster(this.yunshiPosArr[i], hurt, lethR);
- if (i == this.yunshiArr.length - 1) {
- if (towerManger.instance.talantData[23].length > 0) {
- this.schedule(this.burningHurt24, 1, towerManger.instance.talantData[23][1]-1, 0);
- this.burningHurtAction();
- }
- else
- {
- if (towerManger.instance.talantData[21].length > 0) {
- this.schedule(this.burningHurt22, 1, towerManger.instance.talantData[21][1]-1, 0);
- this.burningHurtAction();
- }
- }
-
- }
- })
- .removeSelf()
- .start();
- }
- this.yunshiQuan(cc.v2(this.yunshiPosArr[0]));
- }
- /**燃烧陷阱 */
- private burningHurt22() {
- this.hurtMonster(this.yunshiPosArr[0], towerManger.instance.talantData[21][0], this.lenthR);
- }
- /**燃烧陷阱 */
- private burningHurt24() {
- this.hurtMonster(this.yunshiPosArr[0], towerManger.instance.talantData[23][0], this.lenthR);
- }
- /**燃烧陷阱动画 */
- private burningHurtAction() {
- }
- /**陨石掉落伤害 */
- private hurtMonster(pos: cc.Vec3, attack: number, sqrt: number) {
- let monarr = monsterManger.instance.GetMonsterArr();
- for (let k = 0; k < monarr.length; k++) {
- const minster = monarr[k];
- let monPos = minster.node.getPosition();
- if (monPos.sub(cc.v2(pos)).mag() < sqrt) {
- minster.hpDown(attack);
- }
- }
- }
- /**陨石圈 */
- public yunshiQuan(poss: cc.Vec2) {
- this.tapQuan.node.opacity = 255;
- this.tapQuan.node.setPosition(poss);
- this.tapQuan.node.setContentSize(this.lenthR * 2, this.lenthR * 2);
- this.tapQuan.node.stopAllActions();
- cc.tween(this.tapQuan.node)
- .to(0.3, { opacity: 100 })
- .to(0.3, { opacity: 255 })
- .to(0.3, { opacity: 100 })
- .to(0.6, { opacity: 255 })
- .to(0.3, { opacity: 0 })
- .start();
- }
- }
|