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