Beispiel #1
0
Datei: S.cs Projekt: Boykooo/Boom
        public byte[] Serialize(Messages m)
        {
            MemoryStream stream = new MemoryStream();
            BinaryFormatter b = new BinaryFormatter();
            b.Serialize(stream, m);

            return stream.GetBuffer();
        }
Beispiel #2
0
        public void Send(Messages message)
        {
            try
            {
                MemoryStream stream = new MemoryStream();
                BinaryFormatter b = new BinaryFormatter();
                stream.Position = 0;
                b.Serialize(stream, message);

                socket.Send(stream.GetBuffer());
            }
            catch (Exception e)
            {
                BigStaticClass.logger.Log(e.ToString());

            }
        }
Beispiel #3
0
        void Step(Messages message)
        {
            ShootMessage shoot = message as ShootMessage;

            Gamer first = gamers.First(x => x.client.Id != shoot.Id);
            Gamer second = gamers.First(x => x.client.Id == shoot.Id);

            BigStaticClass.logger.Log("Игрок " + second.client.nick + " сделал ход по координатам " + shoot.x.ToString() + " " + shoot.y.ToString());
            if (second.turn)
            {

                second.turn = first.client.gameField.Shoot(shoot.x, shoot.y);
                first.turn = !second.turn;
                if (second.turn && first.client.gameField.IsGameOver())
                {
                    GameOver();
                }

                StateOfRoom();
            }
        }