コード例 #1
0
ファイル: TownRenderer.cs プロジェクト: eylvisaker/Xle
        protected void DrawGuards(SpriteBatch spriteBatch, Point playerPos, Rectangle inRect)
        {
            Point topLeftMapPt = new Point(playerPos.X - 11, playerPos.Y - 7);

            int px = inRect.Left;
            int py = inRect.Top;

            for (int i = 0; i < TheMap.Guards.Count; i++)
            {
                Guard guard = TheMap.Guards[i];

                if (TheMap.ClosedRoofAt(guard.X, guard.Y) == null)
                {
                    var facing = guard.Facing;

                    int rx = px + (guard.X - topLeftMapPt.X) * 16;
                    int ry = py + (guard.Y - topLeftMapPt.Y) * 16;

                    if (rx >= inRect.Left && ry >= inRect.Top && rx <= inRect.Right - 32 && ry <= inRect.Bottom - 32)
                    {
                        Renderer.DrawCharacterSprite(spriteBatch, rx, ry, facing, true, TheMap.Guards.AnimFrame, false, guard.Color);
                    }
                }
            }
        }
コード例 #2
0
 public TreatmentMap(IEnumerable <ILocalizedStringResultTreatment> treatments)
 {
     foreach (var treatment in treatments)
     {
         TheMap.Add(treatment.Key, treatment);
     }
 }
コード例 #3
0
ファイル: TheCell.cs プロジェクト: UncleJey/treasure
    public void step()
    {
        if (myCell != null)
        {
            switch (myCell.loot)
            {
            case LootType.PIRATE_WITH_SWORD:
            case LootType.PIRATE:
                Sounds.Play(SoundType.DIE);
                TheMap.PlayerDie();
                break;

            case LootType.SCORE:
                Sounds.Play(SoundType.SCORE);
                TheMap.instance.Score += 3;
                TheMap.UpdateCell(myCellNo, myCell.nextSprite.name, this);
                break;

            case LootType.SWORD:
                Sounds.Play(SoundType.SCORE);
                Player.instance.HaveSword = true;
                TheMap.UpdateCell(myCellNo, myCell.nextSprite.name, this);
                break;

            case LootType.NONE:
                break;

            default:
                Debug.LogError("unknow loot " + myCell.loot.ToString());
                break;
            }
        }
    }
コード例 #4
0
        /// <summary>
        /// A Unity coroutine that runs the turn of every unit in this group.
        /// Default behavior: For every unit, takes its turn. Adds a separation of
        /// "UnityLogic.Options.UnitTurnInterval" seconds between each turn.
        /// </summary>
        public virtual IEnumerable TakeTurn()
        {
            //Keep careful track of the units we're going to update.
            HashSet <Unit> unitsToUpdate = new HashSet <Unit>(UnitsByID.Select(id => TheMap.GetUnit(id)));
            Action <LockedSet <ulong>, ulong> onUnitAdded = (units, unitID) =>
                                                            unitsToUpdate.Add(TheMap.GetUnit(unitID));
            Action <LockedSet <ulong>, ulong> onUnitRemoved = (units, unitID) =>
                                                              unitsToUpdate.Remove(TheMap.GetUnit(unitID));

            UnitsByID.OnElementAdded   += onUnitAdded;
            UnitsByID.OnElementRemoved += onUnitRemoved;

            while (unitsToUpdate.Count > 0)
            {
                Unit unit = unitsToUpdate.First();
                unitsToUpdate.Remove(unit);

                //Take the unit's turn.
                foreach (object o in unit.TakeTurn())
                {
                    yield return(o);
                }

                //Wait for the next turn.
                yield return(UnityLogic.Options.UnitTurnIntervalFlag);
            }

            UnitsByID.OnElementRemoved -= onUnitAdded;
            UnitsByID.OnElementRemoved -= onUnitRemoved;
        }
コード例 #5
0
        public override System.Collections.IEnumerable TakeTurn()
        {
            //Lose food over time.
            if (Food > 0.0f)
            {
                float foodLoss = Player_Char.Consts.FoodLossPerTurn(Strength);
                Food.Value = Mathf.Max(0.0f, Food - foodLoss);
            }
            //If no food is left, lose health over time (i.e. starvation).
            else
            {
                float newHealth = Health - Player_Char.Consts.StarvationDamagePerTurn;
                if (newHealth <= 0.0f)
                {
                    Health.Value = 0.0f;
                    TheMap.RemoveUnit(this);
                    yield break;
                }
                else
                {
                    Health.Value = newHealth;
                }
            }


            //Grab the most pressing job and do it.

            //If no current job exists, find one.
            if (currentlyDoing == null)
            {
                var job = TakeAJob(false);
                if (job != null)
                {
                    StartDoingJob(job, null);
                }
            }
            //If we have a job but it isn't an emergency, see if there IS an emergency.
            else if (!currentlyDoing.IsEmergency)
            {
                var emergencyJob = TakeAJob(true);
                if (emergencyJob != null)
                {
                    var msg = Localization.Get("INTERRUPT_JOB_EMERGENCY",
                                               emergencyJob.ToString());
                    StartDoingJob(emergencyJob, msg);
                }
            }

            //Perform the current job.
            if (currentlyDoing != null)
            {
                foreach (object o in currentlyDoing.TakeTurn())
                {
                    yield return(o);
                }
            }
        }
