Exemple #1
0
    public void Load(string state)
    {
        if (state != null)
        {
            StateSerializer.Load(this, state.Trim(' ', '\n', '\r'));
            return;
        }

        var inputs = Console.ReadLine().Split(' ');

        PlayersNumber = int.Parse(inputs[0]); // total number of players (2 to 4).
        MyIndex       = int.Parse(inputs[1]); // your player number (0 to 3).

        for (int i = 0; i < PlayersNumber; i++)
        {
            var s = Console.ReadLine();
            inputs = s.Split(' ');
            int x0 = int.Parse(inputs[0]); // starting X coordinate of lightcycle (or -1)
            int y0 = int.Parse(inputs[1]); // starting Y coordinate of lightcycle (or -1)
            int x1 = int.Parse(inputs[2]); // starting X coordinate of lightcycle (can be the same as X0 if you play before this player)
            int y1 = int.Parse(inputs[3]); // starting Y coordinate of lightcycle (can be the same as Y0 if you play before this player)

            if (x1 >= 0)
            {
                Cells[x1, y1] = i;
                Cells[x0, y0] = i;
            }
            else if (Players[i].X >= 0)
            {
                Log.D("dead:", i);
                ClearPlayer(i);
            }

            Players[i].X = x1;
            Players[i].Y = y1;
        }
    }