Example #1
0
        public void GetPlayerIDs()
        {
            if (string.IsNullOrEmpty(PlayersIDString))
            {
                return;
            }

            var splitted = PlayersIDString.Split(' ');

            foreach (var id in splitted)
            {
                PlayersID.Add(int.Parse(id));
            }
        }
Example #2
0
            public void StartGame(List <DTOPlaying> players)
            {
                //cc.Add(new CliChat())

                List <DTOPlaying> pls  = players.ToList();
                DTOPlaying        temp = null;

                foreach (DTOPlaying C in pls)
                {
                    if (PlayersID.FirstOrDefault(x => x.Value == 1).Key == C.name)
                    {
                        // If we are ourselves, do nothing
                        temp = C;
                        chatClientsVectorClock.Add(C.name, 0);
                    }
                    else
                    {
                        //else add respective player to players list
                        PlayersID.Add(C.name, pacID++);
                        chatClientsVectorClock.Add(C.name, 0);
                        String[] splitUrl = C.url.Split(new Char[] { ':', '/' });
                        ///  A : / / B : C / D
                        ///  0  1 2  3   4   5
                        Clients.Add(splitUrl[4], "tcp://" + splitUrl[3] + "/" + splitUrl[4] + "/chatClientServerService");
                    }
                }
                if (temp != null)
                {
                    pls.Remove(temp);
                }
                registerChatClients(this, new PacEventArgs(pls));


                foreach (KeyValuePair <String, int> p in PlayersID)
                {
                    //TURNS PACMAN PLAYERS VISIBLE
                    changePacmanVisibility(this, new PacEventArgs(p.Value));
                }

                launch_mainloop(this, new PacEventArgs(0));
                running = true;
            }