using System.Collections.Generic; using Game.Player; using UnityEngine; namespace Game.Room; public interface IRoom { RoomData roomData { get; } RoomInfo roomInfo { get; } List players { get; } bool Join(IPlayer player); bool Quit(IPlayer player); float ClearAll(); void Dispose(); bool InvestmentJinbei(IPlayer player, float jinbei); } class Room : IRoom { private GameObject self; private RoomInfo _roomInfo; private RoomData _roomData; public RoomType roomType => this._roomData.roomType; public RoomData roomData => this._roomData; public RoomInfo roomInfo => this._roomInfo; public List players => this._roomData.players; public Room(RoomType roomType, GameObject roomGo) { this._roomData = new RoomData(roomType); // view this._roomInfo = roomGo.GetComponent(); this.self = roomGo; } public bool Join(IPlayer player) { if (this.players.Contains(player)) return false; this.players.Add(player); return true; } public bool Quit(IPlayer player) { if (!this.players.Contains(player)) return false; this.players.Remove(player); return true; } public float ClearAll() { this.players.Clear(); return this._roomData.jinbei; } public void Dispose() { throw new System.NotImplementedException(); } public bool InvestmentJinbei(IPlayer player, float jinbei) { if (!this.players.Contains(player)) return false; this._roomData.jinbei += jinbei; return true; } }