예제 #1
0
    public Level createNew(Level best, Level pair)
    {
        Level next = new Level ();
        List<int[]> lp = new List<int[]> ();
        List<int[]> lc = new List<int[]> ();
        List<int[]> le = new List<int[]> ();
        int[] pPos;
        int[] fPos;

        int bestLineNumber = Mathf.FloorToInt(horizontalWalls * 0.7f);
        int pairLineNumber = Mathf.FloorToInt(horizontalWalls * 0.2f);
        int randomLineNumber = Mathf.FloorToInt(horizontalWalls * 0.1f);

        lp.AddRange (getNPositions (best.getLine (), bestLineNumber));
        lp.AddRange (getNPositions (pair.getLine (), pairLineNumber));
        lp.AddRange (getNPositonsRandom(randomLineNumber,true));

        int bestColumnNumber = Mathf.FloorToInt(verticalWalls * 0.7f);
        int pairColumnNumber = Mathf.FloorToInt(verticalWalls * 0.2f);
        int randomColumnNumber = Mathf.FloorToInt(verticalWalls * 0.1f);

        lc.AddRange (getNPositions (best.getCollum (), bestColumnNumber));
        lc.AddRange (getNPositions (pair.getCollum (), pairColumnNumber));
        lc.AddRange (getNPositonsRandom(randomColumnNumber,true));

        int bestEnemiesNumber = Mathf.FloorToInt(verticalWalls * 0.7f);
        int pairEnemiesNumber = Mathf.FloorToInt(verticalWalls * 0.2f);
        int randomEnemiesNumber = Mathf.FloorToInt(verticalWalls * 0.1f);

        le.AddRange (getNPositions (best.getEnemies (), bestEnemiesNumber));
        le.AddRange (getNPositions (pair.getEnemies (), pairEnemiesNumber));
        le.AddRange (getNPositonsRandom(randomEnemiesNumber,false));

        if (getFromBest ()) {
            pPos = best.getPlayerPos ();
        } else
        if (getFromPair ()) {
            pPos = pair.getPlayerPos ();
        } else
            pPos = getRandomBlock ();

        if (getFromBest ()) {
            fPos = best.getFinishPos ();
        } else
        if (getFromPair ()) {
            fPos = pair.getFinishPos ();
        } else
            fPos = getRandomBlock ();

        next.setPositions (pPos, fPos);

        next.setEnemies (le);

        next.setLines (lp, lc);

        currentLevel = next;

        return createAndTest ();
    }