public bool AddScript(FluentScript fluentScript) { // Dont add any game actions that are not allowed to be added while active if (FluentScripts.Contains(fluentScript)) { return(false); } if (fluentScript == null) { Debug.LogWarning("You are trying to add a null action to the action manager", this); return(false); } if (possibleActions.Contains(fluentScript)) { return(true); } // set the initiator possibleActions.Add(fluentScript); RecalculateUIActionText(); return(true); }
public void ExecuteClosestAction(GameObject closestToWhat) { // FluentScript closestGameAction = GetClosestAction(closestToWhat); if (closestGameAction == null) { return; } ExecuteAction(closestGameAction); }
public void ExecuteAction(FluentScript gameAction) { if (FluentScripts.Contains(gameAction)) { Debug.LogWarning("This FluentScipt is already active " + gameAction.GetType().Name, gameAction); return; } gameAction.SetDoneCallback(ActionCompleted); FluentScripts.Add(gameAction); gameAction.Run(); }
public void ExecuteClosestAction(GameObject closestToWhat) { // FluentScript closestGameAction = GetClosestAction(closestToWhat); if (closestGameAction == null) { return; } else//jordan added this and tabbed the next line { ExecuteAction(closestGameAction); } }
private void ActionCompleted(FluentScript fluentScript) { FluentScripts.Remove(fluentScript); // The action just completed // The action initiator could have been stopped from adding this action as a viable action // TODO /* * if (fluentScript.Initiator != null) * { * GameAction newGameAction = fluentScript.Initiator.ShouldAddGameAction(); * if (newGameAction != null) * AddAction(newGameAction, fluentScript.Initiator); * }*/ }
private void RecalculateUIActionText() { FluentScript closestGameAction = GetClosestAction(PlayerObject); if (ClosestActionUIText != null) { if (closestGameAction != null) { ClosestActionUIText.GetComponent <TextMeshProUGUI>().text = closestGameAction.Description(); } else { ClosestActionUIText.GetComponent <TextMeshProUGUI>().text = ""; } } }
private FluentScript GetClosestAction(GameObject playerObject) { // // Find the closest game action // FluentScript closestGameAction = null; float closestDistance = float.MaxValue; foreach (FluentScript gameAction in possibleActions) { float distance = (gameAction.gameObject.transform.position - playerObject.transform.position).magnitude; if (distance < closestDistance) { closestDistance = distance; closestGameAction = gameAction; } } return(closestGameAction); }
public void RemoveScript(FluentScript fluentScript) { possibleActions.Remove(fluentScript); RecalculateUIActionText(); }