Ejemplo n.º 1
0
    public void makeObstacleOnMesh(int meshIndex, ObstacleType obstacleType)
    {
        if (ObstacleType.Cube == obstacleType)
        {
            GameObject obstacle   = Instantiate <GameObject>(obstaclePrefab) as GameObject;
            FloorMesh  floorMesh  = FloorBuilder.current.floorMeshes[meshIndex];
            Vector3    cross      = Vector3.Cross(floorMesh.prevDir, floorMesh.dir);
            float      posScale   = cross.y > 0 ? 0.8f : 0.2f;
            Vector3    prevPosMid = floorMesh.prevPos1 + (floorMesh.prevPos2 - floorMesh.prevPos1) * posScale;
            prevPosMid   += floorMesh.dir * floorMesh.length / 2.0f;
            prevPosMid.y += 1.0f;
            obstacle.transform.position = prevPosMid;
            obstacle.transform.forward  = floorMesh.prevDir;

            floorMesh.destroyOnRemake = obstacle;
        }
        else if (ObstacleType.Jump == obstacleType)
        {
            FloorMesh floorMesh = FloorBuilder.current.floorMeshes[meshIndex];

            floorMesh.prevPos1    = floorMesh.prevPos1 + floorMesh.dir * floorMesh.length * 5.0f;
            floorMesh.prevPos2    = floorMesh.prevPos2 + floorMesh.dir * floorMesh.length * 5.0f;
            floorMesh.prevPos1.y -= 5.0f;
            floorMesh.prevPos2.y -= 5.0f;
            floorMesh.makeMesh();
        }
        else if (ObstacleType.BeforeJump == obstacleType)
        {
            FloorMesh floorMesh = FloorBuilder.current.floorMeshes[meshIndex];
            Vector3   dir       = floorMesh.dir;
            dir.y = -floorMesh.dir.y;
            floorMesh.changeNormalByDir(Vector3.Cross(dir, new Vector3(dir.z, 0, -dir.x)));
            //floorMesh.makeMesh();
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     floor    = transform.GetComponentInChildren <FloorMesh>();
     floor.gd = this;
     walls    = transform.GetComponentInChildren <WallMesh>();
     walls.gd = this;
 }
Ejemplo n.º 3
0
    public void putCoin(int meshIndex)
    {
        if (notShowingCoins.Count == 0)
        {
            return;
        }
        Coin coin = notShowingCoins.Dequeue();

        coin.resetCoin();
        FloorMesh floorMesh = FloorBuilder.current.floorMeshes[meshIndex];

        coin.meshIndex      = meshIndex;
        floorMesh.coinIndex = coin.index;
        GameObject obj   = coin.gameObject;
        Vector3    cross = Vector3.Cross(floorMesh.prevDir, floorMesh.dir);
        //print(dot);
        float   posScale   = cross.y < 0 ? 0.8f : 0.2f;
        Vector3 prevPosMid = floorMesh.prevPos1 + (floorMesh.prevPos2 - floorMesh.prevPos1) * posScale;

        prevPosMid   += floorMesh.dir * floorMesh.length / 2.0f;
        prevPosMid.y += 1.0f;

        obj.transform.position = prevPosMid;
        obj.transform.forward  = floorMesh.prevDir;
        coin.startAnim();

        if (currentCoinIndex >= coinCount)
        {
            currentCoinIndex = 0;
        }
    }
Ejemplo n.º 4
0
 public RoomMesh(int width, int height, int quadSize, int borderSize, int wallHeight, IRoomInterface data)
 {
     _borderMesh = new RoomBorderMesh(width, height, quadSize, borderSize, wallHeight, data);
     _borderMesh.Generate();
     _floorMesh = new FloorMesh(width, height, quadSize, borderSize, _borderMesh.getMap());
     _floorMesh.Generate();
 }
Ejemplo n.º 5
0
    public void makeObstacleOnMesh(int meshIndex)
    {
        GameObject obstacle   = Instantiate <GameObject>(obstaclePrefab) as GameObject;
        FloorMesh  floorMesh  = FloorBuilder.current.floorMeshes[meshIndex];
        Vector3    cross      = Vector3.Cross(floorMesh.prevDir, floorMesh.dir);
        float      posScale   = cross.y > 0 ? 0.8f : 0.2f;
        Vector3    prevPosMid = floorMesh.prevPos1 + (floorMesh.prevPos2 - floorMesh.prevPos1) * posScale;

        prevPosMid   += floorMesh.dir * floorMesh.length / 2.0f;
        prevPosMid.y += 1.0f;
        obstacle.transform.position = prevPosMid;
        obstacle.transform.forward  = floorMesh.prevDir;

        floorMesh.destroyOnRemake = obstacle;
    }