private bool IsMade(ModuleFactory factory, GameObject prefab) { foreach(GameObject module in factory.Modules) { if(module.name == prefab.name) { return true; } } return false; }
void IWebApiController.InitializeModule(string name, ModuleFactory makeNewModule) { _log.Info("'{0}': initializing...", name); try { var module = makeNewModule(name, _log); _modules.Add(module); module.Initialize(this); _log.Info("'{0}': initialization is completed", name); } catch (Exception ex) { initialization_is_failed(name, ex); } }
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(); }