public void Setup()
 {
     this._map             = new Rft(3000, 3000);
     this._outpostLocation = new RftVector(_map, 0, 0);
     this._outpostLocation = new RftVector(_map, 15, 15);
     this._outpost         = new Outpost("0", _outpostLocation, new Player("1"), OutpostType.Factory);
     this._outpost2        = new Outpost("1", _outpostLocation, new Player("1"), OutpostType.Factory);
 }
 public void Setup()
 {
     _map      = new Rft(3000, 3000);
     _location = new RftVector(_map, 0, 0);
     _outpost  = new Generator("0", _location, new Player("1"));
     _tick     = new GameTick(10);
     _sub      = new Sub("0", _outpost, _outpost, _tick, 0, new Player("1"));
 }
示例#3
0
 public void Setup()
 {
     _map      = new Rft(3000, 3000);
     _location = new RftVector(_map, 0, 0);
     _outpost  = new Outpost(_location, new Player(1), OutpostType.Generator);
     _tick     = new GameTick(DateTime.Now, 10);
     _sub      = new Sub(_outpost, _outpost, _tick, 0, new Player(1));
     Game server = new Game();
 }
示例#4
0
        public void GlobalMapSize()
        {
            int mapSize = 100;
            Rft map     = new Rft(mapSize, mapSize);

            int       firstPointLocation = 25;
            RftVector vector             = new RftVector(map, firstPointLocation, firstPointLocation);

            Assert.AreEqual(map, RftVector.Map);
        }
示例#5
0
        public void GettersAndSetters()
        {
            int mapDimensions   = 100;
            int pointDimensions = 50;

            Rft       map        = new Rft(mapDimensions, mapDimensions);
            RftVector vectorTest = new RftVector(map, pointDimensions, pointDimensions);

            Assert.AreEqual(pointDimensions, vectorTest.X);
            Assert.AreEqual(pointDimensions, vectorTest.Y);
            Assert.AreEqual(mapDimensions, map.Height);
            Assert.AreEqual(mapDimensions, map.Width);
        }
示例#6
0
        public void AddEvent()
        {
            Player  player1 = new Player(1);
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Outpost(new RftVector(map, 0, 0), player1, OutpostType.Generator);

            outpost.AddDrillers(10);
            Sub         sub         = new Sub(outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, new GameTick(), outpost.GetTargetPosition(sub.GetCurrentPosition(), sub.GetSpeed()));

            Game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(1, Game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, Game.TimeMachine.GetQueuedEvents()[0]);
        }
示例#7
0
        public void AddEvent()
        {
            Player  player1 = new Player("1");
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Outpost("0", new RftVector(map, 0, 0), player1, OutpostType.Generator);

            outpost.AddDrillers(10);
            Sub         sub         = new Sub("1", outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, new GameTick());

            game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(1, game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, game.TimeMachine.GetQueuedEvents()[0]);
        }
        public void Setup()
        {
            _player1 = new Player("1");
            List <Player> players = new List <Player>();

            GameConfiguration config = testUtils.GetDefaultGameConfiguration(players);

            Assert.IsNotNull(config);

            _state   = new GameState(config);
            _map     = new Rft(300, 300);
            _outpost = new Generator("0", new RftVector(_map, 0, 0), _player1);
            _outpost.GetComponent <DrillerCarrier>().AddDrillers(10);
            _tempSub = new Sub("1", _outpost, _outpost, new GameTick(), 10, _player1);
        }
示例#9
0
        public void CanNormalize()
        {
            int mapDimension = 100;
            Rft map          = new Rft(mapDimension, mapDimension);

            RftVector vector = new RftVector(map, 0, 1);

            Assert.AreEqual(1, vector.Normalize().Length());

            for (int i = 0; i < 300; i++)
            {
                vector = new RftVector(map, 0, i);
                Assert.AreEqual(1, vector.Normalize().Length());
            }
        }
示例#10
0
        public void Setup()
        {
            _player1 = new Player(1);
            List <Player> players = new List <Player>();

            GameConfiguration config = new GameConfiguration(players);

            Assert.IsNotNull(config);

            _state   = new GameState(config);
            _map     = new Rft(300, 300);
            _outpost = new Outpost(new RftVector(_map, 0, 0), _player1, OutpostType.Generator);
            _outpost.AddDrillers(10);
            _tempSub = new Sub(_outpost, _outpost, new GameTick(), 10, _player1);
        }
        public void CanRemoveEvents()
        {
            Player  player1 = new Player("1");
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Generator("0", new RftVector(map, 0, 0), player1);

            outpost.GetComponent <DrillerCarrier>().AddDrillers(10);
            Sub         sub         = new Sub("1", outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, new GameTick(5));

            _game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(2, _game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, _game.TimeMachine.GetQueuedEvents()[0]);

            _game.TimeMachine.RemoveEvent(arriveEvent);
            Assert.AreEqual(1, _game.TimeMachine.GetQueuedEvents().Count);
        }
示例#12
0
        public void EventsSwitchQueuesWhenPassedForward()
        {
            Player  player1 = new Player(1);
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Outpost(new RftVector(map, 0, 0), player1, OutpostType.Generator);

            outpost.AddDrillers(10);
            Sub         sub         = new Sub(outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, GameTick.FromTickNumber(5), outpost.GetTargetPosition(sub.GetCurrentPosition(), sub.GetSpeed()));

            Game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(1, Game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, Game.TimeMachine.GetQueuedEvents()[0]);

            // Go past the tick
            Game.TimeMachine.Advance(6);
            Assert.AreEqual(0, Game.TimeMachine.GetQueuedEvents().Count);
        }
