BaseCreator.cs Reference
Reminder - Keep Daily Backups
When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.
What is BaseCreator.cs?
For the City Building Kit, we've optimized the scripting for placing any sort of structure (walls, buildings, decorations, etc.) into a single multi-functional script. StructureCreator (also known as BaseCreator) builds anything, different prefabs and ScriptableObjects (SO) descriptors ( XML files are not being used anymore ); this includes array-builds, for walls and fences, instant builds(without construction sequence).
BaseCreator.cs References
The following list of functions are included in BaseCreator.cs -- the powerhouse for structure creation in city-building games. These functions include updating labels from the store, moving structures, constructing structures, and reading data from the SO among other major features.
Function | Description |
---|---|
void BuyStoreItem(DrawCategoryData data, ShopCategoryType shopCategoryType, Action callback) | When a building construction menu button is pressed, these functions are triggered by the menu buttons. |
void Verify(Action callback = null, bool isUpgrade = false) | Verifies if the structure can be created |
void Delay() | Runs the delay function in Relay.cs (0.2 second delay) |
void Update () | Update is called once per frame |
IEnumerator MouseOperations(int index) | Mouse operations on OK button push |
void ReadStructure() | Reads structure from ScriptableObject (determines the right SO function to run). A bit of magic here; although the SOs for various structures - Buildings, Weapons, Walls will be different, each child creator script will call and process a different Get***SO |
void GetBuildingsXML() Will be renamed to GetStructureFromSO() | Reads buildings from its ScriptableObject (SO) file |
void GetWallsXML() Will be renamed to GetStructureFromSO() | Reads wall from its ScriptableObject (SO) file |
void GetWeaponsXML() Will be renamed to GetStructureFromSO() | Reads weapon from its ScriptableObject (SO) file |
void GetAmbientXML() Will be renamed to GetStructureFromSO() | Reads ambient decorations from its ScriptableObject (SO) file |
void UpdateStructuresAllowed() | Gets maximum allowed structures from stats based on what type of structure |
void UpdateButtons() | starts UpdateLabelStats() |
IEnumerator UpdateLabelStats() | Updates labels in store for structures depending on player stats (some buttons change text color depending on resources available or not) |
void MoveNW() | Triggers Northwest grid movement Move(0); |
void MoveNE() | Triggers Northeast grid movement Move(1); |
void MoveSE() | Triggers Southeast grid movement Move(2); |
void MoveSW() | Triggers Southwest grid movement Move(3); |
void MovingPadOn() | turns the moving pad arrows on |
void Move(int i) | grid movement (NW, NE, SE, or SW) - this function triggered by all movement options (mouse, touch, buttons) |
void MouseTouchMove() | determines either mouse or touch move |
void TouchMove() | converts touch movement to grid movement |
void MouseMove() | converts mouse movement to grid movement |
GetMousePosition() | gets the mouse position using raycasting |
void AdjustStructureZ(int pivotIndex, int spriteIndex) | adjusts the z-index for the structure (to appear above other objects) |
void InstantiateStructure(bool isUpgrade = false) | instantiates the building and grass prefabs |
SelectStructure(bool isUpgrade = false) | after the grass/building prefabs are instantiated, they must be selected from the existing structures on the map |
void PlaceStructure() | runs when placing a structure that requires a construction time |
void PlaceStructureGridInstant() | runs on either reselect or instan-build structures placement |
void PutBackInPlace() | puts the structure back where it was (when moving and cancels) |
void RegisterGridPosition(StructureSelector sSel) | get row/column of grid coordinate |
void CancelObject() | cancel construction, or reselect building and destroy/cancel |
void DecreaseStorage(string resType, int value) | when a building is reselected and destroyed, the gold/mana storage capacity decrease |
void VerifyConditions(Action callback, bool isUpgrade = false) | verifies if the building can be constructed (exceeds max number of structures / enough gold/mana/free dobbits to build?) pays the price to Stats; updates the Stats interface numbers |
void ReloadExistingStructures(int index) | restarts UpdateExistingStructures() |
void UpdateExistingStructures(int value) | updates total structures. For example, if you are allowed to have 50 walls/50 wooden fences, you can build any type, and the number 50 is decreased as a whole |
void ConstructionFinished(string constructionType) | runs when a building finishes construction - returns the builder and adds cap or stats from that building to the total |
int BuildingTypeToIndex(string constructionType) | converts the building type to the structure type index |
void OnReselect(GameObject structure, GameObject grass, string structureType) | receive a Tk2d button message to select an existing building; the button is in the middle of each building prefab and is invisible |
void GetCurrentSelection(string structureType) | get structure selection by structure Type |
void ReselectStructure() | runs when a building is reselected to be moved |
void Cancel() | cancel the structures |
void OK() | OK button to place the structure when moving or dropping a fresh construction |
IEnumerator Deselect() | pauses to allow menu buttons to work again |
void AdjustConstructionZ() | Changes the z level for construction structures |
void ActivateMovingPad() | structure move pad arrows activated and translated into position |
void RecordSpawnPoint() | Records the starting point for every 3d star effect that appears above walls after they are placed. |
void CreateStarArray() | Calculates the total 3d stars needed to be placed above every wall object. |
IEnumerator LateOnCreateFields() | Same as OnCreateFields but delayed |
IEnumerator CreateStar(Vector3 gridPos, int iRow, int jCol) | The star animation effect from wall placements |
void OnCreateFields() | Used when starting the star animation effect from wall placements |
void OnCloseFields() | Used when ending the star animation effect from wall placements |
void CreateFields() | Used when starting the star animation effect from wall placements |
void OnFieldBuild() | Used when starting the star animation effect from wall placements |
void CloseFields() | Used when closing the star animation effect from wall placements |
void DestroyStars() | Removes the 3D star effect from wall placements |
Updated less than a minute ago