using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI; //important

public class NPCTeleporter : MonoBehaviour
{
    private Transform player;
    public NavMeshAgent agent;
    public CharacterController controller;
    public PlayerMove playerMove;

    public enum TeleportLocation
    {
        Homebase,
        FiringRange,
        Arena
    }

    public TeleportLocation location;

    Vector3 GetPosition(TeleportLocation location)
    {
        switch (location)
        {
            case TeleportLocation.Homebase:
                return new Vector3(-174, 2, -55);
            case TeleportLocation.Arena:
                return new Vector3(-63, 2, -54);
            case TeleportLocation.FiringRange:
                return new Vector3(-62, 2, -39);
            default:
                return new Vector3(-174, 2, -55);
        }
    }

    void Start()
    {
        agent = GetComponent<NavMeshAgent>();
        player = GameObject.Find("Player").GetComponent<Transform>();
        controller = GetComponent<CharacterController>();
    }

    public void TeleportThePlayer(Enum location)
    {
        if (Vector3.Distance(this.transform.position, player.position) <= agent.stoppingDistance)
        {
            playerMove.TeleportPlayer(GetPosition((TeleportLocation)location));
            //player.transform.position = GetPosition((TeleportLocation)location);
            //print("Teleporting Player to " + GetPosition((TeleportLocation)location));
        }
    }

}