//Selects the parent object in the stellar_hierarchy (NONE, STAR, PLANET, SURFACE) public static void Backup_Current_Selection() { Selection_Object current = current_Object; if (current_Object) { CameraController.focus_Level focus_Level = CameraController.Get_Focus_Level(); Planet planet = current.GetComponent <Planet>(); Star star = current.GetComponent <Star>(); if (focus_Level == CameraController.focus_Level.STAR) { StarToGalaxy(); } else if (focus_Level == CameraController.focus_Level.SYSTEM) { SystemToStar(star); } else if (focus_Level == CameraController.focus_Level.PLANET) { SystemToStar(planet.Get_Star()); } else if (focus_Level == CameraController.focus_Level.SURFACE) { SurfaceToPlanet(planet); } } }
public void Deactivate_All() { Deactivate_Indicator(); Deactivate_Mini_Indicator(); blur.enabled = false; select = null; }
public void Select_Star(Star target) { Vector3 pos = target.transform.position; Vector3 camPos = pos; select = null; if (CameraController.target) { camPos = CameraController.target.transform.position; } Activate_All(); Set_Position(pos); if (camPos != pos) { Set_Mini_Position(camPos); } else { Deactivate_Mini_Indicator(); } Activate_Indicator(); Set_Scale(3); Set_Mini_Scale(.8f); }
private static void SurfaceToPlanet(Planet planet) { current_Object = planet.GetComponent <Selection_Object>(); ui_Selector.Select_Planet(planet); CameraController.Set_Focus_Level(CameraController.focus_Level.PLANET); UI_Controller.surface_Manager.Deactivate(); }
private static void Select_New_Planet(Planet planet) { current_Object = planet.GetComponent <Selection_Object>(); ui_Selector.Select_Planet(planet); CameraController.Set_Focus_Level(CameraController.focus_Level.PLANET); planet.Activate_Preview(); }
//Selects an Object when clicked if panels aren't open and a button isn't also clicked. public static void Select_Object() { Ray r = Camera.main.ScreenPointToRay(mousePos); r.origin = Camera.main.transform.position; bool h = Physics.Raycast(r, 2400); RaycastHit hit; Selection_Object currentWinner = null; if (h) { RaycastHit[] hitArray = Physics.RaycastAll(Camera.main.transform.position, r.direction, 2400); hit = hitArray[0]; GameObject objectHit = null; if (hitArray.Length > 0) { for (int i = 0; i < hitArray.Length; i++) { hit = hitArray[i]; objectHit = hit.transform.gameObject; if (objectHit.CompareTag("Selectable_Object")) //- - - - - - Object is a Selectable_Object { if (!buttonHit) //- - - - - - No UI element was also clicked { Selection_Object sHit = objectHit.GetComponentInParent <Selection_Object>(); if (sHit) { int score = sHit.selection_Priority; if (currentWinner) { if (score < currentWinner.selection_Priority) { currentWinner = sHit; } } else { currentWinner = sHit; } } } } } } if (currentWinner) //- - - - - - - A winner was found based on priority { currentWinner.Select_Object(); } } }
private static void PlanetToSystem(Planet planet) { Star star = planet.Get_Star(); current_Object = star.GetComponent <Selection_Object>(); ui_Selector.Select_System(star); CameraController.Set_Focus_Level(CameraController.focus_Level.SYSTEM); CameraController.SetTarget(star.gameObject); }
public static void Zoom_Then_Deselect(Selection_Object destination_Object, float endDepth, float speed) { //Debug.Log("Zoom_Then_Deselect"); Vector3 destination = destination_Object.transform.position; IEnumerator item = cControl.ZoomThenDeselect(destination, endDepth, speed); cControl.StartCoroutine(item); }
private static void PlanetToSurface(Planet planet) { //Debug.Log("PlanetToSurface"); current_Object = planet.GetComponent <Selection_Object>(); ui_Selector.Select_Planet(planet); CameraController.Set_Focus_Level(CameraController.focus_Level.SURFACE); UI_Controller.surface_Manager.Activate(planet); }
private static void Select_New_Star(Star star) { if (current_Object) { current_Object.Deselect_This_Object(); } current_Object = star.GetComponent <Selection_Object>(); ui_Selector.Select_Star(star); CameraController.Set_Focus_Level(CameraController.focus_Level.STAR); star.Star_View_On(); }
private static void StarToGalaxy() { if (current_Object) { current_Object.Deselect_This_Object(); } current_Object = null; ui_Selector.Deactivate_All(); CameraController.Set_Focus_Level(CameraController.focus_Level.NONE); CameraController.SetTarget(null); }
private static void ZoomToStar(Star star) { current_Object = star.GetComponent <Selection_Object>(); float minDepth = -300; float speed = 50; speed = speed * CameraController.Get_Current_Depth_Ratio(); //Zooms camera to SYSTEM view if (CameraController.Get_Depth() != minDepth) { CameraController.Zoom_To_Selection_Object(current_Object, minDepth, speed); } }
public void Select_System(Star target) { Vector3 pos = target.transform.position; select = null; Set_Position(pos); Set_Mini_Position(pos); Activate_Mini_Indicator(); blur.enabled = true; Deactivate_Indicator(); Set_Mini_Scale(.8f); }
public void Select_Planet(Planet target) { Vector3 pos = target.Get_Sprite().gameObject.transform.position; Vector3 starPos = target.Get_Star().transform.position; select = target.GetComponent <Selection_Object>(); Set_Position(starPos); Deactivate_Indicator(); Activate_Mini_Indicator(); Set_Mini_Position(pos); Set_Mini_Scale(.2f); }
private static void SystemToStar(Star star) { current_Object = star.GetComponent <Selection_Object>(); ui_Selector.Select_Star(star); CameraController.Set_Focus_Level(CameraController.focus_Level.STAR); CameraController.SetTarget(star.gameObject); float minDepth = -150; if (CameraController.Get_Depth() > minDepth) { CameraController.Zoom_To_Selection_Object(current_Object, minDepth, 45); } star.Star_View_On(); }
private void GeneralControls() { if (!buttonHit) { cameraControl.MouseControls(); } if (Input_Controller.GetTouch()) { SetMousePos(); } //Stores click location to prevent selecting a hex if the camera is being panned if (Input_Controller.GetTouchDown()) { clickPos = mousePos; Select_UI_Object(); } if (Input_Controller.GetTouchUp()) { if (!buttonHit) { if (clickPos == mousePos) { if (Game_Controller.Get_Game_State() == Game_Controller.gameState.PLAY) { Select_Object(); } } } else { buttonHit = null; } } if (Input.GetMouseButtonDown(1)) { Selection_Object.Backup_Current_Selection(); } }
public void Deselect_This_Object() { Star star = GetComponent <Star>(); Planet planet = GetComponent <Planet>(); if (planet) { star = planet.Get_Star(); star.System_View_Off(); } else if (star) { star.System_View_Off(); } current_Object = null; }
private void Select_Star(Star star) { CameraController.focus_Level focus_Level = CameraController.Get_Focus_Level(); GameObject cameraTarget = null; if (focus_Level == CameraController.focus_Level.NONE) { Select_New_Star(star); } if (focus_Level == CameraController.focus_Level.STAR) { Star prevStar = null; if (current_Object) { prevStar = current_Object.GetComponent <Star>(); } if (prevStar) { if (prevStar == star) { cameraTarget = CameraController.target; if (cameraTarget) //The camera has a target { if (cameraTarget != star.gameObject) //The camera target is not this star { CameraController.SetTarget(star.gameObject); ui_Selector.Set_Mini_Position(star.gameObject.transform.position); ui_Selector.Deactivate_Mini_Indicator(); } else { StarToSystem(star); //The camera target and previous target are this star (Double click) } } CameraController.SetTarget(star.gameObject); //The previous object is thist star, but not the camera target. Make this object the camera target } else { Select_New_Star(star); //Previously selected star is not this star } } else { Select_New_Star(star); } //No previously selected star } if (focus_Level == CameraController.focus_Level.SYSTEM) { Star prevStar = null; if (current_Object) { prevStar = current_Object.GetComponent <Star>(); } if (prevStar) //Previous Object was a Star { if (prevStar != star) //Previous Object was not this Star { Select_New_Star(star); } else { ZoomToStar(star); //Previous Object was this star } } } if (focus_Level == CameraController.focus_Level.PLANET) //Peevious object was a planet { Planet prevPlanet = null; Star hostStar = null; if (current_Object) { prevPlanet = current_Object.GetComponent <Planet>(); } if (prevPlanet) //Prev object was a planet { hostStar = prevPlanet.Get_Star(); if (hostStar != star) //Previous Host Star was not this Star { Select_New_Star(star); } else //Previous Host Star was this Star { //Same as zoom to star without the zooming or re-org of planet manager Planet_Manager.ringState current = GetComponentInChildren <Planet_Manager>().Get_Current_RingState(); if (current == Planet_Manager.ringState.STAR) { current_Object = this; ui_Selector.Select_Star(star); CameraController.Set_Focus_Level(CameraController.focus_Level.STAR); //CameraController.SetTarget(star.gameObject); } else { current_Object = this; ui_Selector.Select_System(star); CameraController.Set_Focus_Level(CameraController.focus_Level.SYSTEM); CameraController.SetTarget(star.gameObject); } } } } if (focus_Level == CameraController.focus_Level.SURFACE) { } }