Exemplo n.º 1
0
 public void GiveCommandsFromClient(GameActCommands commands)
 {
     if (commands != null)
     {
         CommandsFromClient = commands;
     }
 }
Exemplo n.º 2
0
        private void SendCommandsToServer(GameActCommands commands)
        {
            var clientUpdate = new ClientUpdate(commands);

            Network.SendPacket(clientUpdate, serverConnection);

            /*
             * try
             * {
             *  Network.SendPacket(clientUpdate, server.GetStream());
             * }
             * catch (Exception e)
             * {
             *  disconnectedActs++;
             * }
             */
        }
Exemplo n.º 3
0
        private void BeginSessionAct()
        {
            var commands = new GameActCommands(controlSettings, GameForm.PressedKeys);

            Task.Run(() => SendCommandsToServer(commands));

            lock (bottomSideState)
            {
                bottomSideState.GiveCommandsFromClient(commands);
                GameEngine.BeginAct(bottomSideState);

                lock (GameForm.BottomSideHUD)
                {
                    GameForm.BottomSideHUD.Clear();
                    if (!bottomSideState.GameOver)
                    {
                        Visual.UpdatePlayerHUD(GameForm.BottomSideHUD, bottomSideState.PlayerEntity, GameForm.ClientSize, true);
                    }
                }

                if (!bottomSideState.GameOver)
                {
                    Sound.PlaySoundsAtBeginAct(bottomSideState.PlayerEntity);
                }
            }

            lock (topSideState)
            {
                GameEngine.BeginAct(topSideState);
                lock (GameForm.TopSideHUD)
                {
                    GameForm.TopSideHUD.Clear();
                    if (!topSideState.GameOver)
                    {
                        Visual.UpdatePlayerHUD(GameForm.TopSideHUD, topSideState.PlayerEntity, GameForm.ClientSize,
                                               false);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public ClientUpdate(GameActCommands commands)
 {
     Commands = commands;
 }