public override void Attack(GuardAbs guardObj) { GoldCarrier gc = guardObj.gameObject.GetComponent <GoldCarrier>(); if (gc == null || gos.Contains(gc.gameObject)) { return; } gos.Add(gc.gameObject); UnityEventCenter.SendMessage <AudioEvent>(new AudioEvent(gameObject, clip_1)); if (guardObj.getGuardLevel() <= getAttackLevel()) { //等级相同,摧毁对方(只有超载矿车) if (guardObj.DestrotyGameObj(this)) { //成功摧毁对方 TryDestroy(this); } } else { //等级高于检查站,则扣钱 int gold = gc.popGold(); gc.setGoldAmounts(Mathf.FloorToInt(gold * tax)); } }
public override void Attack(GuardAbs guardObj) { if (guardObj.getGuardLevel() <= getAttackLevel() && guardObj.gameObject.layer == Layers.VEHICLE) { if (guardObj.DestrotyGameObj(this)) { UnityEventCenter.SendMessage <AudioEvent>(new AudioEvent(gameObject, clip)); TryDestroy(this); } } }
public override void Attack(GuardAbs guardObj) { enemyAbs = guardObj.gameObject.GetComponent <GuardAbs>(); if (guardObj.gameObject.layer == Layers.CHARACTER && enemyAbs != null) { if (enemyAbs.getGuardLevel() <= ATTACKLEVEL) { gunnerEnemy = guardObj.gameObject.GetComponent <GunnerAttack>(); if (gunnerEnemy != null) { try { enemyAbs.TryDestroy(myAbs); myAbs.TryDestroy(myAbs); UnityEventCenter.SendMessage <AudioEvent>(new AudioEvent(gameObject, clip)); } catch { guardObj.SendMessage(GameobjBase.TryDestroyFUNC); gameObject.SendMessage(GameobjBase.TryDestroyFUNC); //Destroy(guardObj.gameObject); //Destroy(this.gameObject); } } else { try { enemyAbs.TryDestroy(myAbs); UnityEventCenter.SendMessage <AudioEvent>(new AudioEvent(gameObject, clip)); } catch { guardObj.gameObject.SendMessage(GameobjBase.TryDestroyFUNC); //Destroy(guardObj.gameObject); } finally { bulletCount--; if (bulletCount == 0) { myAbs.TryDestroy(myAbs); } } } } } }