Inheritance: vp_Component
    ///////////////////////////////////////////////////////////
    // in 'Start' we do things that potentially depend on all
    // other components first having run their 'Awake' calls
    ///////////////////////////////////////////////////////////
    new void Start()
    {
        base.Start();

        // get hold of the FPSWeapon
        m_Weapon = transform.GetComponent <vp_FPSWeapon>();

        audio.playOnAwake  = false;
        audio.dopplerLevel = 0.0f;

        Refresh();
    }
    ///////////////////////////////////////////////////////////
    // hooks up the FPSCamera object to the inspector target
    ///////////////////////////////////////////////////////////
    void OnEnable()
    {
        m_Component = (vp_FPSWeapon)target;

        if (m_Persister == null)
        {
            m_Persister = new vp_ComponentPersister();
        }
        m_Persister.Component = m_Component;
        m_Persister.IsActive  = true;

        if (m_Component.DefaultState == null)
        {
            m_Component.RefreshDefaultState();
        }
    }
Beispiel #3
0
            public static bool Prefix(float fatigue)
            {
                PlayerManager            playerManager = GameManager.GetPlayerManagerComponent();
                ModAnimationStateMachine animation     = ModComponentUtils.ComponentUtils.GetComponent <ModAnimationStateMachine>(playerManager.m_ItemInHands);

                if (animation is null)
                {
                    return(true);
                }

                var          camera        = GameManager.GetVpFPSCamera();
                vp_FPSWeapon currentWeapon = camera.CurrentWeapon;

                if (currentWeapon != null)
                {
                    currentWeapon.ShakeSpeed     = 0.5f;
                    currentWeapon.ShakeAmplitude = MAX_SHAKE_AMPLITUDE * fatigue;
                }

                return(false);
            }
Beispiel #4
0
    ///////////////////////////////////////////////////////////
    // in 'Start' we do things that need to be run once at the
    // beginning, but potentially depend on all other scripts
    // first having run their 'Awake' calls.
    // NOTE: don't do anything here that depends on activity
    // in other 'Start' calls
    ///////////////////////////////////////////////////////////
    protected new void Start()
    {
        base.Start();

        // instantiate muzzleflash
        if (MuzzleFlashPrefab != null)
        {
            m_MuzzleFlash = (GameObject)Object.Instantiate(MuzzleFlashPrefab,
                                                           m_Camera.transform.position,
                                                           m_Camera.transform.rotation);
            m_MuzzleFlash.name             = transform.name + "MuzzleFlash";
            m_MuzzleFlash.transform.parent = m_Camera.transform;
        }

        // store a reference to the FPSWeapon
        m_Weapon = transform.GetComponent <vp_FPSWeapon>();

        // audio defaults
        audio.playOnAwake  = false;
        audio.dopplerLevel = 0.0f;

        Refresh();
    }
    ///////////////////////////////////////////////////////////
    // any child objects to the FPSCamera component are treated
    // as weapons. these are put in the 'm_Weapons' list in
    // alphabetical order. this method will first disable the
    // currently activated weapon, then activate the one with
    // index 'i'. if 'i' is zero, no child will be activated.
    ///////////////////////////////////////////////////////////
    public void SetWeapon(int i)
    {
        if (m_Weapons.Count < 1)
        {
            Debug.LogError("Error: Tried to set weapon with an empty weapon list.");
            return;
        }

        if (i < 0 || i > m_Weapons.Count)
        {
            Debug.LogError("Error: Weapon list does not have a weapon with index: " + i);
            return;
        }

        // clear current weapon, set all child objects inactive
        // and clear the shooter
        m_CurrentWeapon = null;
        foreach (Transform t in transform)
        {
            if (t.gameObject != m_WeaponCamera)
            {
                DeactivateWhenSilent(t);
            }
        }
        m_CurrentShooter = null;

        // activate the new weapon
        m_CurrentWeaponID = i;
        if (m_CurrentWeaponID > 0)
        {
            // set parent transform of new weapon active
            m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true);

            // store the components of the new weapon and shooter
            m_CurrentWeapon  = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon));
            m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter));

            // activate the new shooter and camera, and make sure the weapon
            // renderer is enabled
            if (m_CurrentWeapon != null)
            {
                if (m_CurrentShooter != null)
                {
                    if (m_CurrentShooter.MuzzleFlash != null)
                    {
                        m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true);
                    }
                }
                if (m_CurrentWeapon.gameObject.renderer != null)
                {
                    m_CurrentWeapon.gameObject.renderer.enabled = true;
                }

                CurrentWeapon.PositionOffset = CurrentWeapon.DefaultPosition;
                CurrentWeapon.RotationOffset = CurrentWeapon.DefaultRotation;

                m_CurrentWeapon.SetPivotVisible(false);
            }
        }


        Refresh();
    }
