Exemplo n.º 1
0
    //-----------------------------------------------------------------------------------------------------------------
    //-----------------------------------------------------------------------------------------------------------------
    void ServerShootAtTarget()
    {
        // sfx/gfx effects...

        /*Vector3  rot = m_MuzzleOriginalRot;
         * Vector3  scl = m_MuzzleOriginalScale;
         *
         * rot.z += Random.Range( -MuzzleRotLimit, +MuzzleRotLimit );
         * scl   += Vector3.one * Random.Range( -MuzzleScaleLimit, +MuzzleScaleLimit );
         *
         * n_Muzzle.SetActive(true);
         * m_PartsSettings.m_Muzzle.localRotation     = Quaternion.Euler( rot );
         * m_PartsSettings.m_Muzzle.localScale        = scl;
         *
         * //Audio.PlayOneShot( m_SndSettings.m_Fire );
         */
        // spawn projectile...

        Vector3 dir = MathUtils.RandomVectorInsideCone(m_AimDir, m_WpnSettings.m_Dispersion);

        ProjectileManager.Instance.SpawnProjectile(m_WpnSettings.m_ProjType,
                                                   m_PartsSettings.m_Muzzle.position,
                                                   dir,
                                                   m_ProjInitSettings);

//		NetworkView.RPC("ClientFire", uLink.RPCMode.Others, dir);
        NetworkView.UnreliableRPC("ClientFire", uLink.RPCMode.Others, dir);

        // update timer(s)...
        m_NextShotTime   = m_WpnSettings.m_FireRate;
        m_ShotEffectTime = m_WpnSettings.m_FireEffectTime;

        if (--m_AmmoClip == 0)
        {
            // schedule reload
            if (m_AmmoRemaining > 0)
            {
                m_ReloadTime = m_WpnSettings.m_ReloadDelay;
            }
            // out-of-ammo ==> deactivate weapon
            else
            {
                float rV = MathUtils.InRange(m_AimSettings.m_VRange, 0.0f, 360.0f) ? m_AimSettings.m_VRange / 2.0f : 0.0f;

                m_HMotor.TargetAngle = m_InitHAngle;
                m_VMotor.TargetAngle = m_InitVAngle - Mathf.Deg2Rad * rV;

                //m_Deactivated    = true;
                m_Target.m_Agent = null;

                if (uLink.Network.isServer)
                {
                    Invoke("OnDeactivation", m_Deactivation.m_Delay);
                }
            }
        }
    }