类银河恶魔城 P16-3Game pause & Dead zone& Invincibility in the time of dash
PlayerDashState.cs
public override void Enter(){ base.Enter(); //SkillManager.instance.clone.CreatClone(player.transform); //player.skill.clone.CreatClone(player.transform, Vector3.zero); //player.skill.clone.CreateCloneOnDashStart(); player.skill.dash.CloneOnDash(); stateTimer = player.dashDuration; player.stats.MakeInvincible(true);}public override void Exit(){ base.Exit(); player.skill.dash.CloneOnArrival(); //player.skill.clone.CreateCloneOnDashOver(); player.SetVelocity(0,rb.velocity.y); player.stats.MakeInvincible(false);}
public bool isInvincible { get; private set; }public virtual void TakeDamage(int _damage){ if (isInvincible) return; DecreaseHealthBy(_damage); //Debug.Log(_damage); GetComponent().DamageImpact(); fx.StartCoroutine(\"FlashFX\"); if (currentHealth isInvincible = _invicible;
EnemyStats.cs
protected override void Die() { base.Die(); enemy.Die(); PlayerManager.instance.currency += soulsDropAmount.GetValue(); myDropSystem.GenerateDrop(); Destroy(gameObject, 5f); }
DeadZone.cs
using System.Collections;using System.Collections.Generic;using UnityEngine;public class DeadZone : MonoBehaviour{ private void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent() != null ) collision.GetComponent().KillEntity(); else Destroy(collision.gameObject); }}
注:在MainMenu场景中,将Canvas-DarkScreen-Animator-UpdateMode 变更为Unscaled time