示例#1
0
    public override void GenerateItem(Pipe pipe)
    {
        float angleStep = pipe.CurveAngle / pipe.CurveSegmentCount;

        for (int i = 0; i < pipe.CurveSegmentCount; i++)
        {
            PipeItem item         = Instantiate(ItemPrefabs[Random.Range(0, ItemPrefabs.Length)]);
            float    pipeRotation = (Random.Range(0, pipe.PipeSegmentCount) + 0.5f) * 360f / pipe.PipeSegmentCount;
            item.Position(pipe, i * angleStep, pipeRotation);
        }
    }
示例#2
0
    public override void GenerateItems(Pipe pipe)
    {
        float angleStep = pipe.CurveAngle / pipe.CurveSegCount;

        for (int i = 0; i < pipe.CurveSegCount; i += 2)
        {
            PipeItem item    = Instantiate <PipeItem>(itemPrefabs[Random.Range(0, itemPrefabs.Length)]);
            float    pipeRot = (Random.Range(0, pipe.pipeSegCount) + 0.5f) * 360f / pipe.pipeSegCount;
            item.Position(pipe, i * angleStep, pipeRot);
        }
    }
    private void Awake()
    {
        GetComponent <MeshFilter>().mesh = mesh = new Mesh();
        mesh.name = "Pipe";
        //generators[Random.Range(0,generators.Length)].GenerateItems(this);
        PipeItem pipeItem     = Instantiate <PipeItem>(itemPrefab[Random.Range(0, itemPrefab.Length)]);
        float    angleStep    = CurveAngle / CurveSegmentCount;
        float    pipeRotation = (Random.Range(0, pipeSegmentCount) + 0.5f) *
                                360f / pipeSegmentCount;

        pipeItem.Position(this, angleStep, pipeRotation);
    }
示例#4
0
    public override void GenerateItem(Pipe pipe)
    {
        float angleStep = pipe.CurveAngle / pipe.CurveSegment;

        for (int i = 0; i < pipe.CurveSegment; i += 4)
        {
            PipeItem item = Instantiate(itemPrefabs[Random.Range(0, itemPrefabs.Length)]);

            float pipeRotation = (Random.Range(0, pipe.pipeSegment) + 0.5f) * (360f / pipe.pipeSegment);

            item.Position(pipe, i * angleStep, new Vector3(0f, pipeRotation, pipeRotation));
        }
    }
示例#5
0
    public override void GenerateItems(Pipe pipe)
    {
        float start     = (Random.Range(0, pipe.pipeSegmentCount) + 0.5f);
        float direction = Random.value < 0.5f ? 1f : -1f;
        float angleStep = pipe.CurveAngle / pipe.CurveSegmentCount;

        for (int i = 0; i < pipe.CurveSegmentCount; i++)
        {
            PipeItem item         = Instantiate <PipeItem>(itemPrefabs[Random.Range(0, itemPrefabs.Length)]);
            float    pipeRotation = (start + i * direction) * 360f / pipe.pipeSegmentCount;
            item.Position(pipe, i * angleStep, pipeRotation);
        }
    }
示例#6
0
    public override void GenerateItems(Pipe pipe)
    {
        for (int i = 0; i < pipe.CurveSegmentCount; i += 20)
        {
            int      pointer = Random.Range(0, itemPrefabs.Length);
            PipeItem item    = Instantiate <PipeItem>(
                itemPrefabs[pointer]);

            float pipeRotation =
                (Random.Range(0, pipe.pipeSegmentCount) + 0.5f) *
                360f / pipe.pipeSegmentCount;
            item.Position(pipe, i, pipeRotation, pipe.GetPipeRadiusBySegmentIndex(i));
        }
    }
示例#7
0
    public void Generate(bool with_obstacles, bool with_egg)
    {
        curveRadius  = Random.Range(minCurveRadius, maxCurveRadius);
        curveSegment = Random.Range(minCurveSegment, maxCurveSegment + 1);

        mesh.Clear();

        SetupVertices();
        SetupUV();
        SetupTriangles();

        mesh.RecalculateNormals();
        mesh.RecalculateBounds();

        meshCollider.sharedMesh = mesh;
        //meshCollider.convex = true;

        for (int i = 0; i < transform.childCount; i++)
        {
            Destroy(transform.GetChild(i).gameObject);
        }


        if (with_obstacles && ciliaGenerators.Length > 0)
        {
            if (ciliaGenerators.Length > 0)
            {
                ciliaGenerators[Random.Range(0, ciliaGenerators.Length)].GenerateItem(this);
            }

            if (obstacleGenerators.Length > 0)
            {
                obstacleGenerators[Random.Range(0, obstacleGenerators.Length)].GenerateItem(this);
            }
        }

        if (with_egg)
        {
            float    angleStep = curveAngle / curveSegment;
            PipeItem egg       = Instantiate(ovum);
            int      segment   = Random.Range(0, curveSegment);
            egg.Position(this, segment * angleStep, new Vector3(360f / pipeSegment, 0f, 0f));
        }
    }