コード例 #1
0
        private async void SaveButton_Clicked(object sender, EventArgs e)
        {
            if (_pinList == null)
            {
                await DisplayAlert("Błąd!", "Nie dodano żadnych punktów trasy na mapie", "Ok");
            }
            else
            {
                var list = new List <PointOnTheMapVm>();

                foreach (var item in _pinList)
                {
                    var pointOnTheMapVm = new PointOnTheMapVm();
                    pointOnTheMapVm.XCoordinate = item.Position.Latitude;
                    pointOnTheMapVm.YCoordinate = item.Position.Longitude;
                    list.Add(pointOnTheMapVm);
                }

                var data = await PointOnTheMapService.AddPointOnTheMap(list);

                var ListVm = new List <WaypointVm>();
                foreach (var item in data)
                {
                    var waypointVm = new WaypointVm();
                    waypointVm.IdPointOnTheMap   = item.IdPointOnTheMap;
                    waypointVm.IdUserInformation = idUserInfo;
                    ListVm.Add(waypointVm);
                }

                WaypointService.AddWaypoint(ListVm);
                await DisplayAlert("Informacja!", "Zapisano nową trasę.", "Ok");
            }
        }
コード例 #2
0
        public void RemoveWaypoint(Waypoint RemoveWp)
        {
            switch (Waypoints.Count)
            {
            case 0:
            case 1:
                break;

            case 2:
                lock (WaypointsTableLock)
                {
                    foreach (Waypoint Wp in Waypoints)
                    {
                        WaypointService.DatabaseDeleteWaypoint(Wp);
                    }
                    Waypoints.Clear();
                }     //lock
                break;

            default:
                lock (WaypointsTableLock)
                {
                    int Index = -1;
                    foreach (Waypoint Wp in Waypoints)
                    {
                        if (Wp.GUID == RemoveWp.GUID)
                        {
                            Index = Waypoints.IndexOf(Wp);
                        }
                    }
                    if (Index != -1)
                    {
                        if (Index != 0)
                        {
                            if (Index == Waypoints.Count)
                            {
                                Waypoints[Index - 1].NextWaypointGUID = 0;
                            }
                            else
                            {
                                Waypoints[Index - 1].NextWaypointGUID = Waypoints[Index].NextWaypointGUID;
                            }

                            WaypointService.DatabaseSaveWaypoint(Waypoints[Index - 1]);
                            WaypointService.DatabaseDeleteWaypoint(Waypoints[Index]);
                            Waypoints.RemoveAt(Index);
                        }
                    }
                }
                // lock (WaypointsTableLock)
                break;
            } // switch
        }
コード例 #3
0
        public void SpawnGuard(Realms realm)
        {
            if (Creature != null)
            {
                Creature.Destroy();
                Creature = null;
            }

            if (realm != Realms.REALMS_REALM_NEUTRAL)
            {
                if (Info.DestroId == 0 && realm == Realms.REALMS_REALM_DESTRUCTION)
                {
                    _logger.Trace($"Creature Id = 0, no spawning");
                }
                else
                {
                    Creature_proto proto = CreatureService.GetCreatureProto(realm == Realms.REALMS_REALM_ORDER ? Info.OrderId : Info.DestroId);

                    if (proto == null)
                    {
                        Log.Error("KeepNPC", "No FlagGuard Proto");
                        return;
                    }
                    _logger.Trace($"Spawning Guard {proto.Name} ({proto.Entry})");

                    Creature_spawn spawn = new Creature_spawn();
                    spawn.BuildFromProto(proto);
                    spawn.WorldO = Info.O;
                    spawn.WorldX = Info.X;
                    spawn.WorldY = Info.Y;
                    spawn.WorldZ = Info.Z;
                    spawn.ZoneId = Info.ZoneId;

                    Creature = new KeepCreature(spawn, this, Keep);
                    Creature.WaypointGUID = Convert.ToUInt32(Info.WaypointGUID);
                    if (Info.WaypointGUID > 0)
                    {
                        Creature.AiInterface.Waypoints = WaypointService.GetKeepNpcWaypoints(Info.WaypointGUID);
                    }


                    Region.AddObject(Creature, spawn.ZoneId);
                }
            }
        }
