类银河恶魔城 P16-3Game pause & Dead zone& Invincibility in the time of dash

PlayerDashState.cs

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);
}
cs 复制代码
public bool isInvincible { get; private set; }

public virtual void TakeDamage(int _damage)
{
    if (isInvincible)
        return;
    DecreaseHealthBy(_damage);
    //Debug.Log(_damage);
    GetComponent<Entity>().DamageImpact();
    fx.StartCoroutine("FlashFX");
    if (currentHealth < 0 && !isDead)
    {
        Die();
    }
}

    public void KillEntity()
    {
        if(!isDead)
            Die();
    }

    public void MakeInvincible(bool _invicible) => isInvincible = _invicible;

EnemyStats.cs

cs 复制代码
    protected override void Die()
    {
        base.Die();
        enemy.Die();

        PlayerManager.instance.currency += soulsDropAmount.GetValue();
        myDropSystem.GenerateDrop();

        Destroy(gameObject, 5f);
    }

DeadZone.cs

cs 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeadZone : MonoBehaviour
{
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent<CharacterStats>() != null )
            collision.GetComponent<CharacterStats>().KillEntity();
        else
            Destroy(collision.gameObject);
    }
}

注:在MainMenu场景中,将Canvas-DarkScreen-Animator-UpdateMode 变更为Unscaled time