コード例 #1
0
        // Remove a single resource
        public void RemoveResource(Resource resource, int key, bool isPlayer = true)
        {
            // Check if it's the player
            if (isPlayer)
            {
                // Get the inventory script
                PlayerInventory inventory = GameObject.Find("Canvas").transform.Find("PlayerInventory").GetComponent<PlayerInventory>();

                // Make sure the inventory exists
                if (inventory != null)
                {
                    // Remove the resource
                    inventory.Remove(key, resource);
                } // end if
            } // end if
            // Otherwise it must be the ally
            else
            {
                // Get the inventory script
                AllyInventory inventory = GameObject.Find("Canvas").transform.Find("AllyInventory").GetComponent<AllyInventory>();

                // Make sure the inventory exists
                if (inventory != null)
                {
                    // Remove the resource
                    inventory.Remove(key, resource);
                } // end if
            } // end else
        }
コード例 #2
0
        // Remove a single resource
        public void RemoveResource(Resource resource, int playerNum)
        {
            // Get the inventory script
            Inventory inventory = GameObject.Find("Canvas").transform.Find("Inventory").GetComponent<Inventory>();

            // Make sure the inventory exists
            if (inventory != null)
            {
                // Set the inventory up for the correct player
                inventory.SetPlayer(playerNum, true);

                // Remove the resource
                inventory.Remove(playerNum, resource);
            } // end if
        }