Beispiel #1
0
        public async void Initialize()
        {
            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:

                // If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
                var geolocator = new Geolocator
                {
                    DesiredAccuracyInMeters = DesireAccuracyInMetersValue,
                    ReportInterval          = ReportIntervalMilliseconds
                };

                // Subscribe to the StatusChanged event to get updates of location status changes.
                geolocator.StatusChanged   += OnStatusChanged;
                geolocator.PositionChanged += OnPositionChanged;

                // Carry out the operation.
                Geoposition pos = await geolocator.GetGeopositionAsync();

                PositionUpdated?.Invoke(pos, PositionUpdateReasons.Normal);

                break;

            case GeolocationAccessStatus.Denied:
                PositionUpdated?.Invoke(null, PositionUpdateReasons.AccessDenied);
                break;

            case GeolocationAccessStatus.Unspecified:
                PositionUpdated?.Invoke(null, PositionUpdateReasons.AccessUnspecified);
                break;
            }
        }
Beispiel #2
0
        private void OnPlayerPosition(string[] data)
        {
            _loadMapTimeout.Set(Rand.Next(1000, 2000));

            IsAuthenticated = true;

            string map     = data[2];
            string mapFile = data[3];
            int    x       = int.Parse(data[4]);
            int    y       = int.Parse(data[5]);

            if (map != MapName || x != PlayerX || y != PlayerY)
            {
                if (map != MapName)
                {
                    MapName = map;
                    LoadMap(mapFile);
                }
                else
                {
                    SendPacket("syn");
                }
                PlayerX = x;
                PlayerY = y;
                PositionUpdated?.Invoke(MapName, PlayerX, PlayerY);
            }
            IsSurfing = data[6] == "1";
            IsInside  = data[7] == "1";

            _movements.Clear();
        }
Beispiel #3
0
 private void RaisePositionUpdated(IUserInfo user, AccountInfo account, Position pos)
 {
     if (user != null)
     {
         PositionUpdated?.Invoke(this, new EventArgs <UserAccount, Position>(new UserAccount(user, account), pos));
     }
 }
Beispiel #4
0
        private void OnUpdatePortfolio(Contract contract, double positionSize, double marketPrice, double marketValue, double avgCost, double unrealisedPNL, double realisedPNL, string account)
        {
            var position = new Position(account, contract, positionSize, avgCost, marketPrice, marketValue, unrealisedPNL, realisedPNL);

            portfolio.Update(position);
            PositionUpdated?.Invoke(position);
        }
Beispiel #5
0
 public void MoveToPosition(CCPoint value)
 {
     Position           = value;
     TargetInWorldspace = new CCPoint3(value, -1);
     CenterInWorldspace = new CCPoint3(value, 0);
     PositionUpdated?.Invoke(this, Position);
 }
Beispiel #6
0
        private void OnStatusChanged(Geolocator sender, StatusChangedEventArgs args)
        {
            if (args.Status == PositionStatus.Disabled)
            {
                PositionUpdated?.Invoke(null, PositionUpdateReasons.AccessDenied);
            }

            StatusChanged?.Invoke(sender, args);
        }
Beispiel #7
0
        private void UpdateAllItemPosition()
        {
            var currentElement = allItems.IndexOf(this);
            var sixteenElement = allItems.IndexOf(SixteenElement);

            allItems[currentElement] = SixteenElement;
            allItems[sixteenElement] = this;

            PositionUpdated?.Invoke(this, EventArgs.Empty);
        }
Beispiel #8
0
        private bool ApplyMovement(Direction direction)
        {
            int destinationX = PlayerX;
            int destinationY = PlayerY;

            switch (direction)
            {
            case Direction.Up:
                destinationY--;
                break;

            case Direction.Down:
                destinationY++;
                break;

            case Direction.Left:
                destinationX--;
                break;

            case Direction.Right:
                destinationX++;
                break;
            }

            Map.MoveResult result    = Map.CanMove(direction, destinationX, destinationY, IsSurfing, Npcs);
            bool           isSuccess = false;

            switch (result)
            {
            case Map.MoveResult.Success:
                isSuccess = true;
                break;

            case Map.MoveResult.Jump:
                isSuccess     = true;
                destinationY += 1;
                break;

            case Map.MoveResult.NoLongerSurfing:
                isSuccess = true;
                IsSurfing = false;
                break;
            }

            if (isSuccess)
            {
                PlayerX = destinationX;
                PlayerY = destinationY;
                PositionUpdated?.Invoke(MapName, PlayerX, PlayerY);
            }

            return(isSuccess);
        }
