Example #1
0
    /// <summary>
    /// this callback is triggered when the activity in question
    /// deactivates
    /// </summary>
    protected virtual void OnStop_SetWeapon()
    {
        // fetch weapon index from when 'SetWeapon.TryStart' was called
        int weapon = (int)m_Player.SetWeapon.Argument;

        // hides the old weapon and activates the new one (at its exit offset)
        SetWeapon(weapon);

        // smoothly moves the new weapon into view and plays a wield sound
        if (m_CurrentWeapon != null)
        {
            m_CurrentWeapon.Wield();
        }

        // make all player components resume their states from before
        // the weapon switch
        vp_Timer.In(SetWeaponRefreshStatesDelay, delegate()
        {
            m_Player.RefreshActivityStates();

            if (m_CurrentWeapon != null)
            {
                if (m_Player.CurrentWeaponAmmoCount.Get() == 0)
                {
                    // the weapon came empty, but if we have ammo clips for it,
                    // try reloading in 0.5 secs
                    m_Player.AutoReload.Try();                          // try to auto-reload
                }
            }
        }, m_SetWeaponRefreshTimer);
    }
Example #2
0
    /// <summary>
    /// various camera and weapon resets
    /// </summary>
    protected override void Reset()
    {
        base.Reset();

        PlayerEventHandler.RefreshActivityStates();
        WeaponHandler.SetWeapon(0);

        PlayerEventHandler.CameraEarthQuake.Stop();
        Camera.BobStepCallback = null;
        Camera.SnapSprings();
        if (WeaponHandler.CurrentWeapon != null)
        {
            ((vp_FPWeapon)WeaponHandler.CurrentWeapon).SetPivotVisible(false);
            WeaponHandler.CurrentWeapon.SnapSprings();
            vp_Layer.Set(WeaponHandler.CurrentWeapon.gameObject, vp_Layer.Weapon, true);
        }

        if (Screen.width < 1024)
        {
            EditorPreviewSectionExpanded = false;
        }
        else
        {
            EditorPreviewSectionExpanded = true;
        }

        if (m_UnFreezePosition != Vector3.zero)
        {
            UnFreezePlayer();
        }
    }