コード例 #1
0
        //  [STAThread]
        public static void Main(String[] args)
        {
            data[0] = new ClientData("akka.tcp://client1@localhost:", 1111, "/user/GameActor", 1, "client1");
            data[1] = new ClientData("akka.tcp://client2@localhost:", 2222, "/user/GameActor", 2, "client2");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            clientClass = new ClientClass(data, "client1");
            clientItem  = clientClass.initializeClient(0, data.Length);

            t1 = new Test();
            t1.setNumPlayer(data.Length);


            // line = Console.ReadLine();
            line = "";
            //System.Threading.Thread.Sleep(5000);

            while (line != null)
            {
                line = Console.ReadLine();
                if (line == "start")
                {
                    clientAlcatraz = clientItem.getAlcatraz();
                    clientItem.getAlcatraz().showWindow();
                    clientAlcatraz.addMoveListener(t1);
                    clientItem.getAlcatraz().getWindow().FormClosed += new FormClosedEventHandler(Test_FormClosed);
                    clientItem.getAlcatraz().start();
                    Application.Run();
                }
            }
        }
コード例 #2
0
        //  [STAThread]
        public static void Main(String[] args)
        {
            string actorSystemName = "client2";

            Console.Title = actorSystemName;

            var actorSystem    = ActorSystem.Create(actorSystemName);
            var localChatActor = actorSystem.ActorOf(Props.Create <GameActor>(), "GameActor");

            child = actorSystem.ActorOf(Props.Create <GameActor>(), "GameActorClient2Child");
            string remoteActorAddressClient1 = "akka.tcp://client1@localhost:1111/user/GameActor";

            remoteChatActorClient1 = actorSystem.ActorSelection(remoteActorAddressClient1);

            data    = new ClientData[1];
            data[0] = new ClientData("akka.tcp://client1@localhost:", 1111, "/user/GameActor", 1, "client1");
            other   = new Alcatraz[data.Length + 1];

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            clientClass = new ClientClass(data, "client2");
            clientItem  = clientClass.initializeClient(1, data.Length + 1, data, "client2");
            // loop here and sent to other
            if (clientItem != null)
            {
                string line = string.Empty;
                while (line != null && line != "received")
                {
                    line = Console.ReadLine();
                    remoteChatActorClient1.Tell(clientItem, child);
                }
            }
            t1 = new Test();
            t1.setNumPlayer(data.Length + 1);


            // line = Console.ReadLine();
            line = "";
            //System.Threading.Thread.Sleep(5000);

            while (line != null)
            {
                line = Console.ReadLine();
                if (line == "start")
                {
                    clientAlcatraz = clientItem.getAlcatraz();
                    clientItem.getAlcatraz().showWindow();
                    clientAlcatraz.addMoveListener(t1);
                    clientItem.getAlcatraz().getWindow().FormClosed += new FormClosedEventHandler(Test_FormClosed);
                    clientItem.getAlcatraz().start();
                    Application.Run();
                }
            }
        }
コード例 #3
0
        public void doMove(Player player, Prisoner prisoner, int rowOrCol, int row, int col)
        {
            Console.WriteLine("moving " + prisoner + " to " + (rowOrCol == Alcatraz.ROW ? "row" : "col") + " " + (rowOrCol == Alcatraz.ROW ? row : col));
            Console.WriteLine("ID" + player.Id);
            ActorSelection[] remoteActors = ClientClass.getRemoteChatActorClient();

            for (int i = 0; i < remoteActors.Length; i++)
            {
                remoteActors[i].Tell(this.convertMove(player, prisoner, rowOrCol, row, col), clientClass.getChild());
            }
        }
コード例 #4
0
        public Client initializeClient(int playerID, int numberOfPlayer)
        {
            ClientClass clientClass    = new ClientClass(numberOfPlayer);
            Alcatraz    clientAlcatraz = new Alcatraz();

            clientClass.setNumPlayer(numPlayer);
            clientAlcatraz.init(numPlayer, playerID);

            for (int j = 1; j < numPlayer + 1; j++)
            {
                int help = j - 1;
                clientAlcatraz.getPlayer(help).Name = "Player " + j;
            }
            return(new Client(clientClass, clientAlcatraz, playerID));
        }