package com.lucasdnd.ags.gameplay; import org.newdawn.slick.Color; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.StateBasedGame; public class Chair { private float x; // Sum of xPos, xOffset and xSpriteOffset private float y; // Sum of yPos, yOffset and ySpriteOffset private int xTile; // Z rendering order private int yTile; // Z rendering order private Customer character; // The Character currently sitting on it, if any private Image[] chairImages; // The Sprite private Color color; // The color (for the alpha) protected Chair() throws SlickException { chairImages = new Image[4]; for(int i = 0; i < chairImages.length; i++) { chairImages[i] = new Image("./res/img/chairs/chair" + (i + 1) + ".png"); chairImages[i].setFilter(Image.FILTER_NEAREST); } } /** * Rendering is called in the Main State * @param container * @param game * @param g * @param facingDirection * @param isBeingMoved */ public void render(GameContainer container, StateBasedGame game, Graphics g, int facingDirection, boolean isBeingMoved) { // Empty chair if(character == null || character.getState() != Customer.PLAYING) { if(facingDirection == Entity.DOWN_RIGHT) { if(isBeingMoved) { g.drawImage(chairImages[Entity.UP_LEFT], x, y, new Color(255, 255, 255, 0.5f)); } else { g.drawImage(chairImages[Entity.UP_LEFT], x, y); } } else if(facingDirection == Entity.DOWN_LEFT) { if(isBeingMoved) { g.drawImage(chairImages[Entity.UP_RIGHT], x, y, new Color(255, 255, 255, 0.5f)); } else { g.drawImage(chairImages[Entity.UP_RIGHT], x, y); } } else if(facingDirection == Entity.UP_LEFT) { if(isBeingMoved) { g.drawImage(chairImages[Entity.DOWN_RIGHT], x, y, new Color(255, 255, 255, 0.5f)); } else { g.drawImage(chairImages[Entity.DOWN_RIGHT], x, y); } } else {//(facingDirection == Entity.UP_RIGHT) if(isBeingMoved) { g.drawImage(chairImages[Entity.DOWN_LEFT], x, y, new Color(255, 255, 255, 0.5f)); } else { g.drawImage(chairImages[Entity.DOWN_LEFT], x, y); } } } else if(character.getState() == Customer.PLAYING) { // In this case, the Chair has an user AND it's playing. We need to print that fucker here if(facingDirection == Entity.DOWN_RIGHT) { g.drawImage(character.getPlayingSprites()[Entity.UP_LEFT], x - 2f, y - 5f); } else if(facingDirection == Entity.DOWN_LEFT) { g.drawImage(character.getPlayingSprites()[Entity.UP_RIGHT], x - 1f, y - 5f); } else if(facingDirection == Entity.UP_LEFT) { g.drawImage(character.getPlayingSprites()[Entity.DOWN_RIGHT], x - 1f, y - 4f); } else { // if(facingDirection == Entity.UP_RIGHT) { g.drawImage(character.getPlayingSprites()[Entity.DOWN_LEFT], x - 1f, y - 4f); } } } public Customer getCharacter() { return character; } public void setCharacter(Customer character) { this.character = character; } public float getX() { return x; } public void setX(float x) { this.x = x; } public float getY() { return y; } public void setY(float y) { this.y = y; } public Color getColor() { return color; } public void setColor(Color color) { this.color = color; } public int getxTile() { return xTile; } public void setxTile(int xTile) { this.xTile = xTile; } public int getyTile() { return yTile; } public void setyTile(int yTile) { this.yTile = yTile; } }