wyvern.lib.properties
Class Projectile

java.lang.Object
  extended bywyvern.lib.properties.Projectile
All Implemented Interfaces:
Timed

public class Projectile
extends java.lang.Object
implements Timed

Property to turn an object into a missile

Version:
1.0, Mar 28, 1999
Author:
Eric Weber

Field Summary
protected  java.lang.String baseImage_
           
protected  Point dest_
           
protected  int interval_
           
protected  int range_
           
protected  Point src_
           
protected  boolean stopped_
          Is set to true when stop() is called, so multiple calls to stop() don't result in duping bugs.
protected  GameObject target_
           
protected  Timer timer_
           
 
Constructor Summary
Projectile(GameObject target)
          Create an inactive projectile
Projectile(GameObject target, Point destination, int interval, int range)
          Create and start a projectile
 
Method Summary
protected  boolean advance()
          Advance the projectile in the default direction
 Point getDestination()
           
 int getInterval()
           
 int getRange()
           
 Point getSource()
           
 GameObject getTarget()
           
 boolean maybeReturnToOwner(Commandable agent)
          Returns item to the owner's inventory, if we can find the owner in an "agent" property, and
 void revertBitmap()
          Reverts the target object's image, if we set it to an in-flight image temporarily.
 void setDestination(Point dest)
           
 void setInFlightImage()
          Sets the in-flight image for the target object that we're moving.
 void setInterval(int interval)
           
 void setRange(int range)
           
 void start()
          Starts projectile moving toward its destination.
 void stop()
          Stops projectile.
 void timerExpired()
          Time to move the projectile
 java.lang.String toString()
          Returns debugging string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

src_

protected Point src_

dest_

protected Point dest_

interval_

protected int interval_

range_

protected int range_

timer_

protected Timer timer_

target_

protected GameObject target_

baseImage_

protected java.lang.String baseImage_

stopped_

protected boolean stopped_
Is set to true when stop() is called, so multiple calls to stop() don't result in duping bugs.

Constructor Detail

Projectile

public Projectile(GameObject target)
Create an inactive projectile

Parameters:
target - object to be moved

Projectile

public Projectile(GameObject target,
                  Point destination,
                  int interval,
                  int range)
Create and start a projectile

Parameters:
target - object to be moved
destination - where the object should go
interval - how long between steps
range - how many steps to make
Method Detail

getTarget

public GameObject getTarget()

getSource

public Point getSource()

getDestination

public Point getDestination()

setDestination

public void setDestination(Point dest)

getRange

public int getRange()

setRange

public void setRange(int range)

getInterval

public int getInterval()

setInterval

public void setInterval(int interval)

start

public void start()
Starts projectile moving toward its destination. If target object has a "move-img" property, tells the object to change its appearance to that image path. If so, the target should have a matching "base-image" property that stores the original image path, so when the projectile stops it can restore the original image.


stop

public void stop()
Stops projectile.


setInFlightImage

public void setInFlightImage()
Sets the in-flight image for the target object that we're moving. If it has a "move-img" property, the target's image is set to that image while it's in flight.


revertBitmap

public void revertBitmap()
Reverts the target object's image, if we set it to an in-flight image temporarily.


timerExpired

public void timerExpired()
Time to move the projectile

Specified by:
timerExpired in interface Timed

advance

protected boolean advance()
Advance the projectile in the default direction

Returns:
true if we should continue moving, false otherwise

maybeReturnToOwner

public boolean maybeReturnToOwner(Commandable agent)
Returns item to the owner's inventory, if we can find the owner in an "agent" property, and

Parameters:
agent - the agent who fired it or threw it - may be null
Returns:
true if we returned it to agent's inventory

toString

public java.lang.String toString()
Returns debugging string.