Example usage for com.badlogic.gdx.graphics Color BLACK

List of usage examples for com.badlogic.gdx.graphics Color BLACK

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Color BLACK.

Prototype

Color BLACK

To view the source code for com.badlogic.gdx.graphics Color BLACK.

Click Source Link

Usage

From source file:com.battleforbronze.game.Screens.WorldRenderer.java

public WorldRenderer(Player1Hand h, Player2Hand h2, HUD p1HUD, HUD p2HUD, HUD turnNew) {
    p1Health = 20;//from  w w  w.  j  a  v  a 2s  . co  m
    p2Health = 20;
    cardOnFieldP1 = 0;
    RedTilesOnMapP1 = false;
    RedTilesOnMapP2 = false;
    highLightP1 = false;
    highLightP2 = false;
    p1OnFieldCards = new Array<Card>();
    p2OnFieldCards = new Array<Card>();
    p1OnFieldXY = new Array<OnField>();
    p2OnFieldXY = new Array<OnField>();
    playerOneHUD = p1HUD;
    playerTwoHUD = p2HUD;
    checkTurn = turnNew;
    cardSelected = false;
    menutime = true;
    instructiontime = false;
    gametime = false;
    playCard = new Card();
    instructions = new Texture("instructions.png");
    menu = new Texture("menu.png");
    p1Turn = new Texture("turnP1.png");
    p2Turn = new Texture("turnP2.png");
    border = new Texture("border.png");
    manaUsed = new Texture("manaUsed.png");
    map = new TmxMapLoader().load("map.tmx");
    buttonNotPressed = new Texture("button_notpressed.png");
    buttonPressed = new Texture("button_pressed.png");
    mana = new Texture("mana.png");
    clicked = new Cell();
    afterClick = new Cell();
    checkCell = new Cell();
    placeTile = new Cell();
    deckOne = new Deck1();
    deckTwo = new Deck2();
    click = new Vector3();
    deckThree = new Deck3();
    hand = h;
    hand2 = h2;
    gameSet = map.getTileSets().getTileSet("tiles");
    path = (TiledMapTileLayer) map.getLayers().get("path");
    base = (TiledMapTileLayer) map.getLayers().get("base");
    card = new Texture("Card.png");
    font = new BitmapFont();
    HealthP1 = new BitmapFont();
    HealthP2 = new BitmapFont();
    int mapWidth = map.getProperties().get("width", Integer.class);
    int mapHeight = map.getProperties().get("height", Integer.class);

    attkNum1 = new Texture("Numbers/Attack/A1.png");
    attkNum2 = new Texture("Numbers/Attack/A2.png");
    attkNum3 = new Texture("Numbers/Attack/A3.png");
    attkNum4 = new Texture("Numbers/Attack/A4.png");
    attkNum5 = new Texture("Numbers/Attack/A5.png");
    attkNum6 = new Texture("Numbers/Attack/A6.png");
    attkNum7 = new Texture("Numbers/Attack/A7.png");
    attkNum8 = new Texture("Numbers/Attack/A8.png");
    attkNum9 = new Texture("Numbers/Attack/A9.png");

    defNum1 = new Texture("Numbers/Defence/D1.png");
    defNum2 = new Texture("Numbers/Defence/D2.png");
    defNum3 = new Texture("Numbers/Defence/D3.png");
    defNum4 = new Texture("Numbers/Defence/D4.png");
    defNum5 = new Texture("Numbers/Defence/D5.png");
    defNum6 = new Texture("Numbers/Defence/D6.png");
    defNum7 = new Texture("Numbers/Defence/D7.png");
    defNum8 = new Texture("Numbers/Defence/D8.png");
    defNum9 = new Texture("Numbers/Defence/D9.png");

    frcNum1 = new Texture("Numbers/Force/F1.png");
    frcNum2 = new Texture("Numbers/Force/F2.png");
    frcNum3 = new Texture("Numbers/Force/F3.png");
    frcNum4 = new Texture("Numbers/Force/F4.png");
    frcNum5 = new Texture("Numbers/Force/F5.png");
    frcNum6 = new Texture("Numbers/Force/F6.png");
    frcNum7 = new Texture("Numbers/Force/F7.png");
    frcNum8 = new Texture("Numbers/Force/F8.png");
    frcNum9 = new Texture("Numbers/Force/F9.png");

    font.setColor(Color.BLACK);

    //        picture = new Texture("Player1.png");
    camera = new OrthographicCamera();
    guiCam = new OrthographicCamera();
    viewport = new FitViewport(V_WIDTH * 0.5f, V_HEIGHT * 0.5f, camera);
    guiViewport = new FitViewport(V_WIDTH * 0.5f, V_HEIGHT * 0.5f, guiCam);
    batch = new SpriteBatch();
    render = new OrthogonalTiledMapRenderer(map, batch);

    // move the x position of the camera
    camera.position.x = 432 / 2;
    guiCam.position.x = V_WIDTH / 2;
    // move the y position of the camera
    camera.position.y = 0 + (592 / 4);
    guiCam.position.y = V_HEIGHT / 2;
    // update the camera
    camera.update();

    // loads in the images
    //AssetManager.load();
}

From source file:com.battleforbronze.game.Screens.WorldRenderer.java

