Beispiel #1
0
 private void StartGame()
 {
     Console.WriteLine("room " + this.id + " StartGame");
     Protocol.ProtocolBytes proto = new Protocol.ProtocolBytes();
     proto.AddString("GameStart");
     Broadcast(proto);
     foreach (var p in m_players)
     {
         m_inputs.Add(p, new Dictionary <int, int>());
     }
     this.status = RoomStatus.Battling;
     // timer = new System.Timers.Timer(1);
     //timer.Elapsed += HandleTimerGameUpdate;
     //timer.AutoReset = true;
     //timer.Enabled = true;
 }
Beispiel #2
0
 public void EndGame()
 {
     Console.WriteLine("room " + this.id + " EndGame");
     //this.timer.Stop();
     //this.timer = null;
     this.status = RoomStatus.Wait;
     Protocol.ProtocolBytes proto = new Protocol.ProtocolBytes();
     proto.AddString("GameEnd");
     Broadcast(proto);
     lock (m_players)
     {
         foreach (var player in m_players.ToArray())
         {
             RemovePlayer(player);
         }
     }
 }
Beispiel #3
0
 private void CreateMatch()
 {
     Console.WriteLine("room " + this.id + " CreateMatch");
     foreach (var p in m_players)
     {
         m_gameLoadProgress.Add(p, 0);
     }
     Protocol.ProtocolBytes proto = new Protocol.ProtocolBytes();
     proto.AddString("MatchCreate");
     proto.AddInt(id);
     Broadcast(proto);
     this.status = RoomStatus.Loading;
     //listening to progress
     timer           = new System.Timers.Timer(1000);
     timer.Elapsed  += ListenLoadProgress;
     timer.AutoReset = false;
     timer.Enabled   = true;
 }
Beispiel #4
0
 void GameUpdate()
 {
     //Console.WriteLine("GameUpdate");
     Protocol.ProtocolBytes proto = new Protocol.ProtocolBytes();
     proto.AddString("GameUpdate");
     proto.AddInt(m_currentFrame);
     lock (m_players)
     {
         for (int i = 0; i < m_players.Count; i++)
         {
             var player = m_players[i];
             proto.AddInt(player.curInput);
             m_inputs[player].Add(m_currentFrame, player.curInput);
         }
         Broadcast(proto);
     }
     m_currentFrame++;
 }