示例#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;
    }
示例#2
0
    public nextState GenerateFinal()
    {
        nextState n = nextState.xNegative;
        int       x = Random.Range(0, 4);

        switch (x)
        {
        case 0:
            n = nextState.xPositive;
            break;

        case 1:
            n = nextState.xNegative;
            break;

        case 2:
            n = nextState.zPositive;
            break;

        case 3:
            n = nextState.zNegative;
            break;
        }
        return(n);
    }
示例#3
0
        public int Next(int limit)
        {
            if (!IsPseudorandom)
            {
                return(random.Next(limit));
            }

            var result = 0;

            switch (nextStatePointer)
            {
            case nextState.First:
                result           = 0;
                nextStatePointer = nextState.Middle;
                break;

            case nextState.Middle:
                result           = limit / 2;
                nextStatePointer = nextState.Last;
                break;

            case nextState.Last:
                result           = limit > 0 ? limit - 1 : 0;
                nextStatePointer = nextState.First;
                break;
            }
            return(result);
        }
示例#4
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);
    }
示例#5
0
 public void Reset()
 {
     next100000Pointer = 0;
     nextStatePointer  = nextState.First;
 }