Beispiel #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 ();
    }
Beispiel #2
0
    //TODO
    private void createSeed()
    {
        Level chosen = new Level ();
        List<int[]> lp = new List<int[]> ();
        List<int[]> lc = new List<int[]> ();
        List<int[]> le = new List<int[]> ();

        for (int i = 0; i<horizontalWalls; i++) {

            int[] randomBlock = getRandomBlock ();
            int wallsize = (int)Random.Range (wallMinSize, wallMaxSize);

            int[] aux = {randomBlock [0],randomBlock [1],wallsize};
            lp.Add (aux);

        }

        for (int i = 0; i<verticalWalls; i++) {

            int wallsize = (int)Random.Range (wallMinSize, wallMaxSize);

            int[] randomBlock = getRandomBlock ();
            int[] aux1 = {randomBlock [0],randomBlock [1],wallsize};
            lc.Add (aux1);

        }

        for (int i = 0; i<numberOfEnemies; i++) {

            int[] randomBlock = getRandomBlock ();

            int[] aux2 = {randomBlock [0],randomBlock [1]};
            le.Add (aux2);
        }

        chosen.setPositions (getRandomBlock (), getRandomBlock ());

        chosen.setEnemies (le);

        chosen.setLines (lp, lc);

        currentLevel = chosen;
    }