/* * Damage Type */ public void DoHurt(int v, bool isCritical, SkillData.DamageType dt = SkillData.DamageType.Physic) { Debug.Log("NpcAttribute::DoHurt Name:" + gameObject.name + " hurtValue:" + v + " Armor:" + Armor + " DamageType " + dt); if (dt == SkillData.DamageType.Physic) { int hurt = v - Armor; Log.Important("Get Hurt is " + hurt); if (hurt > 0) { if (!isCritical) { PopupTextManager.popTextManager.ShowRedText("-" + hurt.ToString(), transform); } else { PopupTextManager.popTextManager.ShowPurpleText("-" + hurt.ToString(), transform); } ChangeHP(-hurt); } else { Log.Important("Armor too big for player " + Armor); } } else if (dt == SkillData.DamageType.Water) { var d = GetWaterDefense(); int hurt = (int)(v * (1 - d / 100.0f)); if (hurt > 0) { ChangeHP(-hurt); } } }
public DamageData(GameObject a, int d, bool critical, SkillData.DamageType dt, bool s) { Attacker = a; Damage = d; damageType = dt; ShowHit = s; isCritical = critical; }
/* * When Birth is inattackable * Birth Add Buff UnAttackable */ public void OnHit(GameObject go, int damage, bool isCritical, SkillData.DamageType damageType = SkillData.DamageType.Physic, bool showHit = true) { if (attribute._characterState != CharacterState.Birth) { CacheDamage.Add(new DamageData(go, damage, isCritical, damageType, showHit)); onHit = true; attacker = go; var evt = new MyEvent(MyEvent.EventType.OnHit); evt.attacker = attacker; MyEventSystem.myEventSystem.PushLocalEvent(photonView.GetLocalId(), evt); } }
/* * When Birth is inattackable * Birth Add Buff UnAttackable */ public void OnHit(GameObject go, int damage, bool isCritical, bool isStaticShoot, SkillData.DamageType damageType = SkillData.DamageType.Physic, bool showHit = true) { if (attribute != null && attribute._characterState != CharacterState.Birth) { lastAttacker = go.GetComponent <NpcAttribute>().GetNetView().GetServerID(); if (attackerList.ContainsKey(lastAttacker)) { attackerList[lastAttacker] += damage; } else { attackerList.Add(lastAttacker, damage); } CacheDamage.Add(new DamageData(go, damage, isCritical, isStaticShoot, damageType, showHit)); onHit = true; attacker = go; var evt = new MyEvent(MyEvent.EventType.OnHit); evt.attacker = attacker; MyEventSystem.myEventSystem.PushLocalEvent(photonView.GetLocalId(), evt); } }