Refactored and reworked mouse based triggers to remove some funky pickup/drop bugs for cleaning items
This commit is contained in:
@@ -297,7 +297,7 @@ GameObject:
|
|||||||
- component: {fileID: 1425971016}
|
- component: {fileID: 1425971016}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Background
|
m_Name: Background
|
||||||
m_TagString: Untagged
|
m_TagString: Background
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -36,47 +36,43 @@ public class GameScript : MonoBehaviour
|
|||||||
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
||||||
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
||||||
|
|
||||||
if (hit.collider != null)
|
|
||||||
|
if(hit.collider != null && hit.collider.gameObject.tag == "Restart" && gameOver)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(hit.collider.gameObject.tag == "Restart" && gameOver)
|
Restart.SetActive(false);
|
||||||
{
|
Object.SetActive(true);
|
||||||
|
Setup();
|
||||||
Restart.SetActive(false);
|
gameOver = false;
|
||||||
Object.SetActive(true);
|
timer = 0.0f;
|
||||||
Setup();
|
objectsPolished = 0;
|
||||||
gameOver = false;
|
|
||||||
timer = 0.0f;
|
|
||||||
objectsPolished = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hit.collider.gameObject.tag == "Item" && !clicked && !gameOver)
|
|
||||||
{
|
|
||||||
pickedUpItem = hit.collider.gameObject;
|
|
||||||
clicked = true;
|
|
||||||
Cursor.visible = false;
|
|
||||||
|
|
||||||
} else if (hit.collider.gameObject.tag == "Item" && clicked)
|
|
||||||
{
|
|
||||||
clicked = false;
|
|
||||||
Cursor.visible = true;
|
|
||||||
|
|
||||||
if(pickedUpItem.name == "Rag")
|
|
||||||
{
|
|
||||||
pickedUpItem.transform.position = new Vector2(7.25f, 2.5f);
|
|
||||||
} else if (pickedUpItem.name == "SprayBottle"){
|
|
||||||
pickedUpItem.transform.position = new Vector2(7.25f, -2.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
pickedUpItem.transform.rotation = Quaternion.identity;
|
|
||||||
pickedUpItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Debug.Log("Clicked " + pickedUpItem.name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hit.collider != null && hit.collider.gameObject.tag == "Item" && !clicked && !gameOver)
|
||||||
|
{
|
||||||
|
pickedUpItem = hit.collider.gameObject;
|
||||||
|
clicked = true;
|
||||||
|
Cursor.visible = false;
|
||||||
|
|
||||||
|
} else if (hit.collider != null && clicked)
|
||||||
|
{
|
||||||
|
clicked = false;
|
||||||
|
Cursor.visible = true;
|
||||||
|
|
||||||
|
if(pickedUpItem.name == "Rag")
|
||||||
|
{
|
||||||
|
pickedUpItem.transform.position = new Vector2(7.25f, 2.5f);
|
||||||
|
} else if (pickedUpItem.name == "SprayBottle"){
|
||||||
|
pickedUpItem.transform.position = new Vector2(7.25f, -2.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
pickedUpItem.transform.rotation = Quaternion.identity;
|
||||||
|
pickedUpItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debug.Log("Clicked " + pickedUpItem.name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ TagManager:
|
|||||||
- Item
|
- Item
|
||||||
- Dirt
|
- Dirt
|
||||||
- Restart
|
- Restart
|
||||||
|
- Background
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|||||||
Reference in New Issue
Block a user