Exemple #1
0
        protected override bool Perform(GameCore <Player> game, out Point newPosition)
        {
            if (CurrentGame.Player.Statuses.Contains(ParalyzedObjectStatus.StatusType))
            {
                newPosition = CurrentGame.PlayerPosition;
                game.Journal.Write(new ParalyzedMessage());
                return(true);
            }

            if (CurrentGame.Player.Statuses.Contains(OverweightObjectStatus.StatusType))
            {
                newPosition = game.PlayerPosition;
                game.Journal.Write(new OverweightBlocksMovementMessage());
                return(true);
            }

            if (CurrentGame.Player.Direction != direction)
            {
                game.Player.Direction = direction;
                newPosition           = game.PlayerPosition;
                return(false);
            }
            var moveResult = MovementHelper.MoveCreature(game.Player, game.PlayerPosition, direction, true, true, false);

            newPosition = moveResult.NewPosition;
            return(moveResult.Success);
        }
Exemple #2
0
        public override void Update(Vehicle vehicle)
        {
            if (HasObstacle(vehicle) && vehicle.Self.EnginePower > 0.85D && vehicle.Self.SpeedModule() < 0.1D)
            {
                vehicle.ChangeState(Reversal.Instance);
                return;
            }


            if (vehicle.Self.EnginePower > 0.93D && vehicle.Self.SpeedModule() < 0.1D && vehicle.World.Tick - 3 > vehicle.Game.InitialFreezeDurationTicks)
            {
                vehicle.ChangeState(Reversal.Instance);
                return;
            }


            var distance = vehicle.Self.GetDistanceTo(TargetPoint);

            //TODO: fix choose path can stay in the same tile
            if (vehicle.InTheSameTile(TargetPoint) ||
                (distance <= MovementHelper.GetDistance(vehicle.Self.NextPoint(), TargetPoint)))
            {
                vehicle.ChangeState(Seek.Instance);
            }
        }
Exemple #3
0
        public override CognitionState Update()
        {
            if (Map.IsPositionDangorous(Unit.LogicPosition))
            {
                return(RememberCurrent().AndChangeStateTo(StatesFactory.CreateStrafing(_target)));
            }

            if (_target.IsVisible)
            {
                if (ProbabilisticTriggering.TestOnAverageOnceEvery(0.1f))
                {
                    _path = Map.PathFinder.FindPath(Unit.LogicPosition,
                                                    _target.Position);
                }

                TargetingHelper.ManageAimingAtTheTarget(_target);

                var distanceToTarget = (_target.Position - Unit.LogicPosition).magnitude;
                if (distanceToTarget > 4)
                {
                    MovementHelper.ManageMovingAlongThePath(_path);
                }

                return(this);
            }

            return(DisposeCurrent().AndChangeStateTo(StatesFactory.CreateSearching(_target)));
        }
        public bool CheckIfPlayerHasLost(int playerIndex)
        {
            Agent current = GetPlayer(playerIndex);

            if (!current.Data.HasLost)
            {
                var targets = MovementHelper.GetTargets(current);
                if (targets.Count == 0)
                {
                    current.Data.HasLost = true;
                }

                // check if the current player has captured MisterX
                if (current.Data.PlayerType != EPlayerType.MISTERX)
                {
                    Agent misterX = GetMisterX();
                    if (misterX != null)
                    {
                        misterX.Data.HasLost = string.Equals(current.Position.GetComponent <StreetPoint>()?.name, misterX.Position.GetComponent <StreetPoint>()?.name);
                    }
                }
            }

            return(current.Data.HasLost);
        }
Exemple #5
0
    /// <summary>
    /// Finishes the intro camera shot by placing the camera in its final position
    /// and destroying the objects that should not exist anymore.
    /// </summary>
    private void FinishIntro()
    {
        // Set the position of the camera to be exactly right.
        var position = gameObject.transform.position;

        position.x = ParentObject.gameObject.transform.position.x;
        position.z = ParentObject.gameObject.transform.position.z;

        gameObject.transform.position = position;

        // Sets the variable to do the movement sequence to false.
        _introMove = false;

        transform.LookAt(ParentObject.gameObject.transform);

        // The camera will move towards the player and rotate to get there.
        // When the game actually starts, this rotation should not be there anymore.
        var rotation = gameObject.transform.localEulerAngles;

        rotation.y = 0;
        gameObject.transform.localEulerAngles = rotation;

        // Set the camera as the child of the object that will be the player.
        // This makes it so the camera will follow the player.
        //gameObject.transform.SetParent(ParentObject.transform);

        // Destroy the rigidbody component as it will hinder the camera from moving
        // with the player.
        Destroy(_rigidbody);

        // This class isn't needed anymore, lets save memory.
        _movementHelper = null;

        Game.IsPaused = false;
    }