Beispiel #9
0
        void ProcessConectedClientMessage(ReceivedClientMessage message)
        {
            message.Client.RefreshLastActivity();

            switch (message.Message.Message.Event)
            {
            case "position":  PositionUpdated?.Invoke(message); break;

            case "netobjcreate":
                var newNetObj = JsonConvert.DeserializeObject <NetObj>(message.Message.Message.Data.ToString());
                _logger.LogInfo("netobjcreate: " + message.Message.Message.Data.ToString());
                NetObjCreated?.Invoke(message.Client, newNetObj);
                break;

            case "request-ownership": OwnershipRequested?.Invoke(message.Client, new Guid(message.Message.Message.Data.ToString())); break;

            default: BadConnectedClientMessage?.Invoke(message); break;
            }
        }
Beispiel #10
0
        protected override void HandleAppPacket(AppPacket packet)
        {
            //WriteLine($"Zone app packet: {(ZoneOp) packet.Opcode}");
            switch ((ZoneOp)packet.Opcode)
            {
            case ZoneOp.PlayerProfile:
                var player = packet.Get <PlayerProfile>();
                //WriteLine(player);
                break;

            case ZoneOp.TimeOfDay:
                var timeofday = packet.Get <TimeOfDay>();
                //WriteLine(timeofday);
                break;

            case ZoneOp.TaskActivity:
                // XXX: Handle short activities!
                //var activity = packet.Get<TaskActivity>();
                //WriteLine(activity);
                break;

            case ZoneOp.TaskDescription:
                var desc = packet.Get <TaskDescription>();
                //WriteLine(desc);
                break;

            case ZoneOp.CompletedTasks:
                var comp = packet.Get <CompletedTasks>();
                //WriteLine(comp);
                break;

            case ZoneOp.XTargetResponse:
                var xt = packet.Get <XTarget>();
                //WriteLine(xt);
                break;

            case ZoneOp.Weather:
                var weather = packet.Get <Weather>();
                //WriteLine(weather);

                if (Entering)
                {
                    Send(AppPacket.Create(ZoneOp.ReqNewZone));
                }
                break;

            case ZoneOp.TributeTimer:
                var timer = packet.Get <TributeTimer>();
                //WriteLine(timer);
                break;

            case ZoneOp.TributeUpdate:
                var update = packet.Get <TributeInfo>();
                //WriteLine(update);
                break;

            case ZoneOp.ZoneEntry:
                var mob = packet.Get <Spawn>();
                if (mob.Name == CharName)
                {
                    PlayerSpawnId = (ushort)mob.SpawnID;
                }
                Spawned?.Invoke(this, mob);
                break;

            case ZoneOp.NewZone:
                Send(AppPacket.Create(ZoneOp.ReqClientSpawn));
                break;

            case ZoneOp.SendExpZonein:
                if (Entering)
                {
                    Send(AppPacket.Create(ZoneOp.ClientReady));
                    Entering = false;
                }

                break;

            case ZoneOp.CharInventory:
                break;

            case ZoneOp.SendFindableNPCs:
                var npc = packet.Get <FindableNPC>();
                //WriteLine(npc);
                break;

            case ZoneOp.ClientUpdate:
                var pu = packet.Get <PlayerPositionUpdate>();
                PositionUpdated?.Invoke(this, pu);
                break;

            case ZoneOp.HPUpdate:
                break;

            case ZoneOp.SpawnDoor:
                for (var i = 0; i < packet.Data.Length; i += 92)
                {
                    var door = new Door(packet.Data, i);
                    WriteLine(door);
                }
                break;

            default:
                WriteLine($"Unhandled packet in ZoneStream: {(ZoneOp) packet.Opcode} (0x{packet.Opcode:X04})");
                Hexdump(packet.Data);
                break;
            }
        }
 internal void OnPositionUpdated(PositionUpdatedResponse message)
 {
     PositionUpdated?.Invoke(this, new EventArgs<string, Position>(message.AccountID,
         message.Position.ToClientPosition()));
 }
 public void OnPositionUpdated()
 {
     PositionUpdated?.Invoke(this, EventArgs.Empty);
 }
Beispiel #13
0
 protected virtual void OnPositionUpdated(PositionUpdatedArgs e)
 {
     PositionUpdated?.Invoke(this, e);
 }
