public void AddPlayer(ServerPlayer player) { if (player == null) return; foreach (ServerPlayer other in _players) if (other.accountID == player.accountID) { return; } foreach (ServerPlayer other in _players) { ServerMessage msg = new ServerMessage(Protocol.netPlayerAdd); msg.WriteInteger(this._ID); msg.WriteString(this._region.Name); msg.WriteInteger(other.TX); msg.WriteInteger(other.TY); msg.WriteByte(other.level); player.SendMessage(msg, other.accountID); msg = null; msg = other.GetKeysMessage(); if (msg!=null) { player.SendMessage(msg, other.accountID); msg = null; } } _players.Add(player); }
public virtual void Write(ServerMessage str) { str.WriteByte(opcode); str.WriteByte(index); str.WriteInteger(turn); str.WriteInteger(priority); str.WriteInteger(speed); }
public override void Write(ServerMessage str) { base.Write(str); str.WriteInteger(moveID); }
public void SetPlayerReady(ServerPlayer p) { if (!loading) return; p.turnState = BattleTurn.turnWaiting; byte count = 0; foreach (ServerPlayer player in _players) if (player.turnState != BattleTurn.turnLoading) { count++; } if (count< this._players.Count) return; this.loading = false; // after sending info to everyone we let them start the battle foreach (ServerPlayer player in _players) { ServerMessage msg = new ServerMessage(Protocol.netBattleStart); msg.WriteByte(count); // player count msg.WriteByte(this.secondsPerTurn); // player timer msg.WriteByte(this.battleMode); // team index msg.WriteInteger(this.seed); msg.WriteByte(player.battleTeam); // team index msg.WriteByte(player.battleSide); // local side msg.WriteByte(player.monstersPerBattle); player.rules.Write(msg); player.SendMessage(msg, player.accountID); } }