예제 #1
0
파일: Unit.java 프로젝트: talah/BBTH
  public void drawHealthBar(Canvas canvas, boolean serverDraw) {
    if (isDead()) return;

    tempPaint.set(paint);
    paint.setStyle(Style.FILL);

    float radius = getRadius();
    float border = 1f;

    float left = getX() - radius;
    float top = (serverDraw) ? getY() + (radius * 2f) : getY() - (radius * 2f);
    float right = left + 2f * radius;
    float bottom = top + radius / 2f;

    paint.setColor(Color.WHITE);
    canvas.drawRect(left - border, top - border, right + border, bottom + border, paint);

    paint.setColor(Color.RED);
    canvas.drawRect(left, top, right, bottom, paint);

    paint.setColor(Color.GREEN);
    float greenStopX = MathUtils.scale(0f, getStartingHealth(), left, right, getHealth(), true);
    canvas.drawRect(left, top, greenStopX, bottom, paint);

    paint.set(tempPaint);
  }
예제 #2
0
파일: UberUnit.java 프로젝트: talah/BBTH
  @Override
  public void drawChassis(Canvas canvas) {
    canvas.save();

    canvas.translate(getX(), getY());

    canvas.rotate(MathUtils.toDegrees(getHeading()) + 90);
    canvas.drawLines(outline, paint);
    canvas.drawCircle(0f, 0f, 5f, paint);

    canvas.restore();

    if (!firing) {
      float radius = POWER_CIRCLE_RADIUS * powerLevel / MAX_POWER_LEVEL;
      if (radius > 0) {
        tempPaint.set(paint);

        paint.setStyle(Style.FILL);
        paint.setColor(Color.GRAY);
        canvas.drawCircle(getX(), getY(), radius, paint);

        paint.set(tempPaint);
      }
    }
  }
예제 #3
0
파일: Unit.java 프로젝트: talah/BBTH
 protected void onDead() {
   for (int i = 0; i < 10 * getRadius(); ++i) {
     float angle = MathUtils.randInRange(0, 2 * MathUtils.PI);
     float sin = FloatMath.sin(angle);
     float cos = FloatMath.cos(angle);
     float xVel = MathUtils.randInRange(25.f, 50.f) * cos;
     float yVel = MathUtils.randInRange(25.f, 50.f) * sin;
     particleSystem
         .createParticle()
         .line()
         .velocity(xVel * getRadius() * .25f, yVel * getRadius() * .25f)
         .angle(angle)
         .shrink(0.1f, 0.15f)
         .radius(getRadius() * 1.5f)
         .width(getRadius() / 2f)
         .position(getX() + sin * 2f, getY() + cos * 2f)
         .color(team.getRandomShade());
   }
 }