Ejemplo n.º 1
0
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (_isMoving && gameObject.tag.Equals(Common.LAYER_BULLET))
        {
            //Debug.Log("Hit " + other.collider.name);
            string nameHit = other.gameObject.tag;
            if (nameHit.Equals(Common.LAYER_BALL) || nameHit.Equals(Common.LAYER_WALL))
            {
                gameObject.tag = Common.LAYER_BALL;
                SetNewLayer(Common.LAYER_BALL);
                FixPosition();

                if (nameHit.Equals(Common.LAYER_BALL))
                {
                    //print("case LAYER_BALL");
                    AssignBulletToGrid(other.gameObject.GetComponent <Ball>().GetGridPosition());
                    //probable error aca
                }
                else
                {
                    //print("case LAYER_BALL else");
                    AssignBulletToGrid(other.transform.localPosition);
                }

                _ballManager.ExplodeSameColorBall(this);
            }
        }
    }
Ejemplo n.º 2
0
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (_isMoving && gameObject.tag.Equals(Common.LAYER_BULLET))
        {
            string nameHit = other.gameObject.tag;
            if (nameHit.Equals(Common.LAYER_BALL) || nameHit.Equals(Common.LAYER_CEILING))
            {
                gameObject.tag = Common.LAYER_BALL;
                SetNewLayer(Common.LAYER_BALL);
                FixPosition();

                if (nameHit.Equals(Common.LAYER_BALL))
                {
                    AssignBulletToGrid(other.gameObject.GetComponent <Ball> ().GetGridPosition());
                }
                else
                {
                    AssignBulletToGrid(other.transform.localPosition);
                }

                _ballManager.ExplodeSameColorBall(this, _wallHits);
            }
            else if (nameHit.Equals(Common.LAYER_WALL))
            {
                _wallHits++;
            }
        }
    }
Ejemplo n.º 3
0
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (_isMoving && gameObject.tag.Equals(Common.LAYER_BULLET))
        {
            Debug.Log("Hit " + other.collider.name);
            string nameHit = other.gameObject.tag;
            if (nameHit.Equals(Common.LAYER_BALL) || nameHit.Equals(Common.LAYER_WALL))
            {
                gameObject.tag = Common.LAYER_BALL;
                SetNewLayer(Common.LAYER_BALL);
                FixPosition();

                if (nameHit.Equals(Common.LAYER_BALL))
                {
                    AssignBulletToGrid(other.gameObject.GetComponent <Ball>().GetGridPosition());
                }
                else
                {
                    AssignBulletToGrid(other.transform.localPosition);
                }

                _ballManager.ExplodeSameColorBall(this);
            }
        }



        /*
         * if (_isMoving && gameObject.tag.Equals(Common.LAYER_BULLET))
         * {
         *  Debug.Log("Hit " + other.collider.name);
         *  string nameHit = other.gameObject.tag;
         *  if(nameHit.Equals(Common.LAYER_BALL) || nameHit.Equals(Common.LAYER_WALL)){
         *      gameObject.tag = Common.LAYER_BALL;
         *      SetNewLayer(Common.LAYER_BALL);
         *      FixPosition();
         *
         *      if (nameHit.Equals(Common.LAYER_BALL))
         *      {
         *          AssignBulletToGrid(other.gameObject.GetComponent<Ball>().GetGridPosition());
         *      }
         *      else
         *      {
         *          AssignBulletToGrid(other.transform.localPosition);
         *      }
         *
         *      _ballManager.ExplodeSameColorBall(this);
         *  }
         *
         * }*/
    }