예제 #1
0
 /**
  * Set the direction of the character
  *
  * @param Pos String specifying direction
  */
 public void setPos(String Pos) {
   // Set position
   switch (TYPE) {
     case 1:
       switch (Pos) {
         case "Up":
           FY = Type1.UP.ordinal();
           break;
         case "Down":
           FY = Type1.DOWN.ordinal();
           break;
         case "Left":
           FY = Type1.LEFT.ordinal();
           break;
         case "Right":
           FY = Type1.RIGHT.ordinal();
           break;
       }
       break;
     case 2:
       switch (Pos) {
         case "Up":
           FY = Type2.UP.ordinal();
           break;
         case "Down":
           FY = Type2.DOWN.ordinal();
           break;
         case "Left":
           FY = Type2.LEFT.ordinal();
           break;
         case "Right":
           FY = Type2.RIGHT.ordinal();
           break;
       }
       break;
     case 3:
       switch (Pos) {
         case "Up":
           FY = Type3.UP.ordinal();
           break;
         case "Down":
           FY = Type3.DOWN.ordinal();
           break;
         case "Left":
           FY = Type3.LEFT.ordinal();
           break;
         case "Right":
           FY = Type3.RIGHT.ordinal();
           break;
       }
       break;
   }
 }
예제 #2
0
  /**
   * Move the character
   *
   * @param dx x displacement
   * @param dy y displacement
   */
  public void Move(int dx, int dy) {
    if (!CANMOVE) return;
    // Move
    X += dx * SPEED;
    Y += dy * SPEED;

    // Set FY depending on the sprite Type
    switch (TYPE) {
      case 1:
        if (dx > 0) {
          FY = Type1.RIGHT.ordinal();
        } else if (dx < 0) {
          FY = Type1.LEFT.ordinal();
        } else if (dy > 0) {
          FY = Type1.DOWN.ordinal();
        } else if (dy < 0) {
          FY = Type1.UP.ordinal();
        }

        break;
      case 2:
        if (dx > 0) {
          FY = Type2.RIGHT.ordinal();
        } else if (dx < 0) {
          FY = Type2.LEFT.ordinal();
        } else if (dy > 0) {
          FY = Type2.DOWN.ordinal();
        } else if (dy < 0) {
          FY = Type2.UP.ordinal();
        }
      case 3:
        if (dx > 0) {
          FY = Type3.RIGHT.ordinal();
        } else if (dx < 0) {
          FY = Type3.LEFT.ordinal();
        } else if (dy > 0) {
          FY = Type3.DOWN.ordinal();
        } else if (dy < 0) {
          FY = Type3.UP.ordinal();
        }

        break;
    }

    // X Frame Change
    FrameChange(SIZE, 4, 1);
  }
예제 #3
0
  /**
   * Physical Meele Attack
   *
   * @param Me
   */
  public void PAttack(MeeleAttack Me) {

    switch (TYPE) {
      case 1:
        // Meele Attack
        if (FY == Type1.UP.ordinal()) {
          Me.PAttack(Type1.UP.name());
        } else if (FY == Type1.DOWN.ordinal()) {
          Me.PAttack(Type1.DOWN.name());
        } else if (FY == Type1.LEFT.ordinal()) {
          Me.PAttack(Type1.LEFT.name());
        } else if (FY == Type1.RIGHT.ordinal()) {
          Me.PAttack(Type1.RIGHT.name());
        }

        break;
      case 2:
        // Meele Attack
        if (FY == Type2.UP.ordinal()) {
          Me.PAttack(Type2.UP.name());
        } else if (FY == Type2.DOWN.ordinal()) {
          Me.PAttack(Type2.DOWN.name());
        } else if (FY == Type2.LEFT.ordinal()) {
          Me.PAttack(Type2.LEFT.name());
        } else if (FY == Type2.RIGHT.ordinal()) {
          Me.PAttack(Type2.RIGHT.name());
        }

        break;
      case 3:
        // Meele Attack
        if (FY == Type3.UP.ordinal()) {
          Me.PAttack(Type3.UP.name());
        } else if (FY == Type3.DOWN.ordinal()) {
          Me.PAttack(Type3.DOWN.name());
        } else if (FY == Type3.LEFT.ordinal()) {
          Me.PAttack(Type3.LEFT.name());
        } else if (FY == Type3.RIGHT.ordinal()) {
          Me.PAttack(Type3.RIGHT.name());
        }

        break;
    }
  }