示例#1
0
    public override void CommandUpdate()
    {
        var distanceToNode  = Vector3.Distance(resourceNode.transform.position, commandManager.transform.position);
        var distancetoDepot = Vector3.Distance(resourceDepot.transform.position, commandManager.transform.position);

        if (distanceToNode <= relaxDistance && !collected)
        {
            if (resourceNode.mineable)
            {
                resourceNode.mineable = false;
                commandManager.InsertCommand(Cmd_Channel.New(transform.gameObject, "Attack", 1, 0.9f, resourceNode.transform.position, gatherAction, cancelAction));
            }
            return;
        }
        else if (distancetoDepot <= relaxDistance && collected)
        {
            GetComponent <Player>().Info.Credits += AmountGathered;
            AmountGathered = GatherAmount;
            collected      = false;
            return;
        }
        else if (distancetoDepot <= relaxDistance)
        {
            commandManager.InsertCommand(Cmd_Move.New(transform.gameObject, resourceNode.transform.position));
            return;
        }
        else if (distanceToNode <= relaxDistance)
        {
            commandManager.InsertCommand(Cmd_Move.New(transform.gameObject, resourceDepot.transform.position));
            return;
        }
    }
示例#2
0
    /// <summary>
    /// this command gets inserted at the front of the command queue to complete an activity animation and time out other events this is command is here to make sure the unit is only doing an action
    /// and nothing else it also allows for animation cancelling minigame.
    /// </summary>

    public static Cmd_Channel New(GameObject prGameObject, string prAnimation, float prDuration, float prActionTriggerPoint, Vector3 prChannelPoint, Delegate prTriggerAction)
    {
        Cmd_Channel newcommand = prGameObject.AddComponent <Cmd_Channel>();

        newcommand.DefineFields(prAnimation, prDuration, prActionTriggerPoint, prChannelPoint, prTriggerAction);

        return(newcommand);
    }