public override void Init(ShipBlueprint shipBP, ShipMove shipMove) { base.Init(shipBP, shipMove); combatInterface = CombatSystemInterface.Instance; spaceGround = SpaceGround.Instance; ConfigureShip(); }
/// <summary> /// Temp method for AI building /// </summary> /// <param name="shipType"></param> /// <param name="blueprint"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <returns></returns> public TurnBasedUnit BuildShip(ShipType shipType, ShipBlueprint blueprint, Vector3 position, Quaternion rotation) { blueprintBeingBuilt = blueprint; #if FULL_DEBUG //if (shipType == ShipType.AI_Ship) //if(false) //{ // Debug.LogError("BEFORE ... blueprint " + blueprintBeingBuilt); // Debug.LogError("hull.emptyCompGrid: "); // foreach (ComponentSlot slot in blueprintBeingBuilt.hull.EmptyComponentGrid) // { // Debug.LogError("ComponentSlot: " + slot.index + ": " + slot.InstalledComponent); // } // Debug.LogError("hull.index_slot_table: "); // foreach (var item in blueprintBeingBuilt.slot_component_table) // { // Debug.LogError("slot: " + item.Key + " comp: " + item.Value); // } //} #endif return InstantiateShip(false, shipType, position, rotation); }
public void GetBlueprint(out ShipBlueprint blueprint, Hull hullBeingBuilt) { blueprint = new ShipBlueprint(hull); foreach (var slotIndex_Comp in SlotIndex_Comp_List) { blueprint.AddComponent(hullBeingBuilt.index_slot_table[slotIndex_Comp.slotIndex], slotIndex_Comp.component); } blueprint.GenerateMetaData(MetaData.BlueprintName); }
/// <summary> /// Creates a BlueprintTemplate form a blueprint. Validation of blueprint should be done already. /// </summary> /// <param name="blueprint"></param> public BlueprintTemplate(ShipBlueprint blueprint) { this.hull = blueprint.Hull; foreach (var slot_comp in blueprint.Slot_component_table) { SlotIndex_Comp_List.Add( new SlotIndexCompEntry { slotIndex = slot_comp.Key.index, component = slot_comp.Value }); } this.metaData = blueprint.MetaData; }
public override void Awake() { base.Awake(); shipMove = gameObject.GetSafeComponent<ShipMove>(); shipAttack = gameObject.GetSafeComponent<ShipAttack>(); shipBlueprint = gameObject.GetSafeComponent<ShipBlueprint>(); componentCamera.enabled = false; //manual init to ensure correct intitialization order shipBlueprint.Init(); shipMove.Init(); shipAttack.Init(); selectedComponents = new List<ShipComponent>(); }
/// <summary> /// initializes the various components of the ship and setups up references /// </summary> /// <param name="shipBP"></param> /// <param name="shipMove"></param> /// <param name="playerAttack"></param> public void Init(ShipBlueprint shipBP, ShipMove shipMove, PlayerAttack playerAttack) { base.Init(shipBP, shipMove); this.playerAttack = playerAttack; this.playerAttack.Init(); combatInterface = CombatSystemInterface.Instance; spaceGround = SpaceGround.Instance; ConfigurePlayerShip(); }
/// <summary> /// sets up references /// </summary> /// <param name="shipBP"></param> /// <param name="shipMove"></param> public virtual void Init(ShipBlueprint shipBP, ShipMove shipMove) { this.shipBP = shipBP; this.ShipBPMetaData = shipBP.MetaData; this.shipMove = shipMove; this.shipMove.Init(); InitStats(); InitReferences(); //component hp bars are only displayed when damaged Components.Where(comp => comp.CompHP >= comp.MaxHP).ToList() .ForEach(comp => comp.ShowHPBars(false)); }
bool ValidateLoadedBlueprint(ShipBlueprint loadedBP, Dictionary<int, int> correct_slotIndex_compID_table, int correct_hull_ID) { if (HullTable.GetID(loadedBP.Hull) != correct_hull_ID) { return false; } if (loadedBP.Slot_component_table.Count != correct_slotIndex_compID_table.Count) { return false; } foreach (var slot_component in loadedBP.Slot_component_table) { int slotIndex = slot_component.Key.index; if(!correct_slotIndex_compID_table.ContainsKey(slotIndex)) { return false; } int loadedCompID = ComponentTable.GetID(slot_component.Value); int correctCompID = correct_slotIndex_compID_table[slotIndex]; if(loadedCompID!=correctCompID ) { return false; } } return true; }
public ShipBlueprint(ShipBlueprint bp) { hull = bp.Hull; componentTable = bp.ComponentTable; }
bool VerifyLoadedBlueprint(ShipBlueprint loadedBlueprint, Dictionary<int, int> slotVerificationTable, int _hullID) { int hullID = hullTable.FirstOrDefault(h => h.Value == loadedBlueprint.Hull).Key; if (hullID != _hullID) { return false; } if (loadedBlueprint.ComponentTable.Count != slotVerificationTable.Count) { return false; } for (int i = 0; i < slotVerificationTable.Count; i++) { int compID = compTable.FirstOrDefault(c => c.Value == loadedBlueprint.ComponentTable.ElementAt(i).Value).Key; if (compID != slotVerificationTable.ElementAt(i).Value || loadedBlueprint.ComponentTable.ElementAt(i).Key.index != slotVerificationTable.ElementAt(i).Key) { //print("compID " + compID + " ver " + slotVerificationTable.ElementAt(i).Value); return false; } } return true; }