Пример #1
0
 void Awake()
 {
     if (singleton == null)
     {
         singleton = this;
         library   = GetComponent <GunLibrary>();
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #2
0
    void PickupWeapon(string name)
    {
        Gun newWeapon = GunLibrary.FindGun(name);

        newWeapon.Initialise();

        if (loadout.Count >= 2)
        {
            loadout[currentIndex] = newWeapon;
            Equip(currentIndex);
        }
        else
        {
            loadout.Add(newWeapon);
            Equip(loadout.Count - 1);
        }
    }
Пример #3
0
    void PickupWeapon(string name)
    {
        //find weapon from library
        //add weapon to the loadout
        Gun newWeapon = GunLibrary.FindGun(name);

        if (loadout.Count >= 2)
        {
            if (loadout[0] != newWeapon && loadout[1] != newWeapon)
            {
                loadout[currentIndex] = newWeapon;
                loadout[currentIndex].Init();
                Equip(currentIndex);
                equippedWeapon = currentIndex + 1;
            }
            else
            {
                for (int i = 0; i < loadout.Count; i++)
                {
                    if (loadout[i] == newWeapon)
                    {
                        loadout[i].Init();
                        Equip(i);
                        equippedWeapon = i + 1;
                    }
                }
            }
        }
        else
        {
            if (loadout[currentIndex] == newWeapon)
            {
                loadout[currentIndex].Init();
                Equip(currentIndex);
                equippedWeapon = 1;
            }
            else
            {
                loadout.Add(newWeapon);
                Equip(loadout.Count - 1);
                equippedWeapon = 2;
            }
        }
    }