Пример #1
0
    private void DoShakeForExplosion(Vector3 explosionPosition, ExplosionSettings explosionConfig)
    {
        // Do screen shake on main camera
        if (ScreenShakeController.s_InstanceExists)
        {
            ScreenShakeController shaker = ScreenShakeController.s_Instance;

            float shakeMagnitude = explosionConfig.shakeMagnitude;
            shaker.DoShake(explosionPosition, shakeMagnitude, m_ExplosionScreenShakeDuration, 0.0f, 1.0f);
        }
    }
Пример #2
0
        private void ExplodeBuilding()
        {
            isAlive = false;
            RpcExplodeBuilding();

            // Скриншейк
            if (ScreenShakeController.s_InstanceExists)
            {
                ScreenShakeController shaker = ScreenShakeController.s_Instance;

                shaker.DoShake(transform.position, magnitude, duration);
            }
        }
Пример #3
0
    private void Fire()
    {
        // Set the fired flag so only Fire is only called once.
        m_Fired = true;

        //Determine which shell we should fire.
        Shell shellToFire = GetShellType().GetComponent <Shell>();

        //Determine our firing solution based on our target location and power.

        Vector3 fireVector = CalculateFireVector(shellToFire, m_TargetFirePosition, m_FireTransform.position, m_CurrentLaunchForce, m_LaunchAngle);
        //Vector3 direction = m_TargetFirePosition - m_FireTransform.position;
        //Vector3 fireVector = m_CurrentLaunchForce * direction / direction.magnitude;

        // Get a random seed to associate with projectile on all clients.
        // This is specifically used for the cluster bomb and any debris spawns, to ensure that their
        // random velocities are identical
        int randSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue);

        // Immediately fire shell on client - this provides players with the necessary feedback they want
        FireVisualClientShell(fireVector, m_FireTransform.position, randSeed);
        myAcademy.AddRewardToPlayer(m_PlayerNumber, 1f);

        // Reset the launch force.  This is a precaution in case of missing button events.
        //m_CurrentLaunchAngle = m_MaxLaunchAngle;
        m_CurrentLaunchForce = m_MinLaunchForce;

        m_ReloadTime = m_RefireRate;

        // Small screenshake on client
        if (ScreenShakeController.s_InstanceExists)
        {
            ScreenShakeController shaker = ScreenShakeController.s_Instance;

            //float chargeAmount = Mathf.InverseLerp(m_MaxLaunchAngle, m_MinLaunchAngle, m_CurrentLaunchAngle);
            float chargeAmount = Mathf.InverseLerp(m_MaxLaunchForce, m_MinLaunchForce, m_CurrentLaunchForce);
            float magnitude    = Mathf.Lerp(m_ShootShakeMinMagnitude, m_ShootShakeMaxMagnitude, chargeAmount);
            // Scale magnitude
            shaker.DoShake(m_TargetFirePosition, magnitude, m_ShootShakeDuration);
        }

        m_RecoilTime = 1;
        Vector3 localVector = transform.InverseTransformVector(fireVector);

        m_RecoilDirection = new Vector2(-localVector.x, -localVector.z);
    }