// Path: core/src/com/ychstudio/ai/astar/AStartPathFinding.java
// public class AStartPathFinding {
// 	 public final AStarMap map;
// 	 private final PathFinder<Node> pathfinder;
// 	 private final Heuristic<Node> heuristic;
// 	 private final GraphPath<Connection<Node>> connectionPath;
// 
//     public AStartPathFinding(AStarMap map) {
//         this.map = map;
//         this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map));
//         this.connectionPath = new DefaultGraphPath<Connection<Node>>();
//         this.heuristic = new Heuristic<Node>() {
//             @Override
//             public float estimate (Node node, Node endNode) {
//                 // Manhattan distance
//                 return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y);
//             }
// 	     };
//     }
// 
//     public Node findNextNode(Vector2 source, Vector2 target) {
//         int sourceX = MathUtils.floor(source.x);
//         int sourceY = MathUtils.floor(source.y);
//         int targetX = MathUtils.floor(target.x);
//         int targetY = MathUtils.floor(target.y);
// 
//         if (map == null
//                || sourceX < 0 || sourceX >= map.getWidth()
//                || sourceY < 0 || sourceY >= map.getHeight()
//                || targetX < 0 || targetX >= map.getWidth()
//                || targetY < 0 || targetY >= map.getHeight()) {
//            return null;
//         }
//        
//         Node sourceNode = map.getNodeAt(sourceX, sourceY);
//         Node targetNode = map.getNodeAt(targetX, targetY);
//         connectionPath.clear();
//         pathfinder.searchConnectionPath(sourceNode, targetNode, heuristic, connectionPath);
// 
//         return connectionPath.getCount() == 0 ? null : connectionPath.get(0).getToNode();
//     }
// 
//     private static final int[][] NEIGHBORHOOD = new int[][] {
//         new int[] {-1,  0},
//         new int[] { 0, -1},
//         new int[] { 0,  1},
//         new int[] { 1,  0}
//     };
// 
//     public static MyGraph createGraph (AStarMap map) {
//         final int height = map.getHeight();
//         final int width = map.getWidth();
//         MyGraph graph = new MyGraph(map);
//         for (int y = 0; y < height; y++) {
//             for (int x = 0; x < width; x++) {
//                 Node node = map.getNodeAt(x, y);
//                 if (node.isWall) {
//                     continue;
//                 } 
//                 // Add a connection for each valid neighbor
//                 for (int offset = 0; offset < NEIGHBORHOOD.length; offset++) {
//                     int neighborX = node.x + NEIGHBORHOOD[offset][0];
//                     int neighborY = node.y + NEIGHBORHOOD[offset][1];
//                     if (neighborX >= 0 && neighborX < width && neighborY >= 0 && neighborY < height) {
//                         Node neighbor = map.getNodeAt(neighborX, neighborY);
//                         if (!neighbor.isWall) {
//                             // Add connection to walkable neighbor
//                             node.getConnections().add(new DefaultConnection<Node>(node, neighbor));
//                         }
//                     }
//                 }
//                 node.getConnections().shuffle();
//             }
//         }
//         return graph;
//     }
// 
//     private static class MyGraph implements IndexedGraph<Node> {
//    		
//         AStarMap map;
// 
//         public MyGraph (AStarMap map) {
//             this.map = map;
//         }
// 
//         @Override
//         public int getIndex(Node node) {
//             return node.getIndex();
//         }
// 
//         @Override
//         public Array<Connection<Node>> getConnections(Node fromNode) {
//             return fromNode.getConnections();
//         }
// 
//         @Override
//         public int getNodeCount() {
//             return map.getHeight() * map.getwidth();
//         }
//    	 
//     }
// }


import com.badlogic.gdx.ai.utils.Location;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Disposable;
import com.ychstudio.ai.astar.AStartPathFinding;
package com.ychstudio.gamesys;


public class GameManager implements Disposable {

    public static final GameManager instance = new GameManager();

    public static final float PPM = 16f;

    public static final short NOTHING_BIT = 0;
    public static final short WALL_BIT = 1;
    public static final short PLAYER_BIT = 1 << 1;
    public static final short PILL_BIT = 1 << 2;
    public static final short GHOST_BIT = 1 << 3;
    public static final short GATE_BIT = 1 << 4;
    public static final short LIGHT_BIT = 1 << 5;

    public AssetManager assetManager;

    public Vector2 playerSpawnPos;
    public Vector2 ghostSpawnPos;

    public int totalPills = 0;

    public int highScore = 0;
    public int score = 0;

    public int displayScore = 0;
    public int displayHighScore = 0;

    public int playerLives = 4;
    public boolean playerIsInvincible = true;

