void ProbabilityRevision() { int survivablePlanetCount = 0; int planetCount = 0; for (int i = 2; i <= 4; i++) { for (int j = 0; j < sectorTiles[i].onSector.transform.childCount; j++) { planetCount++; if (sectorTiles[i].onSector.transform.GetChild(j).GetComponent <PlanetBase>().canSurvive) { survivablePlanetCount++; } } } while ((float)survivablePlanetCount / (float)planetCount < dm.GetCurrentSectorData(currentSector).minimumSuccessRate / 9.0f) { Sector s = sectorTiles[Random.Range(2, 5)].onSector; PlanetBase p = s.transform.GetChild(Random.Range(0, s.transform.childCount)).GetComponent <PlanetBase>(); if (p.canSurvive == false && p.isExplored == false) { p.SetData(planetFactory.GetScript(true), true); survivablePlanetCount++; } } }
public override void OnInspectorGUI() { PlanetBase myPlanet = (PlanetBase)target; //Basic Planet Info EditorGUILayout.LabelField("Basic Info:"); EditorGUILayout.BeginVertical("Box"); myPlanet.planetSize = EditorGUILayout.IntSlider(new GUIContent("Planet Size(radius in miles): ", "Earth's radius is 3959 miles"), myPlanet.planetSize, 1000, 10000); myPlanet.orbitTime = EditorGUILayout.Slider("Orbit Time(in days): ", myPlanet.orbitTime, 200, 1000); myPlanet.revolutionTime = EditorGUILayout.Slider("Revolution Time(in hours): ", myPlanet.revolutionTime, 5, 75); myPlanet.moonAmount = EditorGUILayout.IntSlider("Number of Moons: ", myPlanet.moonAmount, 0, 500); myPlanet.mainColor = EditorGUILayout.ColorField("Main Color: ", myPlanet.mainColor); EditorGUILayout.EndVertical(); //Enviroment Info EditorGUILayout.LabelField("Enviromental Info:"); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.MinMaxSlider(new GUIContent("Tempurature(in c): ", "Earth's average temp is 14c"), ref myPlanet.lowTemp, ref myPlanet.highTemp, -100, 100); EditorGUILayout.LabelField(" ", "Min: " + myPlanet.lowTemp + " Max: " + myPlanet.highTemp); EditorGUILayout.MinMaxSlider(new GUIContent("Elevation(in miles): ", "Above and below sea-level"), ref myPlanet.lowElevation, ref myPlanet.highElevation, -10, 10); EditorGUILayout.LabelField(" ", "Min: " + myPlanet.lowElevation + " Max: " + myPlanet.highElevation); myPlanet.radiationAmount = EditorGUILayout.Slider(new GUIContent("Amount of Radiation(per orbit): ", "Earth's average radiation per year is 3.01"), myPlanet.radiationAmount, 0, 5); myPlanet.hasWater = EditorGUILayout.Toggle("Has Water: ", myPlanet.hasWater); serializedObject.Update(); SerializedProperty myElements = serializedObject.FindProperty("mainElements"); EditorGUILayout.PropertyField(myElements, new GUIContent("Main scientific elements: ", "There are 118 elements known on Earth"), true); serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); //Life info EditorGUILayout.LabelField("Life form Info:"); EditorGUILayout.BeginVertical("Box"); myPlanet.isHabitable = EditorGUILayout.BeginToggleGroup(": Is habitable", myPlanet.isHabitable); myPlanet.flora = EditorGUILayout.Toggle(new GUIContent("Has Flora: ", "Plants"), myPlanet.flora); myPlanet.fauna = EditorGUILayout.Toggle(new GUIContent("Has Fauna: ", "Animals"), myPlanet.fauna); EditorGUILayout.EndToggleGroup(); if (myPlanet.isHabitable == false) { myPlanet.flora = false; myPlanet.fauna = false; } if (myPlanet.intelligentCreatures = EditorGUILayout.Toggle("Has Intelligent Creatures: ", myPlanet.intelligentCreatures) == true) { myPlanet.icPopulation = EditorGUILayout.IntField("Intelligent Population: ", Mathf.Max(0, myPlanet.icPopulation)); } else if (myPlanet.intelligentCreatures == false) { myPlanet.icPopulation = 0; } EditorGUILayout.EndVertical(); //Original //EditorGUILayout.LabelField("-------------------------------------------------------------------------------------------"); //base.OnInspectorGUI(); }
IEnumerator ExploringProcess(PlanetBase target) { int distance = selectedPlanet.transform.parent.GetComponent <Sector>().nowSectorTile.index - 1; player.currentHp -= 5f * distance; Image ring = Instantiate(exploringRing); // Create red ring that shows exploring progress. ring.transform.SetParent(ringHome, false); ring.transform.position = selectedPlanet.transform.position; ring.transform.localScale = target.transform.localScale; ring.GetComponent <Ring>().targetPlanet = selectedPlanet; ring.GetComponent <Ring>().isChasing = true; ring.fillAmount = 0; Text ringText = ring.GetComponentInChildren <Text>(); float elapsedTime = 0; bool isSoundEffected = false; while (true) { if (player.gameObject.activeSelf == false) { break; } if (elapsedTime >= 2f) { break; } if (elapsedTime > 0.3f && !isSoundEffected) { isSoundEffected = true; audioSource.clip = exploringSound; audioSource.Play(); } if (ring.transform.position.x <= -6.4f) // If ring become out of screen, { Destroy(ring); break; } ring.fillAmount += Time.deltaTime / 2; ringText.text = ((int)(ring.fillAmount * 100)).ToString() + "%"; // Show percent of exploring progress. elapsedTime += Time.deltaTime; exploringRing.transform.localScale = target.transform.localScale; yield return(null); } Destroy(ring.gameObject); audioSource.Stop(); audioSource.clip = exploreSuccessSound; audioSource.Play(); PlanetBase destroyingObj = exploringPlanets.Dequeue(); // Destroy first added planet among exploring planets. destroyingObj.Explore(); }
public void Emigration(PlanetBase target) { gameObject.SetActive(true); transform.localScale = new Vector3(1, 1, 1)*(1f/transform.parent.localScale.x); emigrationTarget = target; uiMgr.isEmigrationEnd = false; StartCoroutine(CoroutineUtil.LerpMove(this.gameObject, this.gameObject.transform.position, target.transform.position, 1, true, false, this.gameObject, "MoveEnd")); Vector3 t = target.transform.position - transform.position; float angle = Mathf.Rad2Deg*Mathf.Atan2(t.y, t.x); transform.rotation = Quaternion.identity; transform.Rotate(new Vector3(0, 0, -90+angle)); }
public void Emigration(PlanetBase target) { gameObject.SetActive(true); transform.localScale = new Vector3(1, 1, 1) * (1f / transform.parent.localScale.x); emigrationTarget = target; uiMgr.isEmigrationEnd = false; StartCoroutine(CoroutineUtil.LerpMove(this.gameObject, this.gameObject.transform.position, target.transform.position, 1, true, false, this.gameObject, "MoveEnd")); Vector3 t = target.transform.position - transform.position; float angle = Mathf.Rad2Deg * Mathf.Atan2(t.y, t.x); transform.rotation = Quaternion.identity; transform.Rotate(new Vector3(0, 0, -90 + angle)); }
public void ResetScriptLanguage(PlanetBase planet) { if (planet.name == "Earth") { string[] engEarthScript = new string[3] { "Home of Human race.", "Critical pollution detected.", "Serious resource exhaustion." }; if (languageMgr.currLanguage == Language.English) { planet.SetData(engEarthScript, false); } return; } string[] newScripts = GetScript(planet.canSurvive); planet.SetData(newScripts, planet.canSurvive); }
public void Emigration(PlanetBase target) { this.mainPlanet = target; for (int i = 0; i < mainPlanet.transform.parent.childCount;i++ ) { if (mainPlanet.transform.parent.GetChild(i) != mainPlanet.transform) { mainPlanet.transform.parent.GetChild(i).SetParent(null); i--; } } sectorMgr.OnEmigration(target.transform.parent.GetComponent<Sector>().nowSectorTile.index - 1); if (target.canSurvive) currentHp = maxHp; else currentHp -= 10; um.EmigrationEffect(target.canSurvive); }
public void OnPlanetTouch(PlanetBase planet) { if (!bottomUIMoveEnd || !hpBarMoveEnd) { return; } selectedPlanet = planet; if (planet.transform.parent.GetComponent <Sector>().nowSectorTile == sectorMgr.sectorTiles[1] && selectedPlanet) { selectedPlanetIsCurrentPlanet = true; return; } else { selectedPlanetIsCurrentPlanet = false; } }
public void OnSelectButtonDown() { if (selectedPlanet == null) { return; } if (!isEmigrationEnd) { return; } if (player.mainPlanet == selectedPlanet) { return; } audioSource.clip = exploreSound; audioSource.Play(); if (selectedPlanet.isExplored) { rocket.Emigration(selectedPlanet); audioSource.clip = emigrationSound; audioSource.Play(); selectedPlanet = null; selectButtonText.text = ""; for (int i = 0; i < 3; i++) { descriptionTexts[i].text = ""; } } else { if (exploringPlanets.Contains(selectedPlanet)) { return; } StartCoroutine(ExploringProcess(selectedPlanet)); exploringPlanets.Enqueue(selectedPlanet); OnPlanetTouch(selectedPlanet); } }
Sector CreateSector() { //StartCoroutine(HighlightCurrentPlanet()); sectorData = dm.GetCurrentSectorData(currentSector); player.UpdateSectorData(sectorData); currentSector++; Sector nowSector = sectors[sectorIndex]; while (nowSector.transform.childCount > 0) { Destroy(nowSector.transform.GetChild(0).gameObject); nowSector.transform.GetChild(0).SetParent(null); } int rand = Random.Range(1, 4); for (int i = 0; i < rand; i++) { PlanetBase p = planetFactory.GetNewPlanet(currentSector); p.gameObject.SetActive(true); p.transform.SetParent(nowSector.transform); } nowSector.gameObject.SetActive(true); nowSector.SetSectorTile(sectorTiles[5]); for (int i = 0; i < nowSector.transform.childCount; i++) { nowSector.transform.GetChild(i).position = nowSector.transform.GetChild(i).GetComponent <PlanetBase>().targetPos; } sectorIndex++; if (sectorIndex == sectors.Length) { sectorIndex = 0; } return(nowSector); }
public void Emigration(PlanetBase target) { this.mainPlanet = target; for (int i = 0; i < mainPlanet.transform.parent.childCount; i++) { if (mainPlanet.transform.parent.GetChild(i) != mainPlanet.transform) { mainPlanet.transform.parent.GetChild(i).SetParent(null); i--; } } sectorMgr.OnEmigration(target.transform.parent.GetComponent <Sector>().nowSectorTile.index - 1); if (target.canSurvive) { currentHp = maxHp; } else { currentHp -= 10; } um.EmigrationEffect(target.canSurvive); }
public void OnEnable() { planet = (PlanetBase)target; }
public void HandlePlanetCollide(PlanetBase planet) { _player.Kill(); End(false); //UI Death Message }
public void HandleGravityCollide(PlanetBase planet) { _player.Orbit(planet); _activePlanet = planet; _jumps++; CurrentLevel.updateUIJumps(_jumps.ToString()); CurrentLevel.updateUIDistance(planet.Center.y.ToString("0")); }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); PlanetBase myTarget = (PlanetBase)target; GUIStyle bold = GUI.skin.GetStyle("Label"); bold.fontStyle = FontStyle.Bold; //Atmosphere EditorGUILayout.BeginVertical("button"); EditorGUILayout.LabelField("Atmosphere", bold); myTarget.hasWater = EditorGUILayout.Toggle(new GUIContent("Water?", "Is there water on the planet?"), myTarget.hasWater); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Low Temperature(c°)", "What is the lowest temperature?")); EditorGUILayout.LabelField(new GUIContent("High Temperature(c°)", "What is the highest temperature?")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); myTarget.lowTemp = EditorGUILayout.FloatField(myTarget.lowTemp); myTarget.highTemp = EditorGUILayout.FloatField(myTarget.highTemp); EditorGUILayout.EndHorizontal(); EditorGUILayout.MinMaxSlider(ref myTarget.lowTemp, ref myTarget.highTemp, -100, 100); myTarget.radiationAmount = EditorGUILayout.FloatField(new GUIContent("Radiation(rad)", "How much radiation?"), myTarget.radiationAmount); EditorGUILayout.EndVertical(); //Life EditorGUILayout.BeginVertical("button"); EditorGUILayout.LabelField("Life", bold); myTarget.isHabitable = EditorGUILayout.BeginToggleGroup("Is Habitable", myTarget.isHabitable); EditorGUILayout.BeginHorizontal(); if (myTarget.isHabitable) { myTarget.flora = EditorGUILayout.BeginToggleGroup(new GUIContent("Flora", "Plant Life"), myTarget.flora); } else { myTarget.flora = EditorGUILayout.BeginToggleGroup(new GUIContent("Flora", "Must Be Habitable"), myTarget.flora); } if (myTarget.flora) { myTarget.fauna = EditorGUILayout.Toggle(new GUIContent("Fauna", "Animal Life"), myTarget.flora); } else { myTarget.fauna = EditorGUILayout.Toggle(new GUIContent("Fauna", "Must Have Flora"), myTarget.flora); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.BeginHorizontal(); myTarget.intelligentCreatures = EditorGUILayout.BeginToggleGroup(new GUIContent("Intelligent Creatures", "Are There Intelligent Creatures?"), myTarget.intelligentCreatures); myTarget.icPopulation = EditorGUILayout.IntField(myTarget.icPopulation); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); //Surface EditorGUILayout.BeginVertical("button"); EditorGUILayout.LabelField("Surface", bold); myTarget.mainColor = EditorGUILayout.ColorField("Planet Color", myTarget.mainColor); myTarget.planetSize = EditorGUILayout.IntField(new GUIContent("Planet Size", "The Earth is about 3919"), myTarget.planetSize); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Low Elevation", "Lowest the planet can be")); EditorGUILayout.LabelField(new GUIContent("High Elevation", "Highest the planet can be")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); myTarget.lowElevation = EditorGUILayout.FloatField(myTarget.lowElevation); myTarget.highElevation = EditorGUILayout.FloatField(myTarget.highElevation); EditorGUILayout.EndHorizontal(); EditorGUILayout.MinMaxSlider(ref myTarget.lowElevation, ref myTarget.highElevation, -100, 100); EditorGUILayout.EndVertical(); //Orbit & Time EditorGUILayout.BeginVertical("button"); EditorGUILayout.LabelField("Orbit & Time", bold); myTarget.moonAmount = EditorGUILayout.IntField("Number of Moons", myTarget.moonAmount); GUIStyle myStyle = GUI.skin.GetStyle("Label"); EditorGUILayout.LabelField(""); myStyle.alignment = TextAnchor.MiddleCenter; myStyle.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Time", myStyle); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Revolution", "Hours in a day")); EditorGUILayout.LabelField(new GUIContent("Orbit", "Days it takes to make a full orbit")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); myTarget.revolutionTime = EditorGUILayout.FloatField(myTarget.revolutionTime); myTarget.orbitTime = EditorGUILayout.FloatField(myTarget.orbitTime); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("button"); serializedObject.Update(); SerializedProperty myElem = serializedObject.FindProperty("mainElements"); EditorGUILayout.PropertyField(myElem, true); serializedObject.ApplyModifiedProperties(); //Main Elements /* * EditorGUILayout.BeginVertical("button"); * EditorGUILayout.LabelField("Elements", bold); * EditorGUILayout.IntField("Size", myTarget.mainElements.GetLength(0)); * int elements = myTarget.mainElements.GetLength(0); * for(int count = 0; count < elements; count++) * { * myTarget.mainElements[count] = EditorGUILayout.TextField("Element " + count.ToString(), myTarget.mainElements[count]); * } */ EditorGUILayout.EndVertical(); }
public void Orbit(PlanetBase planet) { if(planet.Center.y > Game.Instance.GoalHeight) { Game.Instance.HandleReachGoal(); return; } Logger.Log("Orbit planet center at " + planet.Center, 2); _orbit = planet; Orbit(planet.Center, false); }
IEnumerator ExploringProcess(PlanetBase target) { int distance = selectedPlanet.transform.parent.GetComponent<Sector>().nowSectorTile.index - 1; player.currentHp -= 5f * distance; Image ring = Instantiate(exploringRing); // Create red ring that shows exploring progress. ring.transform.SetParent(ringHome, false); ring.transform.position = selectedPlanet.transform.position; ring.transform.localScale = target.transform.localScale; ring.GetComponent<Ring>().targetPlanet = selectedPlanet; ring.GetComponent<Ring>().isChasing = true; ring.fillAmount = 0; Text ringText = ring.GetComponentInChildren<Text>(); float elapsedTime = 0; bool isSoundEffected = false; while (true) { if (player.gameObject.activeSelf == false) break; if (elapsedTime >= 2f) break; if (elapsedTime > 0.3f && !isSoundEffected) { isSoundEffected = true; audioSource.clip = exploringSound; audioSource.Play(); } if (ring.transform.position.x <= -6.4f) // If ring become out of screen, { Destroy(ring); break; } ring.fillAmount += Time.deltaTime / 2; ringText.text = ((int)(ring.fillAmount * 100)).ToString() + "%"; // Show percent of exploring progress. elapsedTime += Time.deltaTime; exploringRing.transform.localScale = target.transform.localScale; yield return null; } Destroy(ring.gameObject); audioSource.Stop(); audioSource.clip = exploreSuccessSound; audioSource.Play(); PlanetBase destroyingObj = exploringPlanets.Dequeue(); // Destroy first added planet among exploring planets. destroyingObj.Explore(); }
public override void OnInspectorGUI() { PlanetBase myTarget = (PlanetBase)target; EditorGUILayout.LabelField("Planet Color"); myTarget.mainColor = EditorGUILayout.ColorField(myTarget.mainColor); EditorGUILayout.LabelField(""); EditorGUILayout.BeginVertical("Box"); myTarget.isHabitable = EditorGUILayout.BeginToggleGroup(new GUIContent("Habitable", "Can things live here?"), myTarget.isHabitable); if (myTarget.isHabitable == false) { myTarget.fauna = false; myTarget.flora = false; } myTarget.flora = EditorGUILayout.BeginToggleGroup(new GUIContent("Flora", "Plant Life"), myTarget.flora); if (myTarget.flora == false) { myTarget.fauna = false; } myTarget.fauna = EditorGUILayout.BeginToggleGroup(new GUIContent("Fauna", "Animal Life"), myTarget.fauna); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndToggleGroup(); myTarget.hasWater = EditorGUILayout.Toggle("Water", myTarget.hasWater); myTarget.intelligentCreatures = EditorGUILayout.BeginToggleGroup("Intelligent Life", myTarget.intelligentCreatures); if (myTarget.intelligentCreatures == false) { myTarget.icPopulation = 0; } EditorGUILayout.LabelField("Amount of Intelligent Life"); myTarget.icPopulation = EditorGUILayout.IntField(myTarget.icPopulation); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.LabelField(""); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Temperature Range in Celcius"); EditorGUILayout.MinMaxSlider(ref myTarget.lowTemp, ref myTarget.highTemp, 1f, 100f); EditorGUILayout.BeginHorizontal(); myTarget.lowTemp = EditorGUILayout.FloatField(myTarget.lowTemp); myTarget.highTemp = EditorGUILayout.FloatField(myTarget.highTemp); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Planet Revolution Time in Hours"); myTarget.revolutionTime = EditorGUILayout.FloatField(myTarget.revolutionTime); if (myTarget.revolutionTime < 0) { myTarget.revolutionTime = 0; } EditorGUILayout.LabelField("Planet Orbit Time in Days"); myTarget.orbitTime = EditorGUILayout.FloatField(myTarget.orbitTime); if (myTarget.orbitTime < 0) { myTarget.orbitTime = 0; } EditorGUILayout.LabelField("Radius of Planet in Miles"); myTarget.planetSize = EditorGUILayout.IntField(myTarget.planetSize); EditorGUILayout.LabelField("Amount of Moons"); myTarget.moonAmount = EditorGUILayout.IntField(myTarget.moonAmount); EditorGUILayout.LabelField(new GUIContent("Lowest Elevation", "Measured in miles")); myTarget.lowElevation = EditorGUILayout.FloatField(myTarget.lowElevation); EditorGUILayout.LabelField(new GUIContent("Highest Elevation", "Measured in miles")); myTarget.highElevation = EditorGUILayout.FloatField(myTarget.highElevation); EditorGUILayout.LabelField(new GUIContent("Radiation Levels", "Measured in MSV")); myTarget.radiationAmount = EditorGUILayout.FloatField(myTarget.radiationAmount); serializedObject.Update(); SerializedProperty myElem = serializedObject.FindProperty("mainElements"); EditorGUILayout.PropertyField(myElem, true); serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); //base.OnInspectorGUI(); }
public override void OnInspectorGUI() { PlanetBase myPlanet = (PlanetBase)target; foldOutBasicInfo = EditorGUILayout.Foldout(foldOutBasicInfo, "Basic info"); if (foldOutBasicInfo) { myPlanet.mainColor = EditorGUILayout.ColorField("Main Plant Color", myPlanet.mainColor); myPlanet.GetComponent <Renderer>().material.SetColor("_Color", myPlanet.mainColor); myPlanet.planetSize = EditorGUILayout.IntField(new GUIContent("Plant Size", "Radius in Miles, Example: Earth's is 3,959Mi"), myPlanet.planetSize); if (myPlanet.planetSize <= 0) { myPlanet.planetSize = 0; } myPlanet.transform.localScale = new Vector3(myPlanet.planetSize, myPlanet.planetSize, myPlanet.planetSize); myPlanet.hasWater = EditorGUILayout.Toggle("Does the plant have water", myPlanet.hasWater); myPlanet.moonAmount = EditorGUILayout.IntField("How many moons", myPlanet.moonAmount); if (myPlanet.moonAmount <= 0) { myPlanet.moonAmount = 0; } myPlanet.revolutionTime = EditorGUILayout.FloatField(new GUIContent("RevolutionTime", "In Hours"), myPlanet.revolutionTime); if (myPlanet.revolutionTime <= 0) { myPlanet.revolutionTime = 0; } myPlanet.orbitTime = EditorGUILayout.FloatField(new GUIContent("OrbitTime", "In Days"), myPlanet.orbitTime); if (myPlanet.orbitTime <= 0) { myPlanet.orbitTime = 0; } } foldOutSurface = EditorGUILayout.Foldout(foldOutSurface, "Surface info"); if (foldOutSurface) { myPlanet.lowTemp = EditorGUILayout.FloatField(new GUIContent("Low Temp", "In Celsius"), myPlanet.lowTemp); myPlanet.highTemp = EditorGUILayout.FloatField(new GUIContent("High Temp", "In Celsius"), myPlanet.highTemp); EditorGUILayout.MinMaxSlider(ref myPlanet.lowTemp, ref myPlanet.highTemp, lowTemp, highTemp); myPlanet.lowElevation = EditorGUILayout.FloatField(new GUIContent("Lowest Elevation:", "in Miles"), myPlanet.lowElevation); if (myPlanet.lowElevation <= 0) { myPlanet.lowElevation = 0; } myPlanet.highElevation = EditorGUILayout.FloatField(new GUIContent("Highest Elevation:", "in Miles"), myPlanet.highElevation); if (myPlanet.highElevation <= 0) { myPlanet.highElevation = 0; } myPlanet.radiationAmount = EditorGUILayout.FloatField(new GUIContent("Radiation:", "in rads"), myPlanet.radiationAmount); } foldOutlife = EditorGUILayout.Foldout(foldOutlife, "Life on planet info"); if (foldOutlife) { myPlanet.isHabitable = EditorGUILayout.Toggle("Is the planet Habitable", myPlanet.isHabitable); if (myPlanet.isHabitable == false) { myPlanet.flora = false; myPlanet.fauna = false; myPlanet.intelligentCreatures = false; myPlanet.icPopulation = 0; } myPlanet.flora = EditorGUILayout.Toggle(new GUIContent("Does the planet have flora:", "Plants"), myPlanet.flora); //plant myPlanet.fauna = EditorGUILayout.Toggle(new GUIContent("Does the planet have fauna:", "animal"), myPlanet.fauna); //animal if (myPlanet.fauna == false) { myPlanet.fauna = false; myPlanet.intelligentCreatures = false; myPlanet.icPopulation = 0; } myPlanet.intelligentCreatures = EditorGUILayout.Toggle("Intelligent Creatures? ", myPlanet.intelligentCreatures); if (myPlanet.intelligentCreatures == false) { myPlanet.icPopulation = 0; } myPlanet.icPopulation = EditorGUILayout.IntField(new GUIContent("Intelligent Creatures", "The number of intelligent creatures"), myPlanet.icPopulation); if (myPlanet.icPopulation <= 0) { myPlanet.icPopulation = 0; } } SerializedProperty myElem = serializedObject.FindProperty("mainElements"); EditorGUILayout.PropertyField(myElem, new GUIContent("Elements", "Size is how many"), true); serializedObject.ApplyModifiedProperties(); // base.OnInspectorGUI(); }
public override void OnInspectorGUI() { PlanetBase myTarget = (PlanetBase)target; //Planet Shape EditorGUILayout.LabelField("Planet Shape", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); myTarget.mainColor = EditorGUILayout.ColorField("Planet Color", myTarget.mainColor); myTarget.orbitTime = EditorGUILayout.FloatField(new GUIContent("Orbit Time", "The Earth takes 365 days to orbit"), myTarget.orbitTime); myTarget.planetSize = EditorGUILayout.IntField(new GUIContent("Planet Size in miles", "The Earth has a radius of 3,959 miles"), myTarget.planetSize); myTarget.revolutionTime = EditorGUILayout.FloatField(new GUIContent("Revolution time", "The Earth takes 24 hours to revolve"), myTarget.revolutionTime); EditorGUILayout.Space(); myTarget.lowElevation = EditorGUILayout.FloatField(new GUIContent("Lowest Elevation", "Measured in Miles"), myTarget.lowElevation); myTarget.highElevation = EditorGUILayout.FloatField(new GUIContent("Highest Elevation", "Measured in Miles"), myTarget.highElevation); EditorGUILayout.MinMaxSlider(ref myTarget.lowElevation, ref myTarget.highElevation, 0f, myTarget.planetSize); hasMoons = EditorGUILayout.BeginToggleGroup("Has Moons", hasMoons); myTarget.moonAmount = EditorGUILayout.IntField("Number of Moons", myTarget.moonAmount); if (hasMoons == false) { myTarget.moonAmount = 0; } EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //Planet Surface EditorGUILayout.LabelField("Planet Surface", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); myTarget.radiationAmount = EditorGUILayout.FloatField(new GUIContent("Radiation", "The Earth emits 3-5 mSv per year"), myTarget.radiationAmount); myTarget.hasWater = EditorGUILayout.Toggle("Water", myTarget.hasWater); myTarget.lowTemp = EditorGUILayout.FloatField(new GUIContent("Lowest Temperature", "Measured in Celsius"), myTarget.lowTemp); myTarget.highTemp = EditorGUILayout.FloatField(new GUIContent("Highest Temperature", "Measured in Celsius"), myTarget.highTemp); EditorGUILayout.MinMaxSlider(ref myTarget.lowTemp, ref myTarget.highTemp, 0f, 1000f); serializedObject.Update(); SerializedProperty myElem = serializedObject.FindProperty("mainElements"); EditorGUILayout.PropertyField(myElem, true); serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); //Planet Life EditorGUILayout.LabelField("Planet Life", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("box"); myTarget.isHabitable = EditorGUILayout.Toggle("Habitable", myTarget.isHabitable); GUI.enabled = myTarget.isHabitable; myTarget.flora = EditorGUILayout.Toggle(new GUIContent("Flora", "Plants"), myTarget.flora); GUI.enabled = myTarget.flora; myTarget.fauna = EditorGUILayout.Toggle(new GUIContent("Fauna", "Animals"), myTarget.fauna); GUI.enabled = true; if (!myTarget.isHabitable) { myTarget.flora = false; } if (!myTarget.flora) { myTarget.fauna = false; } EditorGUILayout.Space(); myTarget.intelligentCreatures = EditorGUILayout.BeginToggleGroup("Intelligent Creatures", myTarget.intelligentCreatures); myTarget.icPopulation = EditorGUILayout.IntField("Number of Creatures", myTarget.icPopulation); EditorGUILayout.EndToggleGroup(); if (myTarget.intelligentCreatures == false) { myTarget.icPopulation = 0; } EditorGUILayout.EndVertical(); //base.OnInspectorGUI(); }
void OnEnable() { planetBaseReference = (PlanetBase)target; }
public void OnPlanetTouch(PlanetBase planet) { if (!bottomUIMoveEnd || !hpBarMoveEnd) return; selectedPlanet = planet; if (planet.transform.parent.GetComponent<Sector>().nowSectorTile == sectorMgr.sectorTiles[1] && selectedPlanet) { selectedPlanetIsCurrentPlanet = true; return; } else selectedPlanetIsCurrentPlanet = false; }
public void RemovePlanet(PlanetBase planet) { for(int i=0; i<_planets.Count; i++) { if(_planets[i] == planet) { RemovePlanetAt(i); } } }
void OnEnable() { myTarget = (PlanetBase)target; }
private void OnEnable() { planetBase = (PlanetBase)target; }
public void ResetScriptLanguage(PlanetBase planet) { if (planet.name == "Earth") { string[] engEarthScript = new string[3] { "Home of Human race.", "Critical pollution detected.", "Serious resource exhaustion." }; if (languageMgr.currLanguage == Language.English) planet.SetData(engEarthScript, false); return; } string[] newScripts = GetScript(planet.canSurvive); planet.SetData(newScripts, planet.canSurvive); }
public void OnSelectButtonDown() { if (selectedPlanet == null) return; if (!isEmigrationEnd) return; if (player.mainPlanet == selectedPlanet) return; audioSource.clip = exploreSound; audioSource.Play(); if (selectedPlanet.isExplored) { rocket.Emigration(selectedPlanet); audioSource.clip = emigrationSound; audioSource.Play(); selectedPlanet = null; selectButtonText.text = ""; for (int i = 0; i < 3; i++) descriptionTexts[i].text = ""; } else { if (exploringPlanets.Contains(selectedPlanet)) return; StartCoroutine(ExploringProcess(selectedPlanet)); exploringPlanets.Enqueue(selectedPlanet); OnPlanetTouch(selectedPlanet); } }