public static int applyDamage(ILuaState luaState)
 {
     if (luaState.IsTable(-1))
     {
         DamageResult dmgRes = new DamageResult();
         // 攻击者
         luaState.GetField(-1, "attacker");
         dmgRes.attacker = (Unit)luaState.ToUserData(-1);
         luaState.Pop(1);
         // 受害者
         luaState.GetField(-1, "victim");
         dmgRes.victim = (Unit)luaState.ToUserData(-1);
         luaState.Pop(1);
         // 伤害
         luaState.GetField(-1, "physicalDamage");
         dmgRes.physicalDamage = luaState.ToInteger(-1);
         luaState.Pop(1);
         luaState.GetField(-1, "spellDamage");
         dmgRes.spellDamage = luaState.ToInteger(-1);
         luaState.Pop(1);
         luaState.GetField(-1, "hpRemoval");
         dmgRes.hpRemoval = luaState.ToInteger(-1);
         luaState.Pop(1);
         // 伤害原因
         luaState.GetField(-1, "damageReason");
         dmgRes.damageReason = (BattleConsts.DamageReason)luaState.ToInteger(-1);
         luaState.Pop(1);
         ProcessManager.getInstance().addResult(dmgRes);
     }
     return 0;
 }
 public void execute()
 {
     // 能否反击的判断加入到单位的hurt中
     DamageResult dmgRes = new DamageResult();
     dmgRes.attacker = this.defender;
     dmgRes.victim = this.attacker;
     dmgRes.damageReason = BattleConsts.DamageReason.CounterAttack;
     dmgRes.physicalDamage = this.defender.UnitAttribute.attack;
     ProcessManager.getInstance().addResult(dmgRes);
 }
 public override void onStateEnter()
 {
     Debug.Log("Enter Attack State!");
     BattleInfo info = BattleGlobal.Core.battleInfo;
     this._attacker = info.attacker;
     this._defender = info.defender;
     this._attacker.doAttack();
     // 造成伤害结果
     DamageResult damageResult = new DamageResult();
     damageResult.attacker = this._attacker;
     damageResult.victim = this._defender;
     damageResult.damageReason = BattleConsts.DamageReason.Attack;
     damageResult.physicalDamage = this._attacker.UnitAttribute.attack;
     ProcessManager.getInstance().addResult(damageResult);
     ProcessManager.getInstance().startProcess();
 }
 private void onStateEnter(int stateId)
 {
     switch (stateId)
     {
         case STATE_CHECK_COUNTER_ATTACK:
             this.checkCounterAttack();
             break;
         case STATE_COUNTER_ATTACK:
             // 造成伤害结果
             DamageResult damageResult = new DamageResult();
             damageResult.attacker = this._defender;
             damageResult.victim = this._attacker;
             damageResult.damageReason = BattleConsts.DamageReason.CounterAttack;
             damageResult.physicalDamage = this._defender.UnitAttribute.attack;
             ProcessManager.getInstance().addResult(damageResult);
             ProcessManager.getInstance().startProcess();
             this._nextState = STATE_WAITING_TIMING_PROCESSING;
             break;
     }
 }
Example #5
0
 protected override void OnDamaged(DamageResult damage)
 {
     //StartCoroutine("AfterDamaged");
     Debug.Log("Remain HP = " + AStatus.Hp);
 }