Search in sources :

Example 1 with TeleportCase

use of src.model.board.TeleportCase in project Labyrinthe3d by FauconFan.

the class ContentMazeFactory method initiateSpecialCases.

public void initiateSpecialCases(boolean genStart, boolean genEnd) {
    ArrayList<Point> oldPoints;
    ArrayList<RectInMaze> li;
    RectInMaze rim;
    Random ran;
    int x;
    int y;
    int max;
    Point tmp;
    Point tmp2;
    ran = new Random();
    li = this.mazeDim.getListRectMaze();
    oldPoints = new ArrayList<>();
    if (genStart) {
        tmp = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new StartCase(tmp.x, tmp.y));
    }
    if (genEnd) {
        tmp = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new EndCase(tmp.x, tmp.y));
    }
    max = 0;
    if (this.mazeDim.size() >= 200) {
        max = 3;
    } else if (this.mazeDim.size() >= 100) {
        max = 2;
    }
    for (int i = 0; i < max; i++) {
        tmp = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new SpeedCase(tmp.x, tmp.y, 0.5f));
        tmp = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new TimeCase(tmp.x, tmp.y, 1000));
        tmp = this.genRandomPoint(ran, li, oldPoints);
        tmp2 = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new TeleportCase(tmp.x, tmp.y, tmp2.x, tmp2.y));
        tmp = this.genRandomPoint(ran, li, oldPoints);
        this.contentSpecialCases.add(new JumpCase(tmp.x, tmp.y, 0.05f));
    }
}
Also used : JumpCase(src.model.board.JumpCase) StartCase(src.model.board.StartCase) EndCase(src.model.board.EndCase) Random(java.util.Random) SpeedCase(src.model.board.SpeedCase) RectInMaze(src.model.MazeDimension.RectInMaze) TeleportCase(src.model.board.TeleportCase) TimeCase(src.model.board.TimeCase)

Example 2 with TeleportCase

use of src.model.board.TeleportCase in project Labyrinthe3d by FauconFan.

the class MainMaze method actionCase.

public void actionCase() {
    // TODO to change actually
    for (Case c : cm[current_level].getSpecialCases()) {
        if (this.p.playerInCase(c)) {
            switch(c.type) {
                case END:
                    this.p.setWin(true);
                    break;
                case TELEPORT:
                    this.p.setPosX(((TeleportCase) c).getXDest() + 0.5f);
                    this.p.setPosY(((TeleportCase) c).getYDest() + 0.5f);
                    break;
                case SPEED:
                    if (!((SpeedCase) c).isActivated()) {
                        ((SpeedCase) c).activate();
                        this.p.setSpeed(((SpeedCase) c).getSpeedModif() * this.p.getSpeed());
                    }
                    break;
                case TIME:
                    if (!((TimeCase) c).isActivated()) {
                        ((TimeCase) c).activate();
                        p.updateTime(((TimeCase) c).getTimeMillis());
                    }
                    break;
                case JUMP:
                    this.p.setVelocityZ(0.05f);
            }
        }
    }
}
Also used : SpeedCase(src.model.board.SpeedCase) TeleportCase(src.model.board.TeleportCase) TimeCase(src.model.board.TimeCase) TimeCase(src.model.board.TimeCase) JumpCase(src.model.board.JumpCase) Case(src.model.board.Case) SpeedCase(src.model.board.SpeedCase) TeleportCase(src.model.board.TeleportCase)

Aggregations

JumpCase (src.model.board.JumpCase)2 SpeedCase (src.model.board.SpeedCase)2 TeleportCase (src.model.board.TeleportCase)2 TimeCase (src.model.board.TimeCase)2 Random (java.util.Random)1 RectInMaze (src.model.MazeDimension.RectInMaze)1 Case (src.model.board.Case)1 EndCase (src.model.board.EndCase)1 StartCase (src.model.board.StartCase)1