public void render(float delta) {
    // clear the screen with black
    AudioManager.GAME_MUSIC.setVolume(0.5f);
    AudioManager.YESSIR.setVolume(0.5f);
    AudioManager.DLEGEND.setVolume(0.5f);
    AudioManager.GAME_MUSIC.play();/*from   w  ww.j  av a2s .c o m*/
    Gdx.gl20.glClearColor(0, 2, 0, 1);
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //gggg
    // update the camera
    if (gametime) {
        if (Gdx.input.isKeyPressed(Keys.A)) {
            if (camera.position.x >= 100) {
                camera.position.x = camera.position.x - 5;
            }
        }
        if (Gdx.input.isKeyPressed(Keys.D)) {
            if (camera.position.x <= 300) {
                camera.position.x = camera.position.x + 5;
            }
        }
        if (Gdx.input.isKeyPressed(Keys.W)) {
            if (camera.position.y <= 500) {
                camera.position.y = camera.position.y + 5;
            }
        }
        if (Gdx.input.isKeyPressed(Keys.S)) {
            if (camera.position.y >= 100) {
                camera.position.y = camera.position.y - 5;
            }
        }

        if (Gdx.input.isKeyJustPressed(Keys.SPACE)) {
            if (hand.canDraw()) {
                if (hand.currentHandSize() < 5) {

                    hand.draw();
                }
            }
        }
        if (Gdx.input.isKeyJustPressed(Keys.SHIFT_LEFT)) {
            if (hand.currentHandSize() > 0) {
                hand.removeFromHand();
            }
        }

        camera.update();
        guiCam.update();
        // links the renderer to the camera
        batch.setProjectionMatrix(camera.combined);
        render.setView(camera);
        render.render();
    }
    batch.setProjectionMatrix(guiCam.combined);
    // tells the renderer this is the list
    batch.begin();
    // list of things to draw
    if (menutime) {
        batch.draw(menu, 375, 224, 450, 450);
        if (Gdx.input.justTouched()) {
            AudioManager.HIT.play();
            instructiontime = true;
            menutime = false;
        }
    }
    if (instructiontime) {
        batch.draw(instructions, 375, 224, 450, 450);
        if (Gdx.input.isKeyJustPressed(Keys.ENTER)) {
            AudioManager.HIT.play();
            gametime = true;
            instructiontime = false;
        }
    }
    if (gametime) {

        int cards = 0;
        int cards2 = 0;

        for (Card c : hand.getCards()) {
            attk = c.getAttack();
            dfns = c.getDefense();
            frc = c.getForce();
            name = c.getName();
            cost = c.getCost();
            //            name = getCard.getName();
            //            attk = getCard.getAttack();
            //            cost = getCard.getCost();
            //            frc = getCard.getForce();
            //            dfns = getCard.getDefense();
            if (attk == 1) {
                attkNumFinal = attkNum1;
            }
            if (attk == 2) {
                attkNumFinal = attkNum2;
            }
            if (attk == 3) {
                attkNumFinal = attkNum3;
            }
            if (attk == 4) {
                attkNumFinal = attkNum4;
            }
            if (attk == 5) {
                attkNumFinal = attkNum5;
            }
            if (attk == 6) {
                attkNumFinal = attkNum6;
            }
            if (attk == 7) {
                attkNumFinal = attkNum7;
            }
            if (attk == 8) {
                attkNumFinal = attkNum8;
            }
            if (attk == 9) {
                attkNumFinal = attkNum9;
            }

            if (dfns == 1) {
                defNumFinal = defNum1;
            }
            if (dfns == 2) {
                defNumFinal = defNum2;
            }
            if (dfns == 3) {
                defNumFinal = defNum3;
            }
            if (dfns == 4) {
                defNumFinal = defNum4;
            }
            if (dfns == 5) {
                defNumFinal = defNum5;
            }
            if (dfns == 6) {
                defNumFinal = defNum6;
            }
            if (dfns == 7) {
                defNumFinal = defNum7;
            }
            if (dfns == 8) {
                defNumFinal = defNum8;
            }
            if (dfns == 9) {
                defNumFinal = defNum9;
            }

            if (frc == 1) {
                frcNumFinal = frcNum1;
            }
            if (frc == 2) {
                frcNumFinal = frcNum2;
            }
            if (frc == 3) {
                frcNumFinal = frcNum3;
            }
            if (frc == 4) {
                frcNumFinal = frcNum4;
            }
            if (frc == 5) {
                frcNumFinal = frcNum5;
            }
            if (frc == 6) {
                frcNumFinal = frcNum6;
            }
            if (frc == 7) {
                frcNumFinal = frcNum7;
            }
            if (frc == 8) {
                frcNumFinal = frcNum8;
            }
            if (frc == 9) {
                frcNumFinal = frcNum9;
            }
            HealthP1.setColor(Color.BLACK);
            HealthP2.setColor(Color.BLACK);
            HealthP1.draw(batch, "Player One Health : " + p1Health, 320, 280);
            HealthP1.draw(batch, "Player Two Health : " + p2Health, 735, 630);
            batch.draw(card, 810 - cards * 80, 230, 80, 120);
            batch.draw(attkNumFinal, 810 - cards * 80, 230, 80, 120);
            batch.draw(defNumFinal, 810 - cards * 80, 230, 80, 120);
            batch.draw(frcNumFinal, 810 - cards * 80, 230, 80, 120);

            //            batch.draw(picture, 740, 305, 60, 60);
            font.draw(batch, name, 820 - cards * 80, 343);
            font.draw(batch, "" + cost, 850 - cards * 80, 290);
            cards++;
        }

        for (Card b : hand2.getCards()) {
            attk = b.getAttack();
            dfns = b.getDefense();
            frc = b.getForce();
            name = b.getName();
            cost = b.getCost();
            //            name = getCard.getName();
            //            attk = getCard.getAttack();
            //            cost = getCard.getCost();
            //            frc = getCard.getForce();
            //            dfns = getCard.getDefense();
            if (attk == 1) {
                attkNumFinal = attkNum1;
            }
            if (attk == 2) {
                attkNumFinal = attkNum2;
            }
            if (attk == 3) {
                attkNumFinal = attkNum3;
            }
            if (attk == 4) {
                attkNumFinal = attkNum4;
            }
            if (attk == 5) {
                attkNumFinal = attkNum5;
            }
            if (attk == 6) {
                attkNumFinal = attkNum6;
            }
            if (attk == 7) {
                attkNumFinal = attkNum7;
            }
            if (attk == 8) {
                attkNumFinal = attkNum8;
            }
            if (attk == 9) {
                attkNumFinal = attkNum9;
            }

            if (dfns == 1) {
                defNumFinal = defNum1;
            }
            if (dfns == 2) {
                defNumFinal = defNum2;
            }
            if (dfns == 3) {
                defNumFinal = defNum3;
            }
            if (dfns == 4) {
                defNumFinal = defNum4;
            }
            if (dfns == 5) {
                defNumFinal = defNum5;
            }
            if (dfns == 6) {
                defNumFinal = defNum6;
            }
            if (dfns == 7) {
                defNumFinal = defNum7;
            }
            if (dfns == 8) {
                defNumFinal = defNum8;
            }
            if (dfns == 9) {
                defNumFinal = defNum9;
            }

            if (frc == 1) {
                frcNumFinal = frcNum1;
            }
            if (frc == 2) {
                frcNumFinal = frcNum2;
            }
            if (frc == 3) {
                frcNumFinal = frcNum3;
            }
            if (frc == 4) {
                frcNumFinal = frcNum4;
            }
            if (frc == 5) {
                frcNumFinal = frcNum5;
            }
            if (frc == 6) {
                frcNumFinal = frcNum6;
            }
            if (frc == 7) {
                frcNumFinal = frcNum7;
            }
            if (frc == 8) {
                frcNumFinal = frcNum8;
            }
            if (frc == 9) {
                frcNumFinal = frcNum9;
            }

            batch.draw(card, 310 + cards2 * 80, 550, 80, 120);
            batch.draw(attkNumFinal, 310 + cards2 * 80, 550, 80, 120);
            batch.draw(defNumFinal, 310 + cards2 * 80, 550, 80, 120);
            batch.draw(frcNumFinal, 310 + cards2 * 80, 550, 80, 120);
            //            batch.draw(picture, 740, 305, 60, 60);
            font.draw(batch, name, 320 + cards2 * 80, 663);
            font.draw(batch, "" + cost, 360 + cards2 * 80, 610);
            cards2++;
        }

        if (Gdx.input.justTouched()) {
            AudioManager.HIT.play();
            Vector3 click = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
            guiCam.unproject(click);
            if (checkTurn.getTurnValue() == true) {
                if (click.x > 810 && click.x < 890 && click.y > 230 && click.y < 350 && hand.handSize() >= 1) {
                    cardSelect = 1;
                    playCard = hand.getCard(0);
                    cardSelected = true;
                }
                if (click.x > 730 && click.x < 810 && click.y > 230 && click.y < 350 && hand.handSize() >= 2) {
                    cardSelect = 2;
                    playCard = hand.getCard(1);
                    cardSelected = true;
                }
                if (click.x > 650 && click.x < 730 && click.y > 230 && click.y < 350 && hand.handSize() >= 3) {
                    cardSelect = 3;
                    playCard = hand.getCard(2);
                    cardSelected = true;
                }
                if (click.x > 570 && click.x < 650 && click.y > 230 && click.y < 350 && hand.handSize() >= 4) {
                    cardSelect = 4;
                    playCard = hand.getCard(3);
                    cardSelected = true;
                }
                if (click.x > 490 && click.x < 570 && click.y > 230 && click.y < 350 && hand.handSize() >= 5) {
                    cardSelect = 5;
                    playCard = hand.getCard(4);
                    cardSelected = true;
                }
            } else if (checkTurn.getTurnValue() == false) {
                if (click.x > 310 && click.x < 390 && click.y > 550 && click.y < 670 && hand2.handSize() >= 1) {
                    cardSelect = 6;
                    playCard = hand2.getCard(0);
                    cardSelected = true;
                }
                if (click.x > 390 && click.x < 470 && click.y > 550 && click.y < 670 && hand2.handSize() >= 2) {
                    cardSelect = 7;
                    playCard = hand2.getCard(1);
                    cardSelected = true;
                }
                if (click.x > 470 && click.x < 550 && click.y > 550 && click.y < 670 && hand2.handSize() >= 3) {
                    cardSelect = 8;
                    playCard = hand2.getCard(2);
                    cardSelected = true;
                }
                if (click.x > 550 && click.x < 630 && click.y > 550 && click.y < 670 && hand2.handSize() >= 4) {
                    cardSelect = 9;
                    playCard = hand2.getCard(3);
                    cardSelected = true;
                }
                if (click.x > 630 && click.x < 710 && click.y > 550 && click.y < 670 && hand2.handSize() >= 5) {
                    cardSelect = 10;
                    playCard = hand2.getCard(4);
                    cardSelected = true;
                }
            }
            //                 if(click.x>325 && click.x<405 && click.y>400 && click.y<480){
            //                     lockin = true;
            //                     cardSelected = true;
            //                 }

        }

        if (cardSelect == 1) {

            batch.draw(border, 803, 225, 94, 133);
        } else if (cardSelect == 2) {

            batch.draw(border, 723, 225, 94, 133);
        } else if (cardSelect == 3) {

            batch.draw(border, 643, 225, 94, 133);
        } else if (cardSelect == 4) {

            batch.draw(border, 563, 225, 94, 133);
        } else if (cardSelect == 5) {

            batch.draw(border, 483, 225, 94, 133);
        }

        if (cardSelect == 6) {
            batch.draw(border, 303, 545, 94, 133);
        } else if (cardSelect == 7) {
            batch.draw(border, 383, 545, 94, 133);
        } else if (cardSelect == 8) {
            batch.draw(border, 463, 545, 94, 133);
        } else if (cardSelect == 9) {
            batch.draw(border, 543, 545, 94, 133);
        } else if (cardSelect == 10) {
            batch.draw(border, 623, 545, 94, 133);
        }

        if (checkTurn.getTurnValue() == true) {
            batch.draw(p1Turn, 775, 450);
        } else if (checkTurn.getTurnValue() == false) {
            batch.draw(p2Turn, 775, 450);
        }

        for (int i = 0; i < playerOneHUD.getTurnNumberP1(); i++) {
            if (playerOneHUD.getTurnNumberP1() < 10) {
                batch.draw(mana, 310 + 15 * i, 230, 20, 20);
            } else {
                for (int j = 0; j < 10; j++) {
                    batch.draw(mana, 310 + 15 * j, 230, 20, 20);
                }
            }
        }

        for (int i = 0; i < playerTwoHUD.getTurnNumberP2(); i++) {
            if (playerTwoHUD.getTurnNumberP2() < 10) {
                batch.draw(mana, 870 - 15 * i, 645, 20, 20);
            } else {
                for (int j = 0; j < 10; j++) {
                    batch.draw(mana, 870 - 15 * i, 645, 20, 20);
                }

            }

        }

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

            batch.draw(manaUsed, 310 + 15 * i, 230, 20, 20);

        }
        for (int i = 0; i < manaUsedP2; i++) {

            batch.draw(manaUsed, 870 - 15 * i, 645, 20, 20);

        }

        //playing cards
        if (checkTurn.getTurnValue() == true) {
            batch.draw(buttonNotPressed, 325, 400, 80, 80);
            if (Gdx.input.justTouched() && cardSelected == true) {
                Vector3 click = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
                guiCam.unproject(click);
                if (click.x >= 325 && click.x <= 405 && click.y >= 400 && click.y <= 480) {
                    batch.draw(buttonPressed, 325, 400, 80, 80);
                    if ((playCard.getCost() + manaUsedP1) <= playerOneHUD.getTurnNumberP1()) {
                        AudioManager.DLEGEND.play();
                        p1OnFieldCards.add(playCard);
                        p1OnFieldXY.add(new OnField(13, 2));
                        hand.played(cardSelect - 1);
                        cardSelected = false;
                        cardSelect = 0;
                        checkCell = path.getCell(13, 2);
                        checkCell.setTile(gameSet.getTile(186));
                        cardOnFieldP1++;
                        cardPlayedP1 = true;
                        manaUsedP1 += playCard.getCost();
                        //14,3 p1 first spot
                    }
                }
            }
        }
        //if they click on a card that is on the field player one
        if (Gdx.input.justTouched() && checkTurn.getTurnValue() == true && cardOnFieldP1 > 0) {
            Vector3 click = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
            camera.unproject(click);
            clicked = path.getCell((int) (click.x / (PPU - 1)), (int) (click.y / (PPU - 1)));
            int tempX = (int) (click.x / (PPU - 1));
            int tempY = (int) (click.y / (PPU - 1));
            for (int i = 0; i < p1OnFieldXY.size; i++) {
                OnField check = p1OnFieldXY.get(i);
                if (tempX == check.getX() && tempY == check.getY()) {

                    AudioManager.YESSIR.play();
                    highLightX = check.getX();
                    highLightY = check.getY();
                    clickedCard = p1OnFieldCards.get(i);
                    clickedCardCost = clickedCard.getCost();
                    //what spot in the array of OnFieldXY you clicked on
                    ClickMinionOnFieldArraySpotP1 = i;
                    if (highLightX == 13 || highLightX == 24 || highLightX == 2
                            || (highLightX == 18 && highLightY >= 18)
                            || (highLightX == 8 && highLightY <= 18)) {
                        vertical = true;
                    }
                    if (highLightY == 28 || highLightY == 18 || highLightY == 8
                            || (highLightY == 22 && highLightX >= 13)
                            || (highLightY == 14 && highLightX <= 13)) {
                        horizontal = true;
                    }

                }
            }

        }

        //draw highLighted tiles
        if (vertical == true) {
            //draw card
            attk = clickedCard.getAttack();
            dfns = clickedCard.getDefense();
            frc = clickedCard.getForce();
            name = clickedCard.getName();
            cost = clickedCard.getCost();
            batch.draw(card, 430, 370, 80, 120);
            batch.draw(attkNumFinal, 430, 370, 80, 120);
            batch.draw(defNumFinal, 430, 370, 80, 120);
            batch.draw(frcNumFinal, 430, 370, 80, 120);
            font.draw(batch, name, 440, 483);
            font.draw(batch, "" + cost, 480, 430);
            int tempF = clickedCard.getForce();
            for (int i = 1; i <= tempF; i++) {
                Cell temp = path.getCell(highLightX, highLightY + i);
                if (temp != null && temp.getTile().getId() != 186 && temp.getTile().getId() != 187
                        && temp.getTile().getId() != 205) {
                    if (temp.getTile().getId() != 186) {
                        temp.setTile(gameSet.getTile(188));
                    }
                } else if (temp != null && temp.getTile().getId() == 187) {
                    temp.setTile(gameSet.getTile(205));
                } else if (temp == null && highLightY <= 8) {
                    p2Health -= clickedCard.getAttack();
                }

            }
            RedTilesOnMapP1 = true;
        }
        if (horizontal == true) {
            attk = clickedCard.getAttack();
            dfns = clickedCard.getDefense();
            frc = clickedCard.getForce();
            name = clickedCard.getName();
            cost = clickedCard.getCost();
            batch.draw(card, 430, 370, 80, 120);
            batch.draw(attkNumFinal, 430, 370, 80, 120);
            batch.draw(defNumFinal, 430, 370, 80, 120);
            batch.draw(frcNumFinal, 430, 370, 80, 120);
            font.draw(batch, name, 440, 483);
            font.draw(batch, "" + cost, 480, 430);
            int tempF = clickedCard.getForce();
            for (int i = 1; i <= tempF; i++) {
                Cell temp = path.getCell(highLightX + i, highLightY);
                Cell temp2 = path.getCell(highLightX - i, highLightY);
                if (temp != null && temp.getTile().getId() != 186 && temp.getTile().getId() != 187
                        && temp.getTile().getId() != 205) {
                    if (temp.getTile().getId() != 186) {
                        temp.setTile(gameSet.getTile(188));
                    } else if (temp.getTile().getId() == 187) {
                        temp.setTile(gameSet.getTile(205));
                    } else if (temp != null) {
                        System.out.println("");
                    }
                }
                if (temp2 != null && temp2.getTile().getId() != 187 && temp2.getTile().getId() != 205) {
                    if (temp2.getTile().getId() != 186) {
                        temp2.setTile(gameSet.getTile(188));
                    } else if (temp2.getTile().getId() == 187) {
                        temp2.setTile(gameSet.getTile(205));
                    } else if (temp != null) {
                        System.out.println("");
                    }
                }
            }
            RedTilesOnMapP1 = true;

        }
        //if they click highlight tiles moves the minion
        //if player clicks on highLighted tile we:
        //delete all red tiles
        //delete old player tile
        //check if we are placing on an enemy minion
        //place new player tile
        //update OnFieldXYP1 array for new coords of clicked X,Y
        if (RedTilesOnMapP1 == true) {
            if (Gdx.input.justTouched()) {
                Card enemyClicked = new Card();
                Vector3 tempClick = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
                camera.unproject(tempClick);
                Cell removeMinion = path.getCell(highLightX, highLightY);
                removeMinion.setTile(gameSet.getTile(23));
                Cell tempCell = path.getCell((int) (tempClick.x / (PPU - 1)), (int) (tempClick.y / (PPU - 1)));
                if (tempCell != null) {
                    if (tempCell.getTile().getId() == 188) {
                        for (int x = 0; x <= path.getHeight(); x++) {
                            for (int y = 0; y <= path.getWidth(); y++) {
                                if (path.getCell(x, y) != null && path.getCell(x, y).getTile().getId() == 188
                                        && path.getCell(x, y).getTile().getId() != 187
                                        && path.getCell(x, y).getTile().getId() != 186) {
                                    Cell temp = path.getCell(x, y);
                                    temp.setTile(gameSet.getTile(23));
                                }
                            }
                        }

                        tempCell.setTile(gameSet.getTile(186));
                        OnField tempXY = p1OnFieldXY.get(ClickMinionOnFieldArraySpotP1);
                        int tempX = tempXY.changeX((int) (tempClick.x / (PPU - 1)));
                        int tempY = tempXY.changeY((int) (tempClick.y / (PPU - 1)));
                        p1OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP1);
                        tempXY.changeX(tempX);
                        tempXY.changeY(tempY);
                        p1OnFieldXY.insert(ClickMinionOnFieldArraySpotP1, tempXY);
                        ClickMinionOnFieldArraySpotP1 = 0;
                        horizontal = false;
                        vertical = false;
                        RedTilesOnMapP1 = false;

                        //get what minion is moving
                        //get what minion its moving onto (so get x,y and accociate with array list)
                        //get defense of p1 minion
                        //get attack of p1 minion
                        //get defense of p2 minion
                        //get attack of p2 minion 
                        // if 
                    } else if (tempCell.getTile().getId() == 205) {

                        int tempX = (int) (tempClick.x / (PPU - 1));
                        int tempY = (int) (tempClick.y / (PPU - 1));

                        for (int i = 0; i < p2OnFieldXY.size; i++) {
                            OnField check = p2OnFieldXY.get(i);
                            if (tempX == check.getX() && tempY == check.getY()) {
                                enemyClicked = p2OnFieldCards.get(i);
                                cardDestroyedP2 = i;
                            }

                        }

                        //if the clicked card is better in attack and does not die from defense
                        if (clickedCard.getAttack() > enemyClicked.getDefense()
                                && enemyClicked.getAttack() < clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(186));
                            p2OnFieldXY.removeIndex(cardDestroyedP2);
                            OnField tempXY = p1OnFieldXY.get(ClickMinionOnFieldArraySpotP1);
                            int tempX2 = tempXY.changeX((int) (tempClick.x / (PPU - 1)));
                            int tempY2 = tempXY.changeY((int) (tempClick.y / (PPU - 1)));
                            p1OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP1);
                            tempXY.changeX(tempX2);
                            tempXY.changeY(tempY2);
                            p1OnFieldXY.insert(ClickMinionOnFieldArraySpotP1, tempXY);
                            ClickMinionOnFieldArraySpotP1 = 0;
                            horizontal = false;
                            vertical = false;
                            RedTilesOnMapP1 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card's attack is greater than enemy and enemy attack is bigger than clicked card defense
                        else if (clickedCard.getAttack() > enemyClicked.getDefense()
                                && enemyClicked.getAttack() > clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(23));
                            p2OnFieldXY.removeIndex(cardDestroyedP2);
                            p1OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP1);
                            ClickMinionOnFieldArraySpotP1 = 0;
                            horizontal = false;
                            vertical = false;
                            RedTilesOnMapP1 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card attk is less than and enemy attack is greater, clicked card loses
                        else if (clickedCard.getAttack() < enemyClicked.getDefense()
                                && enemyClicked.getAttack() > clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(187));
                            p1OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP1);
                            ClickMinionOnFieldArraySpotP1 = 0;
                            horizontal = false;
                            vertical = false;
                            RedTilesOnMapP1 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card's attk is less than enemy def and emeny attk is less than clicked card def, nothing happens
                        else if (clickedCard.getAttack() < enemyClicked.getDefense()
                                && enemyClicked.getAttack() < clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(187));
                            OnField tempXY = p1OnFieldXY.get(ClickMinionOnFieldArraySpotP1);
                            int x1 = tempXY.getX();
                            int y1 = tempXY.getY();
                            Cell oldMinion = path.getCell(x1, y1);
                            oldMinion.setTile(gameSet.getTile(186));
                            ClickMinionOnFieldArraySpotP1 = 0;
                            horizontal = false;
                            vertical = false;
                            RedTilesOnMapP1 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        }

                    }

                }
            }

        }

        if (checkTurn.getTurnValue() == false) {
            batch.draw(buttonNotPressed, 325, 400, 80, 80);
            if (Gdx.input.justTouched() && cardSelected == true) {
                Vector3 click = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
                guiCam.unproject(click);
                if (click.x >= 325 && click.x <= 405 && click.y >= 400 && click.y <= 480) {
                    batch.draw(buttonPressed, 325, 400, 80, 80);
                    if ((playCard.getCost() + manaUsedP2) <= playerTwoHUD.getTurnNumberP2()) {
                        AudioManager.DLEGEND.play();
                        p2OnFieldCards.add(playCard);
                        p2OnFieldXY.add(new OnField(13, 18));
                        hand2.played(cardSelect - 6);
                        cardSelected = false;
                        cardSelect = 0;
                        checkCell = path.getCell(13, 18);
                        checkCell.setTile(gameSet.getTile(187));
                        cardOnFieldP2++;
                        manaUsedP2 += playCard.getCost();
                        //14,3 p1 first spot
                    }
                }
            }
        }
        //if they click on a card that is on the field, player two
        if (Gdx.input.justTouched() && checkTurn.getTurnValue() == false && cardOnFieldP2 > 0) {
            Vector3 click = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
            camera.unproject(click);
            clicked = path.getCell((int) (click.x / (PPU - 1)), (int) (click.y / (PPU - 1)));
            int tempX = (int) (click.x / (PPU - 1));
            int tempY = (int) (click.y / (PPU - 1));
            for (int i = 0; i < p2OnFieldXY.size; i++) {
                OnField check = p2OnFieldXY.get(i);
                if (tempX == check.getX() && tempY == check.getY()) {

                    AudioManager.YESSIR.play();
                    highLightX = check.getX();
                    highLightY = check.getY();
                    clickedCard = p2OnFieldCards.get(i);
                    clickedCardCost = clickedCard.getCost();
                    //what spot in the array of OnFieldXY you clicked on
                    ClickMinionOnFieldArraySpotP2 = i;
                    if (highLightX == 13 || highLightX == 24 || highLightX == 2
                            || (highLightX == 18 && highLightY >= 18)
                            || (highLightX == 8 && highLightY <= 18)) {
                        vertical2 = true;
                    }
                    if (highLightY == 28 || highLightY == 18 || highLightY == 8
                            || (highLightY == 22 && highLightX >= 13)
                            || (highLightY == 14 && highLightX <= 13)) {
                        horizontal2 = true;
                    }

                }
            }
        }
        if (vertical2 == true) {
            attk = clickedCard.getAttack();
            dfns = clickedCard.getDefense();
            frc = clickedCard.getForce();
            name = clickedCard.getName();
            cost = clickedCard.getCost();
            batch.draw(card, 430, 370, 80, 120);
            batch.draw(attkNumFinal, 430, 370, 80, 120);
            batch.draw(defNumFinal, 430, 370, 80, 120);
            batch.draw(frcNumFinal, 430, 370, 80, 120);
            font.draw(batch, name, 440, 483);
            font.draw(batch, "" + cost, 480, 430);
            int tempF = clickedCard.getForce();
            for (int i = 1; i <= tempF; i++) {
                Cell temp = path.getCell(highLightX, highLightY - i);
                if (temp != null && temp.getTile().getId() != 187 && temp.getTile().getId() != 186
                        && temp.getTile().getId() != 205) {
                    if (temp.getTile().getId() != 187) {
                        temp.setTile(gameSet.getTile(188));
                    }
                } else if (temp != null && temp.getTile().getId() == 186) {
                    temp.setTile(gameSet.getTile(205));
                } else if (temp == null && highLightY >= 28) {
                    p1Health -= clickedCard.getAttack();
                }
            }
            RedTilesOnMapP2 = true;
        }
        //draw highLighted tiles
        if (horizontal2 == true) {
            attk = clickedCard.getAttack();
            dfns = clickedCard.getDefense();
            frc = clickedCard.getForce();
            name = clickedCard.getName();
            cost = clickedCard.getCost();
            batch.draw(card, 430, 370, 80, 120);
            batch.draw(attkNumFinal, 430, 370, 80, 120);
            batch.draw(defNumFinal, 430, 370, 80, 120);
            batch.draw(frcNumFinal, 430, 370, 80, 120);
            font.draw(batch, name, 440, 483);
            font.draw(batch, "" + cost, 480, 430);
            int tempF = clickedCard.getForce();
            for (int i = 1; i <= tempF; i++) {
                Cell temp = path.getCell(highLightX + i, highLightY);
                Cell temp2 = path.getCell(highLightX - i, highLightY);
                if (temp != null && temp.getTile().getId() != 186 && temp.getTile().getId() != 187
                        && temp.getTile().getId() != 205) {
                    if (temp.getTile().getId() != 186) {
                        temp.setTile(gameSet.getTile(188));
                    } else if (temp.getTile().getId() == 186) {
                        temp.setTile(gameSet.getTile(205));
                    }
                }
                if (temp2 != null && temp2.getTile().getId() != 187 && temp2.getTile().getId() != 205) {
                    if (temp2.getTile().getId() != 186) {
                        temp2.setTile(gameSet.getTile(188));
                    } else if (temp2.getTile().getId() == 186) {
                        temp2.setTile(gameSet.getTile(205));
                    }
                }
            }
            RedTilesOnMapP2 = true;

        }
        //if they click highlight tiles moves the minion
        //if player clicks on highLighted tile we:
        //delete all red tiles
        //delete old player tile
        //place new player tile
        //update OnFieldXYP1 array for new coords of clicked X,Y
        if (RedTilesOnMapP2 == true) {
            if (Gdx.input.justTouched()) {
                Vector3 tempClick = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
                Card enemyClicked2 = new Card();
                camera.unproject(tempClick);
                Cell removeMinion = path.getCell(highLightX, highLightY);
                removeMinion.setTile(gameSet.getTile(23));
                Cell tempCell = path.getCell((int) (tempClick.x / (PPU - 1)), (int) (tempClick.y / (PPU - 1)));
                if (tempCell != null) {
                    if (tempCell.getTile().getId() == 188) {
                        for (int x = 0; x < path.getHeight(); x++) {
                            for (int y = 0; y < path.getWidth(); y++) {
                                if (path.getCell(x, y) != null && path.getCell(x, y).getTile().getId() == 188) {
                                    Cell temp = path.getCell(x, y);
                                    temp.setTile(gameSet.getTile(23));
                                }
                            }
                        }

                        tempCell.setTile(gameSet.getTile(187));
                        OnField tempXY = p2OnFieldXY.get(ClickMinionOnFieldArraySpotP2);
                        int tempX = tempXY.changeX((int) (tempClick.x / (PPU - 1)));
                        int tempY = tempXY.changeY((int) (tempClick.y / (PPU - 1)));
                        p2OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP2);
                        tempXY.changeX(tempX);
                        tempXY.changeY(tempY);
                        p2OnFieldXY.insert(ClickMinionOnFieldArraySpotP2, tempXY);
                        ClickMinionOnFieldArraySpotP2 = 0;
                        horizontal2 = false;
                        vertical2 = false;
                        RedTilesOnMapP2 = false;

                    } else if (tempCell.getTile().getId() == 205) {

                        int tempX = (int) (tempClick.x / (PPU - 1));
                        int tempY = (int) (tempClick.y / (PPU - 1));

                        for (int i = 0; i < p1OnFieldXY.size; i++) {
                            OnField check = p1OnFieldXY.get(i);
                            if (tempX == check.getX() && tempY == check.getY()) {
                                enemyClicked2 = p1OnFieldCards.get(i);
                                cardDestroyedP1 = i;
                            }

                        }

                        //if the clicked card is better in attack and does not die from defense
                        if (clickedCard.getAttack() > enemyClicked2.getDefense()
                                && enemyClicked2.getAttack() < clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(187));
                            p1OnFieldXY.removeIndex(cardDestroyedP1);
                            OnField tempXY = p2OnFieldXY.get(ClickMinionOnFieldArraySpotP2);
                            int tempX2 = tempXY.changeX((int) (tempClick.x / (PPU - 1)));
                            int tempY2 = tempXY.changeY((int) (tempClick.y / (PPU - 1)));
                            p2OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP2);
                            tempXY.changeX(tempX2);
                            tempXY.changeY(tempY2);
                            p2OnFieldXY.insert(ClickMinionOnFieldArraySpotP2, tempXY);
                            ClickMinionOnFieldArraySpotP2 = 0;
                            horizontal2 = false;
                            vertical2 = false;
                            RedTilesOnMapP2 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card's attack is greater than enemy and enemy attack is bigger than clicked card defense
                        else if (clickedCard.getAttack() > enemyClicked2.getDefense()
                                && enemyClicked2.getAttack() > clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(23));
                            p1OnFieldXY.removeIndex(cardDestroyedP1);
                            p2OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP2);
                            ClickMinionOnFieldArraySpotP2 = 0;
                            horizontal2 = false;
                            vertical2 = false;
                            RedTilesOnMapP2 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card attk is less than and enemy attack is greater, clicked card loses
                        else if (clickedCard.getAttack() < enemyClicked2.getDefense()
                                && enemyClicked2.getAttack() > clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(186));
                            p2OnFieldXY.removeIndex(ClickMinionOnFieldArraySpotP2);
                            ClickMinionOnFieldArraySpotP2 = 0;
                            horizontal2 = false;
                            vertical2 = false;
                            RedTilesOnMapP2 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        } //if clicked card's attk is less than enemy def and emeny attk is less than clicked card def, nothing happens
                        else if (clickedCard.getAttack() < enemyClicked2.getDefense()
                                && enemyClicked2.getAttack() < clickedCard.getDefense()) {
                            tempCell.setTile(gameSet.getTile(186));
                            OnField tempXY = p2OnFieldXY.get(ClickMinionOnFieldArraySpotP2);
                            int x1 = tempXY.getX();
                            int y1 = tempXY.getY();
                            Cell oldMinion = path.getCell(x1, y1);
                            oldMinion.setTile(gameSet.getTile(187));
                            ClickMinionOnFieldArraySpotP2 = 0;
                            horizontal2 = false;
                            vertical2 = false;
                            RedTilesOnMapP2 = false;
                            for (int x = 0; x <= path.getHeight(); x++) {
                                for (int y = 0; y <= path.getWidth(); y++) {
                                    if (path.getCell(x, y) != null
                                            && path.getCell(x, y).getTile().getId() == 188
                                            && path.getCell(x, y).getTile().getId() != 187
                                            && path.getCell(x, y).getTile().getId() != 186) {
                                        Cell temp = path.getCell(x, y);
                                        temp.setTile(gameSet.getTile(23));
                                    }
                                }
                            }
                        }

                    }

                }
            }

        }
    }

    // finished listing things to draw
    batch.end();
}

