예제 #1
0
    public Vector3 startPostion()
    {
        if (_agentData.HasEnemyFlag)
        {
            if (this.tag == Tags.BlueTeam)
            {
                _agentInventory.RemoveItem(Names.RedFlag);
                GameObject.Find(Names.RedFlag).GetComponent <Flag>().ResetPositionRed();
            }
            if (this.tag == Tags.RedTeam)
            {
                _agentInventory.RemoveItem(Names.BlueFlag);
                GameObject.Find(Names.BlueFlag).GetComponent <Flag>().ResetPositionBlue();
            }
        }

        if (_agentData.HasFriendlyFlag)
        {
            if (this.tag == Tags.BlueTeam)
            {
                GameObject.Find(Names.BlueFlag).GetComponent <Flag>().ResetPositionBlue();
            }
            if (this.tag == Tags.RedTeam)
            {
                GameObject.Find(Names.RedFlag).GetComponent <Flag>().ResetPositionRed();
            }
        }

        if (_agentInventory.HasItem(Names.HealthKit))
        {
            _agentActions.DropItem(_agentInventory.GetItem(Names.HealthKit));
            GameObject.Find(Names.HealthKit).GetComponent <Collectable>().resetPosition();
        }

        if (_agentInventory.HasItem(Names.PowerUp))
        {
            _agentActions.DropItem(_agentInventory.GetItem(Names.PowerUp));
            GameObject.Find(Names.PowerUp).GetComponent <Collectable>().resetPosition();
        }

        if (hasWon)
        {
            BackpropagationIfWon();
        }
        else
        {
            BackpropagationIfLost();
        }

        return(startingPostion);
    }
예제 #2
0
    protected override IEnumerator Execute()
    {
        SetState(NodeState.RUNNING);

        // This method already checks if item is in agents inventory
        actions.DropItem(itemToDrop);

        SetState(NodeState.SUCCESS);

        yield return(null);
    }
예제 #3
0
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        _isAlive = false;
        _aiMood  = AiMood.Dead;

        Dictionary <string, GameObject> inventory = gameObject.GetComponentInChildren <InventoryController>().Items;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        foreach (var item in inventory)
        {
            actions.DropItem(item.Value);
        }

        Destroy(gameObject);
    }