1
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
"GUID:9354affc93e0f3e4a904785e7d4c0f59",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:8d74bfb2f67c5c14a810215b78383d40",
|
||||
"GUID:1235ca61e7f433b408ed5a68767e7123"
|
||||
"GUID:1235ca61e7f433b408ed5a68767e7123",
|
||||
"GUID:96f476e982d6fb945bfc9140ba094b7f",
|
||||
"GUID:87bea3a21c744b1478660b70494160ba"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
31
Assets/Artists/Scripts/Feel/EntityHealthBlender.cs
Normal file
31
Assets/Artists/Scripts/Feel/EntityHealthBlender.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Feel
|
||||
{
|
||||
public sealed class EntityHealthBlender : EntityBehavior
|
||||
{
|
||||
[SerializeField] private Renderer[] _renderers;
|
||||
[Inject] private IHealth _health;
|
||||
private static readonly int Blend = Shader.PropertyToID("_Blend");
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
_health.OnSetHealthPoint += OnSetHealthPoint;
|
||||
}
|
||||
|
||||
private void OnSetHealthPoint(int obj)
|
||||
{
|
||||
var blend =1- Mathf.Clamp01(obj / (float)_health.MaxHealthPoint);
|
||||
foreach (var x in _renderers)
|
||||
{
|
||||
x.material.SetFloat(Blend, blend);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Entities;
|
||||
using BITFALL.Player.Equip;
|
||||
using BITFALL.Player.Movement;
|
||||
using BITKit;
|
||||
using BITKit.Animations;
|
||||
@@ -17,6 +18,8 @@ namespace BITFALL.Feel
|
||||
private IPlayerMovement _playerMovement;
|
||||
[Inject]
|
||||
private IKnockdown _knockdown;
|
||||
[Inject]
|
||||
private IEquipService _equipService;
|
||||
public override void OnStart()
|
||||
{
|
||||
_playerMovement.OnParachuteOpened += OnParachuteOpened;
|
||||
@@ -24,11 +27,17 @@ namespace BITFALL.Feel
|
||||
|
||||
_knockdown.OnKnockdown += OnKnockdown;
|
||||
}
|
||||
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
base.OnUpdate(deltaTime);
|
||||
_equipService.AllowEquip.SetDisableElements(this,animator[0].stateName != BITConstant.Player.Idle);
|
||||
}
|
||||
|
||||
private void OnKnockdown()
|
||||
{
|
||||
animator.Play("OnKnockdown");
|
||||
}
|
||||
|
||||
private void OnParachuteClosed()
|
||||
{
|
||||
animator.Play("OnParachuteClosed");
|
||||
|
Reference in New Issue
Block a user