Exemple #6
0
 public Moving(MovementHelper movementHelper, TargetingHelper targetingHelper, IUnit unit, IMap map,
               IVisionObserver vision, Vector3 targetPosition)
     : base(ComputerStateIds.Chasing, movementHelper, targetingHelper, unit, map, vision)
 {
     _targetPositoon = targetPosition;
     _path           = Map.PathFinder.FindPath(Unit.LogicPosition, _targetPositoon);
 }
Exemple #7
0
    void Turn()
    {
        var characters = FindObjectsOfType <Character>();

        //MOVEMENT PHASE
        foreach (var character in characters)
        {
            GameCell target = MovementHelper.GetClosestEnemy(character.x, character.y, boardState, character.hero);

            if (target.Range > character.range)
            {
                character.Move();
            }
        }

        foreach (var character in characters)
        {
            character.Attack();
        }

        foreach (var character in characters)
        {
            character.CheckHp();
        }

        Invoke("Turn", gameSpeed);
    }
Exemple #8
0
        public override List <Tile> Tiles(Board <Piece> board, Piece _piece)
        {
            var validTiles = new MovementHelper(board, _piece)
                             .Neigbours(1)
                             .Generate();

            return(validTiles);
        }
Exemple #9
0
 // Start is called before the first frame update
 private void Start()
 {
     UniqueId = GUID.Generate();
     QuickSaveStorage.Get.AddScript(this);
     _movementHelper  = new MovementHelper(gameObject);
     _renderer        = GetComponent <Renderer>();
     _initialMaterial = _renderer.material;
 }
        private List <Tile> Neighbours(Board <Piece> board, Tile from)
        {
            var validTiles = new MovementHelper(board, from)
                             .Neigbours(1, MovementHelper.IsEmpty)
                             .Generate();

            return(validTiles);
        }
        public override List <Tile> Tiles(Board <Piece> board, Piece _piece)
        {
            var validTiles = new MovementHelper(board, _piece)
                             .All(MovementHelper.IsEmpty)
                             .Generate();

            return(validTiles);
        }
Exemple #12
0
        public bool Update(INonPlayableCreatureObject creature, Point position)
        {
            var direction      = RandomHelper.GetRandomElement(Enum.GetValues(typeof(Direction)).Cast <Direction>().ToArray());
            var targetPosition = Point.GetPointInDirection(position, direction);

            MovementHelper.MoveCreature(creature, position, targetPosition, true, true, true);
            return(true);
        }
Exemple #13
0
 public Strafing(MovementHelper movementHelper, TargetingHelper targetingHelper, IUnit unit, IMap map,
                 IVisionObserver vision,
                 ITarget target)
     : base(ComputerStateIds.Chasing, movementHelper, targetingHelper, unit, map, vision)
 {
     _target = target;
     _path   = Map.PathFinder.FindSafespot(Unit.LogicPosition);
 }
Exemple #14
0
        public override void Process(ItemPosition drop)
        {
            Optional <GameObject> opItem = NitroxEntity.GetObjectFrom(drop.Id);

            if (opItem.HasValue)
            {
                MovementHelper.MoveRotateGameObject(opItem.Value, drop.Position.ToUnity(), drop.Rotation.ToUnity(), ITEM_TRANSFORM_SMOOTH_PERIOD);
            }
        }
Exemple #15
0
        /// <summary>
        /// Instantiates a movementhelper, start recording
        /// positions for 30 seconds to a file named my_waypoint.
        /// Copy that file over to the program called PlayWaypoint
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            FFXIVLIB       instance = new FFXIVLIB();
            MovementHelper mh       = instance.GetMovementHelper();

            mh.StartRecordingCoordinates("my_waypoint");
            Thread.Sleep(30000);
            mh.StopRecordingWaypoint();
        }
        public override void Process(ItemPosition drop)
        {
            Optional <GameObject> opItem = GuidHelper.GetObjectFrom(drop.Guid);

            if (opItem.IsPresent())
            {
                MovementHelper.MoveGameObject(opItem.Get(), ApiHelper.Vector3(drop.Position), ApiHelper.Quaternion(drop.Rotation), ITEM_TRANSFORM_SMOOTH_PERIOD);
            }
        }
 public bool TryJumpInDirection(Direction d)
 {
     if (CanJumpInDirection(d))
     {
         CurrentPoint = MovementHelper.Move(CurrentPoint, d, Size);
         return(true);
     }
     return(false);
 }
        public override void Process(ItemPosition drop)
        {
            Optional <GameObject> opItem = NitroxIdentifier.GetObjectFrom(drop.Id);

            if (opItem.IsPresent())
            {
                MovementHelper.MoveRotateGameObject(opItem.Get(), drop.Position, drop.Rotation, ITEM_TRANSFORM_SMOOTH_PERIOD);
            }
        }
