Example #1
0
        }         // end Update function

        // Attempts to pick up a resource for the character.
        public void PickupResource(Resource resource, int amount)
        {
            // Check if picking up this resource will put the character overweight.
            if ((ResourceWeight + resource.WeightValue) * amount <= MaxWeight)
            {
                // Check if there is enough room for this resource.
                if (m_resourceList.TotalSize + resource.SizeValue <= MaxInventory)
                {
                    // Add the resource.
                    m_resourceList.AddResource(resource, amount);

                    // Get the resource's position.
                    Vector3 tmp = transform.localPosition;
                    // Change the z to make tiles work.
                    tmp.z = -0.01f;
                    TileDictionary.RemoveResource(TileManager.ToPixels(tmp));
                }                 // end if size
                else
                {
                    print("Pickup failed. Max inventory capacity reached.");
                }         // end else size
            }             // end if weight
            else
            {
                print("Pickup failed. Max inventory weight reached.");
            }     // end else weight
        }         // end PickupResource function