示例#1
0
 void OnTriggerEnter(Collider a)
 {
     if (a.gameObject.tag == "Player") // if the player enters the collider
     {
         Debug.Log("entered");
         pickupSound.GetComponent <AudioSource>().Play();
         GameObject       Sniper = GameObject.Find("Sniper");                // find the sniper rifle
         MachineGunScript mgs2   = Sniper.GetComponent <MachineGunScript>(); // get the script component of the sniper rifle
         mgs2.reserveAmmo += 10;                                             // add 10 ammo to the reserve
         Destroy(gameObject);                                                // delete the ammo box
     }
 }
 void OnTriggerEnter(Collider a)
 {
     if (a.gameObject.tag == "Player") // if the player enters the collider
     {
         Debug.Log("entered");
         pickupSound.GetComponent <AudioSource>().Play();
         GameObject       M4a1 = GameObject.Find("M4a1");                // find the machinegun
         MachineGunScript mgs1 = M4a1.GetComponent <MachineGunScript>(); // get the script component of the machinegun
         mgs1.reserveAmmo += 30;                                         // add 30 ammo to the reserve
         Destroy(gameObject);                                            // delete the ammo box
     }
 }
示例#3
0
    private void MachineGunFire()
    {
        Rigidbody shellInstance = Instantiate(m_MachineGunBullet, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;

        shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward * 2;
        MachineGunScript fire = shellInstance.GetComponent <MachineGunScript> ();

        fire.m_PlayerNumber = this.m_PlayerNumber;

        //m_ShootingAudio.clip = m_FireClip;
        //m_ShootingAudio.Play ();
        m_CurrentLaunchForce = m_MinLaunchForce;
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        var machineGun = GameObject.Find("MachineGunObject");

        machineGunScr = machineGun.GetComponent <MachineGunScript>();
    }