示例#1
0
    /*
     * Purpose:                Remove object from caravan.
     * Effects:                Part's parent is now attach_point of the capsule (capsule is now grandparent!)
     * Input/Output:           N/A.
     * Global Variables Used:  caravan_tf, parts_tf, caravan, char_control (Class Caravan), transform (Class Part),
     *                      has_object (Class CharacterControl)
     */
    private void RemoveFromCaravan()
    {
        Transform part_tf = caravan.FindPartSlot();

        if (part_tf != null)
        {
            part_tf.GetComponent <Part>().Drop();
            caravan.parts_tf.RemoveLast();
        }
        else
        {
            Debug.Log("No part attached to caravan");
        }
    }
示例#2
0
    /*
     * Purpose:                Remove object from caravan.
     * Effects:                Part's parent is now attach_point of the capsule (capsule is now grandparent!)
     * Input/Output:           N/A.
     * Global Variables Used:  caravan_tf, parts_tf, caravan, char_control (Class Caravan), transform (Class Part),
     *                      has_object (Class CharacterControl)
     */
    public void RemoveFromCaravan()
    {
        if (caravan.FindPartSlot())
        {
            Part part = PartToBeRemoved();
            part.Drop();
            caravan.parts_tf.Remove(part.transform);

            if (!health)
            {
                health = caravan.GetComponent <Health>();
            }

            health.Reduce(part.healthValue);
        }
        else
        {
            Debug.Log("No part attached to caravan");
        }
    }