Пример #1
0
 public void updateDS(int delayTime) {
   if (stateDS == 1) {
     if (_screen.itemUi.idItem1 == 0 && _screen.itemUi.state == 1 && (state == 1 || state == 2)) {
       if (!isLeft) {
         if (x >= xStartRight && x <= xEndRight + deltaDS) {
           stateDS = 2;
           timeStep *= mulStep;
           ani.TIME_PER_FRAME *= mulFPS;
         }
       } else if (isLeft) {
         if (x <= xEndLeft && x >= xStartLeft - deltaDS) {
           stateDS = 2;
           timeStep *= mulStep;
           ani.TIME_PER_FRAME *= mulFPS;
         }
       }
     }
   } else if (stateDS == 2) {
     if ((_screen.itemUi.idItem1 == 0 && _screen.itemUi.state != 1) || state == 3) {
       if (state == 1) {
         stateDS = 1;
         timeStep = TIME_STEP;
         ani.TIME_PER_FRAME = timeFrameNor;
       } else if (state == 2) {
         stateDS = 1;
         timeStep = TIME_STEP;
         ani.TIME_PER_FRAME = timeFrameAttack;
       } else if (state == 3) {
         stateDS = 1;
         timeStep = TIME_STEP;
         ani.TIME_PER_FRAME = timeFrameKick;
       }
     }
   }
 }
Пример #2
0
  @Override
  public void start() {
    // TODO Auto-generated method stub
    ani.setInfo(frameStartNor, frameEndNor, timeFrameNor);
    if (!isLeft) {
      x = game.X(839);
      y = game.Y(50);
    } else {
      x = game.X(0) - game.X(250);
      y = game.Y(50);
    }
    state = 1;
    xStartLeft = (int) (_screen.nvc.x + _screen.nvc.wiLeftAT + game.X((20 - 180) * 1f));
    xEndLeft = _screen.nvc.x + _screen.nvc.wi;
    xStartRight = _screen.nvc.x;
    xEndRight = (int) (_screen.nvc.x + _screen.nvc.wi - _screen.nvc.wiRightAT - game.X(20 * 1f));
    if (isLeft) deltaBloodX = game.X(80 - 100);
    else {
      deltaBloodX = game.X(80 - 100);
    }
    deltaBloodY = game.Y(-180);
    deltaX = game.X(20);
    xStartAttackLeft =
        (int) (_screen.nvc.x + _screen.nvc.wi * _screen.nvc.legL + game.X((-180 + 10) * 1f));
    xStartAttackRight = (int) (_screen.nvc.x + _screen.nvc.wi * _screen.nvc.legR + game.X(-10f));
    bloodX = _screen.nvc.x + _screen.nvc.wi / 2 - Asset.blood.frames[0].wi / 2;
    bloodY = _screen.nvc.y;
    totalVang = game.X(70);
    vang = game.X(35);
    vangPlus = game.X(20);
    deltaDS = game.X(50);

    deltaX *= _screen.enemyManager.scale;
    deltaY *= _screen.enemyManager.scale;
  }
Пример #3
0
 public void explode() {
   if (state == 1) {
     state = 2;
     ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);
     brokenXY();
   }
 }
Пример #4
0
 public void explode() {
   if (state == 1 || state == 2) {
     state = 3;
     ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);
     isDrawEnd = false;
     tickDraw = 0;
     deltaVang = 0;
   }
 }
