コード例 #1
0
    void DestroyEnemy()
    {
        CameraShakeManager.Shake();

        Destroy(gameObject);
        GameObject effect = Instantiate(destroyG, transform.position, Quaternion.identity) as GameObject;

        Destroy(effect, 0.5f);
    }
コード例 #2
0
 /// <summary>
 /// 手动创建单例,不会重复的
 /// </summary>
 public static void TrySpawn()
 {
     if (!_instance)
     {
         var go = new GameObject("_CameraShakeManager");
         DontDestroyOnLoad(go);
         _instance = go.AddComponent <CameraShakeManager>(); //这时候会触发Awake()
     }
 }
コード例 #3
0
    void Update()
    {
        gK = glitchesKilled;
        bK = bugsKilled;

        if (HopeScript.hope <= 0)
        {
            isPlayerGonnaDie = true;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            CameraShakeManager.Shake();
            SoundManager.PlaySound("shoot");
            FireBullet();
        }


        if (Input.GetKeyDown(KeyCode.UpArrow) && isGrounded)
        {
            playerAnimator.SetTrigger("takeOff");
            rb.velocity = Vector2.up * jumpHeight;
        }

        if (isGrounded)
        {
            playerAnimator.SetBool("isJumping", false);
        }
        else if (!isGrounded)
        {
            playerAnimator.SetBool("isJumping", true);
        }

        if (moveInput == 0)
        {
            playerAnimator.SetBool("isRunning", false);
        }
        else
        {
            playerAnimator.SetBool("isRunning", true);
        }
    }
コード例 #4
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        cinemachineBasicMultiChannelPerlinTop = cinemachineVirtualCamera.GetRig(0)
                                                .GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>();

        cinemachineBasicMultiChannelPerlinMiddle = cinemachineVirtualCamera.GetRig(1)
                                                   .GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>();

        cinemachineBasicMultiChannelPerlinBottom = cinemachineVirtualCamera.GetRig(2)
                                                   .GetCinemachineComponent <CinemachineBasicMultiChannelPerlin>();
    }
コード例 #5
0
    //public static List<Module> modulesList;
    //public static List<GameObject> weaponsList;
    //public static List<GameObject> deployablesList;

    // Start is called before the first frame update
    void Awake()
    {
        camShakeManager = GetComponent <CameraShakeManager>();
        clock           = GetComponent <Clock>();
        data            = GetComponent <DataManager>();
    }
コード例 #6
0
 private void Start()
 {
     m_cameraShake = GameObject.FindGameObjectWithTag("CameraShake").
                     GetComponent <CameraShakeManager>();
 }
コード例 #7
0
 /// <summary>
 /// Initialize singleton.
 /// </summary>
 void Awake()
 {
     m_instance = this;
 }
コード例 #8
0
    private void TriggerEffects(PlayerBaseAttackLogic attackLogic, uint damage, EAttackResult attackResult, EHitNotificationType hitNotificationType)
    {
        Profiler.BeginSample("PlayerHealthComponent.TriggerEffects");
        PlayerAttack attack = attackLogic.GetAttack();
        bool         isDead = IsDead();

        // No stun neither pushback when an attack is parried
        if (attackResult != EAttackResult.Parried)
        {
            if (attackLogic.CanStunOnDamage())
            {
                m_StunInfoSC.StartStun(attackLogic, attackResult);
            }

            // If stun duration is not anim driven, we can set the duration and apply a pushback
            if (!m_StunInfoSC.IsStunDurationAnimDriven())
            {
                if (attackLogic.CanStunOnDamage())
                {
                    float stunDuration = attackLogic.GetStunDuration(attackResult);
                    if (stunDuration > 0f)
                    {
                        m_StunInfoSC.SetStunDuration(attackLogic, stunDuration);
                    }
                }

                if (attackLogic.CanPushBack())
                {
                    float pushBackForce = attackLogic.GetPushBackForce(attackResult);
                    if (pushBackForce > 0.0f && m_MovementComponent)
                    {
                        if (isDead)
                        {
                            pushBackForce *= AttackConfig.Instance.m_OnDeathPushbackMultiplier;
                        }
                        m_MovementComponent.PushBack(pushBackForce);
                    }
                }
            }
        }

        PlayerSuperGaugeSubComponent superGaugeSC = m_AttackComponent.GetSuperGaugeSubComponent();

        if (superGaugeSC != null)
        {
            superGaugeSC.IncreaseGaugeValue(AttackConfig.Instance.m_DefenderSuperGaugeBonus);
        }

        if (attackResult == EAttackResult.Hit)
        {
            m_StunInfoSC.IncreaseGaugeValue(attackLogic.GetStunGaugeHitAmount());
        }

        TimeScaleParams timeScaleParams = null;

        if (isDead)
        {
            timeScaleParams = AttackConfig.Instance.m_OnDeathTimeScaleParams;
        }
        else if (attack.m_UseTimeScaleEffect)
        {
            timeScaleParams = attack.m_TimeScaleParams;
        }

        if (timeScaleParams != null)
        {
            ChronicleManager.AddChronicle(gameObject, EChronicleCategory.Health, "StartTimeScale - Amount: " + timeScaleParams.m_TimeScaleAmount + " Duration: " + timeScaleParams.m_TimeScaleDuration);
            m_TimeScaleManager.StartTimeScale(timeScaleParams);
            if (timeScaleParams.m_TimeScaleAmount == 0f)
            {
                TriggerHitStopShake(timeScaleParams.m_TimeScaleDuration);
            }
        }

        if (!attackLogic.GetLastHitPoint(out Vector3 hitPoint))
        {
            hitPoint = attackLogic.GetOwner().transform.position;
        }

        if (attackResult != EAttackResult.Blocked)
        {
            if (attack.m_UseCameraShakeEffect || isDead)
            {
                Vector3           hitDirection        = (transform.position - attackLogic.GetOwner().transform.position).normalized;
                CameraShakeParams camShakeParamsToUse = isDead ? AttackConfig.Instance.m_OnDeathCamShakeParams : attack.m_CameraShakeParams;
                CameraShakeManager.GenerateImpulseAt(camShakeParamsToUse, hitPoint, hitDirection);
            }
        }

        TriggerHitFX(attackLogic, hitPoint, attackResult, hitNotificationType);
        PlayHitSFX(attackLogic, attackResult, hitNotificationType);

        Profiler.EndSample();
    }
コード例 #9
0
 /// <summary>
 /// Initialize singleton.
 /// </summary>
 void Awake()
 {
     m_instance = this;
     m_camera   = GetComponent <Camera>();
 }