public virtual void Start(StartGameParameters parameters) { Calendar = new Calendar( ); GameRule = parameters.EnviromentSetting; StartMoney = parameters.StartMoney; GameLenth = parameters.GameTime; foreach (Tuple <PlayerModelProxy, PlayerConsole> item in parameters.PlayerConfig) { Player player = new Player(item.Item1.Model, StartMoney); player.BankruptcyEvent += OnPlayerBankruptcy; GamePlayers.Add(player); break; } Calendar = new Calendar( ); Map = parameters.Map; StockMarket = new StockMarket( ); WinningCondition = parameters.WinningCondition; Status = GameStatus.Playing; }
public void AddPlayer(Player newPlayer) { if (newPlayer != null && newPlayer.PlayerClient != null) { newPlayer.InitMap(SizeX, SizeY); newPlayer.PlayerClient.GiveMapSizeToClient(SizeX, SizeY); GamePlayers.Add(newPlayer.PlayerClient.ClientName, newPlayer); } }
/// <summary> /// 初始化 /// </summary> /// <param name="gameInput"></param> /// <returns></returns> public async override Task <bool> Init(GameInput gameInput) { if (!IsFullPlayer) { return(false); } if (GamePlayers.Count > 0) { return(true); } int index = 1; foreach (var item in BaseInfos) { GamePlayers.Add(new FiveGamePlayer() { PlayerId = item.Id, PlayerNickName = item.Name, Number = 0, Index = index++ }); } DoPlayer = GamePlayers[this.Random.Next(0, GamePlayers.Count)] as FiveGamePlayer; UpdatePlayerInfo(0, 0, false, true); return(true); }
public Game(Player player1, Player player2) : this() { GamePlayers.Add(player1); GamePlayers.Add(player2); }