1
This commit is contained in:
3
Assets/BITFALL/Player/Equip/BITFALL.Player.Equip.asmdef
Normal file
3
Assets/BITFALL/Player/Equip/BITFALL.Player.Equip.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "BITFALL.Player.Equip"
|
||||
}
|
18
Assets/BITFALL/Player/Equip/IEquipService.cs
Normal file
18
Assets/BITFALL/Player/Equip/IEquipService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class IEquipService : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"name": "BITFALL.Player.Movement",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"references": [
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
|
12
Assets/BITFALL/Player/Movement/IPlayerMovement.cs
Normal file
12
Assets/BITFALL/Player/Movement/IPlayerMovement.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace BITFALL.Player.Movement
|
||||
{
|
||||
public interface IPlayerMovement
|
||||
{
|
||||
void AddViewEuler(float2 euler);
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,23 @@
|
||||
namespace BITFALL.Player.Movement
|
||||
{
|
||||
public struct PlayerCancelRunCommand{}
|
||||
public struct PlayerDisableRunCommand
|
||||
{
|
||||
public readonly object Lock;
|
||||
public PlayerDisableRunCommand(object @lock)
|
||||
{
|
||||
Lock = @lock;
|
||||
}
|
||||
}
|
||||
public struct PlayerEnableRunCommand
|
||||
{
|
||||
public readonly object Lock;
|
||||
public PlayerEnableRunCommand(object @lock)
|
||||
{
|
||||
Lock = @lock;
|
||||
}
|
||||
}
|
||||
public struct OnPlayerJumpCommand{}
|
||||
public struct OnPlayerLandCommand{}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITFALL.Player.Survival",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
69
Assets/BITFALL/Player/Survival/IPlayerSurvival.cs
Normal file
69
Assets/BITFALL/Player/Survival/IPlayerSurvival.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using BITKit;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Survival
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家生存接口
|
||||
/// </summary>
|
||||
public interface IPlayerSurvival
|
||||
{
|
||||
/// <summary>
|
||||
/// 当玩家生存元素更新时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalState> OnSurvivalStateChanged;
|
||||
/// <summary>
|
||||
/// 当玩家进入状态时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalEvent> OnSurvivalEventOpened;
|
||||
/// <summary>
|
||||
/// 当玩家退出状态时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalEvent> OnSurvivalEventClosed;
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家生存元素,例如生命值、饥饿值、水分值等
|
||||
/// </summary>
|
||||
public interface IPlayerSurvivalState
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
void OnStateInitialize();
|
||||
/// <summary>
|
||||
/// 初始化异步状态
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">取消令牌</param>
|
||||
/// <returns></returns>
|
||||
UniTask OnStateInitializeAsync(CancellationToken cancellationToken);
|
||||
/// <summary>
|
||||
/// 已完成初始化
|
||||
/// </summary>
|
||||
void OnStateInitialized();
|
||||
/// <summary>
|
||||
/// 处理状态,类似于Update
|
||||
/// </summary>
|
||||
void ProcessState();
|
||||
/// <summary>
|
||||
/// 尝试获取新的状态事件
|
||||
/// </summary>
|
||||
bool TryGetNewEvent(out IPlayerSurvivalEvent newState);
|
||||
/// <summary>
|
||||
/// 尝试获取已关闭的状态事件
|
||||
/// </summary>
|
||||
bool TryGetClosedEvent(out IPlayerSurvivalEvent closedState);
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家生存时间,例如饿了,渴了和生病了
|
||||
/// </summary>
|
||||
public interface IPlayerSurvivalEvent
|
||||
{
|
||||
string Title { get; }
|
||||
string Message { get; }
|
||||
}
|
||||
}
|
105
Assets/BITFALL/Player/Survival/PlayerSurvivalElement.cs
Normal file
105
Assets/BITFALL/Player/Survival/PlayerSurvivalElement.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using BITKit;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Survival
|
||||
{
|
||||
public abstract class PlayerSurvivalState:IPlayerSurvivalState
|
||||
{
|
||||
public virtual void OnStateInitialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual UniTask OnStateInitializeAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void OnStateInitialized()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void ProcessState()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool TryGetNewEvent(out IPlayerSurvivalEvent newState)
|
||||
{
|
||||
newState = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool TryGetClosedEvent(out IPlayerSurvivalEvent closedState)
|
||||
{
|
||||
closedState = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 递减的玩家生存状态
|
||||
/// </summary>
|
||||
public abstract class PlayerSurvivalDecrementState:PlayerSurvivalState
|
||||
{
|
||||
[SerializeField] protected int value;
|
||||
public override void ProcessState()
|
||||
{
|
||||
value = Mathf.Clamp(value - 1, 0, 100);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家饥饿值
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PlayerHunger : PlayerSurvivalDecrementState
|
||||
{
|
||||
private bool _isHungry;
|
||||
public override bool TryGetNewEvent(out IPlayerSurvivalEvent newState)
|
||||
{
|
||||
newState = null;
|
||||
if (_isHungry|| value >= 50) return false;
|
||||
_isHungry = true;
|
||||
newState = new PlayerFeelHungryEvent();
|
||||
BIT4Log.Log<PlayerHunger>("玩家饿了");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool TryGetClosedEvent(out IPlayerSurvivalEvent closedState)
|
||||
{
|
||||
if(_isHungry && value >= 50)
|
||||
{
|
||||
_isHungry = false;
|
||||
closedState = new PlayerFeelHungryEvent();
|
||||
BIT4Log.Log<PlayerHunger>("玩家不饿了");
|
||||
return true;
|
||||
}
|
||||
closedState = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家水分值
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PlayerHydration : PlayerSurvivalState
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家健康值
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PlayerHealth : PlayerSurvivalState
|
||||
{
|
||||
|
||||
}
|
||||
public class PlayerFeelHungryEvent : IPlayerSurvivalEvent
|
||||
{
|
||||
public string Title => "饿了";
|
||||
public string Message =>"你饿了,找点东西吃吧";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user