Skip to content
Snippets Groups Projects
wimmelbild.cs 3.07 KiB
Newer Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class wimmelbild : MonoBehaviour
{
Meike Wienholt's avatar
Meike Wienholt committed
    // public GameObject text;
    // Start is called before the first frame update
Meike Wienholt's avatar
Meike Wienholt committed
    List<int> destroyed = new List<int>();
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
Meike Wienholt's avatar
Meike Wienholt committed
        searchBild();
    }
    void searchBild()
    {
        if (Input.GetMouseButtonDown(0))
        {
Meike Wienholt's avatar
Meike Wienholt committed
            OnMouseDown();
Meike Wienholt's avatar
Meike Wienholt committed
        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
        }


Meike Wienholt's avatar
Meike Wienholt committed