コード例 #6
0
        public async Task GetPosition()
        {
            Geolocator geolocator = new Geolocator()
            {
                DesiredAccuracyInMeters = 5
            };
            Geoposition pos = await geolocator.GetGeopositionAsync();

            await TheMap.TrySetViewAsync(pos.Coordinate.Point, 15.0);
        }
コード例 #7
0
ファイル: Unit.cs プロジェクト: heyx3/EscapeTheMine
 /// <summary>
 /// Prepares this unit to do pathfinding with the "AStarEdgeCalc()" heuristic method.
 /// Note that to reduce garbage, this heuristic may reuse global variables,
 ///		which means only one Unit can have a heuristic at any time.
 /// </summary>
 private void PrepareAStarEdgeCalc(bool avoidEnemies)
 {
     _temp_enemies.Clear();
     foreach (ulong enemyGroupID in MyGroup.EnemiesByID)
     {
         foreach (ulong enemyUnitID in TheMap.Groups.Get(enemyGroupID).UnitsByID)
         {
             _temp_enemies.Add(TheMap.GetUnit(enemyUnitID));
         }
     }
 }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: winappkits/TomTomAPI
        /// <summary>
        /// Navigates map centering on given location
        /// </summary>
        /// <param name="position">Latitude/longitude point of new location (if null, current location is detected via GPS)</param>
        /// <param name="showMessage">Whether to show message informing user that location tracking is not enabled on device.</param>
        async Task GotoLocation(LatLong position, Boolean showMessage = false)
        {
            Boolean currentLocationRequested = position == null;

            try
            {
                // a null location is the cue to use geopositioning
                if (currentLocationRequested)
                {
                    try
                    {
                        Geoposition currentPosition = await _geolocator.GetGeopositionAsync();

                        position = new LatLong(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude);
                    }
                    catch (Exception)
                    {
                        if (showMessage)
                        {
                            MessageDialog md =
                                new MessageDialog("This application is not able to determine your current location. This can occur if your machine is operating in Airplane mode or if the GPS sensor is otherwise not operating.");
                            md.ShowAsync();
                        }
                    }
                }

                // don't assume a valid location at this point GPS/Wifi disabled may lead to a null location
                if (position != null)
                {
                    // register event handler to do work once the view has been reset
                    TheMap.ViewChangeEnded += TheMap_ViewChangeEndedWithRefreshNeeded;

                    // set pin for current location
                    if (currentLocationRequested)
                    {
                        TheMap.SetCurrentLocationPin(_locationMarker, position);
                    }

                    // pan map to desired location with a default zoom level (when complete, ViewChangeEndedWithRefreshNeeded event will fire)
                    TheMap.SetView(new Location(position.Latitude, position.Longitude), (Double)App.Current.Resources["DefaultZoomLevel"]);
                }
            }

            // catch exception if location permission not granted
            catch (UnauthorizedAccessException)
            {
                if (showMessage)
                {
                    MessageDialog md =
                        new MessageDialog("This application has not been granted permission to capture your current location. Use the Settings charm to provide this access, then try the operation again.");
                    md.ShowAsync();
                }
            }
        }
コード例 #9
0
 private void txtFindAddress_KeyPress(object sender, KeyPressEventArgs e)
 {
     if ((Keys)e.KeyChar == Keys.Enter)
     {
         GeoCoderStatusCode status = TheMap.SetPositionByKeywords(txtFindAddress.Text);
         if (status != GeoCoderStatusCode.G_GEO_SUCCESS)
         {
             _Dh.msgExclamation("Не могу найти '" + txtFindAddress.Text + "', причина: " + status.ToString());
         }
     }
 }
コード例 #10
0
        private void editObject(xObject obj)
        {
            // Check if user has Edit permissions for this group of objects
            if (_Dh.getGroupAccessLevel(_Dh.getGroupById(obj.ObGroupId)).CompareTo(_Dh.AccessLevel.Edit) < 0)
            {
                _Dh.msgExclamation("У вас на достаточно привилегий");
                return;
            }

            // Show markers of polygons
            if (wObject.Polygon != null && _Dh.getGroupById(obj.ObGroupId).GroupType == ObjectType.POLYGON)
            {
                for (int i = 0; i < wObject.Polygon.Points.Count; i++)
                {
                    GMapMarker m = new GMarkerGoogle(wObject.Polygon.Points[i], GMarkerGoogleType.green_pushpin)
                    {
                        Tag = (i) + "", IsVisible = true, ToolTipMode = MarkerTooltipMode.Always
                    };
                    wObject.Polygon.Overlay.Markers.Add(m);

                    TheMap.UpdateMarkerLocalPosition(m);
                }

                TheMap.UpdatePolygonLocalPosition(wObject.Polygon);
            }

            // Show markers of route
            if (wObject.Route != null && _Dh.getGroupById(obj.ObGroupId).GroupType == ObjectType.ROUTE)
            {
                for (int i = 0; i < wObject.Route.Points.Count; i++)
                {
                    GMapMarker m = new GMarkerGoogle(wObject.Route.Points[i], GMarkerGoogleType.green_pushpin)
                    {
                        Tag = (i) + "", IsVisible = true, ToolTipMode = MarkerTooltipMode.Always
                    };
                    wObject.Route.Overlay.Markers.Add(m);

                    TheMap.UpdateMarkerLocalPosition(m);
                }

                TheMap.UpdateRouteLocalPosition(wObject.Route);
            }

            var fObjInfo = new FrmObjInfo(obj);

            fObjInfo.Show();
            if (_Dh.myAccount.IsModerator)
            {
                isEditMode = true;
            }

            //    RefreshUI();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var geolocator = new Windows.Devices.Geolocation.Geolocator()
            {
                DesiredAccuracyInMeters = 5
            };
            var pos = await geolocator.GetGeopositionAsync();

            LongBlock.Text = $"{pos.Coordinate.Point.Position.Longitude:#.00}";
            LatBlock.Text  = $"{pos.Coordinate.Point.Position.Latitude:#.00}";
            await TheMap.TrySetViewAsync(pos.Coordinate.Point, 15.0);
        }
