|
@@ -5,6 +5,8 @@ import { GameEvent } from '../Enum/GameEvent';
|
|
import { UIJoyStick } from '../UIJoyStick';
|
|
import { UIJoyStick } from '../UIJoyStick';
|
|
import { GameMgr, GameStatus } from '../Manager/GameMgr';
|
|
import { GameMgr, GameStatus } from '../Manager/GameMgr';
|
|
import { PropComponent, PropStatus } from './PropComponent';
|
|
import { PropComponent, PropStatus } from './PropComponent';
|
|
|
|
+import { PlayerInfo } from './PlayerInfoComponent';
|
|
|
|
+import { Effect2DUIMgr } from '../Manager/Effect2DUIMgr';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
const rotateSpeed = 500;
|
|
const rotateSpeed = 500;
|
|
@@ -22,13 +24,16 @@ export class TornadoComponent extends Component {
|
|
attack: number = 20;
|
|
attack: number = 20;
|
|
speed: number = 50;
|
|
speed: number = 50;
|
|
currentExp: number = 0;
|
|
currentExp: number = 0;
|
|
|
|
+ currentLv: number = 1;
|
|
nextExp: number = 100;
|
|
nextExp: number = 100;
|
|
ai: boolean = false;
|
|
ai: boolean = false;
|
|
|
|
+ nickName: string = null;
|
|
|
|
|
|
_attackInterval: number = 0.5; // 攻击间隔
|
|
_attackInterval: number = 0.5; // 攻击间隔
|
|
_lastAttackTime: Map<string, number> = new Map(); // 记录上次攻击时间
|
|
_lastAttackTime: Map<string, number> = new Map(); // 记录上次攻击时间
|
|
|
|
|
|
protected start(): void {
|
|
protected start(): void {
|
|
|
|
+ this.initializeData();
|
|
this.initilizeUI();
|
|
this.initilizeUI();
|
|
this.registerEvent();
|
|
this.registerEvent();
|
|
}
|
|
}
|
|
@@ -43,11 +48,20 @@ export class TornadoComponent extends Component {
|
|
this.tigger.on('onTriggerStay', this.onTriggerStay, this);
|
|
this.tigger.on('onTriggerStay', this.onTriggerStay, this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ initializeData() {
|
|
|
|
+ //DOTO 计算方式根据配置表
|
|
|
|
+ this.currentLv = 1;
|
|
|
|
+ this.currentExp = 0;
|
|
|
|
+ this.nextExp = 100;
|
|
|
|
+ this.attack = 20;
|
|
|
|
+ this.speed = 50;
|
|
|
|
+ this.nickName = '爸爸在此';
|
|
|
|
+ }
|
|
|
|
+
|
|
protected registerEvent() {
|
|
protected registerEvent() {
|
|
EventDispatcher.instance.on(GameEvent.EVENT_STORM_LEVEL_UP, this.stormLevelUp, this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_STORM_LEVEL_UP, this.stormLevelUp, this);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
onTriggerEnter(event: ITriggerEvent): void {
|
|
onTriggerEnter(event: ITriggerEvent): void {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -85,19 +99,28 @@ export class TornadoComponent extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
update(deltaTime: number) {
|
|
update(deltaTime: number) {
|
|
if (GameMgr.inst.gameStatus != GameStatus.Playing) return;
|
|
if (GameMgr.inst.gameStatus != GameStatus.Playing) return;
|
|
- this.MoveHandler();
|
|
|
|
- // //自身旋转
|
|
|
|
- this.RotateHandler();
|
|
|
|
|
|
+
|
|
|
|
+ this.onPlayerInfoHandler();
|
|
|
|
+ this.onMoveHandler();
|
|
|
|
+ this.onRotateHandler();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async onPlayerInfoHandler() {
|
|
|
|
+ const playerInfo: PlayerInfo = {
|
|
|
|
+ nickName: this.nickName,
|
|
|
|
+ level: this.currentLv
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await Effect2DUIMgr.Instance.addPlayerInfo(this.node, playerInfo);
|
|
}
|
|
}
|
|
|
|
|
|
- RotateHandler(): void {
|
|
|
|
|
|
+ onRotateHandler(): void {
|
|
this.node.eulerAngles = new Vec3(this.node.eulerAngles.x, this.node.eulerAngles.y + rotateSpeed * game.deltaTime, this.node.eulerAngles.z);
|
|
this.node.eulerAngles = new Vec3(this.node.eulerAngles.x, this.node.eulerAngles.y + rotateSpeed * game.deltaTime, this.node.eulerAngles.z);
|
|
}
|
|
}
|
|
|
|
|
|
- MoveHandler(): void {
|
|
|
|
|
|
+ onMoveHandler(): void {
|
|
const playerDir = UIJoyStick.ins.dir;
|
|
const playerDir = UIJoyStick.ins.dir;
|
|
const playerX = playerDir.x * this.speed * game.deltaTime;
|
|
const playerX = playerDir.x * this.speed * game.deltaTime;
|
|
const playerZ = playerDir.y * this.speed * game.deltaTime;
|
|
const playerZ = playerDir.y * this.speed * game.deltaTime;
|
|
@@ -110,6 +133,7 @@ export class TornadoComponent extends Component {
|
|
this.currentExp += propExp;
|
|
this.currentExp += propExp;
|
|
if (this.currentExp >= this.nextExp) {
|
|
if (this.currentExp >= this.nextExp) {
|
|
this.stormLevelUp();
|
|
this.stormLevelUp();
|
|
|
|
+ this.currentLv++;
|
|
|
|
|
|
//TODO 计算升级经验
|
|
//TODO 计算升级经验
|
|
this.currentExp = 0;
|
|
this.currentExp = 0;
|