This commit is contained in:
CortexCore
2023-10-02 23:24:56 +08:00
parent 8ef5c7ec0a
commit 947e52e748
183 changed files with 107857 additions and 9378 deletions

View File

@@ -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
}

View File

@@ -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; }
}
}

View File

@@ -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
}

View 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;
}
}

View File

@@ -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{}
}

View File

@@ -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 =>"你饿了,找点东西吃吧";
}
}

View 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{}
}