예제 #1
0
        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);
        }
예제 #2
0
 public virtual void Write(ServerMessage str)
 {
     str.WriteByte(opcode);
     str.WriteByte(index);
     str.WriteInteger(turn);
     str.WriteInteger(priority);
     str.WriteInteger(speed);
 }
예제 #3
0
 public override void Write(ServerMessage str)
 {
     base.Write(str);
     str.WriteInteger(moveID);
 }
예제 #4
0
        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);
            }
        }