public static string GetState(GameState state)
        {
            string str = "";
            string sc = " ";
            int playersCount = state.players.Count;

            for (int i = 0; i < playersCount; i++)
            {
                str += state.players[i].name + sc;
                str += state.players[i].ID + sc;
                str += state.players[i].position.x.ToString() + sc;
                str += state.players[i].position.y.ToString() + sc;
                str += state.players[i].currentSpeed.x.ToString() + sc;
                str += state.players[i].currentSpeed.y.ToString() + sc;
                str += state.players[i].radius + sc;
            }
            str += ";";

            return str;
        }
Exemple #2
0
        static bool Init()
        {
            //log = new StreamWriter("log.log", false);
            clientConnected = false;
            port = 11000;
            playersCount = 1;       ///////////NET WORK///////////
            playerRadius = 10;
            tickCurrent = 0;
            tickCount = 3000;           ///////////NET WORK///////////
            worldHeightSize = 768;
            worldWidthSize = 1024;

            world = new GameState(0, playerRadius); //debug
            cout("loading config");
            if (!configLoad())
            {
                cout("config load filed");
                return false;
            }

            if (!connectToCore())
            {
                return false;
            }

            if (!initNetwork())
            {
                return false;
            }

            logWriter = new StreamWriter(logFileName,false);

            return true;
        }
Exemple #3
0
 static void logStateReader()
 {
     if (tickCurrent < tickCount)
     {
         world = new GameState(logReader.ReadLine(), playersCount);
         tickCurrent++;
     }
 }