Ver Fonte

计算 玩家攻击力 速度加成

woso_javan há 2 meses atrás
pai
commit
828b11e9d7

+ 18 - 14
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -7,6 +7,7 @@ import { GameMgr, GameStatus } from '../Manager/GameMgr';
 import { PropComponent, PropStatus } from './PropComponent';
 import { PlayerInfo } from './PlayerInfoComponent';
 import { Effect2DUIMgr } from '../Manager/Effect2DUIMgr';
+import { AttributeBonusMgr } from '../Manager/AttributeBonusMgr';
 const { ccclass, property } = _decorator;
 
 const rotateSpeed = 500;
@@ -30,6 +31,7 @@ export class TornadoComponent extends Component {
     speed: number = 50;
     currentExp: number = 0;
     currentLv: number = 1;
+    giveExp: number = 10; //被吃掉给予经验
     nextExp: number = 100;
     nickName: string = null;
     playerStatus: PlayerStatus = PlayerStatus.LIFE;
@@ -65,18 +67,19 @@ export class TornadoComponent extends Component {
     }
 
     protected initPlayer() {
-        //DOTO 计算方式根据配置表
-        this.currentLv = 3;
+        const attributeBonusMgr = AttributeBonusMgr.inst;
+        const userModel = attributeBonusMgr.userModel;
+
+        this.currentLv = userModel.userTornadoLevel;
         this.currentExp = 0;
-        this.nextExp = 100;
-        this.attack = 20;
-        this.speed = 50;
-        this.nickName = '爸爸在此';
+        this.nextExp = attributeBonusMgr.getExpNeed(this.currentLv + 1);
+        this.attack = attributeBonusMgr.getStormSunderAttack(userModel.userTornadoLevel);
+        this.speed = attributeBonusMgr.getStormSunderSpeed(userModel.userTornadoLevel);
+        this.nickName = userModel.nickName;
 
         this.playerInfo = {
             nickName: this.nickName,
             level: this.currentLv,
-            exp: 0,
         }
     }
 
@@ -219,14 +222,15 @@ export class TornadoComponent extends Component {
         if (this.curHitObj.getComponent(PropComponent)) {
             objExp = propComp.currentExp;
         } else {
-            //TODO 计算经验
-            objExp = this.currentLv * 10;
+            const lv = this.curHitObj.getComponent(TornadoComponent).currentLv;
+            objExp = AttributeBonusMgr.inst.getStormSunderExp(lv);
         }
 
         this.currentExp += objExp;
         if (this.currentExp >= this.nextExp) {
-            this.stormLevelUp();
             this.currentLv++;
+            AttributeBonusMgr.inst.userModel.userTornadoLevel = this.currentLv;
+            this.stormLevelUp();
 
             this.playerInfo.level = this.currentLv;
             Effect2DUIMgr.inst.updatePlayerInfo(this.node, this.playerInfo);
@@ -234,10 +238,10 @@ export class TornadoComponent extends Component {
     }
 
     private stormLevelUp() {
-        //DOTO  计算攻击速度等属性
-        this.attack += this.attack;
-        this.speed += this.speed * 0.1;
-        this.nextExp += this.nextExp;
+        const attributeBonusMgr = AttributeBonusMgr.inst;
+        this.nextExp = attributeBonusMgr.getExpNeed(this.currentLv + 1);
+        this.attack = attributeBonusMgr.getStormSunderAttack(this.currentLv);
+        this.speed = attributeBonusMgr.getStormSunderSpeed(this.currentLv);
         this.currentExp = 0;
     }
 

+ 33 - 0
assets/module_storm_sunder/Script/Manager/AttributeBonusMgr.ts

@@ -76,6 +76,39 @@ export class AttributeBonusMgr {
         const { level, base, up_value } = this.userModel.bonusData[type];
         return base + (level - 1) * up_value;
     }
+
+    /** 升级需要的经验*/
+    public getExpNeed(level: number): number {
+        return 25 * (level * level - level + 2);
+    }
+
+    /** 计算玩家龙卷风攻击力*/
+    public getStormSunderAttack(lv: number, isAI?: boolean): number {
+        const external_attack = this.getBonus(BonusType.ATTACK);
+        const game_attack_base = this.userModel.game_attack_base;
+        const game_lv_attack_up = this.userModel.game_lv_attack_up;
+        return external_attack + game_attack_base + game_lv_attack_up * lv;
+    }
+
+    /** 计算玩家龙卷风速度*/
+    public getStormSunderSpeed(lv: number, isAI?: boolean): number {
+        const external_speed = this.getBonus(BonusType.SPEED);
+        const game_speed_base = this.userModel.game_speed_base;
+        const game_lv_speed_up = this.userModel.game_lv_speed_up;
+        return external_speed + game_speed_base + game_lv_speed_up * lv;
+    }
+
+    /** 被吃掉提供的经验值*/
+    public getStormSunderExp(lv: number): number {
+        const game_absorbec_exp_base = this.userModel.game_absorbec_exp_base;
+        const game_lv_absorbec_exp_up = this.userModel.game_lv_absorbec_exp_up;
+        return game_absorbec_exp_base + game_lv_absorbec_exp_up * lv;
+    }
+
+    /** DOTO 计算经验加成百分比*/
+    public getExpBonus(isAI?: boolean): number {
+        return 0;
+    }
 }
 
 //属性加成类型