Beispiel #6
0
    ///////////////////////////////////////////////////////////
    // hooks up the FPSCamera object to the inspector target
    ///////////////////////////////////////////////////////////
    void OnEnable()
    {
        m_Component = (vp_FPSWeapon)target;

        EditorApplication.playmodeStateChanged = delegate()
        {
            vp_ComponentPreset.m_Component = (Component)target;
            vp_ComponentPersister.m_Component = (Component)target;
            vp_ComponentPersister.PlayModeCallback();
        };
    }
    ///////////////////////////////////////////////////////////
    // any child objects to the FPSCamera component are treated
    // as weapons. these are put in the 'm_Weapons' list in
    // alphabetical order. this method will first disable the
    // currently activated weapon, then activate the one with
    // index 'i'. if 'i' is zero, no child will be activated.
    ///////////////////////////////////////////////////////////
    public void SetWeapon(int i)
    {
        if (m_Weapons.Count < 1)
        {
            Debug.LogError("Error: Tried to set weapon with an empty weapon list.");
            return;
        }

        if (i < 0 || i > m_Weapons.Count)
        {
            Debug.LogError("Error: Weapon list does not have a weapon with index: " + i);
            return;
        }

        // clear current weapon, set all child objects inactive
        // and clear the shooter
        m_CurrentWeapon = null;
        foreach (Transform t in transform)
        {
            if(t.gameObject != m_WeaponCamera)
                DeactivateWhenSilent(t);
        }
        m_CurrentShooter = null;

        // activate the new weapon
        m_CurrentWeaponID = i;
        if (m_CurrentWeaponID > 0)
        {

            // set parent transform of new weapon active
            m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true);

            // store the components of the new weapon and shooter
            m_CurrentWeapon = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon));
            m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter));

            // activate the new shooter and camera, and make sure the weapon
            // renderer is enabled
            if (m_CurrentWeapon != null)
            {

                if (m_CurrentShooter != null)
                {
                    if (m_CurrentShooter.MuzzleFlash != null)
                        m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true);
                }
                if (m_CurrentWeapon.gameObject.renderer != null)
                    m_CurrentWeapon.gameObject.renderer.enabled = true;

                CurrentWeapon.PositionOffset = CurrentWeapon.DefaultPosition;
                CurrentWeapon.RotationOffset = CurrentWeapon.DefaultRotation;

                m_CurrentWeapon.SetPivotVisible(false);

            }

        }

        Refresh();
    }
Beispiel #8
0
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    void Start()
    {
        // get hold of the FPSWeapon
        m_Weapon = transform.GetComponent<vp_FPSWeapon>();

        audio.dopplerLevel = 0.0f;
    }
    ///////////////////////////////////////////////////////////
    // hooks up the FPSCamera object to the inspector target
    ///////////////////////////////////////////////////////////
    void OnEnable()
    {
        m_Component = (vp_FPSWeapon)target;

        if (m_Persister == null)
            m_Persister = new vp_ComponentPersister();
        m_Persister.Component = m_Component;
        m_Persister.IsActive = true;

        if (m_Component.DefaultState == null)
            m_Component.RefreshDefaultState();
    }
Beispiel #10
0
    ///////////////////////////////////////////////////////////
    // any child objects to the FPSCamera component are treated
    // as weapons. these are put in the 'm_Weapons' list in
    // alphabetical order. this method will first disable the
    // currently activated weapon, then activate the one with
    // index 'i'. if 'i' is zero, no child will be activated.
    ///////////////////////////////////////////////////////////
    public void SetWeapon(int i)
    {
        if (m_Weapons.Count < 1)
        {
            Debug.LogError("Error: Tried to set weapon with an empty weapon list.");
            return;
        }
        if (i < 0 || i > m_Weapons.Count)
        {
            Debug.LogError("Error: Weapon list does not have a weapon with index: " + i);
            return;
        }

        foreach (Transform t in transform)
        {
            t.gameObject.SetActiveRecursively(false);
        }

        m_CurrentWeaponID = i;

        if (m_CurrentWeaponID > 0)
        {
            m_Weapons[m_CurrentWeaponID - 1].transform.parent.gameObject.SetActiveRecursively(true);
            m_CurrentWeapon = (vp_FPSWeapon)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSWeapon));
            m_CurrentShooter = (vp_FPSShooter)m_Weapons[m_CurrentWeaponID - 1].GetComponentInChildren(typeof(vp_FPSShooter));

            if (m_CurrentWeapon != null)
            {
                if (m_CurrentWeapon.WeaponCamera != null)
                    m_CurrentWeapon.WeaponCamera.SetActiveRecursively(true);
                if (m_CurrentShooter != null)
                {
                    if (m_CurrentShooter.MuzzleFlash != null)
                        m_CurrentShooter.MuzzleFlash.SetActiveRecursively(true);
                }
                m_CurrentWeapon.SetPivotVisible(false);
            }
        }
    }
    ///////////////////////////////////////////////////////////
    // in 'Start' we do things that need to be run once at the
    // beginning, but potentially depend on all other scripts
    // first having run their 'Awake' calls.
    // NOTE: don't do anything here that depends on activity
    // in other 'Start' calls
    ///////////////////////////////////////////////////////////
    protected new void Start()
    {
        base.Start();

        // instantiate muzzleflash
        if (MuzzleFlashPrefab != null)
        {
            m_MuzzleFlash = (GameObject)Object.Instantiate(MuzzleFlashPrefab,
                                                            m_Camera.transform.position,
                                                            m_Camera.transform.rotation);
            m_MuzzleFlash.name = transform.name + "MuzzleFlash";
            m_MuzzleFlash.transform.parent = m_Camera.transform;
        }

        // store a reference to the FPSWeapon
        m_Weapon = transform.GetComponent<vp_FPSWeapon>();

        // audio defaults
        GetComponent<AudioSource>().playOnAwake = false;
        GetComponent<AudioSource>().dopplerLevel = 0.0f;

        _shotSounds = GetComponent<ShotSounds>();

        Refresh();
    }
    ///////////////////////////////////////////////////////////
    // in 'Start' we do things that potentially depend on all
    // other components first having run their 'Awake' calls
    ///////////////////////////////////////////////////////////
    new void Start()
    {
        base.Start();

        // get hold of the FPSWeapon
        m_Weapon = transform.GetComponent<vp_FPSWeapon>();

        audio.playOnAwake = false;
        audio.dopplerLevel = 0.0f;

        Refresh();
    }