public void damage(Character[] target, Attack spell = null) { bool dodge = false; bool crit = false; int damaged = 0; if(spell == null) spell = this.attackMode; else spell.action = 2; switch(spell.prop){ case 1: case 3: damaged = (int) System.Math.Round(this.atk * spell.rate); break; case 2: case 4: damaged = (int) System.Math.Round(this.mp * spell.rate); break; default: break; } foreach(Character t in target){ Buff buff = null; Debuff debuff = null; if(spell.prop == 1) //物理攻擊進行閃避判斷 dodge = this.isDodge(t); if(!dodge){ //沒閃掉的話進行傷害計算及暴擊判定 this._damage = this.calcDamage(damaged, t, spell.prop); this.buffEffect("damage"); this.debuffEffect("damage"); crit = this.isCrit(t, spell.prop); if(crit) this._damage = (int) System.Math.Round(this._damage * this.critRate); t.hurt(new popupText(){type=1,value=this._damage, isCrit=crit}, this); if(spell.buff > 0){ buff = t.addBuff(this, spell.buff); if(spell.buffInstantly) buff.effectInstantly(); } if(spell.debuff > 0) debuff = t.addDebuff(this, spell.debuff); if(spell.debuffInstantly) debuff.effectInstantly(); } Dictionary<string, string> data = new Dictionary<string, string>(); data.Add("action", spell.action.ToString()); data.Add("prop", spell.prop.ToString()); data.Add("attkerId", this.side.ToString() + '-' + this.charId.ToString()); data.Add("attkerTitle", this.side.ToString() + " - " + this.title + this.name); data.Add("targetId", t.side.ToString() + '-' + t.charId.ToString()); data.Add("targetTitle", t.side.ToString() + " - " + t.title + t.name); data.Add("title", spell.title); data.Add("damage", t._hurt.ToString()); data.Add("isCrit", crit.ToString()); data.Add("isDodge", dodge.ToString()); data.Add("buff", (buff != null)? string.Format("{0} ({1})", buff.title, buff.duration.ToString()):""); data.Add("debuff", (debuff != null)? string.Format("{0} ({1})", debuff.title, debuff.duration.ToString()):""); BG.addMessage("attack", data); } }