1
This commit is contained in:
@@ -35,6 +35,19 @@ namespace BITFALL.Entities.Player.Movement
|
||||
|
||||
[SerializeField] private Transform fpvPoint;
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get => actor.Position;
|
||||
set=>actor.Position = value;
|
||||
}
|
||||
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get => actor.Rotation;
|
||||
set => actor.Rotation = value;
|
||||
}
|
||||
|
||||
public Vector3 Forward => actor.Forward;
|
||||
public Vector3 ViewCenter { get; set; }
|
||||
public Quaternion ViewRotation { get; set; }
|
||||
public Vector3 LocomotionBasedVelocity { get;private set; }
|
||||
@@ -230,6 +243,11 @@ namespace BITFALL.Entities.Player.Movement
|
||||
return;
|
||||
}
|
||||
|
||||
if (MovementInput.x is not 0 && MovementInput.z is 0)
|
||||
{
|
||||
TransitionState<Dodge>();
|
||||
return;
|
||||
}
|
||||
if (climbClosePoint.TryGetClosePoint(out var closePoint))
|
||||
{
|
||||
ExpectClimb.shouldBe = closePoint;
|
||||
@@ -345,15 +363,15 @@ namespace BITFALL.Entities.Player.Movement
|
||||
case < -16:
|
||||
entity.Invoke<DamageMessage>(new DamageMessage()
|
||||
{
|
||||
damage = value < -30 ? int.MaxValue : (int)math.abs(value) * 2 ,
|
||||
damageType = new GravityDamage(),
|
||||
location = new Location()
|
||||
Damage = value < -30 ? int.MaxValue : (int)math.abs(value) * 2 ,
|
||||
DamageType = new GravityDamage(),
|
||||
Location = new Location()
|
||||
{
|
||||
position = actor.Position,
|
||||
rotation = actor.Rotation
|
||||
},
|
||||
initiator = entity,
|
||||
target = entity,
|
||||
Initiator = entity,
|
||||
Target = entity,
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -393,7 +411,8 @@ namespace BITFALL.Entities.Player.Movement
|
||||
|
||||
ViewRotation = rotation;
|
||||
|
||||
ViewCenter = additiveTransform.position + additiveTransform.forward;
|
||||
//ViewCenter = additiveTransform.position + additiveTransform.forward;
|
||||
ViewCenter = additiveTransform.position + Quaternion.Euler(LookInput) * Vector3.forward;
|
||||
}
|
||||
private float _stamina = 100;
|
||||
public float Stamina
|
||||
|
@@ -212,6 +212,55 @@ namespace BITFALL.Entities.Player.Movement.States
|
||||
characterController.CurrentCameraPosition.shouldBe = characterController.FpvLocalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class Dodge : PlayerCharacterState,IPlayerDodgeState
|
||||
{
|
||||
[SerializeField] private int costStamina = 10;
|
||||
[SerializeField] private AnimationCurve curve;
|
||||
[SerializeField] private float duration = 0.32f;
|
||||
private int direction;
|
||||
private float process;
|
||||
|
||||
[Inject] private IHealth _health;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_health.OnDamageFactory += OnDamageFactory;
|
||||
}
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
direction = characterController.MovementInput.x > 0 ? 1 : -1;
|
||||
process = 0;
|
||||
characterController.Stamina-= costStamina;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||
{
|
||||
currentVelocity = actor.transform.right * (direction * curve.Evaluate(process+=deltaTime / duration));
|
||||
}
|
||||
|
||||
public override void AfterUpdateMovement(float deltaTime)
|
||||
{
|
||||
if(process>=1)
|
||||
Exit();
|
||||
}
|
||||
|
||||
private int OnDamageFactory(DamageMessage msg, int currentDamage)
|
||||
{
|
||||
if (characterController.CurrentState is not IPlayerDodgeState || msg.Initiator is not Entity initiator)
|
||||
return currentDamage;
|
||||
var _direction = characterController.Position - initiator.transform.position;
|
||||
var verticalAngle = Vector3.Angle(initiator.transform.forward, _direction) - 90.0f;
|
||||
Debug.Log(verticalAngle);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Fixed:PlayerCharacterState,IPlayerFixedState
|
||||
{
|
||||
|
@@ -5,7 +5,6 @@ using System.Diagnostics;
|
||||
using BITFALL.Player.Movement;
|
||||
using BITKit.Entities;
|
||||
using BITKit.StateMachine;
|
||||
using Unity.SharpZipLib.Zip;
|
||||
using UnityEngine;
|
||||
// ReSharper disable UnassignedField.Global
|
||||
|
||||
@@ -51,6 +50,9 @@ namespace BITFALL.Player.Animation.States
|
||||
case IPlayerSprintState:
|
||||
animationController.TransitionState<Sprint>();
|
||||
break;
|
||||
default:
|
||||
animationController.TransitionState<Walk>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,8 @@
|
||||
"GUID:ef0bb553b58b90b488bdbe8672e3be0b",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:30cdc242b1ac6a944a460f4ab0b77b88",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:48ef04d98836e2640bf90b524bdff904"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Player.Inventory;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
@@ -10,34 +11,27 @@ namespace BITFALL.Player.Survival
|
||||
{
|
||||
public class PlayerEatService : EntityComponent
|
||||
{
|
||||
private IPlayerSurvivalService _survival;
|
||||
private IPlayerInventory _inventory;
|
||||
[Inject] private IPlayerSurvivalService _survival;
|
||||
[Inject] private IEntityInventory _inventory;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
_inventory = entity.Get<IPlayerInventory>();
|
||||
_inventory.OnUseItem += OnUseItem;
|
||||
_survival = entity.Get<IPlayerSurvivalService>();
|
||||
_inventory.OnUsedItem += OnUseItem;
|
||||
}
|
||||
|
||||
private bool OnUseItem(IBasicItem arg)
|
||||
private void OnUseItem(IBasicItem arg)
|
||||
{
|
||||
var used = false;
|
||||
if (arg.GetAssetable().TryGetProperty<PlayerEatAddHunger>(out var addHunger) &&
|
||||
_survival.Elements.TryGetAny(x => x is PlayerSurvivalHunger, out var element))
|
||||
{
|
||||
if (arg.GetAssetable().TryGetProperty<PlayerEatAddHunger>(out var addHunger) &&
|
||||
_survival.Elements.TryGetAny(x => x is PlayerSurvivalHunger, out var element))
|
||||
{
|
||||
element.Value += addHunger.Value;
|
||||
used = true;
|
||||
}
|
||||
if (arg.GetAssetable().TryGetProperty<PlayerEatAddThirst>(out var addThirst) &&
|
||||
_survival.Elements.TryGetAny(x => x is PlayerSurvivalThirst, out element))
|
||||
{
|
||||
element.Value += addThirst.Value;
|
||||
used = true;
|
||||
}
|
||||
element.Value += addHunger.Value;
|
||||
}
|
||||
|
||||
if (arg.GetAssetable().TryGetProperty<PlayerEatAddThirst>(out var addThirst) &&
|
||||
_survival.Elements.TryGetAny(x => x is PlayerSurvivalThirst, out element))
|
||||
{
|
||||
element.Value += addThirst.Value;
|
||||
}
|
||||
return used;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,11 +26,24 @@ namespace BITFALL.Player.Survival
|
||||
public override void OnAwake()
|
||||
{
|
||||
Elements = initialElements;
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
}
|
||||
|
||||
private void OnSetAlive(bool obj)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
foreach (var VARIABLE in Elements)
|
||||
{
|
||||
VARIABLE.Value = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (_interval.AllowUpdate is false) return;
|
||||
if (_health.IsAlive is false) return;
|
||||
foreach (var x in Elements)
|
||||
{
|
||||
x.Value -= 1;
|
||||
@@ -38,12 +51,12 @@ namespace BITFALL.Player.Survival
|
||||
{
|
||||
_damageService.Execute(new DamageMessage()
|
||||
{
|
||||
damageType = new SurvivalDamage()
|
||||
DamageType = new SurvivalDamage()
|
||||
{
|
||||
element = x,
|
||||
},
|
||||
target = entity,
|
||||
damage = 1,
|
||||
Target = entity,
|
||||
Damage = 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user