public void OnTackle(Unit tackler, Unit tackled) { if (tackler != null && tackled == null) { tackler.sm.event_Tackle(); game.OnDodgeSuccess(); return; } TackleManager tm = this.game.refs.managers.tackle; if (tm == null) throw new UnityException("Game needs a TackleManager !"); if (tackler == null || tackled == null || tackler.Team == tackled.Team) throw new UnityException("Error : " + tackler + " cannot tackle " + tackled + " !"); tm.game = this.game; tm.tackler = tackler; tm.tackled = tackled; // End of a tackle, according to the result tm.callback = (TackleManager.RESULT res) => { TacklePlaceUnitsAtEnd(tackler, tackled); switch (res) { // Plaquage critique, le plaqueur recupère la balle, le plaqué est knockout case TackleManager.RESULT.CRITIC: this.game.Ball.Owner = tackler; break; // Passe : les deux sont knock-out mais la balle a pu être donnée à un allié case TackleManager.RESULT.PASS: Unit target = tackled.GetNearestAlly(); if (tackled.unitAnimator) { tackled.unitAnimator.OnTacklePass(); } game.Ball.Pass(target); tackled.sm.event_Tackle(); tackler.sm.event_Tackle(); break; // Normal : les deux sont knock-out et la balle est par terre // /!\ Mêlée possible /!\ case TackleManager.RESULT.NORMAL: //super game.Ball.TeleportOnGround(); IncreaseSuper(game.settings.Global.Super.tackleWinSuperPoints, tackler.Team); tackled.sm.event_Tackle(); tackler.sm.event_Tackle(); break; } tackler.Team.Player.UpdateControlled(); tackled.Team.Player.UpdateControlled(); LastTackle = Time.time; }; this.TacklePlaceUnitsAtStart(tackler, tackled); tm.atUpdate = TacklePlaceUnitsAtUpdate; tm.Tackle(); }