Pacman 3D .:. www.stormzone.de/uni/pacman3d/

pacman3d.pacman
Class Pacman

java.lang.Object
  |
  +--pacman3d.pacman.Pacman
All Implemented Interfaces:
Identifiable, Introspectable, MessageListener, XMLSerializeable

public class Pacman
extends Object
implements MessageListener, Identifiable, XMLSerializeable, Introspectable

Pacman

This Class holds all the logic for the player character of our game. To be able to successfully use it, you should be sure, that the following points are met. First of all you should be certain, that a KeyControl Object exists, with the ID of this Pacman. Otherwise you would have a Pacman subject unable to move, 'cause it'll never receive a movement message. (One possible exception would be, that this Pacman is created as Shadow-Pacman. That is a Pacman, that is only created on other clients to mirror the moves of the master Pacman. In this case a KeyControl for the Masterpacman would exist, and since the shadow Pacmen have the same ID like the Masterpacman, they to would receive the movement messages).

As you see there are two kinds of Pacmen, that can be instantiated:

When instantiated you should get the ID of this Pacman and create a KeyControl for this one.

Copyright: Copyright (c) 2001

Author:
Frank Bergmann

Constructor Summary
Pacman()
          constructor initializing the PacMan.
Pacman(ID oID, Labyrinth oLabyrinth)
          constructor initializing the PacMan.
Pacman(ID oID, Labyrinth oLabyrinth, String sPacmanModel, boolean isFriendly)
          constructor initializing the PacMan.
Pacman(Labyrinth oLabyrinth)
          constructor initializing the PacMan.
Pacman(Labyrinth oLabyrinth, String sPacmanModel, boolean isFriendly)
          constructor initializing the PacMan.
 
Method Summary
 void enableFightAnimation(boolean bStartAnimation)
          en- or disables the animation sequence that will allow the pacman to swing his katana.
 ID getID()
          Gibt die eindeutige Bezeichnung eines Objektes in Form einer Instanz der Klasse ID zurück.
 Node getJ3DNode()
          returns Java3D Node containing PacMan this function should be called only once right after creaing PacMan
 Vector3d getLineOfSight()
          returns line of sight
 void getMessage(Message oMessage)
          adds Message to the Message queue
static Vector getModelList()
          get vector of all available models
 TransformGroup getModelPreview(String sPacmanModel)
          this function will create a model and return it for the intro
 Point3i getPacmanPos()
          returns the current position of this pacman
 Object getParameter(String sParametername)
          returns any parameter
 int getParameterCount()
          returns number of parameters available for the pacman
 String getParameterDescription(int nPos)
          this function returns the description for the given parameter
 String getParameterName(int nPosition)
          returns name of parameter at the given position
 Object getParameterType(int nPosition)
          returns the type of the parameter at the given position
 Vector3d getRealLineOfSight()
          returns line of sight
 Point3d getRealPacmanPos()
          returns the real position of this pacman
 boolean isInvincible()
          get invincibility status
 void loadFromDOM(Element oElement)
          right now this code won't do anything good ... later it will be possible to initialize PacMan with parameters given in XML format
 void makeLoop(int nTicks)
          This is the main function for all operations regarding this pacman.
 void movePacman(Point3d oPoint)
          explicitly sets the position should be called after initalizing pacman
 Element saveToDOM(Document oDoc)
          not yet implemented
 void sendInventoryMessage()
          sends the current inventory state to the inventory-panel
 void sendScoreMessage()
          sends the current score to the score-panel
 void setDemoMode(boolean bIsDemoMode)
          with this method it is possible to influence the mode with which messages are handled.
 void setLineOfSight(Vector3d oCurrentLineOfSight)
          sets line of sight should be called initially
 void setMovementCost(int nCost)
          this method will set the number of ticks needed to complete a Movement operation
 void setPacmanPos(int nX, int nY, int nZ)
          explicitly sets the position should be called after initalizing pacman
 void setPacmanPos(Point3i oPoint)
          explicitly sets the position should be called after initalizing pacman
 void setParameter(String sParametername, Object oParametervalue)
          this function allows to set any parameter available to the pacman
 void setRotationCost(int nCost)
          this method will set the number of ticks needed to complete a Rotate operation
 void setVisible(boolean bIsVisible)
          updates the visibility status of PacMan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pacman