From source file:com.binarytenshi.nopassing.core.SplineHandler.java

public static void drawSplines() {
    shaper.setProjectionMatrix(CameraHandler.getCamera().combined);
    shaper.setColor(Color.GRAY);/*from  ww w . j av a 2  s  .c o m*/
    for (Spline spline : splines) {
        drawSpline(spline);
    }

    shaper.setColor(Color.BLACK);
    if (currentSpline != null) {
        drawSpline(currentSpline);
    }
}

From source file:com.blackboxgaming.engine.factories.LayerFactory.java

public static Layer createLevelAndHealthLayer() {
    Stage stage = new Stage(new StretchViewport(486, 864));
    Skin skin = new Skin();
    Table table = new Table();
    table.top().pad(10);/*from   w  w  w .j  av a  2s .c  om*/

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
            Gdx.files.internal("ui/fonts/Century Gothic Bold.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 40;
    parameter.borderColor = Color.BLACK;
    parameter.borderWidth = 3;
    BitmapFont font = generator.generateFont(parameter);
    generator.dispose();
    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);

    skin.add("star", new Texture("ui/icons/star.png"));
    skin.add("shield", new Texture("ui/icons/shield.png"));
    skin.add("brick", new Texture("ui/icons/brick.png"));
    skin.add("swipe128", new Texture("ui/icons/swipe128.png"));

    float padding = 10;
    Image icon = new Image(skin.getDrawable("star"));
    if (Global.debugLevelUp) {
        icon.addListener(new ClickListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                if (Engine.systemManager.has(LevelProgressionSystem.class)) {
                    for (Entity entity : Engine.systemManager.get(LevelProgressionSystem.class).entities) {
                        Engine.garbageManager.markForDeletion(entity);
                    }
                }
                super.touchUp(event, x, y, pointer, button);
            }
        });
    }
    table.add(icon).pad(padding);
    Label levelLabel = new Label("", labelStyle);
    table.add(levelLabel).pad(padding);
    icon = new Image(skin.getDrawable("shield"));
    table.add(icon).pad(padding);
    Label healthLabel = new Label("", labelStyle);
    table.add(healthLabel).pad(padding);
    icon = new Image(skin.getDrawable("brick"));
    table.add(icon).pad(padding);
    Label brickLabel = new Label("", labelStyle);
    table.add(brickLabel).pad(padding);

    table.row();

    // swipe
    if (Engine.systemManager.has(LevelProgressionSystem.class)) {
        if (Engine.systemManager.get(LevelProgressionSystem.class).level < 5) {
            icon = new Image(skin.getDrawable("swipe128"));
            table.add(icon).padTop(350).colspan(6);
            Global.swipeIcon = icon;

        }
    }

    //        table.setDebug(true);
    table.setFillParent(true);
    stage.addActor(table);

    Global.LEVEL_LABEL = levelLabel;
    Global.HEALTH_LABEL = healthLabel;
    Global.BRICK_LABEL = brickLabel;

    if (Engine.systemManager.has(LevelProgressionSystem.class)) {
        Global.LEVEL_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).level);
        Global.HEALTH_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).health);
        Global.BRICK_LABEL.setText("" + Engine.systemManager.get(LevelProgressionSystem.class).nrOfBricks);
    }

    Engine.inputManager.add(stage);
    return new Layer("topLayer", stage, table);
}

