基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
37
Assets/Feel/FeelDemos/Barbarians/Scripts/BarbarianEnemy.cs
Normal file
37
Assets/Feel/FeelDemos/Barbarians/Scripts/BarbarianEnemy.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feel
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple class used to handle enemies in Feel's Barbarian demo scene
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class BarbarianEnemy : MonoBehaviour
|
||||
{
|
||||
/// a feedback to play when getting damage
|
||||
public MMFeedbacks DamageFeedback;
|
||||
/// a cooldown, in seconds, during which the character can't be damaged
|
||||
public float DamageCooldown = 1f;
|
||||
|
||||
protected float _lastDamageTakenAt = -10f;
|
||||
|
||||
/// <summary>
|
||||
/// Applies damage to this character, if not in cooldown
|
||||
/// </summary>
|
||||
/// <param name="damage"></param>
|
||||
public virtual void TakeDamage(int damage)
|
||||
{
|
||||
// we make sure enough time has passed since the last time this enemy took damage
|
||||
if (Time.time - _lastDamageTakenAt < DamageCooldown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_lastDamageTakenAt = Time.time;
|
||||
DamageFeedback?.PlayFeedbacks(this.transform.position, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user