コード例 #12
0
 public Bed(Map theMap, ulong groupID, Vector2i pos)
     : base(theMap, groupID, pos)
 {
     //Keep track of when sleeping units die.
     SleepingUnitsByID.OnElementAdded += (ids, id) =>
     {
         TheMap.GetUnit(id).OnKilled += Callback_SleeperKilled;
     };
     SleepingUnitsByID.OnElementRemoved += (ids, id) =>
     {
         TheMap.GetUnit(id).OnKilled -= Callback_SleeperKilled;
     };
 }
コード例 #13
0
        public async void MyPositionClicked(object sender, EventArgs e)
        {
            try
            {
                var pos = VM.CurrentLocation;

                var update = CameraUpdateFactory.NewPosition(new Position(pos.Latitude, pos.Longitude));

                await TheMap.AnimateCamera(update, TimeSpan.FromMilliseconds(200));
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
コード例 #14
0
    void Awake()
    {
        QualitySettings.vSyncCount      = 1;
        Application.targetFrameRate     = 50;
        QualitySettings.maxQueuedFrames = 3;

        Language.rus = Application.systemLanguage == SystemLanguage.Russian ||
                       Application.systemLanguage == SystemLanguage.Ukrainian ||
                       Application.systemLanguage == SystemLanguage.Belarusian;
        instance = this;
        InitMap();

        btnPlay.onClick.AddListener(DoStartGame);
        btnInfo.onClick.AddListener(ShowInformation);
    }
コード例 #15
0
        private async void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Geolocator geolocator = new Geolocator()
            {
                DesiredAccuracyInMeters = 5
            };
            Geoposition pos = await geolocator.GetGeopositionAsync();

            string longitude = pos.Coordinate.Point.Position.Longitude.ToString();
            string latitude  = pos.Coordinate.Point.Position.Latitude.ToString();

            LongBlock.Text = longitude;
            LatBlock.Text  = latitude;

            await TheMap.TrySetViewAsync(pos.Coordinate.Point, 15.0);
        }
コード例 #16
0
ファイル: MainPage.xaml.cs プロジェクト: winappkits/TomTomAPI
        /// <summary>
        /// Synchronizes changes to the ApiViewModel's Results collection. The elements of that collection are assumed
        /// to implement IMappable (see the APIMASH_TomTom.TomTomCameraViewModel implementation for a sample reference).
        /// This code should require no changed regardless as long as the items in the Results collection implement IMappable.
        /// </summary>
        void Results_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            // only additions and wholesale reset of the ObservableCollection are currently supported
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    IMappable mapItem = (IMappable)item;

                    PointOfInterestPin poiPin = new PointOfInterestPin(mapItem);
                    poiPin.Tap += async(s, e2) =>
                    {
                        TheMap.HighlightPointOfInterestPin(DefaultViewModel.SelectedItem, false);
                        TheMap.HighlightPointOfInterestPin(poiPin.PointOfInterest, true);

                        await ProcessSelectedItem(item);
                    };

                    TheMap.AddPointOfInterestPin(poiPin, mapItem.Position);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                TheMap.ClearPointOfInterestPins();
                break;

                // case NotifyCollectionChangedAction.Remove:
                //
                // TODO: (optional) if your application allows items to be selectively removed from the view model
                //       code to remove a single associated push pin will be required.
                //
                //
                //
                // break;


                // not implemented in this context
                // case NotifyCollectionChangedAction.Replace:
                // case NotifyCollectionChangedAction.Move:
            }
        }
コード例 #17
0
ファイル: TownRenderer.cs プロジェクト: eylvisaker/Xle
        protected override int TileToDraw(int x, int y)
        {
            int tile = base.TileToDraw(x, y);

            var roof = TheMap.ClosedRoofAt(x, y);

            if (roof == null)
            {
                return(tile);
            }

            var roofTile = roof.TileAtMapCoords(x, y);

            if (roofTile == 0)
            {
                return(tile);
            }

            return(roofTile);
        }
コード例 #18
0
        private async void LocationsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            var newItems = new List <Location>();

            if (e.NewItems?.Count > 0)
            {
                foreach (var item in e.NewItems)
                {
                    var loc = item as Location;
                    newItems.Add(loc);
                }

                var minLat = Vm.Locations.OrderBy(x => x.Latitude).FirstOrDefault().Latitude;
                var maxLat = Vm.Locations.OrderByDescending(x => x.Latitude).FirstOrDefault().Latitude;
                var minLon = Vm.Locations.OrderBy(x => x.Longitude).FirstOrDefault().Longitude;
                var maxLon = Vm.Locations.OrderByDescending(x => x.Longitude).FirstOrDefault().Longitude;
                var update = Xamarin.Forms.GoogleMaps.CameraUpdateFactory.NewBounds(new Xamarin.Forms.GoogleMaps.Bounds(new Xamarin.Forms.GoogleMaps.Position(minLat, minLon), new Xamarin.Forms.GoogleMaps.Position(maxLat, maxLon)), 50);
                await TheMap.AnimateCamera(update, TimeSpan.FromMilliseconds(100));
            }
        }
