예제 #1
0
    public void LetStart(QuadInfo quadInfo)
    {
        info = quadInfo;

        bool  startAtLeft = Random.Range(0, 2) != 0;
        float height      = Random.Range(0.2f, 5f);

        Vector3 position = startAtLeft ? quadInfo.EndOfLeft.position : quadInfo.EndOfRight.position;

        position.y = height;

        isAlive   = true;
        direction = Vector3.zero;

        if ((quadInfo.Side & QuadInfo.Left) != 0)
        {
            direction.z = 1;
        }

        if (!startAtLeft)
        {
            Flip();
        }

        gameObject.SetActive(true);
    }
    public KeyValuePair <List <int>, int> AddAndIncrement(QuadInfo q, List <int> allInds, int numVerts)
    {
        List <int> inds = q.Triangles;

        inds = AddValue(inds, numVerts);
        allInds.AddRange(inds);
        numVerts += q.GetNumVertices();
        return(new KeyValuePair <List <int>, int>(allInds, numVerts));
    }
    public void BuildBackFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[2], allVertices[3], allVertices[6], allVertices[7]
        };

        Back = new QuadInfo(Vector3.forward, coords, new List <int>()
        {
            0, 1, 2, 2, 1, 3
        }, ownCube);
    }
    public void BuildFrontFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[0], allVertices[1], allVertices[4], allVertices[5]
        };

        Front = new QuadInfo(Vector3.back, coords, new List <int>()
        {
            0, 2, 3, 0, 3, 1
        }, ownCube);
    }
    public void BuildRightFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[1], allVertices[3], allVertices[5], allVertices[7]
        };

        Right = new QuadInfo(Vector3.right, coords, new List <int>()
        {
            0, 2, 3, 0, 3, 1
        }, ownCube);
    }
    public void BuildLeftFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[0], allVertices[2], allVertices[4], allVertices[6]
        };

        Left = new QuadInfo(Vector3.left, coords, new List <int>()
        {
            0, 3, 2, 0, 1, 3
        }, ownCube);
    }
    public void BuildBottomFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[0], allVertices[1], allVertices[2], allVertices[3]
        };

        Bottom = new QuadInfo(Vector3.down, coords, new List <int>()
        {
            0, 1, 2, 2, 1, 3
        }, ownCube);
    }
    public void BuildUpFace()
    {
        List <Vector3> coords = new List <Vector3> {
            allVertices[4], allVertices[5], allVertices[6], allVertices[7]
        };

        Top = new QuadInfo(Vector3.up, coords, new List <int>()
        {
            0, 2, 1, 2, 3, 1
        }, ownCube);
    }
    /**
     * By position in visibles:
     * 0 -> Top
     * 1 -> Bottom
     * 2 -> Left
     * 3 -> Right
     * 4 -> Front
     * 5 -> Back
     *
     * realCoordCube a real position in worldSpace
     *
     * sizeEdge is the length of any edge of cube
     *
     */
    public CubeQuadsInfo(Cube ownCube)
    {
        Top          = Bottom = Left = Right = Front = Back = null;
        this.ownCube = ownCube;


        /*this.realCoordCube = realCoordCube;
         * this.sizeEdge = sizeEdge;*/

        /* Util:
         * xOffset is -1 for face Left, 1 for face Right, the rest 0
         * yOffset is -1 for face Down, 1 for face Top, the rest 0
         * zOffset is -1 for face Front, 1 for face Back, the rest 0
         */
    }
예제 #10
0
        ///<summary>
        ///   Find the suitable bucket for the quad in the list of
        ///   buckets.  If create is false and you don't find it in
        ///   the list, create the bucket and add it to the list.
        ///   If create is false and the bucket doesn't exist, return
        ///   null.
        ///</summary>
        public QuadBucket FindBucketForQuad(QuadInfo quad, List <QuadBucket> buckets, bool create)
        {
            float      z             = quad.z;
            int        textureHandle = quad.texture.Handle;
            int        hashCode      = (quad.clipRect != null ? quad.clipRect.GetHashCode() : 0);
            QuadBucket quadBucket    = null;

            foreach (QuadBucket bucket in quadBuckets)
            {
                if (bucket.z == z && bucket.textureHandle == textureHandle && bucket.clipRectHash == hashCode)
                {
                    quadBucket = bucket;
                    break;
                }
            }
            if (create && quadBucket == null)
            {
                quadBucket = new QuadBucket(z, textureHandle, hashCode, this);
                buckets.Add(quadBucket);
            }
            return(quadBucket);
        }
예제 #11
0
    private bool ExecOnBuildLinkOrQuadInfo(string id, string name, HyperText text, out LinkInfo linkInfo, out QuadInfo quadInfo)
    {
        bool isLink = true;

        if (null != onBuildLinkOrQuadInfo)
        {
            isLink = onBuildLinkOrQuadInfo(id, name, text, out linkInfo, out quadInfo);
        }
        else
        {
            linkInfo = null;
            quadInfo = null;
        }
        return(isLink);
    }
예제 #12
0
        ///<summary>
        ///   The TextureAndClipRect value is interned, so we can just
        ///   look it up, and don't have to iterate.
        ///</summary>
        public void AddQuad(QuadInfo quad)
        {
            QuadBucket quadBucket = FindBucketForQuad(quad, quadBuckets, true);

            quadBucket.quads.Add(quad);
        }