Exemple #19
0
        private Point Find(Vehicle vehicle)
        {
            var currentPoint = GetStartPoint(vehicle);
            var route        = vehicle.CreateRouteOf(30, currentPoint);

            double nextWaypointX = (route[0].X + 0.5D) * vehicle.Game.TrackTileSize;
            double nextWaypointY = (route[0].Y + 0.5D) * vehicle.Game.TrackTileSize;

            if (Math.Abs(vehicle.Self.GetAngleTo(nextWaypointX, nextWaypointY)) > Math.PI / 1.57)
            {
                var excludeCell = vehicle.GetCurrentCell(new Point(nextWaypointX, nextWaypointY));

                var routeNoBackPoint = vehicle.CreateRouteOf(30, currentPoint, excludeCell);

                var nextCell = vehicle.GetCellByIndex(vehicle.Self.NextWaypointIndex + 1);

                if (routeNoBackPoint.IndexOf(nextCell) - route.IndexOf(nextCell) < 8) //TODO: speed check here
                {
                    nextWaypointX = (routeNoBackPoint[0].X + 0.5D) * vehicle.Game.TrackTileSize;
                    nextWaypointY = (routeNoBackPoint[0].Y + 0.5D) * vehicle.Game.TrackTileSize;

                    route = routeNoBackPoint;
                }
            }

            var addOn = vehicle.Game.TrackTileSize * 0.4D;

            left  = 0.0D;
            right = 0.0D;

            top    = 0.0D;
            bottom = 0.0D;

            var startCell = vehicle.GetCurrentCell(currentPoint);
            var prevCell  = vehicle.GetCurrentCell(vehicle.Self.CurrentPoint());

            if (MovementHelper.IsOnLine(prevCell, startCell, route[0], route[1]))
            {
                nextWaypointX = (route[0].X + 0.5D) * vehicle.Game.TrackTileSize;
                nextWaypointY = (route[0].Y + 0.5D) * vehicle.Game.TrackTileSize;
                NextWaypointApdate(route[1], route[0], 0.49 * vehicle.Game.TrackTileSize);

                //TODO: Move nitro in other place
                vehicle.CanUseNitro = MovementHelper.IsOnLine(prevCell, startCell, route[2], route[3]) &&
                                      MovementHelper.IsOnLine(prevCell, startCell, route[4], route[5]);// &&
                // MovementHelper.IsOnLine(prevCell, startCell, route[6], route[7]);

                return(OptimalPoint(nextWaypointX, nextWaypointY));
            }


            // NextWaypointApdate(route[0], startCell, addOn);
            NextWaypointApdate(route[1], route[0], addOn);

            return(OptimalPoint(nextWaypointX, nextWaypointY));
        }
Exemple #20
0
    // Start is called before the first frame update
    void Start()
    {
        _movementHelper = new MovementHelper(gameObject);
        _rigidbody      = GetComponent <Rigidbody>();

        if (!DoIntro)
        {
            FinishIntro();
        }
    }
Exemple #21
0
 public ComputerStatesFactory(IMap map, IUnit unit, IVisionObserver vision,
                              MovementHelper movementHelper,
                              TargetingHelper targetingHelper)
 {
     _map             = map;
     _unit            = unit;
     _vision          = vision;
     _movementHelper  = movementHelper;
     _targetingHelper = targetingHelper;
 }
Exemple #22
0
        public Searching(MovementHelper movementHelper, TargetingHelper targetingHelper, IUnit unit, IMap map,
                         IVisionObserver vision,
                         ITargetMemory memory)
            : base(ComputerStateIds.Chasing, movementHelper, targetingHelper, unit, map, vision)
        {
            _targetMemory    = memory;
            _initialDistance = (_targetMemory.LastSeenPosition - Unit.LogicPosition).magnitude;

            FindPath();
        }
Exemple #23
0
 public void CanRotateRightTest2()
 {
     for (int i = 0; i < 7; i++)
     {
         Figure figure = new Figure(i, _canvas, _width, _width, _width);
         figure.SetLocation(_width * 4, _width * 4);
         Assert.IsTrue(MovementHelper.CanRotateRight(figure, _canvas));
         _canvas.Children.Clear();
     }
 }
 public void JumpInDirection(Direction d)
 {
     if (CanJumpInDirection(d))
     {
         CurrentPoint = MovementHelper.Move(CurrentPoint, d, Size);
     }
     else
     {
         throw new ArgumentException("Cannot Jump in that direction.");
     }
 }