コード例 #19
0
        private void TheMap_MouseMove(object sender, MouseEventArgs e)
        {
            PointLatLng point = TheMap.FromLocalToLatLng(e.X, e.Y);

            lblCoords.Text = _Dh.getLatitude(point) + " " + _Dh.getLongitude(point);

            //polygon.Points[2] = polygon.Points[4];
            //TheMap.UpdatePolygonLocalPosition(polygon);

            if (e.Button == MouseButtons.Left && isMouseDown && isEditMode)
            {
                // Show on map the change of position
                if (wObject != null)
                {
                    int index = Convert.ToInt32(wMarker.Tag);

                    switch (_Dh.getGroupById(wObject.ObGroupId).GroupType)
                    {
                    case ObjectType.POLYGON:
                        wMarker.Position = point;

                        wObject.Polygon.Points[index] = wMarker.Position;
                        TheMap.UpdatePolygonLocalPosition(wObject.Polygon);
                        break;

                    case ObjectType.ROUTE:
                        wMarker.Position = point;

                        wObject.Route.Points[index] = wMarker.Position;
                        TheMap.UpdateRouteLocalPosition(wObject.Route);
                        break;

                    case ObjectType.DOT:
                        wObject.Marker.Position = point;
                        break;
                    }
                }
            }
        }
コード例 #20
0
ファイル: TheCell.cs プロジェクト: UncleJey/treasure
    // Попали ли во что-то мечём
    public hitType hit(bool isPlayer)
    {
        if (image.sprite.name == "empty")
        {
            return(hitType.NONE);
        }

        if (myCell != null)
        {
            switch (myCell.loot)
            {
            case LootType.PIRATE:
            case LootType.PIRATE_WITH_SWORD:
                if (isPlayer)
                {
                    TheMap.UpdateCell(myCellNo, "empty", this);
                    Sounds.Play(SoundType.DIE);
                    return(hitType.PIRATE);
                }
                else
                {
                    return(hitType.NONE);
                }
                break;

            case LootType.NONE:                         // хз что
                break;

            default:
                return(hitType.NONE);                           // через лут пролетает

                break;
            }
        }
        return(hitType.FOREST);
    }
コード例 #21
0
ファイル: MainPage.xaml.cs プロジェクト: msruzy/hydronumerics
        void TheMap_MouseDoubleClick(object sender, MapMouseEventArgs e)
        {
            Pushpin  p = new Pushpin();
            Location loc;

            if (TheMap.TryViewportPointToLocation(e.ViewportPoint, out loc))
            {
            }
            p.Location = loc;
            var ts = new HydroNumerics.Time.Web.TimeSeriesService.GeoXYPointTime();

            var val = new HydroNumerics.Time.Web.TimeSeriesService.TimestampValue();

            val.Time  = DateTime.Now;
            val.Value = 0;
            ts.items  = new System.Collections.ObjectModel.ObservableCollection <HydroNumerics.Time.Web.TimeSeriesService.TimestampValue>();
            ts.items.Add(val);

            p.Tag = ts;

            TheMap.Children.Add(p);
            TheMap.MouseDoubleClick -= TheMap_MouseDoubleClick;
            p_MouseLeftButtonUp(p, null);
        }
コード例 #22
0
ファイル: MainPage.xaml.cs プロジェクト: winappkits/TomTomAPI
 /// <summary>
 /// Dismiss current item's detail image
 /// </summary>
 private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     TheMap.HighlightPointOfInterestPin(DefaultViewModel.SelectedItem, false);
     DefaultViewModel.SelectedItem = null;
 }
コード例 #23
0
ファイル: MainPage.xaml.cs プロジェクト: winappkits/TomTomAPI
        /// <summary>
        /// Pans map to given location and queries for cameras now in view
        /// </summary>
        /// <param name="position">Position to which to pan the map (null indicates current location)</param>
        async Task GotoLocation(GeoCoordinate position)
        {
            Boolean currentLocationRequested = position == null;

            // turn on progress bar
            if (_apiMonitor != null)
            {
                _apiMonitor.IsExecuting = true;
            }
            DefaultViewModel.SelectedItem = null;

            // a null location is the cue to use geopositioning
            if (currentLocationRequested)
            {
                try
                {
                    _geolocator = new Geolocator();

#if DEBUG
                    // location emulator will always set current location to Redmond unless accuracy is set to High
                    _geolocator.DesiredAccuracy = PositionAccuracy.High;
#endif

                    // have to set this (or MovementThreshold) in WP8 before attaching event handlers
                    _geolocator.ReportInterval = uint.MaxValue;

                    // register callback to reset (hide) the user's location if location access is revoked while app is running
                    _geolocator.StatusChanged += (s, a) =>
                    {
                        this.Dispatcher.BeginInvoke(
                            new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            if (a.Status == PositionStatus.Disabled)
                            {
                                _settingsViewModel.LocationEnabled = false;
                                _locationMarker.Visibility         = Visibility.Collapsed;
                            }
                        })
                            );
                    };

                    // get current location
                    Geoposition currentPosition = await _geolocator.GetGeopositionAsync();

                    position = currentPosition.Coordinate.ToGeoCoordinate();
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        String.Format("Location services are turned off for this device, so {0} cannot plot your current position. You can, however, still search for and view camera images within the application.", AppResources.ApplicationTitle),
                        "Location services are off",
                        MessageBoxButton.OK);
                }
            }

            // don't assume a valid location at this point GPS/Wifi disabled may lead to a null location
            if (position != null)
            {
                // register event handler to do work once the view has been reset
                TheMap.ViewChanged += TheMap_ViewChanged;

                // set pin for current location
                if (currentLocationRequested)
                {
                    TheMap.SetCurrentLocationPin(_locationMarker, position);
                }

                // pan map to desired location with a default zoom level (when complete, TheMap_ViewChanged event will fire)
                TheMap.SetView(position, (Double)App.Current.Resources["DefaultZoomLevel"]);
            }

            // turn off progress bar
            if (_apiMonitor != null)
            {
                _apiMonitor.IsExecuting = false;
            }
        }
