Пример #1
0
    /// <summary>
    /// Called once every frame.
    /// </summary>
    void Update()
    {
        if (isEquipped && !Input.GetKey(KeyCode.N))
        {
            SetActiveUI(true);

            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                int remaining = currentThrowable.Throw();
                text.text = currentThrowable.Name + ": " + remaining;

                //No more throwables available of currentType.
                if (remaining == 0)
                {
                    string newType = PlayerItems.GetNextThrowable();

                    if (newType == null)
                    {
                        //Unequip if no throwables available.
                        isEquipped = false;
                    }
                    else
                    {
                        //Equip another throwable type.
                        currentThrowable = inventory.GetThrowable(newType);
                        text.text        = newType + ": " + PlayerItems.GetThrowableCount(newType);
                    }
                }
            }
        }
        else
        {
            SetActiveUI(false);
        }
    }
Пример #2
0
 /// <summary>
 /// Activate or equip the throwable and make it ready for throwing.
 /// </summary>
 /// <param name="name"> The throwable type to equip. </param>
 public void Activate(string name)
 {
     isEquipped       = true;
     text.text        = name + ": " + PlayerItems.GetThrowableCount(name);
     currentThrowable = inventory.GetThrowable(name);
 }