public abstract void Fire(); //开火 public virtual void Wound(TankBaseObj tank) //受到伤害 { int dmg = tank.atk - this.def; if (dmg <= 0) { return; } this.hp -= dmg; if (this.hp <= 0) { this.hp = 0; this.Dead(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Wall") || other.CompareTag("Destructible") || other.CompareTag("Player") && fatherObj.CompareTag("NPC") || other.CompareTag("NPC") && fatherObj.CompareTag("Player")) { TankBaseObj obj = other.GetComponent <TankBaseObj>(); if (obj != null) { obj.Wound(fatherObj); } if (effObj != null) { GameObject eff = Instantiate(effObj, this.transform.position, this.transform.rotation); } Destroy(this.gameObject); } }
public void SetFather(TankBaseObj obj) { fatherObj = obj; }
public override void Wound(TankBaseObj tank) { base.Wound(tank); }