Exemplo n.º 1
0
 public static void AmmoHit(BulletSpec bulletSpec)
 {
     if (bulletSpec != null)
     {
         AmmoHit(bulletSpec.bulletName);
     }
     else
     {
         Debug.Log("Cannot read bulletSpec in BulletTracker.AmmoHit().");
     }
 }
Exemplo n.º 2
0
    void EquipWeapon(AmmoTracker ammoTracker)
    {
        currentAmmoTracker = ammoTracker;
        bulletPrefab       = currentAmmoTracker.bulletPrefab;
        bulletSpec         = currentAmmoTracker.bulletSpec;
        ammoUI.UpdateWeapon(currentAmmoTracker);

        if (currentAmmoTracker.AmmoAvailable())
        {
            gunAudio.clip = bulletSpec.shootAudio;
        }
        else
        {
            gunAudio.clip = noAmmoAudio;
        }
    }
Exemplo n.º 3
0
        // If newBulletPrefab == tracked bullet prefab, add the ammo count and return true.
        public bool AddAmmo(Rigidbody newBulletPrefab)
        {
            BulletSpec newBulletSpec = newBulletPrefab.GetComponent <BulletSpec> ();

            if (newBulletSpec != null)
            {
                if (bulletSpec.bulletName.Equals(newBulletSpec.bulletName))
                {
                    bulletCount += newBulletSpec.bulletCount;
                    return(true);
                }
            }
            else
            {
                Debug.Log("Cannot assign bulletSpec in AmmoTracker.AddAmmo().");
            }

            return(false);
        }
Exemplo n.º 4
0
    public static void AmmoShot(BulletSpec bulletSpec)
    {
        if (bulletSpec != null)
        {
            foreach (BulletStats bulletStat in bulletStatsList)
            {
                if (bulletSpec.bulletName.Equals(bulletStat.bulletName))
                {
                    bulletStat.ammoShot++;
                    return;                     // bulletStat found
                }
            }

            Debug.Log("Cannot find bullet in BulletTracker.AmmoShot().");
        }
        else
        {
            Debug.Log("Cannot read bulletSpec in BulletTracker.AmmoShot().");
        }
    }
Exemplo n.º 5
0
    public static void CollectAmmo(BulletSpec bulletSpec)
    {
        if (bulletSpec != null)
        {
            foreach (BulletStats bulletStat in bulletStatsList)
            {
                if (bulletSpec.bulletName.Equals(bulletStat.bulletName))
                {
                    bulletStat.ammoCollected += bulletSpec.bulletCount;
                    return;                     // bulletStat found
                }
            }

            // New bullet type collected
            bulletStatsList.Add(new BulletStats(bulletSpec.bulletName, bulletSpec.bulletCount));
        }
        else
        {
            Debug.Log("Cannot read bulletSpec in BulletTracker.CollectAmmo().");
        }
    }