public Pacman()
constructor initializing the PacMan. A Pacman created by this constructor can do virtually nothing. All it is good for is for creating J3D Nodes. But that is exactly its task. It'll be used by the intro, so to show the available models.


Pacman

public Pacman(Labyrinth oLabyrinth)
constructor initializing the PacMan. A Pacman created by this constructor will be a master pacman ... in other words it will interact with items & monsters.

Parameters:
oLabyrinth - the labyrinth the pacman is moving in

Pacman

public Pacman(ID oID,
              Labyrinth oLabyrinth)
constructor initializing the PacMan. A Pacman created by this constructor will act as shadow-pacman. In other words, it will react only to Movement Messages (or Die-Messages) but it won't take items, or slay monsters

Parameters:
oID - the ID, that the Pacman shall receive
oLabyrinth - the labyrinth the pacman is moving in

Pacman

public Pacman(Labyrinth oLabyrinth,
              String sPacmanModel,
              boolean isFriendly)
constructor initializing the PacMan. A Pacman created by this constructor will be a master pacman ... in other words it will interact with items & monsters.

Parameters:
oLabyrinth - the labyrinth the pacman is moving in
sPacmanModel - the string of the model to be loaded the String should be one of the Strings from getModelList.
isFriendly - if true this pacman doesn't attack other pacman otherwise he'll treat them like he would treat monsters :)

Pacman

public Pacman(ID oID,
              Labyrinth oLabyrinth,
              String sPacmanModel,
              boolean isFriendly)
constructor initializing the PacMan. A Pacman created by this constructor will act as shadow-pacman. In other words, it will react only to Movement Messages (or Die-Messages) but it won't take items, or slay monsters

Parameters:
oID - the ID, that the Pacman shall receive
oLabyrinth - the labyrinth the pacman is moving in
sPacmanModel - the string of the model to be loaded the String should be one of the Strings from getModelList.
isFriendly - if true this pacman doesn't attack other pacman otherwise he'll treat them like he would treat monsters :)
Method Detail

getMessage

public void getMessage(Message oMessage)
adds Message to the Message queue

Specified by:
getMessage in interface MessageListener
Parameters:
oMessage - the message to be added

makeLoop

public void makeLoop(int nTicks)

This is the main function for all operations regarding this pacman. It operates as follows. First will be decided whether an operation is in progress or not.

Parameters:
nTicks - the number of ticks available for operations

setVisible

public void setVisible(boolean bIsVisible)
updates the visibility status of PacMan

Parameters:
bIsVisible - if true pacman is visible otherwise not

getJ3DNode

public Node getJ3DNode()
returns Java3D Node containing PacMan this function should be called only once right after creaing PacMan

Returns:
the J3DNode containing this pacman

setPacmanPos

public void setPacmanPos(Point3i oPoint)
explicitly sets the position should be called after initalizing pacman

Parameters:
oPoint - the position where pacman will spawn

movePacman

public void movePacman(Point3d oPoint)
explicitly sets the position should be called after initalizing pacman

Parameters:
oPoint - the position, pacman will move to

setPacmanPos

public void setPacmanPos(int nX,
                         int nY,
                         int nZ)
explicitly sets the position should be called after initalizing pacman

Parameters:
nX - the x position of Pacman in the labyrinth
nY - the y position of Pacman in the labyrinth
nZ - the z position of Pacman in the labyrinth

getPacmanPos

public Point3i getPacmanPos()
returns the current position of this pacman

Returns:
current descrete position of the pacman

getRealPacmanPos

public Point3d getRealPacmanPos()
returns the real position of this pacman

Returns:
real position of the pacman

getLineOfSight