From source file:com.bladecoder.engine.actions.Param.java

License:Apache License

public static Color parseColor(String color) {
    if (color == null || color.trim().isEmpty()) {
        return null; // the default color in the style will be used
    }//  w  w w  .j  ava  2  s.c  o m

    switch (color.trim()) {
    case "black":
        return Color.BLACK;
    case "white":
        return Color.WHITE;
    default:
        return Color.valueOf(color);
    }
}

From source file:com.bladecoder.engine.ui.defaults.DefaultSceneScreen.java

License:Apache License

private void drawDebugText(SpriteBatch batch) {
    World w = World.getInstance();/*from   w w w  .ja  v  a2s .co  m*/

    w.getSceneCamera().getInputUnProject(viewport, unprojectTmp);

    Color color;

    sbTmp.setLength(0);

    if (EngineLogger.lastError != null) {
        sbTmp.append(EngineLogger.lastError);

        color = Color.RED;
    } else {

        sbTmp.append("( ");
        sbTmp.append((int) unprojectTmp.x);
        sbTmp.append(", ");
        sbTmp.append((int) unprojectTmp.y);
        sbTmp.append(") FPS:");
        sbTmp.append(Gdx.graphics.getFramesPerSecond());
        // sbTmp.append(" Density:");
        // sbTmp.append(Gdx.graphics.getDensity());
        // sbTmp.append(" UI Multiplier:");
        // sbTmp.append(DPIUtils.getSizeMultiplier());
        sbTmp.append(" UI STATE: ");
        sbTmp.append(state.toString());
        sbTmp.append(' ');

        long millis = w.getTimeOfGame();
        long second = (millis / 1000) % 60;
        long minute = (millis / (1000 * 60)) % 60;
        long hour = (millis / (1000 * 60 * 60));

        String time = String.format("%02d:%02d:%02d", hour, minute, second);

        sbTmp.append(time);

        //         if (w.getCurrentScene().getPlayer() != null) {
        //            sbTmp.append(" Depth Scl: ");
        //            sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
        //         }

        color = Color.WHITE;
    }

    String strDebug = sbTmp.toString();

    textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, viewport.getScreenWidth(), Align.left,
            true);
    RectangleRenderer.draw(batch, 0, viewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
            textLayout.height + 10, Color.BLACK);
    ui.getSkin().getFont("debug").draw(batch, textLayout, 0, viewport.getScreenHeight() - 5);

    // Draw actor states when debug
    if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

        for (BaseActor a : w.getCurrentScene().getActors().values()) {

            if (a instanceof AnchorActor)
                continue;

            Rectangle r = a.getBBox().getBoundingRectangle();
            sbTmp.setLength(0);
            sbTmp.append(a.getId());
            if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
                sbTmp.append(".").append(((InteractiveActor) a).getState());

            unprojectTmp.set(r.getX(), r.getY(), 0);
            w.getSceneCamera().scene2screen(viewport, unprojectTmp);
            ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
        }

    }
}

