예제 #1
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Player")
     {
         SniperScript sgs = collision.transform.Find("Head").transform.Find("sniper").GetComponent <SniperScript>();
         sgs.totalAmmo += ammoAmmount;
         sgs.SendMessage("UpdateAmmo");
         Destroy(gameObject);
     }
 }
예제 #2
0
    void ChooseGun()
    {
        switch (currentGunIndex)
        {
        case 0:
            sgs.canShoot = true;
            mgs.canShoot = false;
            sns.canShoot = false;

            allWeaponVisuals[0].SetActive(true);
            allWeaponVisuals[1].SetActive(false);
            allWeaponVisuals[2].SetActive(false);

            sgs.SendMessage("UpdateAmmo");
            break;

        case 1:
            sgs.canShoot = false;
            mgs.canShoot = true;
            sns.canShoot = false;

            allWeaponVisuals[0].SetActive(false);
            allWeaponVisuals[1].SetActive(true);
            allWeaponVisuals[2].SetActive(false);

            mgs.SendMessage("UpdateAmmo");
            break;

        case 2:
            sgs.canShoot = false;
            mgs.canShoot = false;
            sns.canShoot = true;

            allWeaponVisuals[0].SetActive(false);
            allWeaponVisuals[1].SetActive(false);
            allWeaponVisuals[2].SetActive(true);

            sns.SendMessage("UpdateAmmo");
            break;
        }

        currentGun = allWeaponPrefabs[currentGunIndex];
    }