mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-30 12:37:08 +01:00
Building Rework
This commit is contained in:
39
Assets/Buildings/Scripts/Building.cs
Normal file
39
Assets/Buildings/Scripts/Building.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Building : MonoBehaviour
|
||||
{
|
||||
public string title = "New Building";
|
||||
public string description = "A cool new building";
|
||||
[SerializeField] private GameObject buildingPrefab;
|
||||
[SerializeField] private GameObject blueprintPrefab;
|
||||
|
||||
|
||||
public abstract void OnStartUp();
|
||||
public enum BuildingType
|
||||
{
|
||||
Housing,
|
||||
Storage,
|
||||
Decoration
|
||||
}
|
||||
|
||||
public BuildingType buildingType;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameObject blueprint = Instantiate<GameObject>(blueprintPrefab);
|
||||
blueprint.transform.parent = gameObject.transform;
|
||||
|
||||
OnStartUp();
|
||||
}
|
||||
|
||||
public void Place(Transform t)
|
||||
{
|
||||
GameObject building = Instantiate<GameObject>(buildingPrefab);
|
||||
building.transform.position = t.position;
|
||||
building.transform.rotation = t.rotation;
|
||||
building.transform.parent = gameObject.transform;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user