コード例 #1
0
        public void MoveActionTestPositionNull()
        {
            var map  = new SmallMap().BuildMap();
            var unit = new CentaurWarrior(Position.ZERO);

            new MoveAction(map, unit, null);
        }
コード例 #2
0
        public void MoveActionTestUnitNull()
        {
            var map      = new SmallMap().BuildMap();
            var position = new Position(1, 1);

            new MoveAction(map, null, position);
        }
コード例 #3
0
ファイル: AttackActionTests.cs プロジェクト: glinot/Code
        public void AttackActionTestAttackerNull()
        {
            var map      = new SmallMap().BuildMap();
            var defender = new CerberusWarrior(Position.ZERO);

            new AttackAction(map, null, defender);
        }
コード例 #4
0
ファイル: AttackActionTests.cs プロジェクト: glinot/Code
        public void AttackActionTestDefenderNull()
        {
            var map      = new SmallMap().BuildMap();
            var attacker = new CentaurWarrior(Position.ZERO);

            new AttackAction(map, attacker, null);
        }
コード例 #5
0
ファイル: LittleMap.cs プロジェクト: kauhiant/Unity_3DMaze
        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();
        }
コード例 #6
0
ファイル: AttackActionTests.cs プロジェクト: glinot/Code
        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);
        }
コード例 #7
0
ファイル: LittleMap.cs プロジェクト: kauhiant/Unity_3DMaze
        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();
        }
コード例 #8
0
ファイル: UnitTests.cs プロジェクト: glinot/Code
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #11
0
ファイル: AttackActionTests.cs プロジェクト: glinot/Code
        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);
        }
コード例 #12
0
ファイル: MazeMapManager.cs プロジェクト: LiuFeng1011/Diablo
    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);
    }
コード例 #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);
        }
コード例 #14
0
ファイル: AttackActionTests.cs プロジェクト: glinot/Code
        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);
        }
コード例 #15
0
ファイル: MainPage.xaml.cs プロジェクト: TerryBoswell/clock
        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;
        }
コード例 #16
0
ファイル: Dashboard.xaml.cs プロジェクト: nitaaa/Solarizr
        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);
        }
コード例 #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);
        }
コード例 #18
0
ファイル: LittleMap.cs プロジェクト: kauhiant/Unity_3DMaze
 public void ClearMap()
 {
     SmallMap.Clear();
     objsForLittleMap.Clear();
 }
コード例 #19
0
ファイル: BigMap.cs プロジェクト: spicykaiju/rpg-map-revealer
 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;
     }
 }
コード例 #20
0
        public void GetTileTestOutOfRangeXPosition()
        {
            Map map = new SmallMap().BuildMap();

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