﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StarFunctions : MonoBehaviour {

    public Material originalMaterial;
    public string systemName = "";
    public bool rayIsIn = false;
    private void Start()
    {
        
    }

    private void OnMouseOver()
    {
        Material newMaterial = new Material(Shader.Find("Standard"));
        newMaterial.color = Color.green;
        transform.GetComponent<Renderer>().material = newMaterial;
    }

    private void OnMouseExit()
    {
        transform.GetComponent<Renderer>().material = originalMaterial;
    }

    private void OnMouseDown()
    {
        ThreeDViewStarter.HideStarsSystem();
        ThreeDViewStarter.ShowThreeDSystem();
        // ThreeDViewStarter.ResetThreeDView();
        ThreeDViewStarter.ShowTwoDSystem();
        ThreeDViewStarter.AddNewSystem(systemName);
        ThreeDViewStarter.ResetPlayerPosition();
    }

    public void ChangeMaterial()
    {
        if (rayIsIn)
        {
            Material newMaterial = new Material(Shader.Find("Standard"));
            newMaterial.color = Color.green;
            transform.GetComponent<Renderer>().material = newMaterial;
        }
        else
        {
            transform.GetComponent<Renderer>().material = originalMaterial;
        }
    }

    public void ShowPlanetarySystem()
    {
        ThreeDViewStarter.HideStarsSystem();
        ThreeDViewStarter.ShowThreeDSystem();
       // ThreeDViewStarter.ResetThreeDView();
        ThreeDViewStarter.ShowTwoDSystem();
        ThreeDViewStarter.AddNewSystem(systemName);
        ThreeDViewStarter.ResetPlayerPosition();
    }

}
