using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using Random = UnityEngine.Random;

public class MapLocation : MonoBehaviour
{
    public enum TerrainType
    {
        Grass,
        Snow,
        Sand
    }
    public List<MapLocation> Neighbors;
    public List<Enemy> EnemyPool;
    public int ToUnlock = -1;
    public TerrainType Type;

    public Enemy GetEnemy()
    {
        return EnemyPool[Random.Range(0, EnemyPool.Count)];
    }

    public bool IsNeighboring(MapLocation loc)
    {
        return Neighbors.Contains(loc);
    }

    public void OnMouseDown()
    {
        if (GameManager.Instance.BlockInput())
        {
            return;
        }
        
        if (ToUnlock > 0)
        {
            MapManager.Instance.TransformMap(ToUnlock);
        }
        MapManager.Instance.TryToMoveToLocation(this);
    }

    private void OnDrawGizmos()
    {
        if (Neighbors == null) return;

        foreach (MapLocation loc in Neighbors)
        {
            Gizmos.DrawLine(transform.position, loc.transform.position);
        }
    }
}
