コード例 #1
0
        private void TrackForeMove(Body body, Joint head, Joint handLeft, Joint handRight)
        {
            CameraSpacePoint newPoint = default(CameraSpacePoint);

            if (IsHandInInitialGesture(body.HandRightState))
            {
                newPoint = handRight.Position;
                Debug.WriteLine("Force hand: Right");
            }
            else if (IsHandInInitialGesture(body.HandLeftState))
            {
                newPoint = handLeft.Position;
                Debug.WriteLine("Force hand: Left");
            }

            if (newPoint != default(CameraSpacePoint))
            {
                var distance = CoordinateHelper.GetDistance(newPoint, _lastHandPosition);
                if (_handTrackedCount > 0 && distance > 0.15F)
                {
                    Debug.WriteLine("oldPoint: x={0} y={1} z={2}", _lastHandPosition.X, _lastHandPosition.Y, _lastHandPosition.Z);
                    Debug.WriteLine("newPoint: x={0} y={1} z={2}", newPoint.X, newPoint.Y, newPoint.Z);
                    ResetTrackingCounters(1);
                    Debug.WriteLine("Reseted in order ot distance: {0}", distance);
                }

                _lastHeadPosition = _lastHeadPosition.GetAccumulatedAvarage(head.Position, ref _headTrackedCount);
                _lastHandPosition = _lastHandPosition.GetAccumulatedAvarage(newPoint, ref _handTrackedCount);

                Debug.WriteLine("Forse tracked: {0} Frame: {1}", _handTrackedCount, _frameCount);
            }


            if (CanFireForesMove())
            {
                var handPosition = _lastHandPosition;
                var headPosition = _lastHeadPosition;


                // ZY Projection
                var headZY = headPosition.GetProjectionForZY();
                var handZY = handPosition.GetProjectionForZY();
                var y      = CoordinateHelper.FindPointProjection(headZY, handZY);

                // XZ Projection
                var x = CoordinateHelper.FindPointProjection(headPosition.GetProjectionForXZ(), handPosition.GetProjectionForXZ(), y);

                var point = new Point {
                    X = x, Y = y
                };
                ForceApplying.SafeRise(this, point);
                Debug.WriteLine("Force Point: x={0} y={1}", point.X, point.Y);
                ResetTrackingCounters();
            }
            else if (CanFireForesDispel())
            {
                ForceDispel.SafeRise(this);
                ResetTrackingCounters();
            }
        }
コード例 #2
0
        public override void Process(object c)
        {
            var casted = H.Cast <IPlayer>(c);

            base.Process(casted);
            var visibleCities = casted.VisibleCities.ToList();

            foreach (var worldCity in casted.PlayersWorld.Cities.Collection)
            {
                if (!visibleCities.Contains(worldCity.Guid))
                {
                    if (CoordinateHelper.GetDistance(casted.X, casted.Y, worldCity.X, worldCity.Y) < worldCity.Size * 2)
                    {
                        visibleCities.Add(worldCity.Guid);
                    }
                }
            }

            casted.VisibleCities = visibleCities.ToArray();

            if (casted.IsMoving)
            {
                casted.IsMoving = !CoordinateHelper.IsInRadius(casted.X, casted.Y, casted.MoveToX, casted.MoveToY, 0.01f); // !(Math.Abs(casted.X - casted.MoveToX) < 0.01) || !(Math.Abs(casted.Y - casted.MoveToY) < 0.01);

                if (!casted.IsMoving)
                {
                    ProcessStop(casted);
                }
            }
        }
コード例 #3
0
        public IProcessWorldResponse ProcessWorld(IProcessWorldRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.Player == null)
            {
                throw new Exception("Player is null");
            }

            var world = WorldRepository.GetWorld(request.WorldGuid);

            if (world == null)
            {
                throw new Exception($"World with guid='{request.WorldGuid}' not found");
            }

            var player = world.Players.Collection.FirstOrDefault(c => c.Guid == request.Player.Guid);

            if (player == null)
            {
                throw new Exception($"Player with guid='{request.Player.Guid}' not found");
            }

            player.X = request.Player.X;
            player.Y = request.Player.Y;
            if (request.ClientCommands != null && request.ClientCommands.Any())
            {
                foreach (var clientCommand in request.ClientCommands)
                {
                    ProcessorsProvider.ProcessClientCommand(clientCommand, world, player);
                }
            }

            ProcessorsProvider.Process(world);

            foreach (var worldCity in world.Cities.Collection)
            {
                if (!player.VisibleCities.Contains(worldCity.Guid))
                {
                    if (CoordinateHelper.GetDistance(player.X, player.Y, worldCity.X, worldCity.Y) < worldCity.Size * 2)
                    {
                        player.VisibleCities = player.VisibleCities.Union(new[] { worldCity.Guid }).ToArray();
                    }
                }
            }

            ProcessorsProvider.Process(player);


            var result = new ProcessWorldResponseClientSideEntity();

            result.Player = player;
            result.World  = world;

            return(result);
        }
コード例 #4
0
        private void Aim(EnemyBot target, double power)
        {
            Point p = new Point {
                X = target.X, Y = target.Y
            };

            for (int i = 0; i < 10; i++)
            {
                double nextTime = CoordinateHelper.GetDistance(p.X, p.Y, Robot.X, Robot.Y) / Rules.GetBulletSpeed(power);
                double time     = Robot.Time + nextTime;
                p = GuessPosition(time, target);
            }
            Robot.Target = p;
        }
コード例 #5
0
        private void JediForceApplying(object arg1, Point forcePoint)
        {
            Debug.WriteLine("Force Start");
            IsForceApplying = true;

            var p = _spheroPointTransform.Transform(forcePoint);

            if (!_isSpheroGrabed)
            {
                _sphero.SetPosition(p);
                _lastPoint      = forcePoint;
                _isSpheroGrabed = true;
                return;
            }

            if (CoordinateHelper.GetDistance(_lastPoint, forcePoint) >= 0.05F)
            {
                _sphero.MoveTo(p.X, p.Y);
            }

            ForceXZProextion = GetXZProjection(forcePoint.X, forcePoint.Y);
            _lastPoint       = forcePoint;
        }