Example #1
0
    public void PickUp(PlayerInventory playerInventory)
    {
        // Attempt to add food
        bool bAddedFood = playerInventory.AddFood(m_OrderFood);

        // IF food added
        if (bAddedFood)
        {
            Deactivate();
        }
    }
Example #2
0
    public void AddLife()
    {
        if (playerInventory == null)
        {
            playerInventory = FindObjectOfType <PlayerInventory>();
        }

        if (playerLife == null)
        {
            playerLife = FindObjectOfType <PlayerLife>();
        }

        if (playerInventory.food >= addLifeCost)
        {
            playerLife.ChangeLife(addLifeAmount);
            playerInventory.AddFood(-addLifeCost);
        }
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player")
        {
            switch (itemsData.type)
            {
            case ItemsData.itemType.FOOD:
                playerInventory.AddFood(itemsData.amount);
                break;

            default:
                playerInventory.AddScrap(itemsData.amount);
                break;
            }

            Destroy(gameObject);
        }
    }
    private void PerformContextual()
    {
        // Get current drop off zone
        var currentDropOffZone = m_OrderManager.m_CurrentDropOffZone;
        var currentPickUpZone  = m_OrderManager.m_CurrentPickUpZone;

        // IF current drop off zone exists
        if (currentDropOffZone)
        {
            // Attempt to drop off food from inventory
            currentDropOffZone.DropOff(m_PlayerInventory);
        }

        // IF there is dropped food
        if (m_OrderManager.m_DroppedFoodList.Count > 0)
        {
            // Get first in dropped food list
            var droppedFood = m_OrderManager.m_DroppedFoodList[0];

            // IF Dropped Food is colliding with player
            if (droppedFood.m_bColliding)
            {
                // Add food to player inventory
                bool success = m_PlayerInventory.AddFood(droppedFood.m_Food);

                // IF Successfully added food
                if (success)
                {
                    // Delete Dropped food
                    droppedFood.Delete();
                    return;
                }
            }
        }

        // IF Current PickUp Zone exists
        if (currentPickUpZone)
        {
            // Pick up new food
            currentPickUpZone.PickUp(m_PlayerInventory);
        }
    }