1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { director } from "cc";
- import { SoundManager } from "../../../../engines/sounds/SoundManager";
- import { GameController } from "../GameController";
- import { WeaponBase } from "../weapons/WeaponBase";
- import { SkillBase } from "./SkillBase";
- export default class DefaultSkill extends SkillBase
- {
- private startTime:number;
- private lastTime:number=0;
- /**
- * 使用技能
- * @param weapon
- * @param data
- */
- UseSkill(weapon:WeaponBase,data?:any):void{
- super.UseSkill(weapon,data);
- this.weapon.fireKey=2;
- this.weapon.MoveFirePosition();
- this.startTime=director.getCurrentTime();
- }
-
- /**
- * 更新
- * @param dt
- */
- Update(dt:number):void{
- super.Update(dt);
- let current:number=director.getCurrentTime();
- if(current-this.startTime>this.time){
- this.DispatchEvent(SkillBase.SKILL_COMPLETE);
- return;
- }
- let posType:number=GameController.single.FindAttackMonsterPosType;
- if(posType<0){
- SoundManager.single.StopSound("Weapon");
- SoundManager.single.StopSound("WeaponLeft");
- SoundManager.single.StopSound("WeaponRight");
- return;
- }
- //自动攻击
- if(this.unController){
- if(current-this.lastTime>this.fireInterval){
- if(posType==0){
- this.weapon.fireKey=1;
- }else if(posType==1){
- this.weapon.fireKey=2;
- }else if(posType==2){
- this.weapon.fireKey=3;
- }
- this.weapon.MoveFirePosition();
- this.weapon.Fire(this.infiniteAmmo);
- this.lastTime=current;
- }
- }
- }
-
- /**
- * 销毁
- */
- Dispose():void{
- super.Dispose();
- SoundManager.single.StopSound("Weapon");
- SoundManager.single.StopSound("WeaponLeft");
- SoundManager.single.StopSound("WeaponRight");
- }
- // /**
- // * 是否阻断玩家操作
- // */
- // get unController():boolean{
- // return false;
- // }
- // /**
- // * 射击间隔
- // */
- // get fireInterval():number{
- // return 50;
- // }
- }
|