robocraft.player
Class GameObject

java.lang.Object
  extended byrobocraft.player.GameObject
Direct Known Subclasses:
Mine, Robot

public class GameObject
extends java.lang.Object

GameObject is a reference to an object in the robocraft world. Every game object has a unique integer ID associated with it. A RobotPlayer implementation can call methods on any GameObject reference, but they will mostly fail if the object is out of sensor range.

Use equals to determine whether two GameObject instances represent the same object.


Method Summary
 boolean equals(java.lang.Object obj)
          Test for equality
 int getID()
          Return the unique integer ID of this object.
 MapLocation getLocation()
          Return's this object's location.
 Team getTeam()
          This object's team.
 ObjectType getType()
          Return's this object's type.
 int hashCode()
           
 java.lang.String toString()
          String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getID

public int getID()
Return the unique integer ID of this object.

Returns:
unique integer ID of this object.

getTeam

public Team getTeam()
This object's team.

Returns:
team of this object. Will always be one of Team.A, Team.B, or Team.NEUTRAL

getLocation

public MapLocation getLocation()
                        throws GameActionException
Return's this object's location.

Returns:
the current position of this object on the map.
Throws:
GameActionException - under any of the following conditions:
  • Object with this ID not found on the RoboCraft Map.
  • This object is out of sensor-range of calling RobotPlayer

  • getType

    public ObjectType getType()
    Return's this object's type.

    Returns:
    the ObjectType of this object. It will be one of the constants defined in ObjectType.

    equals

    public boolean equals(java.lang.Object obj)
    Test for equality

    Parameters:
    obj - another object
    Returns:
    whether this is equal to obj. A GameObject is equal to obj if and only if obj is an instance of GameObject, and obj's ID is equal to this's ID. In other words, equal GameObjects represent the same object in the world.

    hashCode

    public int hashCode()

    toString

    public java.lang.String toString()
    String representation of this object.

    Returns:
    the string representation.