void Update()
    {
        int lineCount = hud.getLineCount();

        if (lineCount <= 0)
        {
            return;
        }
        if (Input.GetMouseButton(0))
        {
            if (activeLine == null)
            {
                GameObject lineObj = Instantiate(linePrefab);
                Destroy(lineObj, lineDuration);
                activeLine = lineObj.GetComponent <Line>();
                hud.IncreaseLine(-1);
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            activeLine = null;
        }
        if (activeLine != null)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            activeLine.updateLine(mousePos);
        }
    }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         hud.IncreaseLine(1);
         Destroy(gameObject);
         return;
     }
 }