Пример #5
0
  @Override
  public void start() {
    // TODO Auto-generated method stub
    state = 1;
    float xCPy;
    if (type == 1) {
      x = game.X(839 - 100 / 2);
      y = game.Y(490 - 100 / 2);
      xCPy =
          ((float) ((x + game.X(100 / 2)) - (_screen.nvc.x + _screen.nvc.xHead))
              / (float) ((y + game.Y(100 / 2)) - (_screen.nvc.y + _screen.nvc.yHead)));
      deltaX = game.X(9);
      deltaY = (int) game.Y(9 / xCPy);
    } else if (type == 4) {
      x = game.X(0 - 100 / 2);
      y = game.Y(490 - 100 / 2);
      xCPy =
          ((float) (-(x + game.X(100 / 2)) + (_screen.nvc.x + _screen.nvc.xHead))
              / (float) ((y + game.Y(100 / 2)) - (_screen.nvc.y + _screen.nvc.yHead)));
      deltaX = game.X(9);
      deltaY = (int) game.Y(9 / xCPy);
    } else if (type == 2) {
      x = game.X(839);
      y = game.Y(120);
      deltaX = game.X(9);
    } else if (type == 5) {
      x = game.X(0 - 80);
      y = game.Y(120);
      deltaX = game.X(9);
    }
    ani.setInfo(frameStartNor, frameEndNor, timeFrameNor);

    yStartConner = _screen.nvc.y;
    yEndConner = (int) (_screen.nvc.y + _screen.nvc.hiConner);
    xStartRight = _screen.nvc.x;
    xEndRight = _screen.nvc.x + _screen.nvc.wi;
    xStartLeft = (int) (_screen.nvc.x - game.X(100));
    xEndLeft = _screen.nvc.x + _screen.nvc.wi;

    yStartAttackConner = _screen.nvc.y;
    yEndAttackConner = (int) (_screen.nvc.y + _screen.nvc.yHead);

    bloodX = _screen.nvc.x + _screen.nvc.wi / 2 - Asset.blood.frames[0].wi / 2;
    bloodY = _screen.nvc.y;

    xStartAttackRight = _screen.nvc.x + _screen.nvc.wi / 2;
    // xEndAttackRight = _screen.nvc.x+_screen.nvc.wi/2-game.X(50);
    xStartAttackLeft = (int) (_screen.nvc.x + _screen.nvc.wi / 2 + game.X((50 - 100)));
    // xEndAttackLeft=_screen.nvc.x + _screen.nvc.wi;
    deltaDS = game.X(50);

    deltaX *= _screen.enemyManager.scale;
    deltaY *= _screen.enemyManager.scale;
  }
Пример #6
0
  public void brokenXY() {
    x = x + Asset.bua.frames[0].wi / 2;
    y = y + Asset.bua.frames[0].hi / 2;

    x = x - Asset.bua.frames[9].wi / 2;
    y = y - Asset.bua.frames[9].hi / 2;

    xBlood3 = x + Asset.bua.frames[9].wi / 2;
    yBlood3 = y + Asset.bua.frames[9].wi / 2;
    xBlood3 = xBlood3 - Asset.blood3.frames[0].wi / 2;
    yBlood3 = yBlood3 - Asset.blood3.frames[1].hi / 2;
    bloodAnimation.setInfo(0, 3, 100);
  }
Пример #7
0
 public void updateDS(int delayTime) {
   if (stateDS == 1) {
     if (_screen.itemUi.idItem1 == 0 && _screen.itemUi.state == 1 && state == 1) {
       if (type == 1 || type == 4) {
         if (y >= yStartConner && y <= yEndConner + deltaDS) {
           stateDS = 2;
           timeStep *= mulStep;
           ani.TIME_PER_FRAME *= mulFPS;
         }
       } else if (type == 2) {
         if (x >= xStartRight && x <= xEndRight + deltaDS) {
           stateDS = 2;
           timeStep *= mulStep;
           ani.TIME_PER_FRAME *= mulFPS;
         }
       } else if (type == 5) {
         if (x <= xEndLeft && x >= xStartLeft - deltaDS) {
           stateDS = 2;
           timeStep *= mulStep;
           ani.TIME_PER_FRAME *= mulFPS;
         }
       }
     }
   } else if (stateDS == 2) {
     if ((_screen.itemUi.idItem1 == 0 && _screen.itemUi.state != 1) || state == 2) {
       if (state == 1) {
         stateDS = 1;
         timeStep = TIME_STEP;
         ani.TIME_PER_FRAME = timeFrameNor;
       } else {
         stateDS = 1;
         timeStep = TIME_STEP;
         ani.TIME_PER_FRAME = timeFrameKick;
       }
     }
   }
 }
