Exemplo n.º 1
0
        private static string MoveTooLate(string s)
        {
            var args = s.Split();
            var a1   = int.Parse(args[2]);
            var p1   = ColorMaker.GetColoredText(players[a1], colors[a1]);

            return($"{p1} sends move too late");
        }
Exemplo n.º 2
0
        private static string InvalidMove(string s)
        {
            var args = s.Split();
            var a1   = int.Parse(args[2]);
            var p1   = ColorMaker.GetColoredText(players[a1], colors[a1]);

            return($"{p1} sends invalid move");
        }
Exemplo n.º 3
0
        private static string SendMove(string s)
        {
            var args          = s.Split();
            int num           = int.Parse(args[2]);
            var coloredPlayer = ColorMaker.GetColoredText(players[num], colors[num]);

            return($"{coloredPlayer} goes {direction[int.Parse(args[3])]}");
        }
Exemplo n.º 4
0
        private static string Kill(string s)
        {
            var args = s.Split();
            var a1   = int.Parse(args[2]);
            var a2   = int.Parse(args[3]);
            var p1   = ColorMaker.GetColoredText(players[a1], colors[a1]);
            var p2   = ColorMaker.GetColoredText(players[a2], colors[a2]);

            return($"{p1} killed {p2}");
        }
Exemplo n.º 5
0
 private static void DrawPlayers()
 {
     tmpro.text = "";
     for (var i = 0; i < pTab.Length; ++i)
     {
         tmpro.text += ColorMaker.GetColoredText(pTab[i],
                                                 alive[i] ? cTab[i] : deadColors[i]
                                                 ) + '\n';
     }
 }
Exemplo n.º 6
0
        private void ParseGameLogs(string s)
        {
            var lines   = s.Split('\n');
            var totalMs = int.Parse(lines[0]);
            var pseudo  = lines[1].Split(' ');

            Logs.Init(pseudo, ColorMaker.DivideColors((uint)pseudo.Length));

            for (var i = 2; i < lines.Length - 1; i++)
            {
                Logs.AddLog(Logs.Decode(lines[i]), float.Parse(lines[i].Split(' ')[0]) / totalMs);
            }

            readyLogs = true;
        }
Exemplo n.º 7
0
        public static void SetPlayers(string[] allPlayers, Color[] colorTab)
        {
            pTab       = allPlayers;
            cTab       = colorTab;
            alive      = new bool[allPlayers.Length];
            deadColors = new Color[allPlayers.Length];
            for (var i = 0; i < allPlayers.Length; i++)
            {
                alive[i]      = true;
                deadColors[i] = ColorMaker.ChangeColorToDead(cTab[i]);
            }

            if (tmpro)
            {
                DrawPlayers();
            }
        }
Exemplo n.º 8
0
        private void ParseGameSave(string s)
        {
            var lines       = s.Split('\n');
            var playersName = lines[0].Split(' ').ToList();

            nbPlayers = playersName.Count;
            var colors = ColorMaker.DivideColors((uint)nbPlayers);

            var sortPlayers = new List <ColorPlayer>();

            for (var i = 0; i < nbPlayers; i++)
            {
                sortPlayers.Add(new ColorPlayer(playersName[i], colors[i], i));
            }

            sortPlayers.Sort();
            playersName.Clear();
            var sortedColors = new Color[nbPlayers];

            for (var i = 0; i < nbPlayers; i++)
            {
                playersName.Add(sortPlayers[i].Name);
                sortedColors[i] = sortPlayers[i].Color;
            }

            sizeMap  = int.Parse(lines[1]);
            TimeTurn = int.Parse(lines[2]);
            Unit     = WIDTH / (float)sizeMap;
            players  = new Player[nbPlayers];
            Scoreboard.SetPlayers(playersName.ToArray(), sortedColors);
            for (var i = 0; i < nbPlayers; i++)
            {
                var pos = lines[i + 3].Split(' ');
                players[i] = new Player(colors[i],
                                        int.Parse(pos[0]),
                                        int.Parse(pos[1]),
                                        Instantiate(head, transform.parent),
                                        sortPlayers.FindIndex(c => c.Index == i));
            }

            nbTours = lines.Length - (nbPlayers + 3);
            if (lines[lines.Length - 1].Split(' ').Length != nbPlayers)
            {
                nbTours--;
            }
            TotalDuration = nbTours * TimeTurn;
            for (var i = 0; i < nbTours; i++)
            {
                var moves = lines[nbPlayers + 3 + i].Split(' ');
                for (var p = 0; p < nbPlayers; p++)
                {
                    players[p].AddTrail(int.Parse(moves[p]), (float)i / nbTours,
                                        (float)(i + 1) / nbTours);
                }
            }

            foreach (var player in  players)
            {
                player.EndInit();
            }

            readySave = true;
        }