Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag.Equals("Ball"))
        {
            GameObject newLazer = Instantiate(lazer);
            LazerSound.Play();

            GridableObject lazerGridScript = newLazer.GetComponent <GridableObject>();
            GridableObject btnGridScript   = this.gameObject.GetComponent <GridableObject>();
            Debug.Log(btnGridScript.getGridY());

            // lazerGridScript.setGridPosition(btnGridScript.getGridY(), btnGridScript.getGridX());

            if (IsHorizontal)
            {
                lazerGridScript.setGridPosition(btnGridScript.getGridY(), 3);
            }
            else
            {
                lazerGridScript.setGridPosition(5, btnGridScript.getGridX());
            }
        }
    }
Ejemplo n.º 2
0
 //updates grid, destroys temp objects and cleans the temporaryObjs list
 private void destroyTempObjects()
 {
     foreach (GameObject obj in temporaryObjs)
     {
         GridableObject script = obj.GetComponent <GridableObject>();
         int            x      = script.getGridX();
         int            y      = script.getGridY();
         if (x != -1)
         {
             grid[y, x] = false;
         }
         Destroy(obj);
     }
     for (int i = temporaryObjs.Count - 1; i >= 0; --i)
     {
         temporaryObjs.RemoveAt(i);
     }
 }