상속: UnityEngine.MonoBehaviour
예제 #1
0
        public void ChangeWeapon(int weaponNumber)
        {

            Instantiate(mEquippedWeapon, new Vector3(transform.position.x, transform.position.y - 2.0f, transform.position.z), Quaternion.identity);
            //create a clone of the previous weapon just under the player
            //Destroy(InstantiatedWeapon, 3.0f);
            mEquippedWeapon = weaponList[weaponNumber];
            mEquippedWeapon.transform.position = transform.position;
            weaponList[weaponNumber].transform.SetParent(transform);
        }
예제 #2
0
        void Update()
        {
            playerScoreText.text = playerScore.ToString();


            if (isPlayerDead == true)
            {
                timeSpentDead += Time.deltaTime;
                if (timeSpentDead >= timeToRespawn)
                {
                    EnableAndShowPlayer();
                    isPlayerDead = false;
                    timeSpentDead = 0f;
                }
            }

            //if L3 is held, the HUD will appear
            //if (Input.GetButton("Player_" + mPlayerNumber + "_Back"))
            //{
            //    playerHUD.SetActive(true);
            //}
            //else
            //{
            //    playerHUD.SetActive(false);
            //}

            waitTime -= Time.deltaTime;
            if (mEquippedWeapon)
            {
                if (GetComponent<ShellShock.Aiming>().AimDirection.magnitude > 0.9)
                {   //if the fire button is pressed, fire the gun.
                    if (Input.GetButton("Player_" + mPlayerNumber + "_Fire1") && !isPlayerDead)
                    {
                        if (mEquippedWeapon.RemainingAmmo >= 0)
                        {
                            ammoSlider.value = (float)mEquippedWeapon.RemainingAmmo / (float)mEquippedWeapon.MaximumAmmo;
                        }
                        //emit the bullet casing particle system
                        minigunParticleSystem.Emit(1);

                        if (!mEquippedWeapon.Shoot(GetComponent<ShellShock.Aiming>().CorrectedAimDirection, mPlayerNumber))
                        {
                            mEquippedWeapon = null;
                        }
                    }
                }
            }
        }
예제 #3
0
        public void ResetPlayerProperties()
        {
            //reset player's health
            mHealth = mMaxHealth;
            HPSlider.value = 1;
            ammoSlider.value = 1;
            //equip the player with a fully loaded pistol.
            mEquippedWeapon = playerPistol;
            mEquippedWeapon.RemainingAmmo = mEquippedWeapon.MaximumAmmo;

        }