1
This commit is contained in:
44
Assets/Artists/Scripts/Props/Prop_Shield.cs
Normal file
44
Assets/Artists/Scripts/Props/Prop_Shield.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace BITFALL.Props
|
||||
{
|
||||
public class Prop_Shield : MonoBehaviour,IDamagable
|
||||
{
|
||||
[SerializeField] private SpringEulerAngle spring=new();
|
||||
[SerializeField] private Optional<int> maxSpring;
|
||||
public IUnityEntity UnityEntity => null;
|
||||
public Rigidbody Rigidbody => null;
|
||||
private Vector3 initialEulerAngles;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
initialEulerAngles = transform.localEulerAngles;
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
spring.Update(Time.fixedDeltaTime,initialEulerAngles);
|
||||
transform.localEulerAngles = spring.value;
|
||||
}
|
||||
public void GiveDamage(DamageMessage message)
|
||||
{
|
||||
var damage = message.Damage;
|
||||
if (maxSpring.Allow)
|
||||
{
|
||||
damage = Mathf.Min(damage, maxSpring.Value);
|
||||
}
|
||||
spring.value =initialEulerAngles + new Vector3(
|
||||
Random.Range(-damage, damage),
|
||||
Random.Range(-damage, damage),
|
||||
Random.Range(-damage, damage)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user