Пример #8
0
  @Override
  public void update(int delayTime) {
    // TODO Auto-generated method stub
    updateDS(delayTime);
    if (state != 3
        && (((((((_screen.nvc.frame == 14 && _screen.nvc.isFlip == false && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 6
                                && _screen.nvc.isFlip == true
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 8
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 13
                                && _screen.nvc.isFlip == true
                                && _screen.nvc.isUsed))
                        && !isLeft)
                    || (((_screen.nvc.frame == 4
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 6
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 8
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 13
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed))
                        && isLeft)))
                && _screen.nvc.id == 1)
            || (((((_screen.nvc.frame == 13 && _screen.nvc.isFlip == false && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 6
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 8
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 4
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed))
                        && !isLeft)
                    || (((_screen.nvc.frame == 4
                                && _screen.nvc.isFlip == true
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 6
                                && _screen.nvc.isFlip == true
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 8
                                && _screen.nvc.isFlip == false
                                && _screen.nvc.isUsed)
                            || (_screen.nvc.frame == 13
                                && _screen.nvc.isFlip == true
                                && _screen.nvc.isUsed))
                        && isLeft))
                && (_screen.nvc.id == 2 || _screen.nvc.id == 3)))) {
      if (isLeft) {
        if (x >= xStartLeft && x <= xEndLeft) {
          state = 3;
          ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);
          isDrawEnd = false;
          tickDraw = 0;
          deltaVang = 0;

          _screen.score.addScore(score, money);

          commentXY();

          Blood blood = new Blood(game, screen);
          blood.set(new Random().nextInt(2), x + deltaBloodX, y + deltaBloodY);
          _screen.enemyManager.add(blood);
          Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
        }
      } else {
        if (x >= xStartRight && x <= xEndRight) {
          state = 3;
          ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);
          isDrawEnd = false;
          tickDraw = 0;
          deltaVang = 0;

          _screen.score.addScore(score, money);

          commentXY();

          Blood blood = new Blood(game, screen);
          blood.set(new Random().nextInt(2), x + deltaBloodX, y + deltaBloodY);
          _screen.enemyManager.add(blood);
          Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
        }
      }
    }
    if (state == 1) {
      ani.update(delayTime);
      if (tick >= timeStep) {
        tick = 0;
        if (isLeft) {
          x += deltaX;
          if (x >= xStartAttackLeft) {
            state = 2;
            ani.setInfo(frameStartAttack, frameEndAttack, timeFrameAttack);
          }
        } else {
          x -= deltaX;
          if (x <= xStartAttackRight) {
            state = 2;
            ani.setInfo(frameStartAttack, frameEndAttack, timeFrameAttack);
          }
        }
      } else {
        tick += delayTime;
      }
    } else if (state == 2) {
      ani.update(delayTime);
      if (ani.current == frameEndAttack) {
        if (frame != frameEndAttack) {
          _screen.score.subHP();
          frame = frameEndAttack;
          Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
        }
        Blood blood = new Blood(game, screen);
        blood.set(new Random().nextInt(2), bloodX, bloodY);
        _screen.enemyManager.add(blood);
      } else {
        frame = ani.current;
      }
    } else if (state == 3) {
      if (deltaVang <= totalVang) {
        if (tickVang >= timeStepVang) {
          tickVang = 0;
          if (isLeft) {
            x -= vang;
          } else x += vang;
          deltaVang += vangPlus;
        } else {
          tickVang += delayTime;
        }
        return;
      }
      if (ani.current == frameEndKick) {
        if (!isDrawEnd) {
          isDrawEnd = true;
        } else {
          if (tickDraw >= timeWaitKick) {
            // start();
            isDie = true;
          } else {
            tickDraw += delayTime;
          }
        }
      } else {
        ani.update(delayTime);
      }
    }
  }