Exemple #25
0
 protected override void Start()
 {
     base.Start();
     UniqueId = GUID.Generate();
     QuickSaveStorage.Get.AddScript(this);
     _movementHelper  = new MovementHelper(gameObject);
     _navMeshAgent    = GetComponentInParent <NavMeshAgent>();
     _alertBehaviors  = GetComponentsInChildren <BasicTriggerDetection>();
     _renderer        = GetComponent <Renderer>();
     _initialMaterial = _renderer.material;
 }
        public override void Process(VehicleMovement vehicleMovement)
        {
            Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(vehicleMovement.Guid);

            RemotePlayer player = remotePlayerManager.FindOrCreate(vehicleMovement.PlayerId);

            Vector3    remotePosition = ApiHelper.Vector3(vehicleMovement.Position);
            Vector3    remoteVelocity = ApiHelper.Vector3(vehicleMovement.Velocity);
            Quaternion remoteRotation = ApiHelper.Quaternion(vehicleMovement.BodyRotation);

            Vehicle vehicle = null;
            SubRoot subRoot = null;

            if (opGameObject.IsPresent())
            {
                GameObject gameObject = opGameObject.Get();

                Rigidbody rigidbody = gameObject.GetComponent <Rigidbody>();

                if (rigidbody != null)
                {
                    //todo: maybe toggle kinematic if jumping large distances?

                    /*
                     * For the cyclops, it is too intense for the game to lerp the entire structure every movement
                     * packet update.  Instead, we try to match the velocity.  Due to floating points not being
                     * precise, this will skew quickly.  To counter this, we apply micro adjustments each packet
                     * to get the simulation back in sync.  The adjustments will increase in size the larger the
                     * out of sync issue is.
                     *
                     * Besides, this causes the movement of the Cyclops, vehicles and player to be very fluid.
                     */

                    rigidbody.velocity        = MovementHelper.GetCorrectedVelocity(remotePosition, remoteVelocity, gameObject, PlayerMovement.BROADCAST_INTERVAL);
                    rigidbody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(remoteRotation, gameObject, PlayerMovement.BROADCAST_INTERVAL);
                }
                else
                {
                    Console.WriteLine("Vehicle did not have a rigidbody!");
                }

                vehicle = gameObject.GetComponent <Vehicle>();
                subRoot = gameObject.GetComponent <SubRoot>();
            }
            else
            {
                CreateVehicleAt(player, vehicleMovement.TechType, vehicleMovement.Guid, remotePosition, remoteRotation);
            }
            player.SetVehicle(vehicle);
            player.SetSubRoot(subRoot);
            player.SetPilotingChair(subRoot.GetComponentInChildren <PilotingChair>());

            player.animationController.UpdatePlayerAnimations = false;
        }
Exemple #27
0
 public void CanMoveRightTest()
 {
     for (int i = 0; i < 7; i++)
     {
         Figure figure = new Figure(i, _canvas, _width, _width, _width);
         figure.SetLocation((int)_canvas.Width - figure.Width, 0);
         Assert.IsFalse(MovementHelper.CanMoveRight(figure, _canvas));
         figure.SetLocation((int)_canvas.Width / 2, 0);
         Assert.IsTrue(MovementHelper.CanMoveRight(figure, _canvas));
         _canvas.Children.Clear();
     }
 }
Exemple #28
0
        /// <summary>
        /// Please run the RecordWaypoint program first
        /// and copy the file generated over to this demo.
        /// We instantiate a MovementHelper instance and pass the filename to be played.
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            FFXIVLIB       instance = new FFXIVLIB();
            MovementHelper mh       = instance.GetMovementHelper();

            mh.PlayWaypoint("my_waypoint");
            // Run for 5 seconds, then pause the running for 10 seconds
            Thread.Sleep(5000);
            mh.PauseWaypoint();
            Thread.Sleep(10000);
            mh.PauseWaypoint();
        }
Exemple #29
0
    // Use this for initialization
    void Start()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit objectClicked;

        if (Physics.Raycast(ray, out objectClicked) && objectClicked.transform.tag != "Player")
        {
            Vector3 target = objectClicked.transform.tag == "Ground" ? objectClicked.point : objectClicked.transform.position;
            MoveTowardsDirection movement = gameObject.GetComponent <MoveTowardsDirection>();
            movement.direction = MovementHelper.calculateNormalizedDirection(transform.position, target);
        }
    }
Exemple #30
0
        protected virtual void FixedUpdate()
        {
            smoothYaw.FixedUpdate();
            smoothPitch.FixedUpdate();

            smoothPosition.FixedUpdate();
            smoothVelocity.FixedUpdate();
            rigidbody.velocity = MovementHelper.GetCorrectedVelocity(smoothPosition.SmoothValue, smoothVelocity.SmoothValue, gameObject, PlayerMovement.BROADCAST_INTERVAL);
            smoothRotation.FixedUpdate();
            smoothAngularVelocity.FixedUpdate();
            rigidbody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(smoothRotation.SmoothValue, smoothAngularVelocity.SmoothValue, gameObject, PlayerMovement.BROADCAST_INTERVAL);
        }