示例#13
0
        public void CanSubtractVectors()
        {
            int mapDimensions = 100;
            int mapRadius     = mapDimensions / 2;
            Rft map           = new Rft(mapDimensions, mapDimensions);

            // Create a vector at the edge of the map
            RftVector rightEdgeMap = new RftVector(map, mapRadius - 1, 0);

            // Create a vector at the other edge of the map
            RftVector leftEdgeMap = new RftVector(-mapRadius + 1, 0);

            // Determine the distance between them. Expect 2.
            RftVector difference = rightEdgeMap - leftEdgeMap;

            Assert.AreEqual(2, difference.Magnitude());
            Assert.AreEqual(-2, difference.X);
            Assert.AreEqual(0, difference.Y);
        }
示例#14
0
        public void CanAddVectors()
        {
            int mapDimensions = 100;
            int mapRadius     = mapDimensions / 2;
            Rft map           = new Rft(mapDimensions, mapDimensions);

            // Create a vector at the edge of the map
            RftVector rightEdgeMap = new RftVector(map, mapRadius - 1, 0);

            // Create a vector that makes the edge go over the boarder
            RftVector forceWrap = new RftVector(2, 0);

            // Determine location of new point. Expect opposite map edge.
            RftVector sum = rightEdgeMap + forceWrap;

            Assert.AreEqual(mapRadius - 1, sum.Magnitude());
            Assert.AreEqual(-(mapRadius - 1), sum.X);
            Assert.AreEqual(0, sum.Y);
        }
示例#15
0
        public void CanGetVector2()
        {
            int mapDimension = 100;
            Rft map          = new Rft(mapDimension, mapDimension);

            for (int i = 0; i < 300; i++)
            {
                RftVector vector = new RftVector(map, 0, i);

                float   vectorX   = vector.X;
                float   vectorY   = vector.Y;
                Vector2 duplicate = new Vector2(vectorX, vectorY);

                Vector2 derived = vector.ToVector2();

                Assert.AreEqual(duplicate.X, derived.X);
                Assert.AreEqual(duplicate.Y, derived.Y);
            }
        }
示例#16
0
        public void RftCanChangeMapSize()
        {
            int mapDimensions   = 100;
            int pointDimensions = 150;
            int mapDelta        = 200;

            int wrappedDimension;

            if ((pointDimensions % mapDimensions) > mapDimensions / 2)
            {
                wrappedDimension = (pointDimensions % mapDimensions) - (mapDimensions);
            }
            else
            {
                wrappedDimension = (pointDimensions % mapDimensions);
            }

            Rft       map        = new Rft(mapDimensions, mapDimensions);
            RftVector vectorTest = new RftVector(map, pointDimensions, pointDimensions);

            Assert.AreEqual(wrappedDimension, vectorTest.X);
            Assert.AreEqual(wrappedDimension, vectorTest.Y);
            Assert.AreEqual(mapDimensions, map.Height);
            Assert.AreEqual(mapDimensions, map.Width);

            RftVector.Map = new Rft(mapDelta, mapDelta);

            if ((pointDimensions % mapDimensions) > mapDimensions / 2)
            {
                wrappedDimension = (pointDimensions % mapDimensions) - (mapDimensions);
            }
            else
            {
                wrappedDimension = (pointDimensions % mapDimensions);
            }

            Assert.AreEqual(wrappedDimension, vectorTest.X);
            Assert.AreEqual(wrappedDimension, vectorTest.Y);
            Assert.AreEqual(mapDelta, RftVector.Map.Height);
            Assert.AreEqual(mapDelta, RftVector.Map.Height);
        }
示例#17
0
        public void CanGetMagnitude()
        {
            int mapDimension = 100;
            Rft map          = new Rft(mapDimension, mapDimension);

            RftVector vector = new RftVector(map, 0, 1);

            Assert.AreEqual(1, vector.Magnitude());

            for (int i = 0; i < 300; i++)
            {
                vector = new RftVector(map, 0, i);
                float position = vector.Y;
                Assert.AreEqual(Math.Abs(position), vector.Magnitude());
            }

            int       somePosition    = 152;
            RftVector vectorTwo       = new RftVector(somePosition, somePosition);
            float     wrappedPosition = vectorTwo.X;

            Assert.AreEqual((float)Math.Sqrt(wrappedPosition * wrappedPosition + wrappedPosition * wrappedPosition), vectorTwo.Magnitude());
        }
示例#18
0
        public void EventsSwitchQueuesWhenRewind()
        {
            Player  player1 = new Player("1");
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Outpost("0", new RftVector(map, 0, 0), player1, OutpostType.Generator);

            outpost.AddDrillers(10);
            Sub         sub         = new Sub("1", outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, new GameTick(5));

            game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(1, game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, game.TimeMachine.GetQueuedEvents()[0]);

            // Go past the tick
            game.TimeMachine.Advance(6);
            Assert.AreEqual(0, game.TimeMachine.GetQueuedEvents().Count);

            // Rewind back
            game.TimeMachine.Rewind(6);
            Assert.AreEqual(1, game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, game.TimeMachine.GetQueuedEvents()[0]);
        }
示例#19
0
 public void Setup()
 {
     this._map             = new Rft(3000, 3000);
     this._outpostLocation = new RftVector(_map, 0, 0);
     this._outpost         = new Outpost(_outpostLocation, new Player(1), OutpostType.Generator);
 }