Exemplo n.º 1
0
 private void MoveToTarget(NeedAIData data)
 {
     if (!HasMoved && m_PathfindingData.Count > 0)
     {
         Vector2Int    nextPoint     = m_PathfindingData.Peek();
         PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld);
         if (physicsResult != PhysicsResult.EntityCollision)
         {
             m_PathfindingData.Dequeue();
             Move(nextPoint);
             HasMoved = true;
         }
         else if (physicsResult == PhysicsResult.EntityCollision)
         {
             MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint));
             m_PathfindingData.Dequeue();
             Move(nextPoint);
             HasMoved = true;
         }
     }
     else if (m_PathfindingData.Count == 0)
     {
         if (data.target != null)
         {
             m_PathfindingData = m_Pathfinder.FindPath(WorldPosition, data.target.WorldPosition, MyWorld);
         }
         else if (data.targetPoint != Vector2Int.zero)
         {
             m_PathfindingData = m_Pathfinder.FindPath(WorldPosition, data.targetPoint, MyWorld);
         }
     }
 }
Exemplo n.º 2
0
        public PhysicsResult Measure(Marker marker, short cameraWidth, short panStep, bool first)
        {
            var result = new PhysicsResult();

            double cameraAngle = CameraWidthToAngle(cameraWidth);

            marker.HorizontalDistance = Math.Cos(cameraAngle) * marker.EuclideanDistance;
            marker.Height             = Math.Sin(cameraAngle) * marker.EuclideanDistance + 10;

            var pRes  = ParallaxAngle(marker.HorizontalDistance);
            var theta = pRes.Angle;

            marker.HorizontalDistance = pRes.Distance;


            int k = 0;

            while (k-- > 0)
            {
                Console.Clear();
                Console.WriteLine(RadianToDegree(theta));
                Console.WriteLine(marker.HorizontalDistance);
                Console.WriteLine(marker.Height);
                System.Threading.Thread.Sleep(10);
            }

            // 카메라가 노즐보다 앞에 있음
            marker.HorizontalDistance += 9;

            result.EstimatedPanStep     = (short)(panStep - PanAngleToStep(theta));
            result.EstimatedNozzleWidth = NozzleAngleToWidth(WaterAngle(marker.HorizontalDistance, marker.Height, first));

            return(result);
        }