Пример #9
0
  @Override
  public void update(int delayTime) {
    // TODO Auto-generated method stub
    updateDS(delayTime);
    if ((((((state == 1
                            && _screen.nvc.frame == 11
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 5
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 6
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed))
                    && type == 1)
                || (((state == 1
                            && _screen.nvc.frame == 11
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 5
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 6
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed))
                    && type == 4)
                || (((state == 1
                            && _screen.nvc.frame == 1
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 7
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 13
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed))
                    && type == 2)
                || (((state == 1
                            && _screen.nvc.frame == 12
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 7
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 13
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed))
                    && type == 5))
            && (_screen.nvc.id == 1))
        || (((((state == 1
                            && _screen.nvc.frame == 3
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 5
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 6
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed))
                    && type == 1)
                || (((state == 1
                            && _screen.nvc.frame == 3
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 5
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 6
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed))
                    && type == 4)
                || (((state == 1
                            && _screen.nvc.frame == 1
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 7
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 13
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed))
                    && type == 2)
                || (((state == 1
                            && _screen.nvc.frame == 1
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 10
                            && _screen.nvc.isFlip == true
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 7
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed)
                        || (state == 1
                            && _screen.nvc.frame == 13
                            && _screen.nvc.isFlip == false
                            && _screen.nvc.isUsed))
                    && type == 5))
            && (_screen.nvc.id == 2 || _screen.nvc.id == 3))) {
      if (type == 1 || type == 4) {
        if ((y >= yStartConner && y <= yEndConner)
            || (type == 4
                && x
                    > _screen.nvc.x
                        + _screen.nvc.wi / 2
                        - _screen.nvc.deltaConner
                        + Asset.bua.frames[0].wi / 2)
            || (type == 1
                && x
                    <= _screen.nvc.x
                        + _screen.nvc.wi / 2
                        + _screen.nvc.deltaConner
                        - Asset.bua.frames[0].wi / 2)) {

          state = 2;
          ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);

          _screen.score.addScore(score, money);

          commentXY();
          brokenXY();
          Asset.kim_loai.play(game.dataSave.sound ? 1f : 0f);
        }
      } else if (type == 2) {
        if (x >= xStartRight && x <= xEndRight) {
          state = 2;
          ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);

          _screen.score.addScore(score, money);

          commentXY();
          brokenXY();
          Asset.kim_loai.play(game.dataSave.sound ? 1f : 0f);
        }
      } else if (type == 5) {
        if (x <= xEndLeft && x >= xStartLeft) {
          state = 2;

          ani.setInfo(frameStartKick, frameEndKick, timeFrameKick);

          _screen.score.addScore(score, money);

          commentXY();
          brokenXY();
          Asset.kim_loai.play(game.dataSave.sound ? 1f : 0f);
        }
      }
    }
    if (state == 1) {
      ani.update(delayTime);
      frame = ani.current;
      if (tick >= timeStep) {
        if (type == 1) {
          x -= deltaX;
          y -= deltaY;
        } else if (type == 4) {
          x += deltaX;
          y -= deltaY;
        } else if (type == 2) {
          x -= deltaX;
          y -= 0;
        } else if (type == 5) {
          x += deltaX;
          y -= 0;
        }
        tick = 0;
        if (type == 1 || type == 4) {
          if ((y >= yStartAttackConner && y <= yEndAttackConner)
              || ((type == 4
                      && (x >= _screen.nvc.x + _screen.nvc.wi / 2 - Asset.bua.frames[0].wi / 2)
                  || (type == 1
                      && (x >= xStartRight
                          && x
                              <= _screen.nvc.x
                                  + _screen.nvc.wi / 2
                                  - Asset.bua.frames[0].wi / 2))))) {
            state = 2;
            ani.setInfo(frameStartAttack, frameEndAttack, timeFrameAttack);

            _screen.score.subHP();

            Blood blood = new Blood(game, screen);
            blood.set(new Random().nextInt(2), bloodX, bloodY);
            _screen.enemyManager.add(blood);
            brokenXY();
            Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
          }
        } else if (type == 2) {
          if (x <= xStartAttackRight) {
            state = 2;
            ani.setInfo(frameStartAttack, frameEndAttack, timeFrameAttack);
            _screen.score.subHP();

            Blood blood = new Blood(game, screen);
            blood.set(new Random().nextInt(2), bloodX, bloodY);
            _screen.enemyManager.add(blood);
            brokenXY();
            Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
          }
        } else if (type == 5) {
          if (x >= xStartAttackLeft) {
            state = 2;
            ani.setInfo(frameStartAttack, frameEndAttack, timeFrameAttack);
            _screen.score.subHP();

            Blood blood = new Blood(game, screen);
            blood.set(new Random().nextInt(2), bloodX, bloodY);
            _screen.enemyManager.add(blood);
            brokenXY();
            Asset.chuong.play(game.dataSave.sound ? 1f : 0f);
          }
        }
      } else {
        tick += delayTime;
      }
    } else if (state == 2) {
      ani.update(delayTime);
      bloodAnimation.update(delayTime);
      frame = ani.current;
      if (ani.current == frameEndAttack) {
        isDie = true;
      }
    }
  }