Ejemplo n.º 1
0
        public PlayerViewModel(InventoryViewModel inventory, MapViewModel map, Settings settings, SessionViewModel session)
        {
            this.map      = map;
            this.settings = settings;
            this.session  = session;
            Inventory     = inventory;
            minSpeedInmetersPerMillisecond = settings.MinTravelSpeedInKmH / 3600.0;
            maxSpeedInmetersPerMillisecond = settings.MaxTravelSpeedInKmH / 3600.0;

            Position = new Position3DViewModel(settings.DefaultLatitude, settings.DefaultLongitude, settings.DefaultAltitude);

            var xpTimer = new DispatcherTimer();

            xpTimer.Tick    += XpTimer_Tick;
            xpTimer.Interval = TimeSpan.FromSeconds(10);
            xpTimer.Start();
        }
Ejemplo n.º 2
0
        async Task MoveToAsync(Position3DViewModel newPosition)
        {
            var waitTime       = Position.DistanceTo(newPosition) / GetRandomTravelSpeed();
            var startTime      = DateTime.Now;
            var targetTime     = startTime.AddMilliseconds(waitTime);
            var targetVector   = newPosition - Position;
            var startPosition  = Position;
            var lastUpdateTime = startTime;
            var now            = startTime;

            while (now < targetTime)
            {
                var msTraveled      = (now - startTime).TotalMilliseconds;
                var currentPosition = startPosition + (targetVector * (msTraveled / waitTime));
                Position = currentPosition;
                await Task.Delay(100);

                now = DateTime.Now;
            }
            Position = newPosition;
        }
Ejemplo n.º 3
0
 public void SetPosition(Position3DViewModel position)
 {
     session?.Player?.SetCoordinates(position.Latitude, position.Longitude, position.Altitute);
 }
Ejemplo n.º 4
0
 public bool Equals(Position3DViewModel other)
 {
     return base.Equals(other) &&
         Altitute == other.Altitute;
 }