Advertisement
shadowplaycoding

SolarSystem_BeforePart6

Mar 7th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SolarSystem : MonoBehaviour {
  5.  
  6.     public static SolarSystem SolarSystemInstance;
  7.  
  8.     void OnEnable()
  9.     {
  10.         SolarSystemInstance = this;
  11.     }
  12.  
  13.     // Use this for initialization
  14.     void Start () {
  15.    
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.  
  21.         Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
  22.         RaycastHit hit = new RaycastHit();
  23.  
  24.         if (Physics.Raycast(mouseRay, out hit) && Input.GetMouseButtonDown(0))
  25.         {
  26.             Star star = Galaxy.GalaxyInstance.ReturnStarFromGameObject(hit.transform.gameObject);
  27.             Debug.Log("This Star is Called: " + star.starName + "\n" + "It Has " + star.numberOfPlanets + " Planets");
  28.  
  29.             Galaxy.GalaxyInstance.DestroyGalaxy();
  30.             CreateSolarSystem(star);
  31.         }
  32.  
  33.     }
  34.  
  35.     // This method creates the solar system view after a star is clicked on in the galaxy view
  36.     public void CreateSolarSystem(Star star)
  37.     {
  38.         GameObject starGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
  39.         starGO.transform.position = Vector3.zero;
  40.         starGO.name = star.starName;
  41.         starGO.transform.SetParent(this.transform);
  42.  
  43.         for (int i = 0; i < star.planetList.Count; i++)
  44.         {
  45.             Planet planet = star.planetList[i];
  46.  
  47.             Vector3 planetPos = PositionMath.PlanetPosition(i);
  48.  
  49.             SpaceObjects.CreateSphereObject(planet.planetName, planetPos, this.transform);
  50.         }
  51.  
  52.     }
  53.  
  54.     /*
  55.    Copyright Shadowplay Coding 2017 - see www.shadowplaycoding.com for licensing details
  56.    Removing this comment forfits any rights given to the user under licensing.
  57.    */
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement