private void Populate_Mount_Point_Drop_Panels() { ModuleSystemInfo[] modules = UnityFunctions.GetModules(); foreach (ModuleSystemInfo module in modules) { GameObject item = Instantiate(inventory_item, inventory_panel.transform); item.transform.parent = mount_point_drop_zone_list[module.mount_point].transform; InventoryItem inv = item.GetComponent <InventoryItem>(); inv.SetItem(module.gameObject); } }
public void SetScreenNoCommandModule() { //*********************************** //First we need to remove all modules //*********************************** ModuleSystemInfo[] modules = UnityFunctions.GetModules(); foreach (ModuleSystemInfo module in modules) { this.Store_Module(module.gameObject); } Build_Inventory_List_Items(); //******************************** //We need to remove all drop zones //******************************** foreach (GameObject p in this.mount_point_panels) { p.SetActive(false); int childs = p.transform.childCount; for (int i = childs - 1; i >= 0; i--) { GameObject.DestroyImmediate(p.transform.GetChild(i).gameObject); } } //********************************************** //Create a panel to handle adding command module //********************************************** if (!this.tmp_drop_panel) { this.mount_point_panels[0].SetActive(true); this.tmp_drop_panel = Instantiate(mount_point_drop_zone, this.mount_point_panels[0].transform); Populate_Mount_Point_Drop_Panels(); } this.drop_panels_loaded = false; //******************* //Disable all buttons //******************* DisableEnableButtons(false);//Disble all the button }
private void CalcUpgrades() { //************************ //Run once to calc modules //************************ total_upgrade_battery_max = 1; total_upgrade_fuel_max = 1; total_upgrade_shield_max = 1; total_upgrade_cpu = 0; cpu_usage = 0; cpu_max = 0; //This will cal the upgrades values foreach (ModuleSystemInfo ms in UnityFunctions.GetModules()) { if (ms != null) { if (ms.is_in_storage == false) { //********************************* //Calc the module internal upgrades //********************************* //ms.CalcUpgrades(); /* if (shield_obj == null) { * if(ms.GetComponent<ItemResorce>().Item_type== Enums.enum_item.module_shield) { * this.shield_obj = (Shield)ms; * } * }*/ //************** //heat //************** //************ //CPU //************ float cpu = ms.Get_Calculated_CPU_V(); if (cpu > 0) { cpu_max += cpu; } else { cpu_usage += Mathf.Abs(cpu); } //******************* //Power //******************* total_upgrade_battery_max += ms.Get_Calculated_Extra_Battery_Capacity_P(); //****** //Fuel //****** total_upgrade_fuel_max += ms.Get_Calculated_Extra_Fuel_Capacity_P(); fuel_drain += ms.current_fuel; //******* //shield //******* shield_max += ms.Get_Calculated_Max_Shield_Capacity(); } } } }
private void UpdateValues() { heat = 0; battery_drain = 0; fuel_drain = 0; mass = 0; this.shield = 0; int heat_generating_module = 0; //**************************************** //Loop through each module and gather data //**************************************** foreach (ModuleSystemInfo ms in UnityFunctions.GetModules()) { if (ms != null) { if (ms.is_in_storage == false) { //************** //heat //************** heat += ms.current_heat; if (ms.Generates_Heat()) { heat_generating_module += 1; } //******************* //Power //******************* if (ms.current_power > 0) { } battery_drain += ms.current_power; //****** //Fuel //****** fuel_drain += ms.current_fuel; //******* //Mass //******* mass += ms.Get_Calculated_Mass(); //Shield shield += ms.current_shield; ms.ResetUsage(); } } } //****** //Heat //****** if (heat < 0) { heat = 0; } heat_max = (heat_generating_module * 100); //******* //Battery //******* battery += battery_drain; upgraded_battery_max = total_upgrade_battery_max * battery_max; battery = Mathf.Clamp(battery, 0, upgraded_battery_max); //******* //Fuel //******* fuel += fuel_drain; upgraded_fuel_max = total_upgrade_fuel_max * fuel_max; fuel = Mathf.Clamp(fuel, 0, upgraded_fuel_max); //******* //Mass //******* if (rb != null) { rb.mass = mass; } //****** //health //****** this.health_max = command_mod_system_info.settings.Health_start; this.health = command_mod_system_info.current_health; //****************************************** //This feeds back information to each module //****************************************** foreach (ModuleSystemInfo ms in UnityFunctions.GetModules()) { if (ms != null) { ms.Set_Values(heat, heat_max, battery, upgraded_battery_max, fuel, fuel_max); } } }