using UnityEngine;
using System.Collections;

public class Mg_Player : Singleton<Mg_Player>
{
    public GameObject _prefabPlayer;
    public Player _player;

    public IEnumerator Spawn_R(Vector3 pos, Vector3 direction, bool controlsActive)
    {
        if (_player == null)
        {
            GameObject go = Instantiate(_prefabPlayer) as GameObject;
            go.transform.parent = transform;
            _player = go.GetComponentInChildren<Player>();
            _player.controlsActive = controlsActive;
        }

        Vector2 dir = (Vector2)direction.normalized;
        pos += (Vector3)dir * 0.5f;
        _player.HardSetPosition(pos, dir);
        _player.gameObject.SetActive(true);
        if (controlsActive) Mg_Camera.Instance.StartFollowingPlayer();
        yield return null;// StartCoroutine(_player.Spawn_R(dir));
    }
}