Exemplo n.º 3
0
        public void UpdateMe()
        {
            if (this.MyWorld.IsDirty)
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.MyWorld.Dimensions, this.VisionMod, this.MyWorld.Walls.Keys.ToList());
                m_Vision = board.Vision;
            }
            else
            {
                FOVBasicBoard board = (FOVBasicBoard)m_FOVHandler.Do(this.WorldPosition, this.VisionMod);
                m_Vision = board.Vision;
            }

            HasMoved = false;

            if (!PlayerControlled)
            {
                //Attack immediate threats

                /*
                 * REDO THIS TO BE IN LUA
                 * //List<NeedAIData> targets = MyWorld.SearchForEntities(this, "Any", Intent.Attack, EntityTypeSearch.Any, EntitySentienceSearch.Any);
                 * //List<NeedAIData> validTargets = targets.Where(x => this.HasRelationship(x.target.GUID) < ATTACK_THRESHOLD).ToList();
                 * if(validTargets.Count > 0 && CurrentTarget.target == null)
                 * {
                 *  //TODO: Write a threat assessment system
                 *  //For now, choose a random target and go after them
                 *  int result = RNG.Roll(0, validTargets.Count - 1);
                 *  NeedAIData data = validTargets[result];
                 *
                 *  CurrentTarget = data;
                 *  m_PathfindingData = m_Pathfinder.FindPath(this.WorldPosition, CurrentTarget.target.WorldPosition, this.MyWorld);
                 * }
                 */

                //If you're idle
                if (CurrentTarget.idle == true)
                {
                    //Let's find something to do
                    List <EntityNeed> needs = m_Needs.Values.OrderByDescending(x => x.priority).ToList();
                    //Act on first need

                    bool idle = true;
                    foreach (EntityNeed need in needs)
                    {
                        if (need.contributingHappiness)
                        {
                            continue;
                        }

                        Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                        ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                        idle = false;
                        break;
                    }
                    m_CurrentTarget.idle = idle;
                }
                //Otherwise, carry on with what you're doing
                else
                {
                    if (WorldPosition == CurrentTarget.targetPoint || (CurrentTarget.target != null && WorldPosition == CurrentTarget.target.WorldPosition))
                    {
                        //If we have a target
                        if (CurrentTarget.target != null)
                        {
                            //We're interacting with an entity here
                            if (CurrentTarget.intent == Intent.Interact)
                            {
                                //TODO: WRITE AN ENTITY INTERACTION
                                EntityNeed need = this.Needs[CurrentTarget.need];

                                Debug.Log("Running LUA script: FindFulfilmentObject (" + need.name + ") requested by: " + this.JoyName);
                                ScriptingEngine.RunScript(need.InteractionFileContents, need.name, "FindFulfilmentObject", new object[] { new MoonEntity(this) });
                            }
                            else if (CurrentTarget.intent == Intent.Attack)
                            {
                                CombatEngine.SwingWeapon(this, CurrentTarget.target);
                            }
                        }
                    }
                    //If we've not arrived at our target
                    else if (WorldPosition != CurrentTarget.targetPoint || (CurrentTarget.target != null && AdjacencyHelper.IsAdjacent(WorldPosition, CurrentTarget.target.WorldPosition) == false))
                    {
                        //Move to target
                        MoveToTarget(CurrentTarget);
                    }
                }
            }
            else
            {
                if (!HasMoved && m_PathfindingData.Count > 0)
                {
                    Vector2Int    nextPoint     = m_PathfindingData.Peek();
                    PhysicsResult physicsResult = PhysicsManager.IsCollision(WorldPosition, nextPoint, MyWorld);
                    if (physicsResult != PhysicsResult.EntityCollision)
                    {
                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                    else if (physicsResult == PhysicsResult.EntityCollision)
                    {
                        MyWorld.SwapPosition(this, MyWorld.GetEntity(nextPoint));

                        m_PathfindingData.Dequeue();
                        Move(nextPoint);
                        HasMoved = true;
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override void Loop()
        {
            _turretService.Mono = true;

            bool completed = false;

            Marker m1 = null;

            bool w = false,
                 b = false;

            PhysicsResult p1 = null;

            for (; ; CheckCancelAndImageProcess())
            {
                completed = false;

                // Idle
                for (; ; CheckCancelAndImageProcess())
                {
                    break;
                }

                // Searching 시작을 위해 기본값으로 이동
                _deviceService.TiltNozzleSet(_configService.DeviceConfig.TiltNozzleDefault);
                _deviceService.TiltCameraSet((short)(_configService.DeviceConfig.TiltNozzleDefault));
                _deviceService.PanSet((short)(1), 0);

                Marker targetMarker = null;


                CheckCancelAndImageProcess();
                for (var i = _configService.DeviceConfig.TiltNozzleDefault;
                     i <= _configService.DeviceConfig.TiltCameraMax;
                     i += 60)
                {
                    for (short j = 0;
                         j <= _configService.DeviceConfig.PanMax;
                         j += 200)
                    {
                        // 이동
                        _deviceService.TiltCameraSet(i);
                        _deviceService.PanSet(j, 0);

                        // 화면 잔상 제거
                        SpinCheckSleep(1500);
                        CheckCancelAndImageProcess();

                        // 마커 검사
                        foreach (var marker in _result.Markers)
                        {
                            var match = from p in GetWaterRequiredPlants()
                                        where (marker.Color == MarkerColor.Black && !b) ||
                                        (marker.Color == MarkerColor.White && !w)
                                        select p;

                            if (match.Count() != 0)
                            {
                                // 추적 도움
                                // TODO 방향성
                                _deviceService.TiltCameraAdd(5);
                                _deviceService.PanAdd(10, 0);

                                targetMarker = marker;
                                break;
                            }
                        }

                        if (targetMarker != null)
                        {
                            break;
                        }
                    }
                    if (targetMarker != null)
                    {
                        break;
                    }
                }

                if (targetMarker == null)
                {
                    // 처음부터 다시 시작
                    completed = true;
                    continue;
                }

                for (; completed == false; CheckCancelAndImageProcess())
                {
                    Track(targetMarker);

                    // Tracking

                    Stopwatch failStopwatch = new Stopwatch();

                    // 이동 멈춤 대기
                    SpinCheck(() => _deviceService.PanRunning() == false);

                    CheckCancelAndImageProcess();
                    for (; completed == false; CheckCancelAndImageProcess())
                    {
                        var targetRecognized = from m in _result.Markers
                                               where m.Color == targetMarker.Color
                                               select m;

                        if (targetRecognized.Count() == 0)
                        {
                            Console.WriteLine("실패");

                            // 인식 실패
                            if (failStopwatch.IsRunning == false)
                            {
                                failStopwatch.Start();
                            }

                            // 추적 포기
                            if (failStopwatch.ElapsedMilliseconds > 3000)
                            {
                                completed = true;
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("성공");

                            // 추적 중
                            failStopwatch.Reset();

                            var target = targetRecognized.First();

                            bool
                                xOk = false,
                                yOk = false;

                            var x = target.X;
                            var y = target.Y;

                            var xa = Math.Abs(x);
                            var ya = Math.Abs(y);

                            if (xa > 50)
                            {
                                if (xa * 1.2 > 80)
                                {
                                    _deviceService.PanAdd((short)(x > 0 ? 80 : -80), 0);
                                }
                                else
                                {
                                    _deviceService.PanAdd((short)(x * 1.2), 0);
                                }
                            }
                            else if (xa > 15)
                            {
                                _deviceService.PanAdd((short)(x > 0 ? 5 : -5), 0);
                            }
                            else
                            {
                                xOk = true;
                            }

                            if (ya > 50)
                            {
                                _deviceService.TiltCameraAdd((short)(y > 0 ? 6 : -6));
                            }
                            else if (ya > 15)
                            {
                                _deviceService.TiltCameraAdd((short)(y > 0 ? 2 : -2));
                            }
                            else
                            {
                                yOk = true;
                            }

                            // 추적 성공
                            if (xOk && yOk)
                            {
                                CheckCancel();

                                if (targetMarker.Color == MarkerColor.White)
                                {
                                    w = true;
                                }
                                else
                                {
                                    b = true;
                                }

                                if (m1 == null)
                                {
                                    m1 = target;
                                    p1 = _physicsService.Measure(m1,
                                                                 _deviceService.TiltCameraGet(),
                                                                 _deviceService.PanGet(), true);
                                    completed = true;
                                    break;
                                }
                                else
                                {
                                    var m2 = target;
                                    var p2 = _physicsService.Measure(m2,
                                                                     _deviceService.TiltCameraGet(),
                                                                     _deviceService.PanGet(), true);


                                    short leftStep  = Math.Min(p1.EstimatedPanStep, p2.EstimatedPanStep);
                                    short rightStep = Math.Max(p1.EstimatedPanStep, p2.EstimatedPanStep);

                                    // inv
                                    short topWidth    = Math.Min(p1.EstimatedNozzleWidth, p2.EstimatedNozzleWidth);
                                    short bottomWidth = Math.Max(p1.EstimatedNozzleWidth, p2.EstimatedNozzleWidth);

                                    while (true)
                                    {
                                        Console.WriteLine("{0} {1}", leftStep, rightStep);
                                        Console.WriteLine("{0} {1}", topWidth, bottomWidth);
                                        Console.WriteLine();
                                        break;
                                    }

                                    /*
                                     * lock (_turretService.ImageProcessorLock)
                                     * {
                                     *  Thread.Sleep(100000);
                                     * }
                                     */
                                    _deviceService.WaterOn();

                                    _deviceService.TiltCameraSet(short.MinValue);

                                    for (int i = leftStep; i <= rightStep; i += 60)
                                    {
                                        for (int j = topWidth; j <= bottomWidth; j += 3)
                                        {
                                            _deviceService.PanSet((short)i, 0);
                                            _deviceService.TiltNozzleSet((short)j);
                                            Thread.Sleep(20);
                                            CheckCancel();
                                        }
                                    }

                                    _deviceService.WaterOff();

                                    m1        = null;
                                    completed = true;
                                    break;

                                    // 수평 분해
                                    for (int i = 0; i < 1000; i++)
                                    {
                                        if (m2.HorizontalDistance > m1.HorizontalDistance)
                                        {
                                            var temp = m2.HorizontalDistance;
                                            m2.HorizontalDistance = m1.HorizontalDistance;
                                            m1.HorizontalDistance = temp;
                                        }

                                        double distanceDiff = m2.HorizontalDistance - m1.HorizontalDistance;
                                        double distance     = m1.HorizontalDistance + (distanceDiff / 1000) * i;

                                        if (p2.EstimatedPanStep < p1.EstimatedPanStep)
                                        {
                                            var temp = p2.EstimatedPanStep;
                                            p2.EstimatedPanStep = p1.EstimatedPanStep;
                                            p1.EstimatedPanStep = temp;
                                        }

                                        double panDiff = p2.EstimatedPanStep - p1.EstimatedPanStep;
                                        double pan     = p1.EstimatedPanStep + (panDiff / 1000) * i;

                                        _deviceService.PanSet((short)pan, 0);

                                        // 수직 분해
                                        for (int j = 0; j < 1000; j++)
                                        {
                                            if (m2.Height < m1.Height)
                                            {
                                                var temp = m2.Height;
                                                m2.Height = m1.Height;
                                                m1.Height = temp;
                                            }

                                            double hDiff  = m2.Height - m1.Height;
                                            double height = m1.Height + (hDiff / 1000) * i;

                                            double angle = _physicsService.WaterAngle(distance, height, true);
                                            _deviceService.TiltCameraSet(_physicsService.NozzleAngleToWidth(angle));
                                        }
                                    }

                                    _deviceService.WaterOff();

                                    m1        = null;
                                    completed = true;
                                    break;
                                }
                            }
                            else
                            {
                                // 추적 실패

                                // 멈춤 대기
                                SpinCheck(() => _deviceService.PanRunning() == false);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override void HandleInput(InputEvent @event)
        {
            InputEvent action = @event;

            bool    hasMoved = false;
            IEntity player   = GlobalConstants.GameManager.Player;

            /*
             * if(Input.GetMouseButtonDown(0))
             * {
             *  Vector3 mouseWorld = m_Camera.ScreenToWorldPoint(Input.mousePosition);
             *  int x = (int)mouseWorld.x;
             *  int y = (int)mouseWorld.y;
             *
             *  Pathfinder pathfinder = new Pathfinder();
             *  Queue<Vector2Int> path = pathfinder.FindPath(player.WorldPosition, new Vector2Int(x, y), m_ActiveWorld);
             *  player.SetPath(path);
             *  autoTurn = true;
             * }
             */

            if (action.IsActionReleased("auto turn"))
            {
                this.AutoTurn       = !this.AutoTurn;
                this.ManualAutoTurn = this.AutoTurn;
            }

            Vector2Int newPlayerPoint = GlobalConstants.GameManager.Player.WorldPosition;

            if (action.IsActionReleased("close all windows"))
            {
                if (this.GUIManager.AreAnyOpen() == false)
                {
                    this.GUIManager.OpenGUI(this, GUINames.PAUSE);
                }
                else
                {
                    this.GUIManager.CloseAllGUIs();
                }
            }

            if (action.IsActionReleased("toggle inventory"))
            {
                this.ToggleWindow(GUINames.INVENTORY);
                if (this.GUIManager.IsActive(GUINames.INVENTORY) == false)
                {
                    this.GUIManager.CloseGUI(this, GUINames.INVENTORY_CONTAINER);
                }
            }
            else if (action.IsActionReleased("toggle equipment"))
            {
                this.ToggleWindow(GUINames.EQUIPMENT);
            }
            else if (action.IsActionReleased("toggle journal"))
            {
                this.ToggleWindow(GUINames.QUEST_JOURNAL);
            }
            else if (action.IsActionReleased("toggle job management"))
            {
                this.ToggleWindow(GUINames.JOB_MANAGEMENT);
            }
            else if (action.IsActionReleased("toggle character sheet"))
            {
                this.ToggleWindow(GUINames.CHARACTER_SHEET);
            }
            else if (action.IsActionReleased("toggle_crafting"))
            {
                this.ToggleWindow(GUINames.CRAFTING_SCREEN);
            }

            if (this.GUIManager.AreAnyOpen() == false)
            {
                this.GUIManager.OpenGUI(this, GUINames.NEEDS_PANEL);
                this.GUIManager.OpenGUI(this, GUINames.DERIVED_VALUES);
            }

            if (this.GUIManager.RemovesControl())
            {
                return;
            }

            if (action.IsActionReleased("interact"))
            {
                if (this.m_ActiveWorld.IsObjectAt(player.WorldPosition) == PhysicsResult.ObjectCollision)
                {
                    this.m_ActiveWorld.PickUpObject(player);
                    return;
                }

                //Going up a level
                if (this.m_ActiveWorld.Parent != null && player.WorldPosition == this.m_ActiveWorld.SpawnPoint &&
                    !player.HasMoved)
                {
                    this.ChangeWorld(this.m_ActiveWorld.Parent, this.m_ActiveWorld.GetTransitionPointForParent());
                    return;
                }

                //Going down a level
                if (this.m_ActiveWorld.Areas.ContainsKey(player.WorldPosition) && !player.HasMoved)
                {
                    this.ChangeWorld(this.m_ActiveWorld.Areas[player.WorldPosition],
                                     this.m_ActiveWorld.Areas[player.WorldPosition].SpawnPoint);
                    return;
                }
            }

            if (action.IsActionReleased("skip turn"))
            {
                this.Tick();
            }
            //North
            else if (action.IsActionReleased("N"))
            {
                newPlayerPoint.y -= 1;
                hasMoved          = true;
            }
            //North east
            else if (action.IsActionReleased("NE"))
            {
                newPlayerPoint.x += 1;
                newPlayerPoint.y -= 1;
                hasMoved          = true;
            }
            //East
            else if (action.IsActionReleased("E"))
            {
                newPlayerPoint.x += 1;
                hasMoved          = true;
            }
            //South east
            else if (action.IsActionReleased("SE"))
            {
                newPlayerPoint.x += 1;
                newPlayerPoint.y += 1;
                hasMoved          = true;
            }
            //South
            else if (action.IsActionReleased("S"))
            {
                newPlayerPoint.y += 1;
                hasMoved          = true;
            }
            //South west
            else if (action.IsActionReleased("SW"))
            {
                newPlayerPoint.x -= 1;
                newPlayerPoint.y += 1;
                hasMoved          = true;
            }
            //West
            else if (action.IsActionReleased("W"))
            {
                newPlayerPoint.x -= 1;
                hasMoved          = true;
            }
            //North west
            else if (action.IsActionReleased("NW"))
            {
                newPlayerPoint.x -= 1;
                newPlayerPoint.y -= 1;
                hasMoved          = true;
            }

            if (hasMoved)
            {
                this.AutoTurn = false;
                player.NeedFulfillmentData = new NeedFulfillmentData();

                PhysicsResult physicsResult = this.PhysicsManager.IsCollision(
                    player.WorldPosition,
                    newPlayerPoint,
                    this.m_ActiveWorld);

                if (physicsResult == PhysicsResult.EntityCollision)
                {
                    IEntity tempEntity = this.m_ActiveWorld.GetEntity(newPlayerPoint);
                    this.PlayerWorld.SwapPosition(player, tempEntity);
                    this.Tick();
                }
                else if (physicsResult == PhysicsResult.WallCollision)
                {
                    //Do nothing!
                }
                else
                {
                    if (newPlayerPoint.x >= 0 && newPlayerPoint.x < this.m_ActiveWorld.Tiles.GetLength(0) &&
                        newPlayerPoint.y >= 0 && newPlayerPoint.y < this.m_ActiveWorld.Tiles.GetLength(1))
                    {
                        player.Move(newPlayerPoint);
                        this.Tick();
                    }
                }
            }
        }
Exemplo n.º 6
0
        public override void HandleInput()
        {
            base.HandleInput();

            bool hasMoved = false;

            Entity player = m_ActiveWorld.Player;

            /*
             * if (m_Input.currentMouseState.ScrollWheelValue > m_Input.lastMouseState.ScrollWheelValue)
             * {
             *  m_Camera.zoom += 0.05f;
             * }
             *
             * if (m_Input.currentMouseState.ScrollWheelValue < m_Input.lastMouseState.ScrollWheelValue)
             * {
             *  m_Camera.zoom -= 0.05f;
             * }
             *
             * if(m_Input.IsOldPress(MouseButtons.RightButton))
             * {
             *  m_GUIManager.Screen.Desktop.Children.Remove(m_ContextMenu);
             *  m_ContextMenu.MoveTo(m_Input.currentMouseState.Position);
             *  m_GUIManager.Screen.Desktop.Children.Add(m_ContextMenu);
             *
             *  Vector2 mouseVector = (m_Input.currentMouseState.Position - (new Point(m_Renderer.m_ScreenWidth / 2, m_Renderer.m_ScreenHeight / 2))).ToVector2();
             *  m_MenuTile = new Point((int)Math.Floor(mouseVector.X / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom)), (int)Math.Floor(mouseVector.Y / (ObjectIcons.SPRITE_SIZE * m_Camera.zoom))) + s_ActiveWorld.player.position;
             * }
             *
             * if(m_Input.IsOldPress(Keys.Space))
             * {
             *  autoTurn = !autoTurn;
             * }
             *
             * if(m_Input.IsOldPress(Keys.L))
             * {
             *  s_ActiveWorld.player.LevelUp();
             * }
             *
             */

            /*
             * if(Input.GetMouseButtonDown(0))
             * {
             *  Vector3 mouseWorld = m_Camera.ScreenToWorldPoint(Input.mousePosition);
             *  int x = (int)mouseWorld.x;
             *  int y = (int)mouseWorld.y;
             *
             *  Pathfinder pathfinder = new Pathfinder();
             *  Queue<Vector2Int> path = pathfinder.FindPath(player.WorldPosition, new Vector2Int(x, y), m_ActiveWorld);
             *  player.SetPath(path);
             *  autoTurn = true;
             * }
             */

            if (Input.GetKeyDown(KeyCode.I))
            {
                m_InventoryOpen = !m_InventoryOpen;
                if (m_InventoryOpen == false)
                {
                    s_GUIManager.OpenGUI("NeedsPanel");
                }
                else
                {
                    s_GUIManager.OpenGUI("GUIInventory");
                }
            }

            if (s_GUIManager.RemovesControl())
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                //Going up a level
                if (m_ActiveWorld.Parent != null && player.WorldPosition == m_ActiveWorld.SpawnPoint && !player.HasMoved)
                {
                    ChangeWorld(m_ActiveWorld.Parent, m_ActiveWorld.GetTransitionPointForParent());
                    return;
                }

                //Going down a level
                else if (m_ActiveWorld.Areas.ContainsKey(player.WorldPosition) && !player.HasMoved)
                {
                    ChangeWorld(m_ActiveWorld.Areas[player.WorldPosition], m_ActiveWorld.Areas[player.WorldPosition].SpawnPoint);
                    return;
                }

                PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, player.WorldPosition, m_ActiveWorld);
                if (physicsResult == PhysicsResult.ObjectCollision)
                {
                    //Get the item picked up
                    ItemInstance pickUp = m_ActiveWorld.PickUpObject(player);

                    //And try to destroy the corresponding GameObject
                    if (pickUp != null)
                    {
                        GameObject.Destroy(GameObject.Find(pickUp.JoyName + ":" + pickUp.GUID));
                    }
                }
            }
            Vector2Int newPlayerPoint = m_ActiveWorld.Player.WorldPosition;

            //North
            if (Input.GetKeyDown(KeyCode.Keypad8))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y - 1);
                }
                else
                {
                    newPlayerPoint.y += 1;
                    hasMoved          = true;
                }
            }
            //North east
            else if (Input.GetKeyDown(KeyCode.Keypad9))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y - 1);
                }
                else
                {
                    newPlayerPoint.x += 1;
                    newPlayerPoint.y += 1;
                    hasMoved          = true;
                }
            }
            //East
            else if (Input.GetKeyDown(KeyCode.Keypad6))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y);
                }
                else
                {
                    newPlayerPoint.x += 1;
                    hasMoved          = true;
                }
            }
            //South east
            else if (Input.GetKeyDown(KeyCode.Keypad3))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x + 1, player.TargetPoint.y + 1);
                }
                else
                {
                    newPlayerPoint.x += 1;
                    newPlayerPoint.y -= 1;
                    hasMoved          = true;
                }
            }
            //South
            else if (Input.GetKeyDown(KeyCode.Keypad2))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x, player.TargetPoint.y + 1);
                }
                else
                {
                    newPlayerPoint.y -= 1;
                    hasMoved          = true;
                }
            }
            //South west
            else if (Input.GetKeyDown(KeyCode.Keypad1))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y + 1);
                }
                else
                {
                    newPlayerPoint.x -= 1;
                    newPlayerPoint.y -= 1;
                    hasMoved          = true;
                }
            }
            //West
            else if (Input.GetKeyDown(KeyCode.Keypad4))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y);
                }
                else
                {
                    newPlayerPoint.x -= 1;
                    hasMoved          = true;
                }
            }
            //North west
            else if (Input.GetKeyDown(KeyCode.Keypad7))
            {
                if (m_GameplayFlags == GameplayFlags.Targeting)
                {
                    player.TargetPoint = new Vector2Int(player.TargetPoint.x - 1, player.TargetPoint.y - 1);
                }
                else
                {
                    newPlayerPoint.x -= 1;
                    newPlayerPoint.y += 1;
                    hasMoved          = true;
                }
            }
            else if (Input.GetKeyDown(KeyCode.Keypad5))
            {
                Tick();
                return;
            }

            if (hasMoved)
            {
                PhysicsResult physicsResult = PhysicsManager.IsCollision(player.WorldPosition, newPlayerPoint, m_ActiveWorld);

                if (physicsResult == PhysicsResult.EntityCollision)
                {
                    Entity tempEntity = m_ActiveWorld.GetEntity(newPlayerPoint);
                    if (m_GameplayFlags == GameplayFlags.Interacting)
                    {
                        if (tempEntity.Sentient)
                        {
                            TalkToPlayer(tempEntity);
                        }
                    }
                    else if (m_GameplayFlags == GameplayFlags.Giving)
                    {
                    }
                    else if (m_GameplayFlags == GameplayFlags.Moving)
                    {
                        playerWorld.SwapPosition(player, tempEntity);
                        Tick();
                    }
                    else if (m_GameplayFlags == GameplayFlags.Attacking)
                    {
                        if (tempEntity.GUID != player.GUID)
                        {
                            CombatEngine.SwingWeapon(player, tempEntity);
                            tempEntity.InfluenceMe(player.GUID, -50);
                            if (!tempEntity.Alive)
                            {
                                m_ActiveWorld.RemoveEntity(newPlayerPoint);

                                //Find a way to remove the GameObject
                                for (int i = 0; i < m_EntitiesHolder.transform.childCount; i++)
                                {
                                    if (m_EntitiesHolder.transform.GetChild(i).name.Contains(tempEntity.GUID.ToString()))
                                    {
                                        GameObject.Destroy(m_EntitiesHolder.transform.GetChild(i).gameObject);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    Tick();
                }
                else if (physicsResult == PhysicsResult.WallCollision)
                {
                    //Do nothing!
                }
                else
                {
                    if (newPlayerPoint.x >= 0 && newPlayerPoint.x < m_ActiveWorld.Tiles.GetLength(0) && newPlayerPoint.y >= 0 && newPlayerPoint.y < m_ActiveWorld.Tiles.GetLength(1))
                    {
                        player.Move(newPlayerPoint);
                        Tick();
                    }
                }
            }
            else if (m_GameplayFlags == GameplayFlags.Targeting)
            {
                if (player.TargetingAbility.targetType == AbilityTarget.Adjacent)
                {
                    if (AdjacencyHelper.IsAdjacent(player.WorldPosition, player.TargetPoint))
                    {
                        Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint);
                        if (tempEntity != null && Input.GetKeyDown(KeyCode.Return))
                        {
                            player.TargetingAbility.Use(player, tempEntity);
                            Tick();
                            m_GameplayFlags = GameplayFlags.Moving;
                        }
                    }
                }
                else if (player.TargetingAbility.targetType == AbilityTarget.Ranged)
                {
                    Entity tempEntity = m_ActiveWorld.GetEntity(player.TargetPoint);
                    if (tempEntity != null && Input.GetKeyDown(KeyCode.Return))
                    {
                        player.TargetingAbility.Use(player, tempEntity);
                        Tick();
                        m_GameplayFlags = GameplayFlags.Moving;
                    }
                }
            }

            if (autoTurn)
            {
                Tick();
            }
            m_Camera.transform.position = new Vector3(player.WorldPosition.x, player.WorldPosition.y, m_Camera.transform.position.z);
        }