public void MoveNextTile() //start to try to move unit { if (currentPath == null || !TurnSystem.selectedUnit.CheckUnitState(UnitConfig.UnitState.Idle)) // if there is no path (or unit shoots) leave function { return; } int remainingMovement = movePoints * actionPoints.ReturnAvailableActions(); int moveTo = currentPath.Count - 1; for (int cost = 1; cost < moveTo; cost++)//is the path possible { remainingMovement -= (int)mapConfig.tileMap.CostToEnterTile(currentPath[cost].x, currentPath[cost].y, currentPath[1 + cost].x, currentPath[1 + cost].y); } if (remainingMovement > movePoints)//can you move the unit { mapConfig.turnSystem.cameraControl.SetCameraTime(0); cameraStartPosition = mapConfig.turnSystem.cameraControl.GetCameraPosition(); //HACK: idle check should replace isSprinting & isMoving if possible SetUnitState(UnitState.Walking); //start moving in the update mapConfig.tileMap.ResetColorGrid(); mapConfig.tileMap.removeUnitMapData(tileX, tileY); actionPoints.SubtractActions(unitClassStats.moveCost); //1 should be whatever it costs to move the unit return; } if (remainingMovement > 0 && actionPoints.CheckAvailableActions(1))//can you move the unit { mapConfig.turnSystem.cameraControl.SetCameraTime(0); cameraStartPosition = mapConfig.turnSystem.cameraControl.GetCameraPosition(); //HACK: idle check should replace isSprinting & isMoving if possible SetUnitState(UnitState.Sprinting); mapConfig.tileMap.ResetColorGrid(); mapConfig.tileMap.removeUnitMapData(tileX, tileY); actionPoints.SubtractAllActions(); return; } else//is too far away do not move { return; } }