private IEnumerator WaitForCondition() { //Wait while the commande pannel is displayed to avoid issues yield return(new WaitWhile(() => PlayersTurnManager.IsCommandPhase)); GameManager gameManager = GameUtils.FetchGameManager(); //Wait an additionnal 4 second to be sure the catcher wait tat the ball gone far enough //Also check for the pannel display to be realy sure if (gameManager.AttackTeamRunnerList.Count > 1) { yield return(new WaitForSeconds(4f)); yield return(new WaitWhile(() => PlayersTurnManager.IsCommandPhase)); } //Catcher must go look for the ball PlayerActionsManager playerActionsManager = GameUtils.FetchPlayerActionsManager(); CatcherBehaviour catcherBehaviour = PlayerUtils.FetchCatcherBehaviourScript(this.gameObject); playerActionsManager.AimForTheBall(catcherBehaviour); //switch the catcher mode (mode normal, mode fielder) this.CatcherMode = ModeConstants.CATCHER_FIELDER_MODE; //Add the relevant abilities this.AddFielderAbilitiesToCatcher(this.gameObject); }
public void GenericPassAction(GameObject actionUser) { List <GameObject> fielders = PlayerUtils.GetFieldersOnField() .Where(fielder => !fielder.Equals(actionUser)) .OrderBy(fielder => Vector3.Distance(actionUser.transform.position, fielder.transform.position)) .ToList(); Action <GameObject, GameObject> finalActionsToPerform = PassBallAction; //Add an additionnal action for the pass. => go back to initial placement for the catcher. if (PlayerUtils.HasCatcherPosition(actionUser)) { CatcherBehaviour catcherBehaviour = PlayerUtils.FetchCatcherBehaviourScript(actionUser); finalActionsToPerform += catcherBehaviour.ReturnToInitialPosition; } TargetSelectionManager.EnableSelection(fielders.First().transform.position, fielders, finalActionsToPerform, actionUser); }