Beispiel #14
0
        void HandleDrag(HitType MouseHitType, DragDeltaEventArgs Args)
        {
            if (!(AdornedElement is FrameworkElement fel))
            {
                return;
            }

            var offsetX = (int)Args.HorizontalChange;
            var offsetY = (int)Args.VerticalChange;

            var har = fel.HorizontalAlignment == HorizontalAlignment.Right;
            var vab = fel.VerticalAlignment == VerticalAlignment.Bottom;

            var newX      = (int)(har ? fel.Margin.Right : fel.Margin.Left);
            var newY      = (int)(vab ? fel.Margin.Bottom : fel.Margin.Top);
            var newWidth  = (int)fel.ActualWidth;
            var newHeight = (int)fel.ActualHeight;

            void ModifyX(bool Possitive)
            {
                if (Possitive)
                {
                    newX += offsetX;
                }
                else
                {
                    newX -= offsetX;
                }
            }

            void ModifyY(bool Possitive)
            {
                if (Possitive)
                {
                    newY += offsetY;
                }
                else
                {
                    newY -= offsetY;
                }
            }

            void ModifyWidth(bool Possitive)
            {
                if (Possitive)
                {
                    newWidth += offsetX;
                }
                else
                {
                    newWidth -= offsetX;
                }
            }

            void ModifyHeight(bool Possitive)
            {
                if (Possitive)
                {
                    newHeight += offsetY;
                }
                else
                {
                    newHeight -= offsetY;
                }
            }

            switch (MouseHitType)
            {
            case HitType.Body:
                ModifyX(!har);
                ModifyY(!vab);
                break;

            case HitType.UpperLeft:
                if (har)
                {
                    ModifyWidth(false);
                }
                else
                {
                    ModifyX(true);
                    ModifyWidth(false);
                }

                if (vab)
                {
                    ModifyHeight(false);
                }
                else
                {
                    ModifyY(true);
                    ModifyHeight(false);
                }
                break;

            case HitType.UpperRight:
                if (har)
                {
                    ModifyX(false);
                    ModifyWidth(true);
                }
                else
                {
                    ModifyWidth(true);
                }

                if (vab)
                {
                    ModifyHeight(false);
                }
                else
                {
                    ModifyY(true);
                    ModifyHeight(false);
                }
                break;

            case HitType.LowerRight:
                if (har)
                {
                    ModifyX(false);
                    ModifyWidth(true);
                }
                else
                {
                    ModifyWidth(true);
                }

                if (vab)
                {
                    ModifyY(false);
                    ModifyHeight(true);
                }
                else
                {
                    ModifyHeight(true);
                }
                break;

            case HitType.LowerLeft:
                if (har)
                {
                    ModifyWidth(false);
                }
                else
                {
                    ModifyX(true);
                    ModifyWidth(false);
                }

                if (vab)
                {
                    ModifyY(false);
                    ModifyHeight(true);
                }
                else
                {
                    ModifyHeight(true);
                }
                break;

            case HitType.Left:
                if (har)
                {
                    ModifyWidth(false);
                }
                else
                {
                    ModifyX(true);
                    ModifyWidth(false);
                }
                break;

            case HitType.Right:
                if (har)
                {
                    ModifyX(false);
                    ModifyWidth(true);
                }
                else
                {
                    ModifyWidth(true);
                }
                break;

            case HitType.Bottom:
                if (vab)
                {
                    ModifyY(false);
                    ModifyHeight(true);
                }
                else
                {
                    ModifyHeight(true);
                }
                break;

            case HitType.Top:
                if (vab)
                {
                    ModifyHeight(false);
                }
                else
                {
                    ModifyY(true);
                    ModifyHeight(false);
                }
                break;
            }

            if (newWidth > 0 && newHeight > 0)
            {
                if (newX < 0)
                {
                    newX = 0;
                }

                if (newY < 0)
                {
                    newY = 0;
                }

                double left = 0, top = 0, right = 0, bottom = 0;

                if (har)
                {
                    right = newX;
                }
                else
                {
                    left = newX;
                }

                if (vab)
                {
                    bottom = newY;
                }
                else
                {
                    top = newY;
                }

                fel.Margin = new Thickness(left, top, right, bottom);

                PositionUpdated?.Invoke(new Rect(newX, newY, newWidth, newHeight));

                if (MouseHitType != HitType.Body)
                {
                    fel.Width  = newWidth;
                    fel.Height = newHeight;
                }
            }
        }
Beispiel #15
0
 public void RaisePositionChanged(Rect Rect)
 {
     PositionUpdated?.Invoke(Rect);
 }
Beispiel #16
0
 private void Photo_SetPosition(Photosphere source, Vector3 position)
 {
     PositionUpdated?.Invoke(source, position);
 }
Beispiel #17
0
 protected void OnPositionUpdated(Position position) =>
 PositionUpdated?.Invoke(this, new EventArgs <Position>(position));
Beispiel #18
0
 private void OnPositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     PositionUpdated?.Invoke(args.Position, PositionUpdateReasons.Normal);
 }
Beispiel #19
0
 /// <summary>
 /// Fire the <see cref="onPositionUpdated"/> and <see cref="PositionUpdated"/> events.
 /// </summary>
 private void OnPositionUpdated()
 {
     onPositionUpdated?.Invoke();
     PositionUpdated?.Invoke(this, EventArgs.Empty);
 }
Beispiel #20
0
 public virtual void SetPosition(Point p)
 {
     X = p.X;
     Y = p.Y;
     PositionUpdated?.Invoke();
 }
Beispiel #21
0
 public virtual void SetPosition(int x, int y)
 {
     X = x;
     Y = y;
     PositionUpdated?.Invoke();
 }