예제 #1
0
    public void Update()
    {
        if (f_FireDelay > 0f)
        {
            f_FireDelay -= Time.deltaTime;
            if (f_FireDelay < 0f)
            {
                f_FireDelay = 0f;
            }
        }

        if (WeaponState == WeaponState.Reloading)
        {
            Reload();
        }

        if (WeaponState == WeaponState.Enable)
        {
            if (f_WeaponState_Timer > 0f)
            {
                f_WeaponState_Timer -= Time.deltaTime;

                if (f_WeaponState_Timer <= 0f)
                {
                    f_WeaponState_Timer = 0f;

                    WeaponState = WeaponState.Ready;
                }

                // Rotate game object based on percentage
                float f_Perc = f_WeaponState_Timer / f_WeaponState_Timer_Max;

                UpdateWeaponPosition(f_Perc);
            }
        }
        else if (WeaponState == WeaponState.Disable)
        {
            if (f_WeaponState_Timer < f_WeaponState_Timer_Max)
            {
                // Begin adding to weaponstate timer.
                f_WeaponState_Timer += Time.deltaTime;

                // If capped out, set state to ready.
                if (f_WeaponState_Timer > f_WeaponState_Timer_Max)
                {
                    f_WeaponState_Timer = f_WeaponState_Timer_Max;

                    // Tell Weapon Manager we completed
                    WeaponManager.ReadyForNextWeapon();
                }

                // Rotate game object based on percentage.
                float f_Perc = f_WeaponState_Timer / f_WeaponState_Timer_Max;
                UpdateWeaponPosition(f_Perc);
            }
        }
    }
예제 #2
0
    public void SpawnPlayer()
    {
        // Player is no longer dead
        b_IsDead = false;

        #region Weapons
        // Reset weapons in Weapon Manager
        this_WeaponManager.DisableAllPrimaryGuns();

        // Reset 'Weapons Picked Up' list.
        WeaponsPickedUp = new bool[8];

        // Turn off all weapon icons
        for (int i_ = 0; i_ < 8; ++i_)
        {
            this_WeaponManager.WeaponHUDSetWeaponActive(i_, false);
        }

        // Give the player a shotgun
        PickWeaponUp(WeaponList.Shotgun);

        // Set player weapons
        this_WeaponManager.ReadyForNextWeapon();
        this_WeaponManager.Weapon = WeaponList.Shotgun;  // Current
        #endregion

        #region Colliders and position
        // Turn off player collider
        gameObject.GetComponent <Collider>().enabled = true;

        // Turn off player mesh renderer
        gameObject.GetComponent <MeshRenderer>().enabled = true;

        GameObject spawnPoint = this_SystemManager.PlayerRequestsSpawn(TeamColor);

        // Set Position and Rotation
        this_GameObject.transform.position = spawnPoint.transform.position;
        this_GameObject.transform.rotation = spawnPoint.transform.rotation;

        // Enable weapons (models)
        go_WeaponObject.SetActive(true);
        this_CameraObject.transform.Find("Visors").gameObject.SetActive(true);

        // Reset camera rotation
        f_VertAngle = 0f;
        #endregion

        #region Health and Armor
        // Reset health and armor
        i_Health = i_Health_Max;
        i_Armor  = i_Armor_Max / 2;

        // Reset health (and armor, for now)
        this_HealthManager.SetHealthBar(1.0f);
        this_HealthManager.SetArmorBar(i_Armor, i_Armor_Max);
        #endregion
    }