void OnTriggerEnter2D(Collider2D collider) { //Намагаємося отримати компонент // SelfControl rabit = collider.GetComponent<SelfControl>(); OrcGreen orc = collider.GetComponent <OrcGreen>(); if (orc != null) { if (collider == orc.head) { orc.callDie(); } if (collider == orc.body) { orc.callPunch(); this.callDie(); } } BrownOrc brownOrc = collider.GetComponent <BrownOrc>(); if (brownOrc != null) { if (collider == brownOrc.head) { brownOrc.callDie(); } } }
void OnTriggerEnter2D(Collider2D collider) { HeroRabit rabit = collider.GetComponent <HeroRabit>(); if (rabit != null) { this.OnRabitHit(rabit); } else { BrownOrc orc = collider.GetComponent <BrownOrc>(); if (orc == null) { this.CollectedHide(); } } }
public void OnTriggerEnter2D(Collider2D collider) { if (rabit) { GreenOrc greenOrc = collider.gameObject.GetComponent <GreenOrc> (); if (greenOrc != null) { if (greenOrc.isLive) { if (collider == greenOrc.body) { this.dead(); greenOrc.attack(); } else if (collider == greenOrc.head) { greenOrc.dead(); } } } } if (rabit) { BrownOrc brownOrc = collider.gameObject.GetComponent <BrownOrc> (); if (brownOrc != null) { if (brownOrc.isLive) { if (collider == brownOrc.head) { brownOrc.dead(); } } } } }