예제 #1
0
        /// <summary>
        /// there are four steps for the server
        /// (1) read xml to get necessary information
        /// (2)initalize a new world and add info to the new world
        /// (3)uisng serverawaitClientloop to awit client join in
        /// (4)using update method to send update info to the client
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            xmlRead();
            watch = new Stopwatch();
            list  = new LinkedList <SocketState>();
            watch.Start();
            liveStar = new Stopwatch();
            liveStar.Start();
            theworld = new world();
            sta.setLoc(new Vector2D(200, -200));
            star ss = new star(1, new Vector2D(200, 200), 0.01);

            theworld.addStar(sta);
            theworld.addStar(ss);
            theworld.setSize(UniverSize);
            theworld.setRespawn(RespawnRate);
            theworld.setFrame(MSperFrame);
            NController.ServerAwaitClientLoop(HandleNewClient);
            Console.WriteLine("our server start, and client could join in now");
            //create a new thread to update the world and send the updated info to the client
            Task task = new Task(() =>
            {
                while (true)
                {
                    update();
                }
            });

            task.Start();
            Console.Read();
        }
예제 #2
0
        public void TestStar1Method()
        {
            world world1 = new world();
            star  s      = new star(0, new Vector2D(0, -200), 1);

            s.setLoc(new Vector2D(0, 0));
            Assert.AreEqual(new Vector2D(0, 0), s.getloc());
            world1.addStar(s);
            world1.setFrame(50);
            world1.setRespawn(300);
            world1.setSize(750);
            world1.update();
            s.update(51);
            s.update(102);
            s.update(160);
            s.update(230);
        }
예제 #3
0
        public void TestworldMethod1()
        {
            world      world1 = new world();
            star       s      = new star(0, new Vector2D(0, -200), 1);
            Ship       ship   = new Ship(1, new Vector2D(0, 0), new Vector2D(0, 0), false, "s", 5, 0);
            projectile p1     = new projectile(1, new Vector2D(0, 10), new Vector2D(0, 0), true, 2);

            world1.addproj(p1);
            world1.addShip(ship);

            s.setLoc(new Vector2D(0, 0));
            Assert.AreEqual(new Vector2D(0, 0), s.getloc());
            world1.addStar(s);
            world1.setFrame(50);
            world1.setRespawn(300);
            world1.setSize(750);
            world1.update();
            s.update(51);
            s.update(102);
            s.update(160);
            s.update(230);
        }