Exemplo n.º 1
0
        private static GameTypeCommand GetGameTypeAndLoadEquip()
        {
            ConnectionUtil connection = new ConnectionUtil();

            Task <GameTypeCommand> task = connection.ConnectAsync(ip, port);

            GameTypeCommand gameTypeCommand = task.Result;

            LoadEquip(connection.COMMUNICATION);
            return(gameTypeCommand);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            GameTypeCommand gameType = ClientRobot.Connect(args);

            Spot[] spots = new Spot[gameType.ROBOTS_IN_ONE_TEAM];
            for (int i = 0; i < spots.Length; i++)
            {
                spots[i] = new Spot("spot_" + i);
            }
            while (true)
            {
                foreach (Spot spot in spots)
                {
                    process(spot, getWhatToDo(spot));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Do connection to server.
        /// </summary>
        /// <param name="args">
        ///   <list type="bullet">
        ///     <item>
        ///       <description><code>args[0]</code> is IP address of server.</description>
        ///     </item>
        ///     <item>
        ///       <description><code>args[1]</code> is port.</description>
        ///     </item>
        ///     <item>
        ///       <description>If <code>args.length &lt; 2</code> then default port is choose, if <code>args.length &lt; 1</code> then local adress is use as ip.</description>
        ///     </item>
        ///   </list>
        /// </param>
        /// <returns>Game type</returns>
        public static GameTypeCommand Connect(String[] args)
        {
            GameTypeCommand gameTypeCommand = null;

            lock (ROBOT_COLLECTION) {
                ip   = ConnectionUtil.LOCAL_ADDRESS;
                port = GameProperties.DEFAULT_PORT;
                if (args.Length >= 1)
                {
                    ip = args[0];
                }

                if (args.Length >= 2)
                {
                    port = int.Parse(args[1]);
                }
            }

            gameTypeCommand = GetGameTypeAndLoadEquip();
            connectAllUnconnectedRobots();

            return(gameTypeCommand);
        }