Esempio n. 1
0
        public void MoveActionTestPositionNull()
        {
            var map  = new SmallMap().BuildMap();
            var unit = new CentaurWarrior(Position.ZERO);

            new MoveAction(map, unit, null);
        }
Esempio n. 2
0
        public void MoveActionTestUnitNull()
        {
            var map      = new SmallMap().BuildMap();
            var position = new Position(1, 1);

            new MoveAction(map, null, position);
        }
Esempio n. 3
0
        public void AttackActionTestAttackerNull()
        {
            var map      = new SmallMap().BuildMap();
            var defender = new CerberusWarrior(Position.ZERO);

            new AttackAction(map, null, defender);
        }
Esempio n. 4
0
        public void AttackActionTestDefenderNull()
        {
            var map      = new SmallMap().BuildMap();
            var attacker = new CentaurWarrior(Position.ZERO);

            new AttackAction(map, attacker, null);
        }
Esempio n. 5
0
        public void UpdateForPlayer()
        {
            UpdateMarksInRange(Player.PositOnScene, GlobalAsset.seenRange);
            CreateMarksInRange(Player.PositOnScene, GlobalAsset.seenRange);

            SmallMap.Clear();

            int x, y, s;

            foreach (var e in objsForLittleMap)
            {
                var creater = e.creater;
                x = creater.PositOnScene.X.value;
                y = creater.PositOnScene.Y.value;
                s = e.seenLevel * 2;
                SmallMap.DrawGridAt(x, y, creater.GetColor(), s);
            }

            var player = Player;

            x = player.PositOnScene.X.value;
            y = player.PositOnScene.Y.value;
            s = 3;
            SmallMap.DrawGridAt(x, y, player.GetColor(), s, true);

            SmallMap.UpdateGraphic();
        }
Esempio n. 6
0
        public void AttackActionTestProbability()
        {
            var map = new SmallMap().BuildMap();

            var attackingUnitLoses = 0;
            var defendingUnitLoses = 0;

            for (var i = 0; i < 10000; i++)
            {
                var attackingUnit = new EqualPowerWarrior(Position.ZERO);
                var defendingUnit = new EqualPowerWarrior(new Position(1, 1));

                var action = new AttackAction(map, attackingUnit, defendingUnit);
                action.Do();
                if (action.Loser == attackingUnit)
                {
                    attackingUnitLoses++;
                }
                else
                {
                    defendingUnitLoses++;
                }
            }

            var attackerWin = attackingUnitLoses / (double)(attackingUnitLoses + defendingUnitLoses);
            var defenderWin = defendingUnitLoses / (double)(attackingUnitLoses + defendingUnitLoses);

            var epsilon = 0.01;

            Assert.IsTrue(attackerWin <0.5 + epsilon && attackerWin> 0.5 - epsilon);
            Assert.IsTrue(defenderWin <0.5 + epsilon && defenderWin> 0.5 - epsilon);
        }
Esempio n. 7
0
        public void UpdateForPlayer(List <Creater> creaters)
        {
            SmallMap.Clear();

            int x, y, s;

            foreach (var e in creaters)
            {
                if (!e.PositOnScene.Plain.IsEqual(Player.PositOnScene.Plain))
                {
                    continue;
                }

                var creater = e;
                x = creater.PositOnScene.X.value;
                y = creater.PositOnScene.Y.value;
                s = e.Range * 2;
                SmallMap.DrawGridAt(x, y, creater.GetColor(), s);
            }

            var player = Player;

            x = player.PositOnScene.X.value;
            y = player.PositOnScene.Y.value;
            s = 3;
            SmallMap.DrawGridAt(x, y, player.GetColor(), s, true);

            SmallMap.UpdateGraphic();
        }
Esempio n. 8
0
        public void GetBestWayTest()
        {
            var map       = new SmallMap().BuildMap();
            var race      = new Cyclops();
            var unit      = race.ProduceWarrior(Position.ZERO);
            var positions = unit.FindReachablePositions(map);

            var reacheablePositions = new List <Position>()
            {
                new Position(0, 0),
                new Position(0, 1),
                new Position(0, 2),
                new Position(0, 3),
                new Position(1, 0),
                new Position(2, 0),
                new Position(3, 0),
                new Position(1, 1),
                new Position(1, 2),
                new Position(2, 1)
            };

            foreach (var reachablePosition in reacheablePositions)
            {
                if (!positions.Contains(reachablePosition))
                {
                    Assert.Fail();
                }
            }
            Assert.AreEqual(positions.Count, reacheablePositions.Count);
        }
Esempio n. 9
0
        public void MoveActionTestErrorCost()
        {
            var map      = new SmallMap().BuildMap();
            var unit     = new CerberusWarrior(Position.ZERO);
            var position = new Position(map.Size, map.Size);

            new MoveAction(map, unit, position);
        }
Esempio n. 10
0
        public void MoveActionTest()
        {
            var        map      = new SmallMap().BuildMap();
            var        unit     = new CentaurWarrior(Position.ZERO);
            var        position = new Position(1, 1);
            MoveAction action   = new MoveAction(map, unit, position);

            Assert.AreEqual(action.Unit, unit);
            Assert.AreEqual(action.Position, position);
        }
Esempio n. 11
0
        public void AttackActionTest()
        {
            var map      = new SmallMap().BuildMap();
            var attacker = new CentaurWarrior(Position.ZERO);
            var defender = new CerberusWarrior(new Position(1, 1));

            AttackAction action = new AttackAction(map, attacker, defender);

            Assert.AreEqual(action.Attacker, attacker);
            Assert.AreEqual(action.Defender, defender);
            Assert.AreEqual(action.InitialAttackerPosition, Position.ZERO);
        }