From source file:com.bladecoder.engine.ui.defaults.DefaultSceneScreen.java

License:Apache License

private void drawHotspots(SpriteBatch batch) {
    final World world = World.getInstance();
    for (BaseActor a : world.getCurrentScene().getActors().values()) {
        if (!(a instanceof InteractiveActor) || !a.isVisible() || a == world.getCurrentScene().getPlayer())
            continue;

        InteractiveActor ia = (InteractiveActor) a;

        if (!ia.canInteract())
            continue;

        Polygon p = a.getBBox();//  w ww  .  j  a  v  a  2 s . co  m

        if (p == null) {
            EngineLogger.error("ERROR DRAWING HOTSPOT FOR: " + a.getId());
        }

        Rectangle r = a.getBBox().getBoundingRectangle();

        unprojectTmp.set(r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2, 0);
        world.getSceneCamera().scene2screen(viewport, unprojectTmp);

        if (!showDesc || ia.getDesc() == null) {

            float size = DPIUtils.ICON_SIZE * DPIUtils.getSizeMultiplier();

            if (ia.getVerb("leave") != null) {
                TextureRegionDrawable drawable = (TextureRegionDrawable) getUI().getSkin().getDrawable("leave");

                // drawable.draw(batch, unprojectTmp.x - size / 2,
                // unprojectTmp.y - size / 2, size, size);

                drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size / 2, size / 2,
                        size, size, 1.0f, 1.0f, calcLeaveArrowRotation(ia));
            } else {
                Drawable drawable = ((TextureRegionDrawable) getUI().getSkin().getDrawable("hotspot"))
                        .tint(Color.RED);

                drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size, size);
            }
        } else {
            BitmapFont font = getUI().getSkin().getFont("desc");
            String desc = ia.getDesc();
            if (desc.charAt(0) == I18N.PREFIX)
                desc = I18N.getString(desc.substring(1));

            textLayout.setText(font, desc);

            float textX = unprojectTmp.x - textLayout.width / 2;
            float textY = unprojectTmp.y + textLayout.height;

            RectangleRenderer.draw(batch, textX - 8, textY - textLayout.height - 8, textLayout.width + 16,
                    textLayout.height + 16, Color.BLACK);
            font.draw(batch, textLayout, textX, textY);
        }
    }
}