コード例 #4
0
        public override bool Load()
        {
            _unit = (Unit)_Owner;

            if (!(_Owner is Player))
            {
                if (CurrentBrain == null)
                {
                    SetBrain(new DummyBrain(_unit));
                }
            }

            _unit.EvtInterface.AddEventNotify(EventName.OnTargetDie, OnTargetDie);

            ResetThinkInterval();

            // Load Waypoints if they exist.
            //if (_unit.WaypointGUID != 0) // Conflicting with load from KeepNPCCreature
            //    this.Waypoints = WaypointService.GetNpcWaypoints(_unit.WaypointGUID);

            if (_Owner is KeepCreature)
            {
            }
            else
            {
                if (_unit is Creature)
                {
                    if ((_unit as Creature).Spawn != null)
                    {
                        if ((_unit is GuardCreature) || (_unit is Siege) || (_unit is Pet))
                        {
                        }
                        else
                        {
                            this.Waypoints = WaypointService.GetNpcWaypoints((_unit as Creature).Spawn.Guid);
                        }
                    }
                }
            }


            return(base.Load());
        }
コード例 #5
0
        private async void DrawRoute()
        {
            locationsMap.MapElements.Clear();

            Polyline polyline = new Polyline
            {
                StrokeColor = Color.Red,
                StrokeWidth = 15
            };

            List <WaypointVm> data = new List <WaypointVm>();

            data = await WaypointService.GetWaypoints(idUserInfo);

            if (data != null)
            {
                foreach (var item in data)
                {
                    Pin newPin = new Pin()
                    {
                        Label = "punkt",
                        Type  = PinType.Place
                    };

                    newPin.Position = new Xamarin.Forms.Maps.Position(item.XCoordinate, item.YCoordinate);

                    _pinList.Add(newPin);
                    locationsMap.Pins.Add(newPin);

                    newPin.MarkerClicked += (s, args) =>
                    {
                        ClickedPin(newPin);
                    };
                }
                foreach (var item in _pinList)
                {
                    polyline.Geopath.Add(item.Position);
                    locationsMap.MapElements.Add(polyline);
                }
            }
        }
コード例 #6
0
        public void AddWaypoint(Waypoint AddWp)
        {
            //System.Diagnostics.Trace.Assert(_Owner.Name != "Heinz Lutzen");
            if (_Owner.IsCreature())
            {
                if (Waypoints.Count == 0)
                {
                    Waypoint StartWp = new Waypoint
                    {
                        CreatureSpawnGUID   = _Owner.GetCreature().Spawn.Guid,
                        GameObjectSpawnGUID = _Owner.Oid,
                        X           = (ushort)_Owner.X,
                        Y           = (ushort)_Owner.Y,
                        Z           = (ushort)_Owner.Z,
                        Speed       = AddWp.Speed,
                        WaitAtEndMS = AddWp.WaitAtEndMS
                    };

                    lock (WaypointsTableLock)
                    {
                        StartWp.GUID = Convert.ToUInt32(WorldMgr.Database.GetNextAutoIncrement <Waypoint>());
                        Waypoints.Add(StartWp);
                        WaypointService.DatabaseAddWaypoint(StartWp);
                    }
                    // lock (WaypointsTableLock)
                }
                AddWp.CreatureSpawnGUID   = _Owner.GetCreature().Spawn.Guid;
                AddWp.GameObjectSpawnGUID = _Owner.Oid;
                lock (WaypointsTableLock)
                {
                    AddWp.GUID = Convert.ToUInt32(WorldMgr.Database.GetNextAutoIncrement <Waypoint>());
                    Waypoints.Add(AddWp);
                    WaypointService.DatabaseAddWaypoint(AddWp);
                }
                // lock (WaypointsTableLock)
                Waypoint PrevWp = Waypoints[Waypoints.Count - 1];
                PrevWp.NextWaypointGUID = AddWp.GUID;
                SaveWaypoint(PrevWp);
            }
        }
コード例 #7
0
 public void SaveWaypoint(Waypoint SaveWp)
 {
     WaypointService.DatabaseSaveWaypoint(SaveWp);
 }