コード例 #24
0
        protected virtual async Task FightInDirection(Direction fightDir)
        {
            bool attacked = false;
            int  maxXdist = 1;
            int  maxYdist = 1;
            int  tile = 0, tile1;
            int  hit = 0;

            if (Player.CurrentWeapon.Info(Data).Ranged)
            {
                maxXdist = 12;
                maxYdist = 8;
            }

            Player.FaceDirection = fightDir;

            Point attackPt  = Point.Zero,
                  attackPt2 = Point.Zero;

            attackPt.X  = Player.X;
            attackPt.Y  = Player.Y;
            attackPt2.X = attackPt.X;
            attackPt2.Y = attackPt.Y;

            int dx = 0, dy = 0;

            switch (fightDir)
            {
            case Direction.East:
                attackPt.X++;
                attackPt2.X++;
                attackPt2.Y++;
                dx = 1;
                break;

            case Direction.North:
                dy = -1;
                attackPt2.X++;
                break;

            case Direction.West:
                dx = -1;
                attackPt2.Y++;
                break;

            case Direction.South:
                dy = 1;
                attackPt.Y++;
                attackPt2.X++;
                attackPt2.Y++;
                break;
            }

            for (int i = 1; i <= maxXdist && attacked == false && tile < 128; i++)
            {
                for (int j = 1; j <= maxYdist && attacked == false && tile < 128; j++)
                {
                    for (int k = 0; k < guards.Count; k++)
                    {
                        if ((guards[k].X == attackPt.X + dx * i ||
                             guards[k].X + 1 == attackPt.X + dx * i ||
                             guards[k].X == attackPt2.X + dx * i ||
                             guards[k].X + 1 == attackPt2.X + dx * i
                             )
                            &&
                            (guards[k].Y == attackPt.Y + dy * j ||
                             guards[k].Y + 1 == attackPt.Y + dy * j ||
                             guards[k].Y == attackPt2.Y + dy * j ||
                             guards[k].Y + 1 == attackPt2.Y + dy * j
                            )
                            &&
                            attacked == false)
                        {
                            await AttackGuard(k, Math.Max(i, j));

                            attacked = true;

                            await GameControl.WaitAsync(200);
                        }
                    }

                    tile  = TheMap[attackPt.X + dx, attackPt.Y + dy];
                    tile1 = TheMap[attackPt2.X + dx, attackPt2.Y + dy];

                    int t = TheMap.RoofTile(attackPt.X + dx, attackPt.Y + dy);
                    if (t != 127 && t != 0)
                    {
                        tile = 128;
                    }

                    t = TheMap.RoofTile(attackPt2.X + dx, attackPt2.Y + dy);
                    if (t != 127 && t != 0)
                    {
                        tile1 = 128;
                    }


                    if (tile == 222 || tile == 223 || tile == 238 || tile == 239)
                    {
                        hit = 1;
                    }
                    else if (tile1 == 222 || tile1 == 223 || tile1 == 238 || tile1 == 239)
                    {
                        hit = 2;
                    }
                    if (hit > 0)
                    {
                        if (hit == 1)
                        {
                            if (tile == 223)
                            {
                                attackPt.X--;
                            }
                            else if (tile == 238)
                            {
                                attackPt.Y--;
                            }
                            else if (tile == 239)
                            {
                                attackPt.X--;
                                attackPt.Y--;
                            }
                        }
                        else if (hit == 2)
                        {
                            attackPt = attackPt2;

                            if (tile1 == 223)
                            {
                                attackPt.X--;
                            }
                            else if (tile1 == 238)
                            {
                                attackPt.Y--;
                            }
                            else if (tile1 == 239)
                            {
                                attackPt.X--;
                                attackPt.Y--;
                            }
                        }

                        int dam = Random.Next(10) + 30;

                        await TextArea.PrintLine();

                        await TextArea.PrintLine("Merchant killed by blow of " + dam.ToString());

                        TheMap[attackPt.X + dx, attackPt.Y + dy]         = 0x52;
                        TheMap[attackPt.X + dx, attackPt.Y + dy + 1]     = 0x52;
                        TheMap[attackPt.X + dx + 1, attackPt.Y + dy + 1] = 0x52;
                        TheMap[attackPt.X + dx + 1, attackPt.Y + dy]     = 0x52;

                        IsAngry = true;

                        SoundMan.PlaySound(LotaSound.EnemyDie);

                        attacked = true;
                    }

                    if (tile == 176 || tile1 == 176 || tile == 192 || tile == 192)
                    {
                        await TextArea.PrintLine("The prison bars hold.");

                        SoundMan.PlaySound(LotaSound.Bump);

                        attacked = true;
                    }
                }
            }

            if (attacked == false)
            {
                await TextArea.PrintLine("Nothing hit");
            }

            await GameControl.WaitAsync(200 + 50 *Player.Gamespeed, keyBreak : true);
        }
