//普通攻击 public void attack(HeroBaseModel model) { bool isCrit = false; if (!BaseConfig.isHit(get(Constants.HERO_ATTR_HIT), get(Constants.HERO_ATTR_DODGE))) { Debug.Log("attack error! is not hit!!"); return; } else { if (BaseConfig.isCrit(get(Constants.HERO_ATTR_CRIT), get(Constants.HERO_ATTR_DECRIT)))//暴击 { Debug.Log("attack status is crit!!"); GlobalObject.EventDispatcher.dispatchEvent(Events.EVT_HERO_CRIT); isCrit = true; } else if (BaseConfig.isFreeze(get(Constants.HERO_ATTR_FREEZE), get(Constants.HERO_ATTR_IMMUNITY)))//冰冻 { Debug.Log("attack status is freeze!!"); model.enableStatus(Constants.HERO_STATUS_FREEZE, new HeroStatus() { startTime = Time.time, isActive = true, time = 3 }); } else if (BaseConfig.isVertigo(get(Constants.HERO_ATTR_VERTIGO), get(Constants.HERO_ATTR_IMMUNITY)))//眩晕 { Debug.Log("attack status is vertigo!!"); model.enableStatus(Constants.HERO_STATUS_FREEZE, new HeroStatus() { startTime = Time.time, isActive = true, time = 3 }); } else if (BaseConfig.isPoison(get(Constants.HERO_ATTR_POISON), get(Constants.HERO_ATTR_IMMUNITY)))//中毒 { Debug.Log("attack status is poison!!"); model.enableStatus(Constants.HERO_STATUS_FREEZE, new HeroStatus() { startTime = Time.time, isActive = true, time = 3, value = 300 }); } } float attackValue = get(Constants.HERO_ATTR_ATTACK); float mattackValue = get(Constants.HERO_ATTR_MATTACK); float defenseValue = model.get(Constants.HERO_ATTR_DEFENSE); float mdefenseValue = model.get(Constants.HERO_ATTR_MDEFENSE); float damage = 0; if (attackValue < mattackValue) { damage = BaseConfig.damage(attackValue, mattackValue, defenseValue, mdefenseValue); } else { damage = BaseConfig.mdamage(attackValue, mattackValue, defenseValue, mdefenseValue); } if (isCrit) { damage *= 2; } //掉血 model.add(Constants.HERO_ATTR_HEALTH, -damage); }