From source file:com.bladecoder.engine.ui.defaults.ScenePointer.java

License:Apache License

public void draw(SpriteBatch batch, Viewport v) {

    getInputUnproject(v, mousepos);/* w w w .ja  va  2s  .c o  m*/

    boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);

    // DRAW TARGET DESCRIPTION
    if (desc != null && (!multiTouch || Gdx.input.isTouched())) {
        float margin = DPIUtils.UI_SPACE;

        float textX = mousepos.x - layout.width / 2;
        float textY = mousepos.y + layout.height + DPIUtils.UI_SPACE + DPIUtils.getTouchMinSize();

        if (textX < 0)
            textX = 0;

        RectangleRenderer.draw(batch, textX - margin, textY - layout.height - margin, layout.width + margin * 2,
                layout.height + margin * 2, Color.BLACK);
        font.draw(batch, layout, textX, textY);
    }

    if (draggingRenderer == null) {
        if (!multiTouch || currentIcon == leaveIcon) {

            batch.draw(currentIcon, mousepos.x - currentIcon.getRegionWidth() / 2,
                    mousepos.y - currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth() / 2,
                    currentIcon.getRegionHeight() / 2, currentIcon.getRegionWidth(),
                    currentIcon.getRegionHeight(), pointerScale, pointerScale,
                    currentIcon == leaveIcon ? leaveRotation : 0);
        }
    } else {
        float h = (draggingRenderer.getHeight() > draggingRenderer.getWidth() ? draggingRenderer.getHeight()
                : draggingRenderer.getWidth());
        float size = DPIUtils.getTouchMinSize() / h * 1.8f;

        if (currentIcon != hotspotIcon) {
            batch.setColor(DRAG_NOT_HOTSPOT_COLOR);
        }

        draggingRenderer.draw(batch, mousepos.x, mousepos.y - draggingRenderer.getHeight() * size / 2, size);

        if (currentIcon != hotspotIcon) {
            batch.setColor(Color.WHITE);
        }
    }
}