public Vector3d getLineOfSight()
returns line of sight

Returns:
Vector3D containing the direction, that pacman looks to

getRealLineOfSight

public Vector3d getRealLineOfSight()
returns line of sight

Returns:
Vector3D containing the real direction, that pacman looks to

setLineOfSight

public void setLineOfSight(Vector3d oCurrentLineOfSight)
sets line of sight should be called initially

Parameters:
oCurrentLineOfSight - the line of sight to be set

isInvincible

public boolean isInvincible()
get invincibility status

Returns:
true if pacman is incincible false otherwise

getID

public ID getID()
Description copied from interface: Identifiable
Gibt die eindeutige Bezeichnung eines Objektes in Form einer Instanz der Klasse ID zurück.

Specified by:
getID in interface Identifiable
Returns:
the ID of this pacman

getModelPreview

public TransformGroup getModelPreview(String sPacmanModel)
this function will create a model and return it for the intro

Parameters:
sPacmanModel - model to be shown
Returns:
TransformGroup containing the selected pacman

getModelList

public static Vector getModelList()
get vector of all available models

Returns:
vector of all available models

loadFromDOM

public void loadFromDOM(Element oElement)

right now this code won't do anything good ... later it will be possible to initialize PacMan with parameters given in XML format

Specified by:
loadFromDOM in interface XMLSerializeable
Parameters:
oElement - xml-element containing initparameters

saveToDOM

public Element saveToDOM(Document oDoc)

not yet implemented

Specified by:
saveToDOM in interface XMLSerializeable
Parameters:
oDoc - the document to be saved to
Returns:
the xml-node to be saved

setParameter

public void setParameter(String sParametername,
                         Object oParametervalue)
this function allows to set any parameter available to the pacman

Specified by:
setParameter in interface Introspectable
Parameters:
sParametername - the parameter to be set
oParametervalue - the value to be set

getParameter

public Object getParameter(String sParametername)
returns any parameter

Specified by:
getParameter in interface Introspectable
Parameters:
sParametername - the parameter to be returned
Returns:
the parametervalue that was asked vor

getParameterCount

public int getParameterCount()
returns number of parameters available for the pacman

Specified by:
getParameterCount in interface Introspectable
Returns:
number of parameters available for the pacman

getParameterName

public String getParameterName(int nPosition)
returns name of parameter at the given position

Specified by:
getParameterName in interface Introspectable
Parameters:
nPosition - the position of the parameter
Returns:
the name of the parameter

getParameterType

public Object getParameterType(int nPosition)
returns the type of the parameter at the given position

Specified by:
getParameterType in interface Introspectable
Parameters:
nPosition - the position of the parameter
Returns:
the parameter type of that parameter

setMovementCost

public void setMovementCost(int nCost)
this method will set the number of ticks needed to complete a Movement operation

Parameters:
nCost - the new cost of a movement operation

setRotationCost

public void setRotationCost(int nCost)
this method will set the number of ticks needed to complete a Rotate operation

Parameters:
nCost - the new cost of a rotation operation

getParameterDescription

public String getParameterDescription(int nPos)
this function returns the description for the given parameter

Specified by:
getParameterDescription in interface Introspectable
Parameters:
nPos - the position of the parameter
Returns:
the description of the parameter

sendScoreMessage

public void sendScoreMessage()
sends the current score to the score-panel


sendInventoryMessage

public void sendInventoryMessage()
sends the current inventory state to the inventory-panel


enableFightAnimation

public void enableFightAnimation(boolean bStartAnimation)
en- or disables the animation sequence that will allow the pacman to swing his katana.

Parameters:
bStartAnimation - if true animation sequence is started if false sequence is stopped

setDemoMode

public void setDemoMode(boolean bIsDemoMode)
with this method it is possible to influence the mode with which messages are handled.

Parameters:
bIsDemoMode - if true all incoming messages are accepted, if false only new messages are accepted

Pacman 3D .:. www.stormzone.de/uni/pacman3d/