コード例 #25
0
ファイル: MainPage.xaml.cs プロジェクト: winappkits/TomTomAPI
        public MainPage()
        {
            this.InitializeComponent();

            // check to see if this is the first time application is being executed by checking for data in local settings.
            // After checking add some notional data as marker for next time app is run. This will be used to determine whether
            // to prompt the user (or not) that location services are not turned on for the app/system. Without this check, the
            // first time the app is run, it will provide a system prompt, and if that prompt is dismissed without granting
            // access the propmpt displayed by the application would also appear unnecessarily.
            _firstRun = ApplicationData.Current.LocalSettings.Values.Count == 0;
            if (_firstRun)
            {
                ApplicationData.Current.LocalSettings.Values.Add(
                    new System.Collections.Generic.KeyValuePair <string, object>("InitialRunDate", DateTime.UtcNow.ToString()));
            }

            // whenever map view changes track center point and zoom level in page state
            TheMap.ViewChangeEnded += (s, e) =>
            {
                _pageState.MapCenter = new LatLong(TheMap.TargetCenter.Latitude, TheMap.TargetCenter.Longitude);
                _pageState.Zoom      = TheMap.TargetZoomLevel;
            };

            // set the reference to the current map for the LeftPanel (note: using Element binding will not handle all of the page navigation scenarios)
            LeftPanel.Map = TheMap;

            // whenever the contents of left panel are refreshed, save the map coordinates that were in play as part of the page state
            LeftPanel.Refreshed += (s, e) =>
            {
                _pageState.MapBox = new BoundingBox(TheMap.TargetBounds.North, TheMap.TargetBounds.South, TheMap.TargetBounds.West, TheMap.TargetBounds.East);
            };

            // whenver a new item is selected in the left panel, update the map pins and save the item selected as part of the page state
            LeftPanel.ItemSelected += (s, e) =>
            {
                TheMap.HighlightPointOfInterestPin(e.NewItem, true);
                TheMap.HighlightPointOfInterestPin(e.OldItem, false);

                this._pageState.SelectedItemId = e.NewItem == null ? null : e.NewItem.Id;
            };

            // whenever a new location is selected from the SearchFlyout (this is NOT the Search charm) update the position accordingly
            SearchFlyout.LocationChanged += (s, e) =>
            {
                GotoLocation(e.Position);
                SearchFlyout.Hide();
            };

            // manage SearchFlyout visibility/interaction
            this.Tapped += (s, e) =>
            {
                if (SearchFlyout.IsOpen)
                {
                    SearchFlyout.Hide();
                    e.Handled = true;
                }
            };
            BottomAppBar.Opened += (s, e) => { SearchFlyout.Hide(); };
            SearchFlyout.Tapped += (s, e) => { e.Handled = true; };

            // allow type-to-search for Search charm
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;

            // The BingMaps API allows use of a "session key" if the application leverages the Bing Maps control. By using the session
            // key instead of the API key, only one transaction is logged agains the key versus one transaction for every API call! This
            // code sets the key asynchronously and stored it as a resource so it's available when the REST API's are invoked.
            TheMap.Loaded += async(s, e) =>
            {
                if (!Application.Current.Resources.ContainsKey("BingMapsSessionKey"))
                {
                    Application.Current.Resources.Add("BingMapsSessionKey", await TheMap.GetSessionIdAsync());
                }
            };

            // register callback to reset (hide) the user's location, if location access is revoked while app is running
            _geolocator.StatusChanged += (s, a) =>
            {
                this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                         new Windows.UI.Core.DispatchedHandler(() =>
                {
                    if (a.Status == PositionStatus.Disabled)
                    {
                        _locationMarker.Visibility = Visibility.Collapsed;
                    }
                })
                                         );
            };
        }