Esempio n. 12
0
    public virtual void InitMap(int group, int row, int col)
    {
        mapObj   = new GameObject("map");
        mapGroup = group;
        this.row = row;
        this.col = col;

        map        = new InGameMapPointData[row, col];
        astarArray = new int[row, col];

        smallMap = new SmallMap();
        smallMap.Init(row, col);
    }
Esempio n. 13
0
        public void DoTest()
        {
            var        map      = new SmallMap().BuildMap();
            var        unit     = new CerberusWarrior(Position.ZERO);
            var        position = new Position(1, 1);
            MoveAction action   = new MoveAction(map, unit, position);

            action.Do();
            var movePointsLost = 2;

            Assert.AreEqual(unit.Position, position);
            Assert.AreEqual(action.MovePointsLost, movePointsLost);
            Assert.AreEqual(unit.MovePoints, Unit.MAX_MOVE_POINTS - movePointsLost);
        }
Esempio n. 14
0
        public void DoTest()
        {
            var          map      = new SmallMap().BuildMap();
            var          attacker = new CerberusWarrior(Position.ZERO);
            var          defender = new CentaurWarrior(new Position(1, 1));
            AttackAction action   = new AttackAction(map, attacker, defender);

            action.Do();
            var movePointsLost = 2;

            Assert.AreEqual(action.Loser.HealthPoints, action.Loser.InitialHealthPoints - action.HealthPointsLost);
            Assert.AreEqual(action.MovePointsLost, movePointsLost);
            Assert.AreEqual(attacker.MovePoints, Unit.MAX_MOVE_POINTS - movePointsLost);
        }
Esempio n. 15
0
        private async void UpdateWeather()
        {
            main.Visibility = Visibility.Collapsed;
            var forecast = await weatherService.GetForecastAsync();

            Temp.Text              = forecast.Current.Temperature.ToString();
            FeelsLike.Text         = forecast.Current.FeelsLike.ToString();
            Humidity.Text          = forecast.Current.Humidity.ToString();
            Wind.Text              = $"{(int)forecast.Current.WindSpeed}{forecast.Current.WindDirection}";
            CurrentConditions.Text = forecast.Current.WeatherDescription;
            var when  = DateTime.Now;
            var tides = await TideData.GetNextTides(when, TideData.Location.BowleysBar);

            HighTide.Text = tides.HighTide;
            LowTide.Text  = tides.LowTide;
            LargeMap.Navigate(new Uri(largeMapUrl));
            SmallMap.Navigate(new Uri(smallMapUrl));
            main.Visibility = Visibility.Visible;
        }
Esempio n. 16
0
        private async void Mapsample_Loaded(object sender, RoutedEventArgs e)
        {
            var geoLocator = new Geolocator();

            geoLocator.DesiredAccuracy = PositionAccuracy.High;
            Geoposition pos = await geoLocator.GetGeopositionAsync();


            var center =
                new Geopoint(new BasicGeoposition()
            {
                Latitude  = pos.Coordinate.Point.Position.Latitude,
                Longitude = pos.Coordinate.Point.Position.Longitude
            });
            await SmallMap.TrySetSceneAsync(MapScene.CreateFromLocationAndRadius(center, 3000));

            //Define MapIcon
            MapIcon myPOI = new MapIcon {
                Location = center, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "Qaanita", ZIndex = 0
            };

            // add to map and center it
            SmallMap.MapElements.Add(myPOI);
        }
Esempio n. 17
0
        private async void Mapsample_Loaded(object sender, RoutedEventArgs e)
        {
            geoLocator = new Geolocator();
            geoLocator.DesiredAccuracy = PositionAccuracy.High;
            Geoposition pos = await geoLocator.GetGeopositionAsync();

            WebView_Weather.Navigate(new Uri("http://forecast.io/embed/#lat=" + pos.Coordinate.Point.Position.Latitude.ToString() + "&lon=" + pos.Coordinate.Point.Position.Longitude.ToString() + "&name=the Job Site&color=#00aaff&font=Segoe UI&units=ca"));

            var center =
                new Geopoint(new BasicGeoposition()
            {
                Latitude  = pos.Coordinate.Point.Position.Latitude,
                Longitude = pos.Coordinate.Point.Position.Longitude
            });
            await SmallMap.TrySetSceneAsync(MapScene.CreateFromLocationAndRadius(center, 5000));

            //Define MapIcon
            MapIcon myPOI = new MapIcon {
                Location = center, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "You", ZIndex = 0
            };

            //add to map and center it
            SmallMap.MapElements.Add(myPOI);
        }
Esempio n. 18
0
 public void ClearMap()
 {
     SmallMap.Clear();
     objsForLittleMap.Clear();
 }
Esempio n. 19
0
 private void LoadRegion(int x, int y)
 {
     Point regionOffset = CalcRegionOffset(x, y);
     String key = CalcMapKey(regionOffset.X, regionOffset.Y);
     if (currentRegionKey != key)
     {
         SaveCurrentRegion();
         if (!regions.TryGetValue(key, out currentRegion))
         {
             currentRegion = new SmallMap()
             {
                 xOffset = regionOffset.X,
                 yOffset = regionOffset.Y,
                 Tiles = new Tile[RegionWidth, RegionHeight]
             };
         }
         currentRegionKey = key;
         currentRegionTiles = currentRegion.Tiles;
     }
 }
Esempio n. 20
0
        public void GetTileTestOutOfRangeXPosition()
        {
            Map map = new SmallMap().BuildMap();

            map.GetTile(new Position(map.Size, 0));
        }