1
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
{
|
||||
"name": "BITFALL.Player.Equip"
|
||||
}
|
||||
"name": "BITFALL.Player.Equip",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -1,18 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class IEquipService : MonoBehaviour
|
||||
using BITKit;
|
||||
namespace BITFALL.Player.Equip
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public interface IEquipService
|
||||
{
|
||||
IOptional<float> Zoom { get; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "BITFALL.Player.Inventory",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
15
Assets/BITFALL/Player/Inventory/IPlayerInventory.cs
Normal file
15
Assets/BITFALL/Player/Inventory/IPlayerInventory.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Inventory
|
||||
{
|
||||
public interface IPlayerInventory
|
||||
{
|
||||
bool TryUseItem(IBasicItem item);
|
||||
event Func<IBasicItem, bool> OnUseItem;
|
||||
}
|
||||
}
|
||||
|
@@ -8,62 +8,34 @@ using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Survival
|
||||
{
|
||||
public interface IPlayerSurvivalService
|
||||
{
|
||||
IPlayerSurvivalElement[] Elements { get; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家生存接口
|
||||
/// </summary>
|
||||
public interface IPlayerSurvival
|
||||
public interface IPlayerSurvivalElement
|
||||
{
|
||||
/// <summary>
|
||||
/// 当玩家生存元素更新时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalState> OnSurvivalStateChanged;
|
||||
/// <summary>
|
||||
/// 当玩家进入状态时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalEvent> OnSurvivalEventOpened;
|
||||
/// <summary>
|
||||
/// 当玩家退出状态时
|
||||
/// </summary>
|
||||
event Action<IPlayerSurvivalEvent> OnSurvivalEventClosed;
|
||||
string Name { get; }
|
||||
public int Value { get; set; }
|
||||
event Action<int> OnValueChanged;
|
||||
}
|
||||
/// <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; }
|
||||
public abstract class PlayerSurvivalElement:IPlayerSurvivalElement{
|
||||
public virtual string Name=>GetType().Name;
|
||||
private int _value = 100;
|
||||
public int Value {
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
_value = Mathf.Clamp(value, 0, 100);
|
||||
OnValueChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
public event Action<int> OnValueChanged;
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class PlayerSurvivalHunger:PlayerSurvivalElement{}
|
||||
[Serializable]
|
||||
public sealed class PlayerSurvivalThirst:PlayerSurvivalElement{}
|
||||
}
|
||||
|
@@ -1,105 +0,0 @@
|
||||
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 =>"你饿了,找点东西吃吧";
|
||||
}
|
||||
}
|
30
Assets/BITFALL/Player/Survival/PlayerSurvivalProperty.cs
Normal file
30
Assets/BITFALL/Player/Survival/PlayerSurvivalProperty.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Survival
|
||||
{
|
||||
public abstract class PlayerEatAdd:IProperty
|
||||
{
|
||||
[SerializeField] private int value;
|
||||
public int Value => value;
|
||||
}
|
||||
[Serializable]
|
||||
public class PlayerEatAddHunger:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddThirst:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddHealth:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddStamina:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddEnergy:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddSanity:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddTemperature:PlayerEatAdd{}
|
||||
[Serializable]
|
||||
public class PlayerEatAddWetness:PlayerEatAdd{}
|
||||
}
|
Reference in New Issue
Block a user