using System; using System.Collections.Generic; using Game.Player; namespace Game.Room { [System.Serializable] public class RoomData { private float jinBeiCountCache; private List _players; public float jinBeiCount => this.jinBeiCountCache; public IReadOnlyList players => _players; public RoomType roomType { get; } public Action jinBeiCallback; public RoomData(RoomType roomType, float jinBei) // , Vector2 down, Vector2 up { this.jinBeiCountCache = jinBei; this.roomType = roomType; _players = new List(); } 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, 伏龙阁, 杂物室, 沙慕龙阁, 圣龙残骸, 英雄圣殿, 先祖大厅, 天池遗址, 训练堂, } }