ch.sahits.game.graphic.display.gameplay
Class MainView

java.lang.Object
  extended by ch.sahits.game.rendering.AbstractRenderPart
      extended by ch.sahits.game.graphic.display.gameplay.MainView
All Implemented Interfaces:
ch.sahits.game.event.IEventListener, ch.sahits.game.rendering.Renderable, ch.sahits.game.rendering.RenderablePart

public class MainView
extends ch.sahits.game.rendering.AbstractRenderPart
implements ch.sahits.game.event.IEventListener

This represents the main game screen

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 30, 2011

Field Summary
private  CityPlayerProxy city
          Model of the city currently displayed.
private  OpenPatricianGameDialog dialog
           
private  double dialogScale
          Scale of the dialog
private static String[] imageNames
           
private  BufferedImage img
          This image holds the background of the currently rendered View
private  ch.sahits.game.graphic.image.ImagesLoader loader
           
private static String[] polyNames
           
private static byte PORT_SCENE
          Indicate that currently the port scene is displayed
private  Map<Integer,NamedPolygon> portPolygons
          Store the polygons for checking against clicking them Using a TreeMap so it may be possible do define polygons that cover the same are but in a different z-order.
private  byte viewState
          Use low level byte to indicate what is displayed instead of an enum.
 
Fields inherited from class ch.sahits.game.rendering.AbstractRenderPart
rect
 
Constructor Summary
MainView(Rectangle rect, ch.sahits.game.graphic.image.ImagesLoader loader, ch.sahits.game.openpatrician.client.IClient cl)
          Instantiate the main view with the port scene of the players home town
 
Method Summary
private  String findPolygon(int x, int y)
          Find the polygon name that contains the coordinates.
 void gameRender(Graphics gScr)
           
 void gameUpdate(ch.sahits.game.event.Event e, Object eventNotice)
           
private  void initPortPolygons(double scale, Rectangle bounds)
          Setting the positions of the polygons on the screen
private  void resetDialog()
          Scale the dialog so it has the correct proportions
 
Methods inherited from class ch.sahits.game.rendering.AbstractRenderPart
getBounds, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

img

private final BufferedImage img
This image holds the background of the currently rendered View


dialog

private OpenPatricianGameDialog dialog

dialogScale

private final double dialogScale
Scale of the dialog


polyNames

private static final String[] polyNames

imageNames

private static final String[] imageNames

loader

private final ch.sahits.game.graphic.image.ImagesLoader loader

portPolygons

private Map<Integer,NamedPolygon> portPolygons
Store the polygons for checking against clicking them Using a TreeMap so it may be possible do define polygons that cover the same are but in a different z-order.


PORT_SCENE

private static final byte PORT_SCENE
Indicate that currently the port scene is displayed

See Also:
Constant Field Values

viewState

private byte viewState
Use low level byte to indicate what is displayed instead of an enum.


city

private CityPlayerProxy city
Model of the city currently displayed. May be null if no city is displayed

Constructor Detail

MainView

public MainView(Rectangle rect,
                ch.sahits.game.graphic.image.ImagesLoader loader,
                ch.sahits.game.openpatrician.client.IClient cl)
Instantiate the main view with the port scene of the players home town

Parameters:
rect -
loader -
cl -
Method Detail

resetDialog

private void resetDialog()
Scale the dialog so it has the correct proportions


gameRender

public void gameRender(Graphics gScr)
Specified by:
gameRender in interface ch.sahits.game.rendering.Renderable

gameUpdate

public void gameUpdate(ch.sahits.game.event.Event e,
                       Object eventNotice)
Specified by:
gameUpdate in interface ch.sahits.game.event.IEventListener
Specified by:
gameUpdate in interface ch.sahits.game.rendering.Renderable

findPolygon

private String findPolygon(int x,
                           int y)
Find the polygon name that contains the coordinates. It is expected that the polygons are not overlapping. Is this not the case the first found polygon name is returned.

Parameters:
x - coordinate
y - coordinate
Returns:
name of the polygon

initPortPolygons

private void initPortPolygons(double scale,
                              Rectangle bounds)
Setting the positions of the polygons on the screen



Copyright © 2011 Sahits GmbH. All Rights Reserved.