1
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:ea5474181b324dd49a5976cd68f44f18",
|
||||
"GUID:bea3628e8b592ae47ade218cb9ec98db"
|
||||
"GUID:bea3628e8b592ae47ade218cb9ec98db",
|
||||
"GUID:8d74bfb2f67c5c14a810215b78383d40"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -26,7 +26,7 @@ namespace BITFALL.Props
|
||||
{
|
||||
damagable.GiveDamage(new DamageMessage()
|
||||
{
|
||||
Target = damagable.Entity,
|
||||
Target = damagable.UnityEntity,
|
||||
Damage = damage,
|
||||
Location = new Location()
|
||||
{
|
||||
|
Reference in New Issue
Block a user