Package games.mapacman.common

Source Code of games.mapacman.common.Dot

package games.mapacman.common;

import games.mapacman.client.GameScreen;
import games.mapacman.server.MaPacmanZone;
import marauroa.common.game.RPClass;
import marauroa.common.game.RPObject;
import marauroa.server.game.Statistics;

public class Dot {

  public static final int TYPE_DOT = 1;
  public static final int TYPE_SUPERDOT = 2;
  public static final int TYPE_FRUIT = 3;
  public static final int TYPE_POWERPILL = 4;
 
 
  protected int x,y;
  protected int dot_score;
  protected MaPacmanZone zone;
  private int dot_respawn_time;
  protected RPObject myObject;
 
  public Dot(int x, int y, int dot_score, MaPacmanZone zone) {
    myObject = new RPObject(RPObject.INVALID_ID);
    myObject.put("type",consts.TYPE_DOT);
    myObject.put("x",x);
    myObject.put("y",y);
    myObject.put("score",dot_score);
    myObject.put("respawn",-1);
    myObject.put("zoneid",zone.getName());
    this.x=x;
    this.y=y;
    this.dot_score=dot_score;
    this.zone=zone;
  }

  public Dot(RPObject object)
  {
    myObject = object;
    x=object.getInt("x");
    y=object.getInt("y");
  }
 
  public static void initRPClass()
  {
     RPClass dot = new RPClass(consts.TYPE_DOT);
     dot.isA("position");
     dot.add("score",RPClass.BYTE,RPClass.VOLATILE);
     dot.add("respawn", RPClass.INT);
  }

  public RPObject getRPObject() {
    return myObject;
  }

  public int getX() {
    return myObject.getInt("x");
  }
  public int getY() {
    return myObject.getInt("y");
  }

  public void setRespawnTime()
  {   
    setRespawnTime(zone.getDotRespawnTime());
  }
 
  public void setRespawnTime(int dot_respawnTime) {
    myObject.put("respawn",dot_respawnTime);
   
  }

  public boolean respawn() {
    myObject.put("respawn",myObject.getInt("respawn")-1);
   
    return (myObject.getInt("respawn")<1);
  }

  public int getScore() {
    return myObject.getInt("score");
  }

  public void addStats(Statistics stats) {
    stats.add("Dots eaten",1);   
  }

  public void draw(GameScreen screen) {
    screen.draw(screen.getDotSprite(TYPE_DOT),x,y);   
  }

  public void eaten(RPObject object) {
    // nothing happens to player when Dot is eaten
  }


}
TOP

Related Classes of games.mapacman.common.Dot

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.