Example #1
0
    void Start()
    {
        Broom = transform.Find("Broom").gameObject;
        Gun   = transform.Find("Gun").gameObject;

        Script = this;

        HealthScript.SetMax(healthMax);
        BulletUI.AddBullets(bullets);
        animator = transform.Find("Sprite").GetComponent <SpriteAnimator>();
        animator.SetSpeed(10);
    }
Example #2
0
    public void PickupItem(GameObject item)
    {
        if (item.GetComponent <ItemScript>().type == Item.Type.Bullet && bullets < 20)
        {
            bullets++;
            BulletUI.AddBullets(1);
            nearbyItems[0].SendMessage("Pickup");
        }

        if (item.GetComponent <ItemScript>().type == Item.Type.Medkit && health < healthMax)
        {
            float newHealth = health + 20;

            if (newHealth > healthMax)
            {
                newHealth = healthMax;
            }

            SetHealth(newHealth);
            nearbyItems[0].SendMessage("Pickup");
        }
    }