コード例 #1
0
ファイル: CubeScript.cs プロジェクト: mwudunn/VRShatter
    public void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject == lastCollidedWith)
        {
            return;
        }
        lastCollidedWith = collision.gameObject;

        if (collision.gameObject.tag == "Projectile")
        {
            SetType(GetNextType());
        }
        else if (collision.gameObject.tag == "Box")
        {
            if (IsCubeBelow(gameObject, collision.gameObject))
            {
                SetAdjacency(collision.gameObject, 2);
                PropagateRowIndex();
            }
            else
            {
                SetAdjacency(collision.gameObject, 3);
                SetCubeRowIndex(collision.gameObject.GetComponent <CubeScript>().cubeRowIndex + 1);
                SetLeftRightAdjacencies();

                if (type != CubeType.Glass && destroyable)
                {
                    cubeManager.HandleCubeCollision(gameObject);
                }
                destroyable = false;
            }
        }
        else if (collision.gameObject.tag == "Ground")
        {
            cubeManager.SetCubeBottomRow(gameObject, cubeColIndex);
            SetCubeRowIndex(0);
            SetLeftRightAdjacencies();
            PropagateRowIndex();


            if (type != CubeType.Glass && destroyable)
            {
                cubeManager.HandleCubeCollision(gameObject);
            }
            destroyable = false;
        }
    }