/* * TODO for version 3 * * add database feature. */ public void Start() { ShipPrefab = Instantiate(ShipPrefab) as GameObject; DontDestroyOnLoad(ShipPrefab); PlayerActivation activater = ShipPrefab.GetComponent <PlayerActivation>(); activater.Hide(); activater.SetBehavioursEnabled(false); activater.SetFactoriesEnabled(true); }
public void Update() { if (needsBuild) { PlayerActivation activater = ShipPrefab.GetComponent <PlayerActivation>(); needsBuild = false; AddBasicBuild(); activater.Recreate(); activater.SetBehavioursEnabled(false); activater.SetFactoriesEnabled(false); activater.Hide(); } }
public void Start() { // Show ship and enable factories GameObject shipPrefab = GameObject.FindGameObjectWithTag("ShipBlueprint"); PlayerActivation activater = shipPrefab.GetComponent <PlayerActivation>(); activater.SetFactoriesEnabled(true); activater.Show(); foreach (ModuleFactory mf in shipPrefab.GetComponents <ModuleFactory>()) { if (mf.FactoryType == "Weapon") { weaponFactory = mf; } else if (mf.FactoryType == "Skill") { skillFactory = mf; } else if (mf.FactoryType == "Control") { controlFactory = mf; } } // Set Factory-dependent variables numWeapons = weaponFactory.Prefabs.Count; numSkills = skillFactory.Prefabs.Count; numControls = controlFactory.Prefabs.Count; // TODO update this stuff to version 3.0 InitUI(); }
public void OnGUI() { GUI.Box(new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 400, 200), ""); GUI.Label(new Rect(Screen.width * 0.5f + 10, Screen.height * 0.5f + 10, 380, 180), message); // Update the toolbar. selectedUI = GUI.Toolbar(new Rect(boxSpacing, boxSpacing, customiseRect.width, boxSpacing * 2), selectedUI, toolbarStrings); GUI.Box(customiseRect, ""); int i = 0; if (selectedUI == 0) { foreach (GameObject prefab in weaponFactory.Prefabs) { Texture buttonGrahpic = (IsMade(weaponFactory, prefab) ? weaponFactory.OnImages[i] : weaponFactory.OffImages[i]); if (GUI.Button(weaponButtons[i++], buttonGrahpic)) { ToggleWeapon(prefab); } } } else if (selectedUI == 1) { foreach (GameObject prefab in skillFactory.Prefabs) { Texture buttonGrahpic = (IsMade(skillFactory, prefab) ? skillFactory.OnImages[i] : skillFactory.OffImages[i]); if (GUI.Button(skillButtons[i++], buttonGrahpic)) { ToggleSkill(prefab); } } } else if (selectedUI == 2) { foreach (GameObject prefab in controlFactory.Prefabs) { Texture buttonGrahpic = (IsMade(controlFactory, prefab) ? controlFactory.OnImages[i] : skillFactory.OffImages[i]); if (GUI.Button(controlsButtons[i++], buttonGrahpic)) { ToggleControls(prefab); } } } Rect backButtonRect = new Rect(boxSpacing, customiseRect.height - boxSpacing, customiseRect.width, boxSpacing * 2); if (GUI.Button(backButtonRect, "Back")) { if (weaponFactory.Modules.Count <= 0 || skillFactory.Modules.Count <= 0 || controlFactory.Modules.Count <= 0) { message = "You must always have atleast one weapon, one skill,\nand control scheme on your ship. Please choose these\nbefore leaving this menu."; return; } GameObject shipPrefab = GameObject.FindGameObjectWithTag("ShipBlueprint"); PlayerActivation activater = shipPrefab.GetComponent <PlayerActivation>(); activater.Hide(); activater.SetFactoriesEnabled(false); Application.LoadLevel("Star Map"); } }