Pull request #5: Jason
Merge in CEGJ/ludumdare50 from jason to dev * commit 'd8289dce3f31a83e05a5c2ddb5cf9ea0823557c0': Reset blood loss to 3 Basic play replay game loop Lose blood overtime and switch to Dead state
This commit is contained in:
commit
ddccbf21a9
@ -1,5 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
//Could be a singleton
|
//Could be a singleton
|
||||||
public class GameFlowManager : MonoBehaviour {
|
public class GameFlowManager : MonoBehaviour {
|
||||||
@ -11,6 +12,7 @@ public class GameFlowManager : MonoBehaviour {
|
|||||||
public bool Paused { get; private set; } = true;
|
public bool Paused { get; private set; } = true;
|
||||||
public BaseState CurrentState { get; private set; } = null!;
|
public BaseState CurrentState { get; private set; } = null!;
|
||||||
bool lastStartButton;
|
bool lastStartButton;
|
||||||
|
bool lastAcceptButton;
|
||||||
|
|
||||||
#region Unity Messages
|
#region Unity Messages
|
||||||
void Awake() => CurrentState = new StartFlowState(this);
|
void Awake() => CurrentState = new StartFlowState(this);
|
||||||
@ -19,23 +21,29 @@ public class GameFlowManager : MonoBehaviour {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
void SetPause(bool value) {
|
void SetPause(bool value) {
|
||||||
|
Debug.Log($"Setting pause to {value}");
|
||||||
Paused = value;
|
Paused = value;
|
||||||
Time.timeScale = value ? 0f : 1f;
|
Time.timeScale = value ? 0f : 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GameOver() => SwitchState(new DeadFlowState(this));
|
||||||
|
|
||||||
#region Inputs
|
#region Inputs
|
||||||
public void OnStart(InputAction.CallbackContext ctx) {
|
public void OnStart(InputAction.CallbackContext ctx) {
|
||||||
//feels pretty redundant ^^'
|
if (!ctx.WasPressedThisFrame(ref lastStartButton))
|
||||||
bool newValue = ctx.ReadValueAsButton();
|
|
||||||
bool wasJustPressed = !lastStartButton && newValue;
|
|
||||||
lastStartButton = newValue;
|
|
||||||
|
|
||||||
if (!wasJustPressed)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (CurrentState is StartFlowState)
|
if (CurrentState is StartFlowState)
|
||||||
SwitchState(new GameplayFlowState(this));
|
SwitchState(new GameplayFlowState(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnAccept(InputAction.CallbackContext ctx) {
|
||||||
|
if (!ctx.WasPressedThisFrame(ref lastAcceptButton))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentState is DeadFlowState deadState)
|
||||||
|
deadState.ReloadGame();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region States
|
#region States
|
||||||
@ -88,8 +96,15 @@ public class GameFlowManager : MonoBehaviour {
|
|||||||
|
|
||||||
public override void EnterState() {
|
public override void EnterState() {
|
||||||
base.EnterState();
|
base.EnterState();
|
||||||
|
|
||||||
|
Debug.Log("You died!\nPress Accept to restart!");
|
||||||
gameFlowManager.SetPause(true);
|
gameFlowManager.SetPause(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReloadGame() {
|
||||||
|
Debug.Log("Reloading scene...");
|
||||||
|
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ PrefabInstance:
|
|||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.size
|
propertyPath: m_ActionEvents.Array.size
|
||||||
value: 15
|
value: 16
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_ActionId
|
propertyPath: m_ActionEvents.Array.data[13].m_ActionId
|
||||||
@ -418,6 +418,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_ActionId
|
propertyPath: m_ActionEvents.Array.data[14].m_ActionId
|
||||||
value: 01a06960-a379-49e3-9d58-9b7c8effcb3d
|
value: 01a06960-a379-49e3-9d58-9b7c8effcb3d
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_ActionId
|
||||||
|
value: 65aa4e67-f805-47b9-adc0-444ca0e0bec8
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_ActionName
|
propertyPath: m_ActionEvents.Array.data[13].m_ActionName
|
||||||
value: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder]
|
value: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder]
|
||||||
@ -426,6 +430,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_ActionName
|
propertyPath: m_ActionEvents.Array.data[14].m_ActionName
|
||||||
value: Player/Start[/XInputControllerWindows/start,/Keyboard/enter]
|
value: Player/Start[/XInputControllerWindows/start,/Keyboard/enter]
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_ActionName
|
||||||
|
value: Player/Accept[/XInputControllerWindows/buttonSouth,/XInputControllerWindows/start,/Keyboard/enter]
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.size
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.size
|
||||||
value: 1
|
value: 1
|
||||||
@ -434,6 +442,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.size
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.size
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
value: 0
|
value: 0
|
||||||
@ -442,6 +454,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
value:
|
value:
|
||||||
@ -450,6 +466,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 1359990806}
|
objectReference: {fileID: 1359990806}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1359990806}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
value: 2
|
value: 2
|
||||||
@ -458,6 +478,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
value: 2
|
value: 2
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
value: ChangeSelectedIcon
|
value: ChangeSelectedIcon
|
||||||
@ -466,6 +490,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
value: OnStart
|
value: OnStart
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: OnAccept
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
value: MinionBar, Assembly-CSharp
|
value: MinionBar, Assembly-CSharp
|
||||||
@ -474,6 +502,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
value: GameFlowManager, Assembly-CSharp
|
value: GameFlowManager, Assembly-CSharp
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: GameFlowManager, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
value: UnityEngine.Object, UnityEngine
|
value: UnityEngine.Object, UnityEngine
|
||||||
@ -482,6 +514,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
value: UnityEngine.Object, UnityEngine
|
value: UnityEngine.Object, UnityEngine
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1214567908930553477, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: m_ActionEvents.Array.data[15].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 1214567908930553592, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: gameFlowManager
|
propertyPath: gameFlowManager
|
||||||
value:
|
value:
|
||||||
@ -542,6 +578,10 @@ PrefabInstance:
|
|||||||
propertyPath: healthBar
|
propertyPath: healthBar
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 1464970062}
|
objectReference: {fileID: 1464970062}
|
||||||
|
- target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
|
propertyPath: playerStats
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 11400000, guid: 12a626b5a296d934ba078d222ad6ba98, type: 2}
|
||||||
- target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
- target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3}
|
||||||
propertyPath: gameFlowManager
|
propertyPath: gameFlowManager
|
||||||
value:
|
value:
|
||||||
|
|||||||
@ -2,11 +2,12 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class AIEntity : Entity
|
public class AIEntity : Entity
|
||||||
{
|
{
|
||||||
[SerializeField] AIStats stats = null!;
|
[FormerlySerializedAs("stats")] [SerializeField] AIStats AIStats = null!;
|
||||||
public string ennemyName {get; protected set; }
|
public string? ennemyName {get; protected set; }
|
||||||
|
|
||||||
abstract class BaseStateAI : BaseState{
|
abstract class BaseStateAI : BaseState{
|
||||||
protected AIEntity entity;
|
protected AIEntity entity;
|
||||||
@ -59,7 +60,7 @@ public class AIEntity : Entity
|
|||||||
if(distance < lastDist){
|
if(distance < lastDist){
|
||||||
lastDist = distance;
|
lastDist = distance;
|
||||||
chosenEntity = other;
|
chosenEntity = other;
|
||||||
if(lastDist <= entity.stats.closeEnough)break;
|
if(lastDist <= entity.AIStats.closeEnough)break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using UnityEngine;
|
|||||||
public class Entity : MonoBehaviour
|
public class Entity : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] [Required]
|
[SerializeField] [Required]
|
||||||
GameFlowManager gameFlowManager = null!;
|
protected GameFlowManager gameFlowManager = null!;
|
||||||
|
|
||||||
[field: SerializeField] [field: Required]
|
[field: SerializeField] [field: Required]
|
||||||
protected EntityStats stats { get; private set; }
|
protected EntityStats stats { get; private set; }
|
||||||
@ -34,6 +34,8 @@ public class Entity : MonoBehaviour
|
|||||||
attackTimer = attackCooldown;
|
attackTimer = attackCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Update() {}
|
||||||
|
|
||||||
protected virtual void FixedUpdate() {
|
protected virtual void FixedUpdate() {
|
||||||
//TODO sqrMagnitude?
|
//TODO sqrMagnitude?
|
||||||
if (beingPushed && rb.velocity.magnitude < stats.MinVelocityWhenPushed) {
|
if (beingPushed && rb.velocity.magnitude < stats.MinVelocityWhenPushed) {
|
||||||
@ -72,6 +74,7 @@ public class Entity : MonoBehaviour
|
|||||||
Health -= amount;
|
Health -= amount;
|
||||||
if(Health <= 0){
|
if(Health <= 0){
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
|
OnDied();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -94,4 +97,6 @@ public class Entity : MonoBehaviour
|
|||||||
beingPushed = true;
|
beingPushed = true;
|
||||||
rb.AddForce(impulse, ForceMode2D.Impulse);
|
rb.AddForce(impulse, ForceMode2D.Impulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDied() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,8 @@ public class Gladiator : AIEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
base.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,10 @@ public class Monster : AIEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
if(IsInAttackRange()){
|
if(IsInAttackRange()){
|
||||||
if(attackTimer >= attackCooldown){
|
if(attackTimer >= attackCooldown){
|
||||||
Attack();
|
Attack();
|
||||||
|
|||||||
@ -14,5 +14,4 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
movementSpeed: 3
|
movementSpeed: 3
|
||||||
suckSpeed: 1
|
suckSpeed: 1
|
||||||
safeZoneJumpDuration: 1.2
|
bloodLossRate: 3
|
||||||
safeZonePosition: {x: 0, y: 0, z: 0}
|
|
||||||
|
|||||||
@ -58,12 +58,7 @@ public class PlayerMovement : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void OnJump(InputAction.CallbackContext ctx) {
|
public void OnJump(InputAction.CallbackContext ctx) {
|
||||||
//feels pretty redundant ^^'
|
if (!ctx.WasPressedThisFrame(ref lastJumpButton))
|
||||||
bool newValue = ctx.ReadValueAsButton();
|
|
||||||
bool wasJustPressed = !lastJumpButton && newValue;
|
|
||||||
lastJumpButton = newValue;
|
|
||||||
|
|
||||||
if (!wasJustPressed)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gameFlowManager.Paused || safeZone == null)
|
if (gameFlowManager.Paused || safeZone == null)
|
||||||
|
|||||||
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
[CreateAssetMenu]
|
[CreateAssetMenu]
|
||||||
public class PlayerStats : ScriptableObject {
|
public class PlayerStats : ScriptableObject {
|
||||||
|
[field: SerializeField] [Min(0f)]
|
||||||
public float movementSpeed = 3f;
|
public float movementSpeed = 3f;
|
||||||
|
|
||||||
|
[field: SerializeField] [Min(0f)]
|
||||||
public float suckSpeed = 1f;
|
public float suckSpeed = 1f;
|
||||||
|
|
||||||
|
[field: SerializeField] [Min(0f)]
|
||||||
|
public float bloodLossRate = 1f;
|
||||||
}
|
}
|
||||||
11
Assets/Scripts/Utils.cs
Normal file
11
Assets/Scripts/Utils.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public static class Utils {
|
||||||
|
public static bool WasPressedThisFrame(this InputAction.CallbackContext ctx, ref bool lastValue) {
|
||||||
|
bool newValue = ctx.ReadValueAsButton();
|
||||||
|
bool wasJustPressed = !lastValue && newValue;
|
||||||
|
lastValue = newValue;
|
||||||
|
|
||||||
|
return wasJustPressed;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Utils.cs.meta
Normal file
3
Assets/Scripts/Utils.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1e5065f064a94fed9f3cc40edc9c60af
|
||||||
|
timeCreated: 1648920968
|
||||||
@ -2,6 +2,9 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class VampireEntity : Entity {
|
public class VampireEntity : Entity {
|
||||||
|
[SerializeField] [field: Required]
|
||||||
|
PlayerStats playerStats = null!;
|
||||||
|
|
||||||
[SerializeField] [Required]
|
[SerializeField] [Required]
|
||||||
HealthBar healthBar;
|
HealthBar healthBar;
|
||||||
[Min(10f)]
|
[Min(10f)]
|
||||||
@ -14,10 +17,21 @@ public class VampireEntity : Entity {
|
|||||||
initialHealth = Health;
|
initialHealth = Health;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update() {
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (gameFlowManager.Paused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TakeDamage(playerStats.bloodLossRate * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool TakeDamage(float amount) {
|
public override bool TakeDamage(float amount) {
|
||||||
bool stillAlive = base.TakeDamage(amount);
|
bool stillAlive = base.TakeDamage(amount);
|
||||||
healthBar.SetHealthFraction(Health / initialHealth);
|
healthBar.SetHealthFraction(Health / initialHealth);
|
||||||
|
|
||||||
return stillAlive;
|
return stillAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDied() => gameFlowManager.GameOver();
|
||||||
}
|
}
|
||||||
@ -49,6 +49,15 @@
|
|||||||
"processors": "",
|
"processors": "",
|
||||||
"interactions": "",
|
"interactions": "",
|
||||||
"initialStateCheck": false
|
"initialStateCheck": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Accept",
|
||||||
|
"type": "Button",
|
||||||
|
"id": "65aa4e67-f805-47b9-adc0-444ca0e0bec8",
|
||||||
|
"expectedControlType": "Button",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
@ -315,6 +324,39 @@
|
|||||||
"action": "Start",
|
"action": "Start",
|
||||||
"isComposite": false,
|
"isComposite": false,
|
||||||
"isPartOfComposite": false
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "6264d8cf-a124-4ae2-a851-5ce21b5b0306",
|
||||||
|
"path": "<Gamepad>/buttonSouth",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Gamepad",
|
||||||
|
"action": "Accept",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "23fc3eaa-8abb-4c1a-b706-4dd2c2e2b760",
|
||||||
|
"path": "<Gamepad>/start",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Gamepad",
|
||||||
|
"action": "Accept",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"id": "4ce4b7b9-060f-4582-ae33-ac536c61a411",
|
||||||
|
"path": "<Keyboard>/enter",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Keyboard&Mouse",
|
||||||
|
"action": "Accept",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user