Example #1
0
    /// <summary>
    /// Hand a new action for the old man to complete
    /// </summary>
    void AssignNextAction()
    {
        //If the old man doesn't have an action
        if (oldMan.currentAction == null)
        {
            oldMan.currentAction = OM_ActionQueue.Dequeue();
            return;
        }

        //Stop the current action
        oldMan.currentAction.StopAction(oldMan);

        //If the old man hasn't completed this action, add it back
        if (!oldMan.currentAction.Completed && !OM_ActionQueue.Contains(oldMan.currentAction))
        {
            Debug.Log("<color=#FDF212>The action \"" + oldMan.currentAction.Name + "\" has been put back into the queue.</color>");
            OM_ActionQueue.Enqueue(oldMan.currentAction, oldMan.currentAction.Priority);
        }

        //Keep the default action inside the queue
        if (OM_ActionQueue.Count == 1)
        {
            oldMan.currentAction = OM_ActionQueue.First;
            return;
        }

        //Get the new action
        oldMan.currentAction = OM_ActionQueue.Dequeue();
        Debug.Log("<color=#FDF212>The action \"" + oldMan.currentAction.Name + "\" has become the old man's current action.</color>");
    }
Example #2
0
    /// <summary>
    /// Create a path action to the queue
    /// </summary>
    /// <param name="priority">How important the action is</param>
    /// <param name="name">The name of this action</param>
    /// <param name="points">Array of all points</param>
    /// <param name="startPoint">Start index for this point</param>
    /// <param name="discardTime">The amount of time this action can spend in the queue without being discarded. 0 for infinite.</param>
    public void AddPathAction(float priority, string name, OM_MoveData[] points, int startPoint = 0,
                              Sprite thoughtItem = null, float discardTime = 0)
    {
        OM_Action_Path action = new OM_Action_Path(priority, name, points, startPoint, thoughtItem, discardTime);

        OM_ActionQueue.Enqueue(action, action.Priority);
    }
Example #3
0
    /// <summary>
    /// Create an action where the Old Man stands in place
    /// </summary>
    /// <param name="priority">How important the action is</param>
    /// <param name="name">The name of this action</param>
    /// <param name="standLength">How long the stand lasts for, x lessthan/= 0 for infinite</param>
    /// <param name="standPoint">The Vector3 to stand at. If null is passed in then there is no movement</param>
    /// <param name="discardTime">The amount of time this action can spend in the queue without being discarded. 0 for infinite.</param>
    public void AddStandStillAction(float priority, string name, float standLength = 0, Vector3?standPoint = null,
                                    Sprite thoughtItem = null, float discardTime = 0)
    {
        OM_Action_StandStill action = new OM_Action_StandStill(priority, name, standLength, standPoint, thoughtItem, discardTime);

        OM_ActionQueue.Enqueue(action, action.Priority);
    }
Example #4
0
    /// <summary>
    /// Add a MoveTo action to the queue
    /// </summary>
    /// <param name="priority">How important the action is</param>
    /// <param name="goalPoint">The point the OM is walking to</param>
    /// <param name="waitBeforeMoving">How long the OM should wait before moving to the goalPoint</param>
    /// <param name="thoughtItem">The sprite to put in the thought bubble. Can be left null for no item to be shown</param>
    /// <param name="discardTime">The amount of time this action can spend in the queue without being discarded. 0 for infinite.</param>
    public void AddMoveToAction(float priority, string name, OM_MoveData goalPoint, float waitBeforeMoving,
                                Sprite thoughtItem = null, float discardTime = 0)
    {
        OM_Action_MoveTo action = new OM_Action_MoveTo(priority, name, goalPoint, waitBeforeMoving, thoughtItem, discardTime);

        OM_ActionQueue.Enqueue(action, action.Priority);
    }
Example #5
0
    /// <summary>
    /// Create an action where an animation plays for the old man
    /// </summary>
    /// <param name="priority">How important the action is</param>
    /// <param name="name">The name of this action</param>
    /// <param name="animName">The name of the animation</param>
    /// <param name="animLength">How long the animation lasts for. 0 for infinite</param>
    /// <param name="discardTime">The amount of time this action can spend in the queue without being discarded. 0 for infinite.</param>
    public void AddAnimationAction(float priority, string name, string animName, float animLength, float discardTime = 0)
    {
        OM_Action_Animation action = new OM_Action_Animation(priority, name, animName, animLength, discardTime);

        OM_ActionQueue.Enqueue(action, action.Priority);
    }