From source file:com.bladecoder.engine.ui.PieMenu.java

License:Apache License

@Override
public void draw(Batch batch, float alpha) {

    super.draw(batch, alpha);

    // DRAW TARGET DESCRIPTION
    String desc = iActor.getDesc();

    if (desc != null) {
        float margin = DPIUtils.UI_SPACE;

        float textX = x - layout.width / 2;
        float textY = y - layout.height - DPIUtils.UI_SPACE;

        if (textX < 0)
            textX = 0;// www  .  j  a v a2 s .  c om

        RectangleRenderer.draw(batch, textX - margin, textY - layout.height - margin, layout.width + margin * 2,
                layout.height + margin * 2, Color.BLACK);
        font.draw(batch, layout, textX, textY);
    }
}

From source file:com.bladecoder.engine.ui.retro.RetroSceneScreen.java

License:Apache License

private void drawDebugText(SpriteBatch batch) {
    World w = World.getInstance();/* www . j  a v  a 2s  .  com*/

    w.getSceneCamera().getInputUnProject(worldViewport, unprojectTmp);

    Color color;

    sbTmp.setLength(0);

    if (EngineLogger.lastError != null) {
        sbTmp.append(EngineLogger.lastError);

        color = Color.RED;
    } else {

        sbTmp.append("( ");
        sbTmp.append((int) unprojectTmp.x);
        sbTmp.append(", ");
        sbTmp.append((int) unprojectTmp.y);
        sbTmp.append(") FPS:");
        sbTmp.append(Gdx.graphics.getFramesPerSecond());
        // sbTmp.append(" Density:");
        // sbTmp.append(Gdx.graphics.getDensity());
        // sbTmp.append(" UI Multiplier:");
        // sbTmp.append(DPIUtils.getSizeMultiplier());
        sbTmp.append(" UI STATE: ");
        sbTmp.append(state.toString());

        if (w.getCurrentScene().getPlayer() != null) {
            sbTmp.append(" Depth Scl: ");
            sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
        }

        color = Color.WHITE;
    }

    String strDebug = sbTmp.toString();

    textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, worldViewport.getScreenWidth(),
            Align.left, true);

    RectangleRenderer.draw(batch, 0, worldViewport.getScreenHeight() - textLayout.height - 10, textLayout.width,
            textLayout.height + 10, Color.BLACK);
    ui.getSkin().getFont("debug").draw(batch, textLayout, 0, worldViewport.getScreenHeight() - 5);

    // Draw actor states when debug
    if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {

        for (BaseActor a : w.getCurrentScene().getActors().values()) {
            Rectangle r = a.getBBox().getBoundingRectangle();
            sbTmp.setLength(0);
            sbTmp.append(a.getId());
            if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
                sbTmp.append(".").append(((InteractiveActor) a).getState());

            unprojectTmp.set(r.getX(), r.getY(), 0);
            w.getSceneCamera().scene2screen(worldViewport, unprojectTmp);

            if (w.getInventory().isVisible()) {
                // unprojectTmp.y += verbUI.getHeight();
            }

            ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
        }

    }
}