public void AdvanceHouse() { Debug.Assert(currentStage >= 0 && currentStage < stages.Count, currentStage + " " + stages.Count); HouseStage stage = stages[currentStage]; stage?.SetQuality(HouseStage.Quality.Good); currentStage++; Instantiate(completionParticles, stage.transform.position, stage.transform.rotation, null); }
private void GetAllStages(Transform transform, List <HouseStage> stages) { foreach (Transform child in transform) { HouseStage houseStage = child.GetComponent <HouseStage>(); if (houseStage != null) { stages.Add(houseStage); } GetAllStages(child, stages); } }
public override void OnInspectorGUI() { HouseStage houseStage = (HouseStage)target; serializedObject.Update(); EditorGUILayout.PropertyField(requiredItemProperty); if (houseStage.requiredItem == Item.Hammer) { EditorGUILayout.PropertyField(nailsProperty, true); } else if (houseStage.requiredItem == Item.Saw) { EditorGUILayout.PropertyField(sawLogProperty); } serializedObject.ApplyModifiedProperties(); }
private void Awake() { mistakes = 0; List <HouseStage> allStages = new List <HouseStage>(); GetAllStages(this.transform, allStages); foreach (HouseStage stage in allStages) { int index = stage.transform.GetSiblingIndex(); while (index >= stages.Count) { stages.Add(null); } HouseStage alreadyExisting = stages[index]; if (alreadyExisting != null) { Debug.LogError("THIS IS NOT GOOD, PLEASE CHECK FOR GRANDCHILD HOUSESTAGES", this); } stages[index] = stage; } }