2024-04-10 16:18:32 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
using Game.Player;
|
|
|
|
|
|
|
|
|
|
namespace Game.Room
|
2024-04-03 17:46:56 +08:00
|
|
|
|
{
|
2024-04-10 16:18:32 +08:00
|
|
|
|
[System.Serializable]
|
2024-04-03 17:46:56 +08:00
|
|
|
|
public class RoomData
|
|
|
|
|
{
|
2024-04-10 16:18:32 +08:00
|
|
|
|
private float jinBeiCountCache;
|
2024-05-05 17:02:33 +08:00
|
|
|
|
private List<IPlayer> _players;
|
2024-04-10 16:18:32 +08:00
|
|
|
|
|
|
|
|
|
public float jinBeiCount => this.jinBeiCountCache;
|
|
|
|
|
|
2024-05-05 17:02:33 +08:00
|
|
|
|
public IReadOnlyList<IPlayer> players => _players;
|
|
|
|
|
public RoomType roomType { get; }
|
2024-04-10 16:18:32 +08:00
|
|
|
|
|
2024-04-12 17:32:37 +08:00
|
|
|
|
public Action<float> jinBeiCallback;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-05-05 17:02:33 +08:00
|
|
|
|
public RoomData(RoomType roomType, float jinBei) // , Vector2 down, Vector2 up
|
2024-04-06 11:59:18 +08:00
|
|
|
|
{
|
2024-05-05 17:02:33 +08:00
|
|
|
|
this.jinBeiCountCache = jinBei;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
this.roomType = roomType;
|
2024-05-05 17:02:33 +08:00
|
|
|
|
_players = new List<IPlayer>();
|
2024-04-06 11:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
public void AddPlayer(IPlayer player)
|
|
|
|
|
{
|
2024-05-05 17:02:33 +08:00
|
|
|
|
this._players.Add(player);
|
2024-04-09 18:16:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-05 17:02:33 +08:00
|
|
|
|
public void RemovePlayer(IPlayer player)
|
2024-04-09 18:16:37 +08:00
|
|
|
|
{
|
2024-05-05 17:02:33 +08:00
|
|
|
|
if (this._players.Contains(player))
|
|
|
|
|
_players.Remove(player);
|
2024-04-10 16:18:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-05 17:02:33 +08:00
|
|
|
|
public bool RefreshMoney(float jinBei)
|
2024-04-10 16:18:32 +08:00
|
|
|
|
{
|
2024-05-05 17:02:33 +08:00
|
|
|
|
jinBeiCountCache = jinBei;
|
|
|
|
|
UpdateJinBei();
|
2024-04-10 16:18:32 +08:00
|
|
|
|
return false;
|
2024-04-09 18:16:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 16:18:32 +08:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
this.jinBeiCountCache = 0;
|
2024-05-05 17:02:33 +08:00
|
|
|
|
UpdateJinBei();
|
|
|
|
|
this._players.Clear();
|
2024-04-10 16:18:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-05 17:02:33 +08:00
|
|
|
|
void UpdateJinBei()
|
2024-04-10 16:18:32 +08:00
|
|
|
|
{
|
|
|
|
|
this.jinBeiCallback?.Invoke(this.jinBeiCountCache);
|
|
|
|
|
}
|
2024-04-06 11:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum RoomType
|
|
|
|
|
{
|
|
|
|
|
出生点 = 0,
|
|
|
|
|
伏龙阁,
|
|
|
|
|
杂物室,
|
|
|
|
|
沙慕龙阁,
|
|
|
|
|
圣龙残骸,
|
|
|
|
|
英雄圣殿,
|
|
|
|
|
先祖大厅,
|
|
|
|
|
天池遗址,
|
|
|
|
|
训练堂,
|
2024-04-03 17:46:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|