    public boolean bigPillEaten = false;
    public boolean playerIsAlive = true;
    private boolean gameOver = false;

// Path: core/src/com/ychstudio/ai/astar/AStartPathFinding.java
// public class AStartPathFinding {
// 	 public final AStarMap map;
// 	 private final PathFinder<Node> pathfinder;
// 	 private final Heuristic<Node> heuristic;
// 	 private final GraphPath<Connection<Node>> connectionPath;
// 
//     public AStartPathFinding(AStarMap map) {
//         this.map = map;
//         this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map));
//         this.connectionPath = new DefaultGraphPath<Connection<Node>>();
//         this.heuristic = new Heuristic<Node>() {
//             @Override
//             public float estimate (Node node, Node endNode) {
//                 // Manhattan distance
//                 return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y);
//             }
// 	     };
//     }
// 
//     public Node findNextNode(Vector2 source, Vector2 target) {
//         int sourceX = MathUtils.floor(source.x);
//         int sourceY = MathUtils.floor(source.y);
//         int targetX = MathUtils.floor(target.x);
//         int targetY = MathUtils.floor(target.y);
// 
//         if (map == null
//                || sourceX < 0 || sourceX >= map.getWidth()
//                || sourceY < 0 || sourceY >= map.getHeight()
//                || targetX < 0 || targetX >= map.getWidth()
//                || targetY < 0 || targetY >= map.getHeight()) {
//            return null;
//         }
//        
//         Node sourceNode = map.getNodeAt(sourceX, sourceY);
//         Node targetNode = map.getNodeAt(targetX, targetY);
//         connectionPath.clear();
//         pathfinder.searchConnectionPath(sourceNode, targetNode, heuristic, connectionPath);
// 
//         return connectionPath.getCount() == 0 ? null : connectionPath.get(0).getToNode();
//     }
// 
//     private static final int[][] NEIGHBORHOOD = new int[][] {
//         new int[] {-1,  0},
//         new int[] { 0, -1},
//         new int[] { 0,  1},
//         new int[] { 1,  0}
//     };
// 
//     public static MyGraph createGraph (AStarMap map) {
//         final int height = map.getHeight();
//         final int width = map.getWidth();
//         MyGraph graph = new MyGraph(map);
//         for (int y = 0; y < height; y++) {
//             for (int x = 0; x < width; x++) {
//                 Node node = map.getNodeAt(x, y);
//                 if (node.isWall) {
//                     continue;
//                 } 
//                 // Add a connection for each valid neighbor
//                 for (int offset = 0; offset < NEIGHBORHOOD.length; offset++) {
//                     int neighborX = node.x + NEIGHBORHOOD[offset][0];
//                     int neighborY = node.y + NEIGHBORHOOD[offset][1];
//                     if (neighborX >= 0 && neighborX < width && neighborY >= 0 && neighborY < height) {
//                         Node neighbor = map.getNodeAt(neighborX, neighborY);
//                         if (!neighbor.isWall) {
//                             // Add connection to walkable neighbor
//                             node.getConnections().add(new DefaultConnection<Node>(node, neighbor));
//                         }
//                     }
//                 }
//                 node.getConnections().shuffle();
//             }
//         }
//         return graph;
//     }
// 
//     private static class MyGraph implements IndexedGraph<Node> {
//    		
//         AStarMap map;
// 
//         public MyGraph (AStarMap map) {
//             this.map = map;
//         }
// 
//         @Override
//         public int getIndex(Node node) {
//             return node.getIndex();
//         }
// 
//         @Override
//         public Array<Connection<Node>> getConnections(Node fromNode) {
//             return fromNode.getConnections();
//         }
// 
//         @Override
//         public int getNodeCount() {
//             return map.getHeight() * map.getwidth();
//         }
//    	 
//     }
// }


// Path: core/src/com/ychstudio/gamesys/GameManager.java
import com.badlogic.gdx.ai.utils.Location;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Disposable;
import com.ychstudio.ai.astar.AStartPathFinding;

package com.ychstudio.gamesys;


public class GameManager implements Disposable {

    public static final GameManager instance = new GameManager();

    public static final float PPM = 16f;

    public static final short NOTHING_BIT = 0;
    public static final short WALL_BIT = 1;
    public static final short PLAYER_BIT = 1 << 1;
    public static final short PILL_BIT = 1 << 2;
    public static final short GHOST_BIT = 1 << 3;
    public static final short GATE_BIT = 1 << 4;
    public static final short LIGHT_BIT = 1 << 5;

    public AssetManager assetManager;

    public Vector2 playerSpawnPos;
    public Vector2 ghostSpawnPos;

    public int totalPills = 0;

    public int highScore = 0;
    public int score = 0;

    public int displayScore = 0;
    public int displayHighScore = 0;

    public int playerLives = 4;
    public boolean playerIsInvincible = true;

    public boolean bigPillEaten = false;
    public boolean playerIsAlive = true;
    private boolean gameOver = false;

    public AStartPathFinding pathfinder;