Example #1
0
 private void OnPickUp(PlayerWeaponController playerWeaponController)
 {
     if (_pickUpSubManager != null)
     {
         _pickUpSubManager.PickUpHealth();
     }
     playerWeaponController.GetComponent <Health>().Heal(healAmount);
 }
Example #2
0
    // Update is called once per frame
    /// <summary>
    /// This method checks to see if the player is colliding with a item. If it does, then determine if
    /// the item is a weapon or a potion. If it's a potion, check to see what type of potion it is and
    /// effect the player's stats
    /// </summary>
    void Update()
    {
        if (selfCollider.IsTouching(playerWeapon.GetComponent <BoxCollider2D>()))
        {
            if (weapon != null)
            {
                itemText.text    = "Press [E] or [U] For " + weapon.itemName;
                itemText.enabled = true;
                if (Input.GetButtonDown("Interact"))
                {
                    playerWeapon.equippedWeapon = weapon;
                    itemText.enabled            = false;
                    Destroy(gameObject);
                }
            }
            else if (potion != null)
            {
                itemText.text    = "Press [E] or [U] To Drink " + potion.itemName;
                itemText.enabled = true;
                if (Input.GetButtonDown("Interact"))
                {
                    switch (potion.potionType)
                    {
                    case Potion.PotionType.Health:
                        PlayerData.instance.AddHealth(25);
                        PlayerData.instance.GetComponent <SpriteRenderer>().color = Color.white;
                        break;

                    case Potion.PotionType.Speed:
                        CustomPlayerController.instance.drankSpeedPotion = true;
                        break;

                    case Potion.PotionType.Strength:
                        PlayerWeaponController.instance.drankStrengthPotion = true;
                        break;

                    case Potion.PotionType.Invisibility:
                        CustomPlayerController.instance.drankInvisPotion = true;
                        break;
                    }
                    itemText.enabled = false;
                    Destroy(gameObject);
                }
            }
        }
        else
        {
            itemText.enabled = false;
        }
    }
Example #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (!_canPickup)
        {
            return;
        }
        PlayerWeaponController weaponController = other.GetComponent <PlayerWeaponController>();

        if (weaponController != null)
        {
            if (pickupClip != null)
            {
                weaponController.GetComponent <AudioSource>().PlayOneShot(pickupClip);
            }
            if (onPick != null)
            {
                _canPickup = false;
                onPick.Invoke(weaponController);
            }
            Destroy(gameObject);
        }
    }