mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-11-01 13:42:29 +01:00
Clean Up
This commit is contained in:
@@ -580,7 +580,7 @@ GameObject:
|
|||||||
- component: {fileID: 708126141}
|
- component: {fileID: 708126141}
|
||||||
- component: {fileID: 708126140}
|
- component: {fileID: 708126140}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Canvas
|
m_Name: HUD
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@@ -1676,7 +1676,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8390537188327133020, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
- target: {fileID: 8390537188327133020, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||||
propertyPath: jumpForce
|
propertyPath: jumpForce
|
||||||
value: 3.5
|
value: 4
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8390537188327133020, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
- target: {fileID: 8390537188327133020, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||||
propertyPath: jumpHeight
|
propertyPath: jumpHeight
|
||||||
@@ -1710,6 +1710,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: FirstPerson Player
|
value: FirstPerson Player
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8390537188327133021, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||||
|
propertyPath: m_TagString
|
||||||
|
value: FPSPlayer
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8390537188327133022, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
- target: {fileID: 8390537188327133022, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 1
|
value: 1
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using UnityEngine;
|
|||||||
public abstract class BuildingBlueprint : MonoBehaviour
|
public abstract class BuildingBlueprint : MonoBehaviour
|
||||||
{
|
{
|
||||||
public bool isColliding;
|
public bool isColliding;
|
||||||
public bool followMouse = true;
|
|
||||||
public GameObject constructionPrefab;
|
public GameObject constructionPrefab;
|
||||||
|
|
||||||
private GameObject terrain;
|
private GameObject terrain;
|
||||||
@@ -20,63 +19,27 @@ public abstract class BuildingBlueprint : MonoBehaviour
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
hud = GameObject.Find("HUD").GetComponent<Canvas>();
|
hud = GameObject.Find("HUD").GetComponent<Canvas>(); //Get HUD Canvas
|
||||||
|
terrain = GameObject.FindGameObjectWithTag("Terrain"); //Get Terrain
|
||||||
|
|
||||||
//Bug Fix Blueprints already existing
|
//Bug Fix Blueprints already existing
|
||||||
|
//Delete/CleanUp all objs with tag "Blueprint"
|
||||||
GameObject[] blueprints = GameObject.FindGameObjectsWithTag("Blueprint");
|
GameObject[] blueprints = GameObject.FindGameObjectsWithTag("Blueprint");
|
||||||
|
|
||||||
foreach (GameObject blueprint in blueprints)
|
foreach (GameObject blueprint in blueprints)
|
||||||
Destroy(blueprint);
|
Destroy(blueprint);
|
||||||
|
|
||||||
|
|
||||||
gameObject.tag = "Blueprint";
|
gameObject.tag = "Blueprint"; //Give Gameobject the tag "Blueprint" (after deleting all objs with this tag)
|
||||||
|
|
||||||
terrain = GameObject.FindGameObjectWithTag("Terrain");
|
hud.enabled = false; //Hide HUD
|
||||||
|
|
||||||
hud.enabled = false;
|
Init(); //Call init callback function for children
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Collision
|
|
||||||
public void OnCollisionEnter(Collision collision)
|
|
||||||
{
|
|
||||||
isColliding = true;
|
|
||||||
|
|
||||||
Debug.Log("Colliding True");
|
|
||||||
}
|
|
||||||
public void OnCollisionStay(Collision collision)
|
|
||||||
{
|
|
||||||
isColliding = true;
|
|
||||||
Debug.Log("Colliding True");
|
|
||||||
}
|
|
||||||
public void OnCollisionExit(Collision collision)
|
|
||||||
{
|
|
||||||
isColliding = false;
|
|
||||||
Debug.Log("Colliding False");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Placing
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (followMouse)
|
FollowMouse();
|
||||||
{
|
Rotate();
|
||||||
//Following Mouse
|
|
||||||
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
||||||
RaycastHit hitData;
|
|
||||||
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
|
|
||||||
{
|
|
||||||
transform.position = hitData.point;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(0) && !isColliding)
|
|
||||||
{
|
|
||||||
Instantiate(constructionPrefab, transform.position, transform.rotation);
|
|
||||||
Destroy(this.gameObject);
|
|
||||||
hud.enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Collinding Callbacks
|
//Collinding Callbacks
|
||||||
if (isColliding)
|
if (isColliding)
|
||||||
@@ -88,15 +51,32 @@ public abstract class BuildingBlueprint : MonoBehaviour
|
|||||||
WhileNotColliding();
|
WhileNotColliding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PLACE
|
||||||
|
if (Input.GetMouseButtonDown(0) && !isColliding)
|
||||||
|
{
|
||||||
|
Place();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Rotate
|
void FollowMouse()
|
||||||
|
{
|
||||||
|
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
|
RaycastHit hitData;
|
||||||
|
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
|
||||||
|
{
|
||||||
|
transform.position = hitData.point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Rotate()
|
||||||
|
{
|
||||||
if (Input.GetButtonDown("Rotate"))
|
if (Input.GetButtonDown("Rotate"))
|
||||||
{
|
{
|
||||||
Debug.Log("Rotate+");
|
Debug.Log("Rotate+");
|
||||||
if (Input.GetKey(KeyCode.LeftShift))
|
if (Input.GetKey(KeyCode.LeftShift))
|
||||||
{
|
{
|
||||||
transform.Rotate(0, 5, 0);
|
transform.Rotate(0, 5, 0);
|
||||||
}else if (Input.GetKey(KeyCode.LeftControl))
|
}
|
||||||
|
else if (Input.GetKey(KeyCode.LeftControl))
|
||||||
{
|
{
|
||||||
transform.Rotate(0, 45, 0);
|
transform.Rotate(0, 45, 0);
|
||||||
}
|
}
|
||||||
@@ -113,7 +93,8 @@ public abstract class BuildingBlueprint : MonoBehaviour
|
|||||||
if (Input.GetKey(KeyCode.LeftShift))
|
if (Input.GetKey(KeyCode.LeftShift))
|
||||||
{
|
{
|
||||||
transform.Rotate(0, -5, 0);
|
transform.Rotate(0, -5, 0);
|
||||||
}else if (Input.GetKey(KeyCode.LeftControl))
|
}
|
||||||
|
else if (Input.GetKey(KeyCode.LeftControl))
|
||||||
{
|
{
|
||||||
transform.Rotate(0, -45, 0);
|
transform.Rotate(0, -45, 0);
|
||||||
}
|
}
|
||||||
@@ -123,8 +104,30 @@ public abstract class BuildingBlueprint : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void Place()
|
||||||
|
{
|
||||||
|
Instantiate(constructionPrefab, transform.position, transform.rotation);
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
hud.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Collision
|
||||||
|
public void OnCollisionEnter(Collision c)
|
||||||
|
{
|
||||||
|
isColliding = true;
|
||||||
|
|
||||||
|
Debug.Log("Colliding True");
|
||||||
|
}
|
||||||
|
public void OnCollisionStay(Collision c)
|
||||||
|
{
|
||||||
|
isColliding = true;
|
||||||
|
Debug.Log("Colliding True");
|
||||||
|
}
|
||||||
|
public void OnCollisionExit(Collision c)
|
||||||
|
{
|
||||||
|
isColliding = false;
|
||||||
|
Debug.Log("Colliding False");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ InputManager:
|
|||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: r
|
positiveButton: x
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton:
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
@@ -378,7 +378,7 @@ InputManager:
|
|||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: q
|
positiveButton: y
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton:
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ TagManager:
|
|||||||
- Terrain
|
- Terrain
|
||||||
- Blueprint
|
- Blueprint
|
||||||
- StorageBuilding
|
- StorageBuilding
|
||||||
|
- FPSPlayer
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|||||||
Reference in New Issue
Block a user