Frame/Assets/Scripts/Dinosaurs/Room/RoomData.cs

70 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using Game.Player;
namespace Game.Room
{
[System.Serializable]
public class RoomData
{
private float jinBeiCountCache;
private List<IPlayer> _players;
public float jinBeiCount => this.jinBeiCountCache;
public IReadOnlyList<IPlayer> players => _players;
public RoomType roomType { get; }
public Action<float> jinBeiCallback;
public RoomData(RoomType roomType, float jinBei) // , Vector2 down, Vector2 up
{
this.jinBeiCountCache = jinBei;
this.roomType = roomType;
_players = new List<IPlayer>();
}
public void AddPlayer(IPlayer player)
{
this._players.Add(player);
}
public void RemovePlayer(IPlayer player)
{
if (this._players.Contains(player))
_players.Remove(player);
}
public bool RefreshMoney(float jinBei)
{
jinBeiCountCache = jinBei;
UpdateJinBei();
return false;
}
public void Reset()
{
this.jinBeiCountCache = 0;
UpdateJinBei();
this._players.Clear();
}
void UpdateJinBei()
{
this.jinBeiCallback?.Invoke(this.jinBeiCountCache);
}
}
public enum RoomType
{
= 0,
,
,
,
,
殿,
,
,
,
}
}