コード例 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         Debug.Log("Adding: " + upgrade.GetGameObject().name);
         UpgradeToolbelt.instance.AddUpgrade(upgrade);
         Destroy(gameObject);
     }
 }
コード例 #2
0
 public void AddUpgrade(IUpgrade upgrade)
 {
     // Transfer the thing physically so it doesn't get destroyed by the pickup going away.
     upgrade.GetGameObject().transform.parent = beltObject;
     upgrades.Add(upgrade);
     PopulateUI();
     // TEMP: Add the upgrade to the current gun
     //upgrade.GetGameObject().transform.parent = GetComponent<GunManagement>().GetCurrentGun().transform;
     //upgrade.SetGun(GetComponent<GunManagement>().GetCurrentGun().GetComponent<Pistol>());
     //upgrade.Equip();
 }
コード例 #3
0
    /// <summary>
    /// Equip the 0th upgrade to the selected gun.
    /// </summary>
    /// <param name="gunType"></param>
    public void EquipTopUpgrade(int gunType)
    {
        IUpgrade upgrade = upgrades[0];

        // Get the gun object and parent the upgrade to it. This actually doesn't really serve a point... but it may later
        upgrade.GetGameObject().transform.parent = GunManagement.instance.guns[(GunManagement.Guns)gunType].transform;
        upgrade.SetGun(GunManagement.instance.guns[(GunManagement.Guns)gunType].GetComponent <Pistol>());
        upgrade.Equip();
        // Remove the upgrade from our list
        upgrades.RemoveAt(0);
        PopulateUI();
    }