Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wimmelbild : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void searchBild()
{
if (Input.GetMouseButtonDown(0))
{
}
}
void OnMouseDown()
{
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var text = GameObject.Find("TextMesh");
Vector2 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//Creating the raycast. Note that a mask is being applied with "~" being used to exclude a specific layer. The latter layer is only used for movement direction detection.
RaycastHit2D h = Physics2D.Raycast(point, Vector2.zero, Mathf.Infinity, ~(1 << LayerMask.NameToLayer("MovementCatcher")));
//print(h.collider.tag);
if (h.collider.name.Equals("1")){
var one = GameObject.Find("1");
Destroy(one);
destroyed.Add(1);
}
if (h.collider.name.Equals("2"))
{
var one = GameObject.Find("2");
Destroy(one);
destroyed.Add(1);
} else if (h.collider.name.Equals("3"))
{
var one = GameObject.Find("3");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("4"))
{
var one = GameObject.Find("4");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("5"))
{
var one = GameObject.Find("5");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("6"))
{
var one = GameObject.Find("6");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("7"))
{
var one = GameObject.Find("7");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("8"))
{
var one = GameObject.Find("8");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("9"))
{
var one = GameObject.Find("9");
Destroy(one);
destroyed.Add(1);
}
else if (h.collider.name.Equals("10"))
{
var one = GameObject.Find("10");
Destroy(one);
destroyed.Add(1);
}
text.GetComponent<TextMesh>().text = destroyed.Count + "/10";
if(destroyed.Count == 10)
{
Debug.Log("I HAVE WON THE GAME");
//Spiel nicht mehr betretbar
// Kohleschauflerin weiter dialog
}