Ejemplo n.º 1
0
  /**
   * Called to deserialize entity's state.
   *
   * @param loader
   */
  public final void load(DataLoader loader) {
    if (loader == null) {
      return;
    }

    // load common entity parameters
    boolean topLeftCoordinatesMode =
        loader.getStringValue("coordinatesMode").equalsIgnoreCase("TopLeft");

    m_bb.load("localBounds", loader);
    m_pos.load("position", loader);
    if (topLeftCoordinatesMode) {
      m_pos.m_x += m_bb.getWidth() * 0.5f;
      m_pos.m_y -= m_bb.getHeight() * 0.5f;
    }

    m_facing = loader.getFloatValue("facing");

    updateWorldBounds();

    // load the aspects
    int aspectsCount = m_aspects.size();
    for (int i = 0; i < aspectsCount; ++i) {
      m_aspects.get(i).load(loader);
    }

    // load implementation specific stuff
    onLoad(loader);
  }
Ejemplo n.º 2
0
  @Override
  public void draw(SpriteBatcher batcher, Camera2D camera, float deltaTime) {
    Vector3 pos = m_hunter.getPosition();
    BoundingBox bs = m_hunter.getBoundingShape();

    // select an animation appropriate to the state the pedestrian's in
    switch (m_hunter.m_state) {
      case Aiming:
        {
          m_animationPlayer.select(ANIM_AIM);
          break;
        }
      case AimingZombie:
        {
          m_animationPlayer.select(ANIM_AIM);
          break;
        }

      case Shooting:
        {
          m_animationPlayer.select(ANIM_SHOOT);
          break;
        }
      case ShootingZombie:
        {
          m_animationPlayer.select(ANIM_SHOOT);
          break;
        }

      case S*****d:
        {
          m_animationPlayer.select(ANIM_SHITTED);
          break;
        }
      case Eaten:
        {
          m_animationPlayer.select(ANIM_AIM);
          break;
        }
    }

    // draw the hunter
    batcher.drawSprite(
        pos.m_x,
        pos.m_y,
        bs.getWidth(),
        bs.getHeight(),
        m_hunter.getFacing(),
        m_animationPlayer.getTextureRegion(m_hunter, deltaTime));
  }