public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); productionSystems = new ProductionSystem(log, Me.CubeGrid, shipComponents); storageSystem = new StorageSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(SensorScan)); operatingOrder.AddLast(new TaskInfo(AnalyzePlanetaryData)); operatingOrder.AddLast(new TaskInfo(InternalSystemScan)); //operatingOrder.AddLast(new TaskInfo(MaintainAltitude)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 100; }
// Use this for initialization void Awake() { offset = new Quaternion(1f, .005f, 0, 1); shCp = new ShipComponents(this.gameObject); abilities = new List <Ability>(); abilities.Add(new TurretAbility(gameObject, abilitiesPreFabs[0], shCp.Turrets, offset, shotSpeed, "Textures/Abilities/LaserIcon", .1f)); }
public CombatDrone() //////public Program() { shipComponents = new ShipComponents(); LocateAllParts(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new NavigationSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, false); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(InternalSystemCheck)); operatingOrder.AddLast(new TaskInfo(NavigationCheck)); operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages)); operatingOrder.AddLast(new TaskInfo(SendPendingMessages)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); operatingOrder.AddLast(new TaskInfo(ScanLocalArea)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); operatingOrder.AddLast(new TaskInfo(FollowOrders)); SetupFleetListener(); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 150; InitialBlockCount = shipComponents.AllBlocks.Count(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public void SaveAsDesign() { OnChange(); if (!RequirementsMet) { Debug.Log("Requirements not met. DEBUG MODE ENABLED, output will continue anyway."); // return; } ShipDesign design = new ShipDesign(DesignName.text); design.HullDesignation = HullDes.DesDictionary[HullDesignation.options [HullDesignation.value].text]; design.ArmorLayers = ArmorThickness; design.CrewMin = ReqCrew; design.CrewBerths = Quarters; design.mass = Mass; design.ArmorType = ArmorType; foreach (ShipComponents c in Components) { int number; if (AddedComponents.TryGetValue(c, out number)) { for (int i = 0; i < number; i++) { ShipComponents comp = new ShipComponents(); comp = c.CloneProperties(); Debug.Log("Original " + c.Name); Debug.Log("Clone " + comp.Name); design.Components.Add(comp); } } } design.SetupDAC(); design.CalculateCost(); // design.Output (); }
public void TakeInternalHit(float damage, int counter = 0) //skips armor { ShipComponents c = Components [random.Next(0, Components.Count)]; if (!c.isDestroyed()) { if (!UseMaintParts(c.MaintReq)) { c.Damage(); AddHistory("<color=yellow>Maintenance Failure</color>", string.Format("\n{0}: {1} experiences a maintenance failure with the {2}, repairs proved impossible with current supplies.", StrategicClock.GetDate(), ShipName, c.Name)); EmpireLogEntry E = new EmpireLogEntry(LogCategories.MILITARY, 3, Emp, "MAINTENANCE FAILURE", string.Format("{0} has experienced a maintenance failure.", ShipName)); ChangeStats(); } else { AddHistory("<color=red>Maintenance Failure</color>", string.Format("\n{0}: {1} experiences a maintenance failure with the {2}, repairs were made with maintenance supplies.", StrategicClock.GetDate(), ShipName, c.Name)); EmpireLogEntry E = new EmpireLogEntry(LogCategories.MILITARY, 4, Emp, "MAINTENANCE FAILURE", string.Format("{0} has experienced a maintenance failure. No damage reported.", ShipName), CharactersAboard, new List <StrategicShip> { this }); } } else { if (counter >= .85 * Components.Count) { DestroyShip(); ShipLog += "\n<color=red>---Loss Resultant from Catastrophic Maintenance Failures---</color>"; } TakeInternalHit(damage, counter++); } }
public Base() //////public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; shipComponents = new ShipComponents(); LocateAllParts(); SetupFleetListener(); log = new Logger(Me.CubeGrid, shipComponents); //communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); //navigationSystems = new BasicNavigationSystem(log, Me.CubeGrid, shipComponents); //productionSystems = new ProductionSystem(log, Me.CubeGrid, shipComponents); //storageSystem = new StorageSystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, true); //weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(InternalSystemCheck)); operatingOrder.AddLast(new TaskInfo(ScanLocalArea)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 400; InitialBlockCount = shipComponents.AllBlocks.Count(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public ProductionSystem(Logger log, IMyCubeGrid grid, ShipComponents components) { L = log; shipComponents = components; primaryGrid = grid; // set primary inventory }
//engines have some special rules so we add them using this. public void AddEngine(ShipComponents engine) { // Debug.Log("Adding " + engine.Name); AddComponent(engine); /* * if (EngineDesign == null) { * EngineDesign = engine; * } * if(EngineDesign != engine){ * EngineCount = 1; * if (AddedComponents.ContainsKey (EngineDesign)) { * AddedComponents.Remove (EngineDesign); * } * Debug.Log("Setting new engine pattern"); * EngineDesign = engine; * } * else{ * EngineCount++; * } * if(AddedComponents.ContainsKey(EngineDesign)){ * AddedComponents [EngineDesign] = EngineCount; * } * else * { * AddedComponents.Add (EngineDesign, EngineCount); * } */ OnChange(); }
//Use this whenever adding a component to a ship. public ShipComponents CloneProperties() { ShipComponents dest = new ShipComponents(); dest.DesignReference = this; foreach (SubComponent c in SubComponents) { dest.SubComponents.Add(c.Clone()); } dest.Mass = Mass; foreach (Ability a in Abilities.Values) { dest.Abilities.Add(a.AbilityType, a.DeepClone()); } if (emissions != null) { dest.emissions = emissions.Clone(); } dest.CrewRequired = CrewRequired; dest.CrewPresent = CrewRequired; dest.HTK = HTK; dest.Name = Name; dest.Description = Description; dest.Obsolete = Obsolete; dest.Category = Category; dest.BuildDate = StrategicClock.GetDate(); dest.DesignDate = DesignDate; return(dest); }
static public void AddDesign(DesignerToken T, ShipComponents C) { if (!MasterComponentDictionary.ContainsKey(T)) { RegisterToken(T); } MasterComponentDictionary [T].Add(C); }
public void LoadComponentToScreen(ShipComponents c) { Comp = c; ComponentName.text = Comp.Name; MassInput.text = Comp.Mass.ToString(); Description.text = Comp.Description; CrewInput.text = Comp.CrewRequired.ToString(); ComponentCategoryDropdown.value = (int)Comp.Category; MaintInput.text = Comp.MaintReq.ToString(); }
void Awake() { offset = new Quaternion(1f, .005f, 0, 1); //Rotational offset for projectile fire shCp = new ShipComponents(this.gameObject); abilities = new List <Ability>(); // Adding all abilities to ship abilities.Add(new TurretAbility(gameObject, abilitiesPreFabs[0], shCp.Turrets, offset, shotSpeed, "Textures/Abilities/LaserIcon", .2f)); abilities.Add(new ProjectileAbility(gameObject, abilitiesPreFabs[1], bombSpawn, offset, shotSpeed, "Textures/Abilities/BombIcon", 2f)); }
public void AddComponent(ShipComponents comp, int number = 1) { if (AddedComponents.ContainsKey(comp)) { AddedComponents[comp] += number; } else { AddedComponents.Add(comp, number); } OnChange(); }
public void RemoveComponent(ShipComponents comp, int number = 1) { if (AddedComponents.ContainsKey(comp)) { AddedComponents[comp] -= number; if (AddedComponents[comp] <= 0) { AddedComponents.Remove(comp); } } OnChange(); }
public void SaveComponent() { UpdateMass(); Comp.Name = ComponentName.text; Comp.Description = Description.text; Comp.CrewRequired = int.Parse(CrewInput.text); Comp.Category = GetComponentCategory(); Comp.MaintReq = int.Parse(MaintInput.text); ShipComponents.AllShipComponents.Add(Comp); Comp = new ShipComponents(); ResetInputs(); Output(); }
/* Initilize AI script with team * Initlize all data to be use in AI calculations */ public void init(GameEnums.Team t) { team = t; isAlive = true; detectionRadius = 100f; nextDecision = 1f; fov = 60f; minDistanceDetect = new Vector3(10, 10, 10); shComps = new ShipComponents(gameObject); th = new Throttle(7, 14); state = GameEnums.AIState.OnSearch; notSeenTarget = 20.0f; nextMoveDecision = 2.0f; }
IEnumerator CheckRequirements() { string OutstandingRequirements = "Requirements:\n"; RequirementsMet = false; int bridgeCount = 0; ShipComponents CommandComp = null; foreach (ShipComponents c in AddedComponents.Keys.ToList()) { if (c.isControl()) { CommandComp = c; bridgeCount++; break; } } if (bridgeCount < 1) { OutstandingRequirements += "Missing Bridge\n"; } else if (AddedComponents[CommandComp] > 1) //Multiple of the same type of commandcomponent. Only safe to check if at least one is found. { OutstandingRequirements += "Cannot have more than 1 Bridge\n"; } if (bridgeCount > 1) //Would only occur if there are multiple different components with the control ability. { OutstandingRequirements += "Cannot have more than 1 Bridge\n"; } if (ShipDesign.DesignDictionary.ContainsKey(DesignName.text)) { RequirementsMet = false; OutstandingRequirements += DesignName.text + " is already being used as a class name.\n"; } if (ArmorThickness <= 0) //This shouldnt be possible outside of an error in the actual unity editor. { RequirementsMet = false; OutstandingRequirements += "Error, change Armor to a positive value of at least 1.\n"; } if (Quarters < ReqCrew) //Quarters sums the crew quartering ability of all added components and compares it to the Required Number. { RequirementsMet = false; OutstandingRequirements += string.Format("Quarters for only {0} of the {1} required crewmembers are present.\n", Quarters, ReqCrew); } yield return(Ninja.JumpToUnity); Requirements.text = OutstandingRequirements; }
// Use this for initialization void Awake() { Comp = new ShipComponents(); StaticComponentDesigner = this; MassInput.onValueChanged.AddListener(UpdateMass); AbilityDropdown.LoadEnum(typeof(AbilityCats)); ComponentCategoryDropdown.LoadEnum(typeof(CompCategory)); AddAbilityButton.onClick.AddListener(AddAbility); SaveComponentButton.onClick.AddListener(SaveComponent); foreach (InputField f in InputFields) { f.onValueChanged.AddListener(CalculateThrust); } }
public void Assign(ShipComponents s) { // button.onClick.AddListener (AddShipComponent); I = GetComponent <Image>(); Name.gameObject.GetComponent <RectTransform> ().localPosition = NamePosition; Mass.gameObject.GetComponent <RectTransform> ().localPosition = MassPosition; Category.gameObject.GetComponent <RectTransform> ().localPosition = CategoryPosition; Crew.gameObject.GetComponent <RectTransform> ().localPosition = CrewPosition; Description.gameObject.GetComponent <RectTransform> ().localPosition = DescriptionPosition; Name.text = s.Name; Mass.text = s.Mass.ToString() + "Kt"; Crew.text = s.CrewRequired.ToString(); Category.text = s.Category.ToString(); Description.text = s.Description; comp = s; }
public MiningBase() //////public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; shipComponents = new ShipComponents(); LocateAllParts(); SetupFleetListener(); log = new Logger(Me.CubeGrid, shipComponents); communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents); navigationSystems = new BasicNavigationSystem(log, Me.CubeGrid, shipComponents); factorySystems = new FactorySystem(log, Me.CubeGrid, shipComponents); trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, true); weaponSystems = new WeaponSystem(log, Me.CubeGrid, shipComponents); operatingOrder.AddLast(new TaskInfo(LocateAllParts)); operatingOrder.AddLast(new TaskInfo(NavigationCheck)); operatingOrder.AddLast(new TaskInfo(InternalSystemCheck)); operatingOrder.AddLast(new TaskInfo(ScanLocalArea)); operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets)); operatingOrder.AddLast(new TaskInfo(UpdateDisplays)); operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages)); operatingOrder.AddLast(new TaskInfo(SendPendingMessages)); operatingOrder.AddLast(new TaskInfo(MaintainAltitude)); operatingOrder.AddLast(new TaskInfo(IssueOrders)); //operatingOrder.AddLast(new TaskInfo(RunProductionRoutine)); maxCameraRange = 5000; maxCameraAngle = 80; //set new defaults hoverHeight = 400; InitialBlockCount = shipComponents.AllBlocks.Count(); Runtime.UpdateFrequency = UpdateFrequency.Update1; }
public void ImportDesign(ShipDesign template) { usingTemplate = true; ShipClassName = template.DesignName; HullDesignation = template.HullDesignation; DesignTemplate = template; foreach (ShipComponents c in template.Components) { ShipComponents copy = c.CloneProperties(); Components.Add(copy); } ship.SetupArmor(template.ArmorLength, template.ArmorLayers, (float)template.ArmorType); mCrew = template.CrewMin; crew = mCrew; SetupDAC(); StartCoroutine(ChangeStats()); // emissions = new Emissions(); foreach (ShipComponents c in Components) { } }
public void PopulateComponentList() { List <ShipComponents> LoadedComponents = ShipComponents.GetComponents(ActiveEmpire.Token).OrderBy(x => x.Category).ToList(); Components.Clear(); if (HideObsolete) { foreach (ShipComponents c in LoadedComponents) { if (!c.Obsolete) { Components.Add(c); } } } else { Components.AddRange(LoadedComponents); } // Debug.Log (Components.Count + " components loaded."); float yOff = ShipComponentsUIButton.GetComponent <RectTransform>().sizeDelta.y * .75f * -1f; int interval = 1; foreach (GameObject g in UIObjects) { Destroy(g); } foreach (ShipComponents c in Components) { GameObject d = Instantiate(ShipComponentsUIButton) as GameObject; UIObjects.Add(d); d.transform.SetParent(ContentParentScrollview); d.GetComponent <RectTransform> ().transform.localScale = new Vector3(1f, 1f, 1f); d.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0f, yOff * interval, 0f); ShipComponentUIManager s = d.GetComponent <ShipComponentUIManager> (); s.Manager = this; s.Assign(c); interval++; } }
void Setup(ShipDesign template) { DesignClass = template; foreach (ShipComponents c in template.Components) { ShipComponents copy = c.CloneProperties(); Components.Add(copy); } UpdateComponentStatusStrings(); SetupArmor(template.ArmorLength, template.ArmorLayers, (float)template.ArmorType / 10); if (template.ArmorLayers > 0) { Armored = true; } mCrew = template.CrewMin; ChangeStats(); ArmorType = template.ArmorType; ChangeStats(); UpdateMaint(); AddHistory("Launched", string.Format("{0}: {1} is launched.", StrategicClock.GetDate(), ShipName)); CommissionDate = StrategicClock.GetDate(); Hull = template.Hull.Clone(); }
/* Initilize components of ship * Get player camera for turret rotation */ void Start() { th = new Throttle(9, 20); shCmps = new ShipComponents(gameObject); mouseCamera = FindObjectOfType <Camera>(); }
// Use this for initialization void Start() { //Design test component ShipComponents c = new ShipComponents(); c.Name = "Heavy Test"; c.Mass = 500; c.CrewRequired = 200; c.SetHTK(3); ShipComponents b = new ShipComponents(); b.Name = "Light Test"; b.Mass = 250; b.CrewRequired = 50; b.SetHTK(2); ShipComponents bridge = new ShipComponents(); bridge.Name = "Bridge"; bridge.Mass = 50; bridge.CrewRequired = 15; bridge.AddAbility(AbilityCats.CONTROL); bridge.Category = CompCategory.REQUIRED; bridge.Description = "A command and control center for the ship's officers."; ShipComponents MilEngine = new ShipComponents(); MilEngine.Category = CompCategory.ENGINE; MilEngine.Name = "MilEngine Mk1"; MilEngine.CrewRequired = 50; MilEngine.Mass = 200; MilEngine.AddAbility(AbilityCats.THRUST, (float)EngineTypes.MAGNETO, 2f, 1f); MilEngine.AddAbility(AbilityCats.USEFUEL, (float)EngineTypes.MAGNETO * MilEngine.Mass * 5f); MilEngine.Description = "An engine designed for maximum thrust with minimum weight."; ShipComponents CivEngine = new ShipComponents(); CivEngine.Name = "CivEngine Mk1"; CivEngine.Category = CompCategory.ENGINE; CivEngine.CrewRequired = 125; CivEngine.Mass = 500; CivEngine.AddAbility(AbilityCats.THRUST, (float)EngineTypes.MAGNETO, .75f, 1f); CivEngine.AddAbility(AbilityCats.USEFUEL, (float)EngineTypes.MAGNETO * CivEngine.Mass); CivEngine.Description = "An engine designed for efficiency."; ShipComponents turnThruster = new ShipComponents(); turnThruster.Name = "Manuevering Thruster"; turnThruster.AddAbility(AbilityCats.TURN, 35f); turnThruster.Mass = 25; turnThruster.CrewRequired = 10; turnThruster.Category = CompCategory.DEFAULT; turnThruster.Description = "Small thruster mounted on the exterior in order to improve turn rates."; ShipComponents berths = new ShipComponents(); berths.Name = "Crew Quarters"; berths.Mass = 100; berths.AddAbility(AbilityCats.CREW, 100); berths.Category = CompCategory.REQUIRED; berths.Description = "Area for the crew to sleep, eat and pray."; ShipComponents smBerths = new ShipComponents(); smBerths.Name = "Crew Quarters (S)"; smBerths.Mass = 10; smBerths.AddAbility(AbilityCats.CREW, 10); smBerths.Category = CompCategory.REQUIRED; smBerths.Description = "Small area for the crew to sleep, eat and pray."; ShipComponents Engineering = new ShipComponents(); Engineering.Name = "Engineering Section"; Engineering.Mass = 35; Engineering.CrewRequired = 15; Engineering.AddAbility(AbilityCats.MAINT, Engineering.Mass, 25f, 25f); Engineering.Category = CompCategory.UTILITY; Engineering.Description = "Provides engineering personnel and equipment to keep the ship in functional condition."; ShipComponents SparePartsLocker = new ShipComponents(); SparePartsLocker.Name = "Maintenance Locker"; SparePartsLocker.Mass = 25; SparePartsLocker.CrewRequired = 15; SparePartsLocker.AddAbility(AbilityCats.MAINT, 0, 50f, 50f); SparePartsLocker.Category = CompCategory.UTILITY; SparePartsLocker.Description = "Contains a reserve of maintenance supplies."; ShipComponents CargoHoldLarge = new ShipComponents(); CargoHoldLarge.Name = "Cargo Hold"; CargoHoldLarge.Mass = 250; CargoHoldLarge.CrewRequired = 0; CargoHoldLarge.AddAbility(AbilityCats.CARGO, 100f, 0f, 0f); CargoHoldLarge.Category = CompCategory.UTILITY; CargoHoldLarge.Description = "Empty space and the infrastructure needed to service it."; ShipComponents CargoHoldSmall = new ShipComponents(); CargoHoldSmall.Name = "Cargo Hold (S)"; CargoHoldSmall.Mass = 25; CargoHoldSmall.CrewRequired = 0; CargoHoldSmall.AddAbility(AbilityCats.CARGO, 10f, 0f, 0f); CargoHoldSmall.Category = CompCategory.UTILITY; CargoHoldSmall.Description = "Empty space and the infrastructure needed to service it."; ShipComponents FuelLarge = new ShipComponents(); FuelLarge.Name = "Fuel Cell"; FuelLarge.Mass = 150; FuelLarge.CrewRequired = 0; FuelLarge.AddAbility(AbilityCats.FUEL, 10000f, 0f, 0f); FuelLarge.Category = CompCategory.UTILITY; FuelLarge.Description = "A refillable fuel cell used to power modern engines."; ShipComponents FuelSmall = new ShipComponents(); FuelSmall.Name = "Fuel Cell (S)"; FuelSmall.Mass = 15; FuelSmall.CrewRequired = 0; FuelSmall.AddAbility(AbilityCats.FUEL, 1000f, 0f, 0f); FuelSmall.Category = CompCategory.UTILITY; FuelSmall.Description = "A small fuel cell for lighter craft."; ShipComponents.AddComponentToPublicDomain(FuelSmall); ShipComponents.AddComponentToPublicDomain(FuelLarge); ShipComponents.AddComponentToPublicDomain(CargoHoldSmall); ShipComponents.AddComponentToPublicDomain(CargoHoldLarge); ShipComponents.AddComponentToPublicDomain(SparePartsLocker); ShipComponents.AddComponentToPublicDomain(bridge); ShipComponents.AddComponentToPublicDomain(smBerths); ShipComponents.AddComponentToPublicDomain(Engineering); ShipComponents.AddComponentToPublicDomain(berths); ShipComponents.AddComponentToPublicDomain(turnThruster); ShipComponents.AddComponentToPublicDomain(CivEngine); ShipComponents.AddComponentToPublicDomain(MilEngine); ShipComponents.AddComponentToPublicDomain(c); ShipComponents.AddComponentToPublicDomain(b); ShipComponents.AllShipComponents.Add(FuelSmall); ShipComponents.AllShipComponents.Add(FuelLarge); ShipComponents.AllShipComponents.Add(CargoHoldSmall); ShipComponents.AllShipComponents.Add(CargoHoldLarge); ShipComponents.AllShipComponents.Add(SparePartsLocker); ShipComponents.AllShipComponents.Add(bridge); ShipComponents.AllShipComponents.Add(smBerths); ShipComponents.AllShipComponents.Add(Engineering); ShipComponents.AllShipComponents.Add(berths); ShipComponents.AllShipComponents.Add(turnThruster); ShipComponents.AllShipComponents.Add(CivEngine); ShipComponents.AllShipComponents.Add(MilEngine); ShipComponents.AllShipComponents.Add(c); ShipComponents.AllShipComponents.Add(b); DesignScreenManager.LoadAllComponents = true; }
public void Setup(ShipComponents c) { comp = c; GetComponentInChildren <Text>().text = c.Name; button.onClick.AddListener(LoadComponent); }
public Logger(IMyCubeGrid grid, ShipComponents components) { this.grid = grid; this.components = components; }
public FactorySystem(Logger log, IMyCubeGrid grid, ShipComponents components) { L = log; shipComponents = components; primaryGrid = grid; }
public ProductionSystem(Logger log, IMyCubeGrid grid, ShipComponents components) { }
public void LoadComponents() { string path = "Assets/Output/Components/Components.txt"; string file = File.ReadAllText(path); List <string> components = new List <string>(); components.AddRange(file.Split('#')); foreach (string s in components) { if (string.IsNullOrEmpty(s)) { continue; } // Debug.LogError(s); //ok ShipComponents c = new ShipComponents(); string fields = s.Split('$')[0]; string abilities = s.Split('$')[1]; // Debug.LogError(fields); //ok List <string> FieldsSplit = new List <string>(); FieldsSplit.AddRange(fields.Split('\n')); // Debug.LogError(FieldsSplit.Count); Debug.LogWarning(FieldsSplit[3]); for (int i = 1; i < FieldsSplit.Count; i++) { if (string.IsNullOrEmpty(FieldsSplit[i])) { continue; } string cleaned = FieldsSplit[i].Split(':')[1].Trim(); FieldsSplit[i] = cleaned; } FieldsSplit.RemoveAt(0); // Debug.LogError(FieldsSplit[0]); try { c.Name = FieldsSplit[0].ToString(); } catch { Debug.LogError(FieldsSplit[0].ToString()); } try { c.Description = FieldsSplit[1].ToString(); } catch { Debug.LogError(FieldsSplit[1].ToString()); } try { // c.Category = Enum.Parse(, fields[2].ToString()); } catch { Debug.LogError(FieldsSplit[2].ToString()); } try { c.Mass = int.Parse(FieldsSplit[3].ToString()); } catch { Debug.LogError(FieldsSplit[3].ToString()); } try { c.CrewRequired = int.Parse(FieldsSplit[4].ToString()); } catch { Debug.LogError(FieldsSplit[4].ToString()); } try { c.MaintReq = int.Parse(FieldsSplit[5].ToString()); } catch { Debug.LogError(FieldsSplit[5].ToString()); } List <string> AbilitiesSplit = new List <string>(); AbilitiesSplit.AddRange(abilities.Trim().Split('\n')); //AbilitiesSplit.RemoveAt(0); Debug.LogError(c.Name + " has " + AbilitiesSplit.Count); foreach (string m in AbilitiesSplit) { if (string.IsNullOrEmpty(m)) { continue; } List <string> split = new List <string>(); split.AddRange(m.Trim().Split('|')); Debug.LogError(split[0]); try { c.AddAbility((AbilityCats)int.Parse(split[0]), float.Parse(split[2]), float.Parse(split[4]), float.Parse(split[6])); } catch { c.AddAbility((AbilityCats)Enum.Parse(typeof(AbilityCats), (split[0].Trim())), float.Parse(split[2]), float.Parse(split[4]), float.Parse(split[6])); } } LoadedComponents.AddExclusive(c); ShipComponents.AllShipComponents.AddExclusive(c); } if (LoadedComponents.Count > 0) { // LoadComponentToScreen(LoadedComponents[0]); } SetupButtons(); }