コード例 #26
0
        public override IEnumerable TakeTurn()
        {
            //Gain stats for everybody in bed.
            foreach (ulong unitID in SleepingUnitsByID)
            {
                var pChar = (PlayerChar)TheMap.GetUnit(unitID);
                pChar.Energy.Value +=
                    Player_Char.Consts.EnergyIncreaseFromBedPerTurn(SleepingUnitsByID.Count,
                                                                    pChar.AdultMultiplier);
                pChar.Health.Value +=
                    Player_Char.Consts.HealthIncreaseFromBedPerTurn(SleepingUnitsByID.Count,
                                                                    pChar.AdultMultiplier);
            }

            //Count the number of male/female pairs.
            int nMales   = 0,
                nFemales = 0;

            foreach (Unit unit in SleepingUnitsByID.Select(id => TheMap.GetUnit(id)))
            {
                PlayerChar pChar = (PlayerChar)unit;
                if (pChar.IsAdult)
                {
                    switch (pChar.Personality.Gender.Value)
                    {
                    case Player_Char.Personality.Genders.Male:
                        nMales += 1;
                        break;

                    case Player_Char.Personality.Genders.Female:
                        nFemales += 1;
                        break;

                    default:
                        throw new NotImplementedException(((PlayerChar)unit).Personality.Gender.ToString());
                    }
                }
            }
            int nPairs = Math.Min(nMales, nFemales);

            //For each pair, give them a chance to make a baby.
            for (int i = 0; i < nPairs; ++i)
            {
                if (UnityEngine.Random.value < Player_Char.Consts.ReproductionChance)
                {
                    //Get the father and mother.
                    ulong fatherID = SleepingUnitsByID.Where(id =>
                    {
                        PlayerChar pc = (PlayerChar)TheMap.GetUnit(id);
                        return(pc.Personality.Gender.Value == Player_Char.Personality.Genders.Male);
                    }).ElementAt(i);
                    ulong motherID = SleepingUnitsByID.Where(id =>
                    {
                        PlayerChar pc = (PlayerChar)TheMap.GetUnit(id);
                        return(pc.Personality.Gender.Value == Player_Char.Personality.Genders.Female);
                    }).ElementAt(i);

                    PlayerChar father = (PlayerChar)TheMap.GetUnit(fatherID),
                               mother = (PlayerChar)TheMap.GetUnit(motherID);

                    //Create the baby.
                    var gender = (UnityEngine.Random.value > 0.5f ?
                                  Player_Char.Personality.Genders.Male :
                                  Player_Char.Personality.Genders.Female);
                    int        seed = UnityEngine.Random.Range(0, int.MaxValue);
                    string     name = Player_Char.Personality.GenerateName(gender, seed);
                    PlayerChar baby =
                        new PlayerChar(TheMap, father.MyGroupID,
                                       UnityEngine.Mathf.Lerp(Player_Char.Consts.MinStart_Food,
                                                              Player_Char.Consts.MaxStart_Food,
                                                              UnityEngine.Random.value),
                                       UnityEngine.Mathf.Lerp(Player_Char.Consts.MinStart_Energy,
                                                              Player_Char.Consts.MaxStart_Energy,
                                                              UnityEngine.Random.value),
                                       UnityEngine.Mathf.Lerp(Player_Char.Consts.MinStart_Strength,
                                                              Player_Char.Consts.MaxStart_Strength,
                                                              UnityEngine.Random.value),
                                       0.0f, name, gender);
                    TheMap.AddUnit(baby);
                    baby.Pos.Value = Pos;

                    if (OnMakeBaby != null)
                    {
                        OnMakeBaby(this, father, mother, baby);
                    }
                }
            }

            yield break;
        }
コード例 #27
0
        private async Task DownloadOnDemandMap()
        {
            var downloadTask = await OfflineMapTask.CreateAsync(TheMap.Map);

            var parameters = await downloadTask.CreateDefaultGenerateOfflineMapParametersAsync(TheMap.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry);

            parameters.AttachmentSyncDirection     = AttachmentSyncDirection.None;
            parameters.ReturnLayerAttachmentOption = ReturnLayerAttachmentOption.None;
            var job = downloadTask.GenerateOfflineMap(parameters, OnDemandDataFolder);

            job.ProgressChanged += OnDemandJob_ProgressChanged;
            var result = await job.GetResultAsync();

            if (!result.HasErrors)
            {
                OnDemandStatusLabel.Text      = "OnDemand Map: Download complete.";
                OnDemandStatusLabel.TextColor = Color.Green;
                _onDemandMap = result.OfflineMap;
            }
            else
            {
                OnDemandStatusLabel.Text      = "OnDemand Map: Completed with errors.";
                OnDemandStatusLabel.TextColor = Color.Red;
            }

            ConditionallyEnableStep2();
        }
