// Use this for initialization void Start() { playerSpawned = false; GM = GameObject.Find("Game Master").GetComponent <GameMaster>()._M; nameEnabled = GM.playername; killsEnabled = GM.kills_tracking; healthBarEnabled = GM.healthbar; crossHair = GM.crosshair; skyEnabled = GM.sky; if (skyEnabled == false) { GameObject.Find("Sky").SetActive(false); } GUISetup = true; healthbarSetup = true; bool SniperEnabled = GM.Sniper; bool ShotgunEnabled = GM.Shotgun; foreach (GameObject g in GameObject.FindGameObjectsWithTag("Pedestal")) { if (!GM.Sniper && g.transform.GetChild(0).name == "Gun_Sniper_Rifle") { g.transform.GetChild(0).gameObject.SetActive(false); } else if (!GM.Shotgun && g.transform.GetChild(0).name == "LAZAR") { g.transform.GetChild(0).gameObject.SetActive(false); } } }
// Use this for initialization void Start() { p1Kills = 0; p2Kills = 0; p3Kills = 0; p4Kills = 0; maxKills = -1; GM = GameObject.Find("Game Master").GetComponent <GameMaster>()._M; }
private bool oneChangeMade(GameMaster.GAME_VALUES mm) { GameObject gm = GameObject.FindGameObjectWithTag("GM"); //get dat GAME_VALUES type Type type_M = gm.GetComponent <GameMaster>()._M.GetType(); Type type = mm.GetType(); //get dem properties FieldInfo[] properties_M = type_M.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); FieldInfo[] properties = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); int changes = 0; for (int i = 0; i < properties_M.Length; i++) { FieldInfo m = properties_M[i]; FieldInfo m2 = properties[i]; changes_made[i] = 0; if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(float)) && m2.GetValue(mm).GetType().Equals(typeof(float))) { changes += (int)Mathf.Abs((float)m.GetValue(gm.GetComponent <GameMaster>()._M) - (float)m2.GetValue(mm)); if ((int)Mathf.Abs((float)m.GetValue(gm.GetComponent <GameMaster>()._M) - (float)m2.GetValue(mm)) > 0) { changes_made[i] = ((float)m.GetValue(gm.GetComponent <GameMaster>()._M) - (float)m2.GetValue(mm)); } } if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(bool)) && m2.GetValue(mm).GetType().Equals(typeof(bool))) { if (!m.GetValue(gm.GetComponent <GameMaster>()._M).Equals(m2.GetValue(mm))) { changes += 1; if ((bool)m.GetValue(gm.GetComponent <GameMaster>()._M) == true) { changes_made[i] = 1.0F; } else { changes_made[i] = -1.0f; } } } } return((changes == MAX_CHANGES) ? true : false); }
void DoMyWindow(int windowID) { if (NewlyGameOver) { Debug.Log("New Game Over!"); //windowRect = new Rect(Screen.width / 2 - ((Screen.width * .4f) / 2), Screen.height / 2 - ((Screen.height * .4f) / 2), Screen.width * .60f, Screen.height * .60f); original = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>()._M; GM = GameObject.Find("Game Master").GetComponent <GameMaster>(); NewlyGameOver = false; } selection = GUILayout.BeginScrollView(selection, GUILayout.Width(Screen.width * .40f), GUILayout.Height(Screen.height * .40f)); //get dat game masta GameObject gm = GameObject.FindGameObjectWithTag("GM"); //get dat GAME_VALUES type Type type = gm.GetComponent <GameMaster>()._M.GetType(); //get dem properties FieldInfo[] properties = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); int count = 0; Color default__ = GUI.color; foreach (FieldInfo m in properties) { if (oneChangeMade(original) && Mathf.Abs(changes_made[count]) > 0) { GUI.color = Color.green; } else if (Mathf.Abs(changes_made[count]) > 0) { GUI.color = Color.red; } else { GUI.color = default__; } //this is the first column with names and values GUILayout.BeginHorizontal(); if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(float))) { //so basically just make a box with info if it's a float if (changes_made[count] > 0) { GUILayout.Box(m.Name + ": " + m.GetValue(original) + "(+" + changes_made[count] + ")", GUILayout.Width(300)); } else if (changes_made[count] < 0) { GUILayout.Box(m.Name + ": " + "(" + m.GetValue(original) + changes_made[count] + ")", GUILayout.Width(300)); } else { GUILayout.Box(m.Name + ": " + m.GetValue(original), GUILayout.Width(300)); } } if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(bool))) { //make a box with just the name if it's a boolean GUILayout.Box(m.Name + ": ", GUILayout.Width(300)); } GUI.color = default__; //this column has the '+' signs and toggle buttons GUILayout.BeginVertical(); if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(float))) { if (GUILayout.Button("-", GUILayout.Width(20))) { //box in that shit and modify object p = (object)gm.GetComponent <GameMaster>()._M; m.SetValue(p, (float)m.GetValue(gm.GetComponent <GameMaster>()._M) - 1f); gm.GetComponent <GameMaster>()._M = (GameMaster.GAME_VALUES)p; } } if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(bool))) { //box in that shit and modify object p = (object)gm.GetComponent <GameMaster>()._M; m.SetValue(p, (bool)GUILayout.Toggle((bool)m.GetValue(gm.GetComponent <GameMaster>()._M), "")); gm.GetComponent <GameMaster>()._M = (GameMaster.GAME_VALUES)p; } GUILayout.EndVertical(); //this is the column that contains the '-' signs GUILayout.BeginVertical(); if (m.GetValue(gm.GetComponent <GameMaster>()._M).GetType().Equals(typeof(float))) { if (GUILayout.Button("+", GUILayout.Width(20))) { //box in that shit and modify object p = (object)gm.GetComponent <GameMaster>()._M; m.SetValue(p, (float)m.GetValue(gm.GetComponent <GameMaster>()._M) + 1f); gm.GetComponent <GameMaster>()._M = (GameMaster.GAME_VALUES)p; } } GUILayout.EndVertical(); GUILayout.Space(125F); GUILayout.EndHorizontal(); count++; } GUILayout.EndScrollView(); GUILayout.Space(20F); oneChangeMade(original); if (original.Equals(gm.GetComponent <GameMaster>()._M)) { GUILayout.Box("Make A Change"); } else { if (oneChangeMade(original)) { if (GUILayout.Button("Confirm")) { GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster> ().Save_Values(); GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>().Load_Values(); windowRect = new Rect(Screen.width / 2 - ((Screen.width * .4f) / 2), Screen.height / 2 - ((Screen.height * .4f) / 2), Screen.width * .40f, Screen.height * .40f); original = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>()._M; GM = GameObject.Find("Game Master").GetComponent <GameMaster>(); /* if (GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>()._M.ColumnArena) * { * Application.LoadLevel(3); * } * else if(GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>()._M.GridArena) * { * Application.LoadLevel(2); * } * else{ * Application.LoadLevel(1); * }*/ GM.SetGameOver(); Application.LoadLevel("MenuMain"); } if (GUILayout.Button("Revert")) { GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster> ()._M = original; } } else { GUILayout.Box("Only " + MAX_CHANGES + " Changes May Be Made"); if (GUILayout.Button("Revert")) { GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster> ()._M = original; } } } }