Exemplo n.º 1
0
    //最大生成数がMAX以下のときオブジェクトを生成するメゾット
    public void RoadAdd()
    {
        //mapData内の基準点とその前後
        Vector3    before, next, now;
        GameObject rail;

        //各インデックス番号の入る配列
        int[] nextIndex   = new int[2];
        int[] beforeIndex = new int[2];
        int[] nowIndex    = new int[2];
        //c[0]にnext,beforeのX軸の和を、c[1]にZ軸の和を入れる配列
        int[] beforeconparison = new int[2];
        int[] nextconparison   = new int[2];
        stageRail = new GameObject[maxRail];

        //始点の生成
        now                = mapData [0];
        next               = mapData [1];
        nowIndex           = NowIndex(now);
        nextIndex          = NextIndex(next);
        nextconparison [0] = nextIndex [0] - nowIndex [0];
        nextconparison [1] = nextIndex [1] - nowIndex [1];
        BeforeState        = CheckBeforeState(beforeconparison);
        NextState          = CheckNextState(nextconparison);
        rail               = RailMake(BeforeState, NextState);
        stageRail [0]      = rail;

        //mapData[1]から終点の一つ前までを生成
        for (int i = 1; i < mapData.Count - 1; i++)
        {
            before      = mapData [i - 1];
            next        = mapData [i + 1];
            now         = mapData [i];
            beforeIndex = BeforeIndex(before);
            nextIndex   = NextIndex(next);
            nowIndex    = NowIndex(now);
            //beforeconparisionにx軸z軸の差を代入
            beforeconparison [0] = nowIndex [0] - beforeIndex [0];
            beforeconparison [1] = nowIndex [1] - beforeIndex [1];
            //nextconparisionにx軸z軸の差を代入
            nextconparison [0] = nextIndex [0] - nowIndex [0];
            nextconparison [1] = nextIndex [1] - nowIndex [1];
            BeforeState        = CheckBeforeState(beforeconparison);
            NextState          = CheckNextState(nextconparison);
            rail          = RailMake(BeforeState, NextState);
            stageRail [i] = rail;
        }

        //終点の生成
        now                     = mapData [mapData.Count - 1];
        before                  = mapData [mapData.Count - 2];
        nowIndex                = NowIndex(now);
        beforeIndex             = BeforeIndex(before);
        beforeconparison [0]    = nowIndex [0] - beforeIndex [0];
        beforeconparison [1]    = nowIndex [1] - beforeIndex [1];
        BeforeState             = CheckBeforeState(beforeconparison);
        NextState               = CheckNextState(nextconparison);
        rail                    = RailMake(BeforeState, NextState);
        stageRail [maxRail - 1] = rail;
    }
Exemplo n.º 2
0
    public beforeState GenerateStart()
    {
        beforeState b = beforeState.xNegative;
        int         x = Random.Range(0, 4);

        switch (x)
        {
        case 0:
            b = beforeState.xPositive;
            break;

        case 1:
            b = beforeState.xNegative;
            break;

        case 2:
            b = beforeState.zPositive;
            break;

        case 3:
            b = beforeState.zNegative;
            break;
        }
        return(b);
    }
Exemplo n.º 3
0
    public GameObject RailMake(beforeState BeforeState, nextState NextState)
    {
        GameObject obj = widthStright;

        switch (BeforeState)
        {
        case beforeState.xPositive:
            switch (NextState)
            {
            case nextState.xPositive:
                obj = widthStright;
                break;

            case nextState.xNegative:
                obj = widthStright;
                break;

            case nextState.zPositive:
                obj = upRight;
                break;

            case nextState.zNegative:
                obj = downRight;
                break;
            }
            break;

        case beforeState.xNegative:
            switch (NextState)
            {
            case nextState.xPositive:
                obj = widthStright;
                break;

            case nextState.xNegative:
                obj = widthStright;
                break;

            case nextState.zPositive:
                obj = upLeft;
                break;

            case nextState.zNegative:
                obj = downLeft;
                break;
            }
            break;

        case beforeState.zPositive:
            switch (NextState)
            {
            case nextState.zPositive:
                obj = lengthStright;
                break;

            case nextState.zNegative:
                obj = lengthStright;
                break;

            case nextState.xPositive:
                obj = downLeft;
                break;

            case nextState.xNegative:
                obj = downRight;
                break;
            }
            break;

        case beforeState.zNegative:
            switch (NextState)
            {
            case nextState.zPositive:
                obj = lengthStright;
                break;

            case nextState.zNegative:
                obj = lengthStright;
                break;

            case nextState.xPositive:
                obj = upLeft;
                break;

            case nextState.xNegative:
                obj = upRight;
                break;
            }
            break;
        }
        return(obj);
    }