コード例 #28
0
ファイル: MainPage.xaml.cs プロジェクト: jimoneil/TrafficCams
        public MainPage()
        {
            this.InitializeComponent();

            // view model
            this.DefaultViewModel["PendingRefresh"] = false;

            // check to see if this is the first time application is being executed by checking for data in local settings.
            // After checking add some notional data as marker for next time app is run. This will be used to determine whether
            // to prompt the user (or not) that location services are not turned on for the app/system. Without this check, the
            // first time the app is run, it will provide a system prompt, and if that prompt is dismissed without granting
            // access the propmpt displayed by the application would also appear unnecessarily.
            _firstRun = ApplicationData.Current.LocalSettings.Values.Count == 0;
            if (_firstRun)
            {
                ApplicationData.Current.LocalSettings.Values.Add(
                    new System.Collections.Generic.KeyValuePair <string, object>("InitialRunDate", DateTime.UtcNow.ToString()));
            }

            this.SizeChanged += (s, e) =>
            {
                // determine if there's been a change in orientation that doesn't require notice that the map view has changed (e.g., app open, snapped mode transitions)
                if (_priorOrientation == ApplicationView.Value)
                {
                    return;
                }

                _noRefreshRequiredViewChange = (_priorOrientation == ApplicationViewState.Snapped || ApplicationView.Value == ApplicationViewState.Snapped);
                _priorOrientation            = ApplicationView.Value;

                VisualStateManager.GoToState(LeftPanel, ApplicationView.Value.ToString(), true);
            };

            // whenever map view changes track center point and zoom level in page state
            TheMap.ViewChangeEnded += (s, e) =>
            {
                // save new center/zoom for page state
                _pageState.MapCenter = new LatLong(TheMap.TargetCenter.Latitude, TheMap.TargetCenter.Longitude);
                _pageState.Zoom      = TheMap.TargetZoomLevel;

                // ViewChangeEnded fires a bit too often, so retain bounding box to determine if the view truly has changed
                BoundingBox thisBox = new BoundingBox(TheMap.TargetBounds.North, TheMap.TargetBounds.South,
                                                      TheMap.TargetBounds.West, TheMap.TargetBounds.East);

                // determine if view change should notify user of pending refresh requirement
                if (_retainRefreshRequiredViewChange)
                {
                    this.DefaultViewModel["PendingRefresh"] = _pageState.PendingRefresh;
                }
                else if (_noRefreshRequiredViewChange)
                {
                    this.DefaultViewModel["PendingRefresh"] = false;
                }
                else if (App.InitialMapResizeHasOccurred)
                {
                    this.DefaultViewModel["PendingRefresh"] = (thisBox != _lastBox);
                }

                // update state variables
                _lastBox = thisBox;
                if (App.InitialMapResizeHasOccurred)
                {
                    _noRefreshRequiredViewChange = false;
                }
                _retainRefreshRequiredViewChange = false;
                App.InitialMapResizeHasOccurred  = true;
            };

            // if refresh prompt is tapped, refresh the map
            RefreshPrompt.Tapped += async(s, e) =>
            {
                await LeftPanel.Refresh(_lastBox);

                this.DefaultViewModel["PendingRefresh"] = false;
            };

            // a tap on map will cause refresh is one is predicated
            TheMap.Tapped += async(s, e) =>
            {
                if ((Boolean)this.DefaultViewModel["PendingRefresh"])
                {
                    await LeftPanel.Refresh(_lastBox);

                    this.DefaultViewModel["PendingRefresh"] = false;
                }
            };

            // set the reference to the current map for the LeftPanel (note: using Element binding will not handle all of the page navigation scenarios)
            LeftPanel.Map = TheMap;

            // whenever the contents of left panel are refreshed, save the map coordinates that were in play as part of the page state
            LeftPanel.Refreshed += (s, e) =>
            {
                _pageState.MapBox = new BoundingBox(TheMap.TargetBounds.North, TheMap.TargetBounds.South, TheMap.TargetBounds.West, TheMap.TargetBounds.East);
            };

            // whenver a new item is selected in the left panel, update the map pins and save the item selected as part of the page state
            LeftPanel.ItemSelected += (s, e) =>
            {
                TheMap.HighlightPointOfInterestPin(e.NewItem, true);
                TheMap.HighlightPointOfInterestPin(e.OldItem, false);

                this._pageState.SelectedItemId = e.NewItem == null ? null : e.NewItem.Id;
            };

            // whenever a new location is selected from the SearchFlyout (this is NOT the Search charm) update the position accordingly
            SearchFlyout.LocationChanged += (s, e) =>
            {
                GotoLocation(e.Position);
                SearchFlyout.Hide();
            };

            // manage SearchFlyout visibility/interaction
            this.Tapped += (s, e) =>
            {
                if (SearchFlyout.IsOpen)
                {
                    SearchFlyout.Hide();
                    e.Handled = true;
                }
            };
            BottomAppBar.Opened += (s, e) => { SearchFlyout.Hide(); };
            SearchFlyout.Tapped += (s, e) => { e.Handled = true; };

            // allow type-to-search for Search charm
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;

            // The BingMaps API allows use of a "session key" if the application leverages the Bing Maps control. By using the session
            // key instead of the API key, only one transaction is logged agains the key versus one transaction for every API call! This
            // code sets the key asynchronously and stored it as a resource so it's available when the REST API's are invoked.
            TheMap.Loaded += async(s, e) =>
            {
                if (!Application.Current.Resources.ContainsKey("BingMapsSessionKey"))
                {
                    Application.Current.Resources.Add("BingMapsSessionKey", await TheMap.GetSessionIdAsync());
                }
            };
        }
コード例 #29
0
ファイル: BingMilSymLayer.cs プロジェクト: HillHouse/MilSym
 /// <summary>
 /// Returns the latitude and longitude corresponding to a screen point.
 /// </summary>
 /// <param name="p">
 /// The screen point.
 /// </param>
 /// <returns>The latitude and longitude corresponding to the screen point.</returns>
 public ILocation PointToLocation(Point p)
 {
     TheMap.GetLocationFromOffset(p, out Geopoint loc);
     return(new BingLocation(loc.Position.Latitude, loc.Position.Longitude));
 }
コード例 #30
0
ファイル: Sword.cs プロジェクト: UncleJey/treasure
    void checkPoint(float pX, float pY)
    {
        int XX = pX < 0 ? -1 : (int)(pX / TheMap.cellSize);
        int YY = pY < 0 ? -1 : (int)(pY / TheMap.cellSize);

        // сначала проверяем не ударилось ли в препятствие
        hitType ht = hitType.NONE;

        if (XX < 0 || XX > 7 || YY < 0 || YY > 5)
        {
            ht = hitType.FOREST;
        }
        else
        {
            ht = TheMap.instance.rows [YY].columns[XX].hit(playerBy);
        }

        if (playerBy)
        {
            switch (ht)
            {
            case hitType.FOREST:
                Sounds.Play(SoundType.DIE);
                Destroy(gameObject);
                break;

            case hitType.NONE:
                break;

            case hitType.PIRATE:
                TheMap.instance.Score += 1;
                Destroy(gameObject);
                break;
            }
        }
        else
        {
            if (flying)
            {
                switch (ht)
                {
                case hitType.FOREST:
                    Sounds.Play(SoundType.DIE);
                    flying = false;
                    break;

                case hitType.NONE:
                    break;

                case hitType.PIRATE:
                    break;
                }

                if (Intersection(Player.instance.Position, Position))
                {
                    TheMap.PlayerDie();
                    Sounds.Play(SoundType.DIE);
                    Destroy(gameObject);
                }
            }
            else
            {
                if (Intersection(Player.instance.Position, Position))
                {
                    Player.instance.HaveSword = true;
                    Sounds.Play(SoundType.SCORE);
                    playerBy = true;
                    if (myOwner != null)
                    {
                        myOwner.nextState();
                    }
                    Destroy(gameObject);
                }
            }
        }
    }