mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 13:17:07 +01:00 
			
		
		
		
	started ReReReWork
This commit is contained in:
		| @@ -6,13 +6,57 @@ public abstract class Building : MonoBehaviour | ||||
| { | ||||
|     public string title = "New Building"; | ||||
|     public string description = "A cool new building"; | ||||
|     public Material blueprintMat; | ||||
|     public Material collisionMat; | ||||
|  | ||||
|  | ||||
|     public abstract void OnStartUp(); | ||||
|     public enum BuildingType | ||||
|     { | ||||
|         Housing, | ||||
|         Storage, | ||||
|         Decoration | ||||
|     } | ||||
|  | ||||
|      | ||||
|     public BuildingType buildingType; | ||||
|  | ||||
|     private void Start() | ||||
|     { | ||||
|         gameObject.AddComponent<BuildingBlueprint>(); | ||||
|  | ||||
|         gameObject.GetComponent<BuildingBlueprint>().blueprintMat = blueprintMat; | ||||
|         gameObject.GetComponent<BuildingBlueprint>().collisionMat = collisionMat; | ||||
|  | ||||
|         FindChildByTag("Building").SetActive(false); | ||||
|         FindChildByTag("Blueprint").SetActive(true); | ||||
|  | ||||
|         OnStartUp(); | ||||
|     } | ||||
|  | ||||
|     public void EndBlueprint(bool place = false) | ||||
|     { | ||||
|         if (place) | ||||
|         { | ||||
|             FindChildByTag("Blueprint").SetActive(false); | ||||
|             FindChildByTag("Building").SetActive(true); | ||||
|             Destroy(gameObject.GetComponent<BuildingBlueprint>()); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             Destroy(gameObject); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public GameObject FindChildByTag(string tag) | ||||
|     { | ||||
|         foreach(Transform child in gameObject.transform) | ||||
|         { | ||||
|             if(child.tag == tag) | ||||
|             { | ||||
|                 return child.gameObject; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return null; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 DerTyp187
					DerTyp187