Ejemplo n.º 1
0
        public virtual void Init(bool isDefaultWeapon)
        {
            // Ignore the object taged as "LocalPlayer" so we won't shot ourself by accident.
            // Also ignore the object taged as "Respawn" because those respawn points has it's own collider for
            // detecting if any obstacle in the area.
            m_BulletLayerMask = ~(1 << LayerMask.NameToLayer("Player") | 1 << LayerMask.NameToLayer("Ignore Raycast"));
            // Is this the default weapon?
            m_DefaultWeapon = isDefaultWeapon;
            // Used to prevent gun switching while reloading and shooting.
            m_CanSwitchWeapon = false;
            // Return TRUE if the weapon is out of ammo or energy.
            m_OutOfAmmo = false;
            // Return TRUE if the weapon currenly is reloading ammo or energy.
            m_IsReloading = false;
            // Record the last fired time used for calculate fire rate.
            m_LastFiredTimeStamp = 0.0f;
            // The weapon will remian hiding until player pull it out.
            m_Phase = WeaponHoldingPhase.Hiding;
            // Fill the cilp.
            m_BulletsLeftInClip = m_WeaponData.MagazineSize;
            // The magazines currently holding.
            m_MagazineLeft = m_WeaponData.MagazineCount;
            // Grab all the ammo as you can.
            m_RestBulletsCount = m_WeaponData.MagazineSize * m_MagazineLeft;
            // The gun is unsed, so the chamber is clean.
            m_OneRoundRemainInChamber = false;

            // Only the character which is control by the local client needs update the UI.
            if (photonView.isMine)
            {
                // The corss hair.
                m_CorssHair = UIframework.UIManager.Instance.GetUI <PlayerHUDUI>(UIframework.UIManager.SceneUIs.PlayerHUDUI).GetCorssHair;

                m_WeaponInfo = UIframework.UIManager.Instance.GetUI <PlayerHUDUI>(UIframework.UIManager.SceneUIs.PlayerHUDUI).GetWeaponInfo;

                if (isDefaultWeapon)
                {
                    // Update the weapon UI



                    m_WeaponInfo.UpdateWeaponInfo(AmmoState.Normal,
                                                  m_WeaponData.WeaponName,
                                                  m_BulletsLeftInClip,
                                                  m_RestBulletsCount,
                                                  m_WeaponData.MagazineSize,
                                                  m_DefaultWeapon);
                }
            }

            #region Muzzle flash light and sprite.
            // Turn off the muzzle flash light at beginning.
            m_MuzzleFlash.MuzzleFlashLight.enabled = false;
            // Initialize light setting.
            m_MuzzleFlash.MuzzleFlashLight.intensity = m_MuzzleFlash.MuzzleFlashLightIntensity;
            m_MuzzleFlash.MuzzleFlashLight.range     = m_MuzzleFlash.MuzzleFlashLigthRange;

            m_MuzzleFlash.ShowSideMuzzleFlashSprite(false);
            m_MuzzleFlash.ShowFrontMuzzleFlashSprite(false);
            #endregion

            // Hide the weapon at the beginning of the game.
            DisplayWeaponModel(false);
        }
Ejemplo n.º 2
0
 void OnEnable()
 {
     Instance = this;
 }
Ejemplo n.º 3
0
 private void Awake()
 {
     Instance = this;
 }