示例#1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     character.InputMoveV = Input.GetAxis("Vertical");
     character.InputMoveH = Input.GetAxis("Horizontal");
     if (Input.GetMouseButtonDown(1))
     {
         RangedWeapon.SetActive(true);
         character.AimingControllerIn = true;
     }
     if (Input.GetMouseButtonUp(1))
     {
         character.AimingControllerOut = true;
         Invoke("DropGun", 0.3f);
     }
     character.Aim();
     character.UpdateMove();
     if (Gun.gameObject.activeSelf)
     {
         if (character.IsAiming)
         {
             if (Input.GetMouseButton(0))
             {
                 animator.SetTrigger("Fire");
                 Gun.Fire();
             }
             if (Gun.weaponstate != GunFire.WeaponStatus.Loading && Input.GetKeyDown(KeyCode.R))
             {
                 Gun.Reload();
             }
         }
     }
 }
    IEnumerator OnTriggerEnter(Collider Player)
    {
        if (Player.gameObject.tag == "Player")
        {
            Debug.Log("Player picked up Ammo");

            // Check the gun is active in the scene
            if (player.GetComponent <WeaponSelect>().GunActive())
            {
                gun.Reload();                                                                                   // Do the reload animation
            }
            //ammo.CurrentAmmo += 10;                                   // Increase the ammo
            gc.GetComponent <ManageAmmo>().AddAmmo(10);                 // Increment the amount of ammo available
            pickupAudio.Play();                                         // Play pickup sound

            yield return(new WaitForSeconds(pickupAudio.clip.length));  // Wait for the sound to play then

            //Destroy(this.gameObject);                                 // Destory the collectable object
            gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("Player can pick up ammo after collecting gun");
        }
    }
示例#3
0
    IEnumerator OnTriggerEnter(Collider Player)
    {
        // if its level 1 and the objective isn't already marked complete, and the player has the gun
        if (SceneManager.GetActiveScene().buildIndex == 3 && !gc.GetComponent <ManageObjectives>().GetObjective2Complete() && gc.GetComponent <ManageObjectives>().GetObjective1Complete())
        {
            gc.GetComponent <ManageObjectives>().SetObjective2Complete(true);           // Mark objective 2 complete and increment completed objectives
        }
        //if (Player.gameObject.tag == "Player" && hasGun.activeInHierarchy)
        if (Player.gameObject.tag == "Player" && player.GetComponent <WeaponSelect>().GetHasGun())
        {
            Debug.Log("Player picked up Ammo");

            // Check the gun is active in the scene before calling the Reload() function
            if (Player.GetComponent <WeaponSelect>().GunActive())
            {
                gun.Reload();
            }

            //ammo.CurrentAmmo += 10;                                   // Increase the ammo
            //ammo.AddAmmo(10);											// Add 10 to ammo and animate text
            gc.GetComponent <ManageAmmo>().AddAmmo(ammoToAdd);          // Add 10 to ammo with animated text on HUD panel
            pickupAudio.Play();                                         // Play pickup sound

            yield return(new WaitForSeconds(pickupAudio.clip.length));  // Wait for the sound to play then

            //Destroy(this.gameObject);                                 // Destory the collectable object
            gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("Player can pick up ammo after collecting gun");
        }

        //if (numObjectives.getObjectiveCount () == 1) {				// If we are looking to complete the 2nd objective (pick up ammo)
        //	getAmmoObjective.SetActive (true);							// Mark the get ammo objective as complete
        //}
    }
    // Update is called once per frame
    void FixedUpdate()
    {
#if UNITY_ANDROID
        MoveInput = joystick.stickinput;

        Debug.Log(joystick.stickinput);

        character.InputMoveV = MoveInput.y;
        character.InputMoveH = MoveInput.x;
#else
        character.InputMoveV = Input.GetAxis("Vertical");
        character.InputMoveH = Input.GetAxis("Horizontal");
#endif


        if (Input.GetMouseButtonDown(1))
        {
            RangedWeapon.SetActive(true);
            character.AimingControllerIn = true;
        }
        if (Input.GetMouseButtonUp(1))
        {
            character.AimingControllerOut = true;
            Invoke("DropGun", 0.3f);
        }
        if (character.IsGrounded)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Debug.Log("Jump");
                character.Jump();
            }
        }
        if (character.InWall)
        {
            if (Input.GetKeyDown(KeyCode.B))
            {
                character.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero;
            }
            if (Input.GetKey(KeyCode.B))
            {
                character.Climb();
            }
        }



        character.Aim();
        character.UpdateMove();
        if (Gun.gameObject.activeSelf)
        {
            if (character.IsAiming)
            {
                if (Input.GetMouseButton(0))
                {
                    animator.SetTrigger("Fire");
                    Gun.Fire();
                }
                if (Gun.weaponstate != GunFire.WeaponStatus.Loading && Input.GetKeyDown(KeyCode.R))
                {
                    Gun.Reload();
                }
            }
        }
    }