Ejemplo n.º 1
0
 void Player_Actions()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector3 mousePos = Input.mousePosition;
         mousePos.z = 5.0f;
         Vector2      v   = Camera.main.ScreenToWorldPoint(mousePos);
         Collider2D[] col = Physics2D.OverlapPointAll(v);
         if (col.Length > 0)
         {
             foreach (Collider2D c in col)
             {
                 if (c.gameObject.tag == "White")
                 {
                     Clicked_Cube = c.gameObject;
                     Clicked_Cube.SetActive(false);
                     CubeBehavior2D C_Behavior = Clicked_Cube.GetComponent <CubeBehavior2D> ();
                     C_Behavior.Box_ID          = Random.Range(0, C_Behavior.Box_Sprites.Length);
                     C_Behavior.UpdateRenderTag = true;
                     C_Behavior.IsMoving        = true;
                     C_Behavior.Box_List [3]    = null;
                     A_C_C.CubesActive         -= 1;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 void Player_ActionsM()
 {
     if (Input.touchCount > 0)
     {
         Vector2      Touch_V = new Vector2(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y);
         Vector2      v       = Camera.main.ScreenToWorldPoint(Touch_V);
         Collider2D[] M_col   = Physics2D.OverlapPointAll(v);
         if (M_col.Length > 0)
         {
             foreach (Collider2D c in M_col)
             {
                 if (c.gameObject.tag == "White")
                 {
                     Clicked_Cube = c.gameObject;
                     Clicked_Cube.SetActive(false);
                     CubeBehavior2D C_Behavior = Clicked_Cube.GetComponent <CubeBehavior2D> ();
                     C_Behavior.Box_ID          = Random.Range(0, C_Behavior.Box_Sprites.Length);
                     C_Behavior.UpdateRenderTag = true;
                     C_Behavior.IsMoving        = true;
                     C_Behavior.Box_List [3]    = null;
                     A_C_C.CubesActive         -= 1;
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 void Cube2D_Reactions()
 {
     //0(Left),1(right),2(Up),3(Down)
     //Reds can only clear when 3 of them at a side.
     if ((Box_List [0] != null) && (Box_List [1] != null))
     {
         //if ((Cube_Contacts [0].tag == "Red") && (Cube_Contacts [1].tag == "Red") && (this.gameObject.tag == "Red"))
         if ((Box_List [0].tag == "Red") && (Box_List [1].tag == "Red") && (this.gameObject.tag == "Red"))
         {
             C_B = Box_List [0].GetComponent <CubeBehavior2D> ();
             Box_List [0].SetActive(false);
             C_B.E_C.isAwake = true;
             C_B.Explosion.SetActive(true);
             C_B.Explosion.transform.position = Box_List [0].transform.position;
             C_B.UpdateRenderTag = true;
             C_B.IsMoving        = true;
             //
             C_B = Box_List [1].GetComponent <CubeBehavior2D> ();
             Box_List [1].SetActive(false);
             C_B.E_C.isAwake = true;
             C_B.Explosion.SetActive(true);
             C_B.Explosion.transform.position = Box_List [1].transform.position;
             C_B.UpdateRenderTag = true;
             C_B.IsMoving        = true;
             //
             this.gameObject.SetActive(false);
             E_C.isAwake = true;
             Explosion.SetActive(true);
             Explosion.transform.position = this.gameObject.transform.position;
             UpdateRenderTag       = true;
             IsMoving              = true;
             A_C_C.CubesActive    -= 3;
             A_C_C.Score          += 3;
             A_C_C.CubesDestroyed += 3;
         }
     }
     //Blues can only clear when 3 of them stacked on top of each other
     if ((Box_List [2] != null) && (Box_List [3] != null))
     {
         if ((Box_List [2].tag == "Blue") && (Box_List [3].tag == "Blue") && (this.gameObject.tag == "Blue"))
         {
             C_B = Box_List [2].GetComponent <CubeBehavior2D> ();
             Box_List [2].SetActive(false);
             C_B.E_C.isAwake = true;
             C_B.Explosion.SetActive(true);
             C_B.Explosion.transform.position = Box_List [2].transform.position;
             C_B.UpdateRenderTag = true;
             C_B.IsMoving        = true;
             //
             C_B = Box_List [3].GetComponent <CubeBehavior2D> ();
             Box_List [3].SetActive(false);
             C_B.E_C.isAwake = true;
             C_B.Explosion.SetActive(true);
             C_B.Explosion.transform.position = Box_List [3].transform.position;
             C_B.UpdateRenderTag = true;
             C_B.IsMoving        = true;
             //
             this.gameObject.SetActive(false);
             E_C.isAwake = true;
             Explosion.SetActive(true);
             Explosion.transform.position = this.gameObject.transform.position;
             UpdateRenderTag       = true;
             IsMoving              = true;
             A_C_C.CubesActive    -= 3;
             A_C_C.Score          += 3;
             A_C_C.CubesDestroyed += 3;
         }
     }
 }