Esempio n. 1
0
 private void Awake()
 {
     //set up nearby connections
     cc           = this.GetComponent <CharacterController>();
     playerCamera = this.GetComponentInChildren <Camera>();
     moveSound    = this.GetComponentInChildren <UFPlayerMoveSounds>();
 }
Esempio n. 2
0
    private bool PickUp()
    {
        UFPlayerLife life = UFLevel.GetPlayer <UFPlayerLife>();

        if (life.isDead)
        {
            return(false);
        }
        UFPlayerMoveSounds sound = life.GetComponentInChildren <UFPlayerMoveSounds>();

        switch (type)
        {
        case ItemType.Health:
            if (life.CanPickUpHealth())
            {
                life.GainHealth(count);
                sound.PickUpPowerup();
                return(true);
            }
            return(false);

        case ItemType.Armor:
            if (life.CanPickUpArmor())
            {
                life.GainArmor(count);
                sound.PickUpPowerup();
                return(true);
            }
            return(false);

        case ItemType.SuperHealth:
            sound.PickUpPowerup();
            life.SuperHealth();
            return(true);

        case ItemType.SuperArmor:
            sound.PickUpPowerup();
            life.SuperArmor();
            return(true);

        case ItemType.Invulnerability:
            sound.PickUpInvuln();
            life.Invulnerability();
            return(true);

        case ItemType.Explosive:
        case ItemType.Gun:
        case ItemType.SpecialWeapon:
            bool weapon = UFLevel.GetPlayer <UFPlayerWeapons>().PickupWeapon(this);
            if (weapon)
            {
                sound.PickUpWeapon();
            }
            return(weapon);

        case ItemType.ExplosiveAmmo:
        case ItemType.GunAmmo:
            bool ammo = UFLevel.GetPlayer <UFPlayerWeapons>().PickupAmmo(this);
            if (ammo)
            {
                sound.PickUpWeapon();
            }
            return(ammo);

        case ItemType.DamageAmp:
            UFLevel.GetPlayer <UFPlayerWeapons>().DamageAmp();
            sound.PickUpDamageAmp();
            return(true);

        default:
            Debug.LogWarning("Tried to collect unkown item type: " + type + " of item " + this.name);
            return(false);
        }
    }