void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, FirstHit); pEnemy.AddHP(-Damage.Item1, Damage.Item2); Statistics.pthis.RecordHit(ENUM_Damage.Rifle, Damage.Item1, FirstHit); if (iCount <= 0) { Destroy(gameObject); } FirstHit = false; --iCount; }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, true); pEnemy.AddHP(-Damage.Item1, Damage.Item2); Statistics.pthis.RecordHit(ENUM_Damage.Pistol, Damage.Item1, true); if (Rule.GetWeaponLevel(ENUM_Weapon.Pistol) > 0) { if (!other.gameObject.GetComponent <Freeze>()) { other.gameObject.AddComponent <Freeze>().FreezeNow(); } else { other.gameObject.GetComponent <Freeze>().fTime = 2; } } Destroy(gameObject); }
// ------------------------------------------------------------------ void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, true); pEnemy.AddHP(-Damage.Item1, false); Statistics.pthis.RecordHit(ENUM_Damage.Eagle, Damage.Item1, true); // 播放爆擊特效 if (Damage.Item2) { if (Rule.GetWeaponLevel(ENUM_Weapon.Eagle) > 0) { pEnemy.HitSfx("G_HeadShot"); } else { pEnemy.HitSfx("G_Crit"); } } //if Destroy(gameObject); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, true); pEnemy.AddHP(-Damage.Item1, Damage.Item2); Statistics.pthis.RecordHit(ENUM_Damage.SUB, Damage.Item1, true); if (Rule.GetWeaponLevel(ENUM_Weapon.SUB) > 0) { GroundHurt(other.gameObject.transform.position, Rule.UpgradeWeaponSUB()); } else { Destroy(gameObject); } }
// 範圍傷害. void GroundHurt(Vector3 vPos, int iDamage) { pAI.bCanMove = false; if (GetComponent <BoxCollider2D>()) { GetComponent <BoxCollider2D>().enabled = false; } if (GetComponent <Animator>()) { GetComponent <Animator>().Play("Grenade"); } // 沒有可作為目標的怪物. if (SysMain.pthis.AtkEnemy.Count <= 0) { return; } pAI.pRander.material = UITool.pthis.M_Sprite; gameObject.transform.localScale = new Vector3(GameDefine.fSUBArea / 0.1f, GameDefine.fSUBArea / 0.1f, 1); foreach (KeyValuePair <GameObject, int> itor in SysMain.pthis.Enemy) { if (itor.Key == null) { continue; } AIEnemy pEnemy = itor.Key.GetComponent <AIEnemy>(); if (pEnemy == null) { continue; } if (pEnemy.iHP <= 0) { continue; } float fDisObj = Vector2.Distance(vPos, itor.Key.transform.position); // 比較距離. if (fDisObj >= GameDefine.fSUBArea) { continue; } pEnemy.AddHP(-iDamage, false); Statistics.pthis.RecordHit(ENUM_Damage.SUB, iDamage, false); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, FirstHit); int iDamage = Rule.UpgradeWeaponRevolver(Damage.Item1, iCountMax - iCount); pEnemy.AddHP(-iDamage, Damage.Item2); Statistics.pthis.RecordHit(ENUM_Damage.Revolver, Damage.Item1, FirstHit); if (FirstHit && Damage.Item2) { pEnemy.HitSfx("G_Crit"); } if (FirstHit == false) { pEnemy.HitSfx("G_Combo"); } History.Add(other.gameObject); if (iCount <= 0) { Destroy(gameObject); } GameObject NewTarget = GetTarget(); if (NewTarget == null) { Destroy(gameObject); } FirstHit = false; --iCount; pAI.Chace(NewTarget); }
// ------------------------------------------------------------------ void Update() { if (!ObjTarget || !pMaster) { Destroy(gameObject); return; } gameObject.transform.position = ObjTarget.transform.position; if (pAI.iHP <= 0) { pMaster.AddHP(-pAI.DBFData.HP, false); pAIBewitch.ObjTarget = null; pMaster.bHasTarget = false; ObjTarget.GetComponent <AIPlayer>().BeFree(); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Enemy") { return; } AIEnemy pEnemy = other.gameObject.GetComponent <AIEnemy>(); if (pEnemy == null) { return; } Tuple <int, bool> Damage = Rule.BulletDamage(pAI.iPlayer, true); pEnemy.AddHP(-Damage.Item1 - Rule.UpgradeWeaponLMG(), Damage.Item2); Statistics.pthis.RecordHit(ENUM_Damage.LMG, Damage.Item1, true); Destroy(gameObject); }