void DestroyEnemy() { CameraShakeManager.Shake(); Destroy(gameObject); GameObject effect = Instantiate(destroyG, transform.position, Quaternion.identity) as GameObject; Destroy(effect, 0.5f); }
/// <summary> /// 手动创建单例,不会重复的 /// </summary> public static void TrySpawn() { if (!_instance) { var go = new GameObject("_CameraShakeManager"); DontDestroyOnLoad(go); _instance = go.AddComponent <CameraShakeManager>(); //这时候会触发Awake() } }
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); } }
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>(); }
//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>(); }
private void Start() { m_cameraShake = GameObject.FindGameObjectWithTag("CameraShake"). GetComponent <CameraShakeManager>(); }
/// <summary> /// Initialize singleton. /// </summary> void Awake() { m_instance = this; }
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(); }
/// <summary> /// Initialize singleton. /// </summary> void Awake() { m_instance = this; m_camera = GetComponent <Camera>(); }