Esempio n. 1
0
 @Override
 public void createUI(GLEx g) {
   if (visible) {
     float tmp = g.alpha();
     if (_alpha > 0 && _alpha < 1) {
       g.setAlpha(_alpha);
     }
     g.draw(image, x(), y());
     g.setAlpha(tmp);
   }
 }
Esempio n. 2
0
 /**
  * 绘制选单
  *
  * @param g
  * @param color1
  * @param color2
  */
 public synchronized void drawChoice(GLEx g) {
   if (!visible) {
     return;
   }
   int x1 = this.getX() - 5;
   int y1 = this.getY();
   int x2 = this.getWidth() + 20;
   int y2 = this.getAllHeight() + 10;
   int w = x2 + 15;
   int h = y2 + 10;
   if (dialogImage == null) {
     dialogImage = createDefaultDialog(w, h);
   }
   g.draw(dialogImage, x1, y1 - 5);
   IFont old = g.getFont();
   try {
     g.setFont(defFont);
     // 选中项
     int i = getDrawContent();
     if (i >= 0 && i < maxSize) {
       LGradation.getInstance(LColor.white, LColor.black, getWidth() + 6, getSpace())
           .drawHeight(g, x1 + 14, y1 + getSpace() * getDrawContent() + 2);
       g.setColor(LColor.darkGray);
       g.drawRect(x1 + 14, y1 + getSpace() * getDrawContent() + 2, getWidth() + 6, getSpace());
       g.resetColor();
     }
     int index = 0;
     // 遍历文字与颜色信息
     for (; ; ) {
       if (index >= maxSize) {
         break;
       }
       int viewIndex = index + view;
       if (viewIndex >= choice.length) {
         break;
       }
       LColor nColor;
       if (colors[viewIndex] != null) {
         nColor = colors[viewIndex];
       } else {
         nColor = LColor.white;
       }
       int i1 = 0;
       for (int j1 = 0; j1 < choice[viewIndex].length; j1++) {
         g.drawString(
             choice[viewIndex][j1],
             posX + i1 + 14,
             posY + index * getSpace() + getHeight() - 14,
             0,
             nColor);
         i1 += mesList[j1] + tab;
       }
       index++;
     }
   } finally {
     g.setFont(old);
     g.resetColor();
   }
 }
Esempio n. 3
0
 public void draw(final GLEx g, Model model, float mx, float my) {
   int span = existTime * 2;
   switch (model) {
     case OVAL:
       g.drawOval(mx + x - span / 2, my + y - span / 2, span, span);
       break;
     case RECT:
       g.drawRect(mx + x - span / 2, my + y - span / 2, span, span);
       break;
   }
   existTime++;
 }
Esempio n. 4
0
 private void drawFruit_s(Fruit fruit, GLEx g) {
   switch (fruit.type) {
     case 0:
       g.draw(Assets.apple_1, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.apple_2, (int) fruit.x + 8, (int) fruit.y);
       break;
     case 1:
       g.draw(Assets.banana_1, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.banana_2, (int) fruit.x - 20, (int) fruit.y);
       break;
     case 2:
       g.draw(Assets.basaha_1, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.basaha_2, (int) fruit.x + 8, (int) fruit.y);
       break;
     case 3:
       g.draw(Assets.sandia_1, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.sandia_2, (int) fruit.x + 8, (int) fruit.y);
       break;
     case 4:
       g.draw(Assets.peach_1, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.peach_2, (int) fruit.x + 8, (int) fruit.y);
       break;
     case 5:
       g.draw(Assets.boom, (int) fruit.x - 9, (int) fruit.y);
       g.draw(Assets.boom, (int) fruit.x + 8, (int) fruit.y);
       break;
   }
 }
Esempio n. 5
0
 @Override
 public void draw(GLEx g) {
   g.draw(Assets.background, 0, 0);
   for (int i = 0; i < fruitGame.fruitList.size(); i++) {
     if (fruitGame.fruitList.get(i).flag) drawFruit(fruitGame.fruitList.get(i), g);
     else {
       drawFruit_s(fruitGame.fruitList.get(i), g);
     }
   }
 }
Esempio n. 6
0
  public void paintResultCards(GLEx canvas) {
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();
    int row;
    int col;

    for (int i = 0; i < cards.length; i++) {
      row = CardsManager.getImageRow(cards[i]);
      col = CardsManager.getImageCol(cards[i]);
      cardImage = Game.getImage(CardImage.cardImages[row][col]);
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      // 当玩家是NPC时,竖向绘制,扑克牌全是背面
      if (paintDirection == CardsType.direction_Vertical) {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) (left * Game.SCALE_HORIAONTAL),
            (int) ((top - 40 + i * 15) * Game.SCALE_VERTICAL),
            (int) ((left + 40) * Game.SCALE_HORIAONTAL),
            (int) ((top + 20 + i * 15) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);

      } else {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) (top * Game.SCALE_VERTICAL),
            (int) ((left + 80 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }
Esempio n. 7
0
  @Override
  public synchronized void draw(GLEx g, int x, int y) {
    next();
    for (int i = 0; i < sd.length; i++) {
      if (sd[i] != null) {
        continue;
      }
      if (MathUtils.random.nextInt(100) >= rand) {
        break;
      }
      float[][] res = {{0.0f, 10f}, {8f, -5f}, {-8f, -5f}};
      int index = MathUtils.random.nextInt(3) + 1;
      for (int j = 0; j < res.length; j++) {
        for (int c = 0; c < res[j].length; c++) {
          res[j][c] *= index;
        }
      }
      int r = MathUtils.random.nextInt(32) + 16;
      float d = r / 10;
      sd[i] = new TriangleEffect(res, r, d, MathUtils.random.nextInt(24) + 24);
      sd[i].setPosY(MathUtils.random(LSystem.viewSize.height));
      sd[i].setPosX(-30f);
      colors[i] = new LColor(0, 128 + MathUtils.random.nextInt(128), MathUtils.random.nextInt(128));
    }

    for (int j = 0; j < sd.length; j++) {
      if (colors[j] == null) {
        continue;
      }
      g.setColor(colors[j]);
      if (sd[j] == null) {
        continue;
      }
      sd[j].drawPaint(g, 0, 0);
      if (sd[j].getPosX() > LSystem.viewSize.width) {
        sd[j] = null;
      }
    }

    if (super.frame > time) {
      setExist(false);
    }
  }
Esempio n. 8
0
 @Override
 public void createUI(GLEx g) {
   if (visible) {
     float old = getAlpha();
     if (alpha > 0f && alpha < 1f) {
       setAlpha(alpha);
     }
     g.draw(
         image,
         x(),
         y(),
         width * scale,
         height * scale,
         rectSrc.x,
         rectSrc.y,
         rectSrc.width,
         rectSrc.height);
     if (alpha != 1f) {
       setAlpha(old);
     }
   }
 }
Esempio n. 9
0
 public void createUI(GLEx g) {
   if (!visible) {
     return;
   }
   tmpColor = g.color();
   if (_alpha > 0 && _alpha < 1) {
     g.setAlpha(_alpha);
   }
   g.setColor(color);
   for (int i = 0; i < drops.length; ++i) {
     g.fillOval((int) drops[i].x, (int) drops[i].y, 2, 2);
   }
   if (_alpha != 1f) {
     g.setAlpha(1f);
   }
   g.setColor(tmpColor);
 }
Esempio n. 10
0
 private void drawFruit(Fruit fruit, GLEx g) {
   switch (fruit.type) {
     case 0:
       g.draw(Assets.apple, (int) fruit.x, (int) fruit.y);
       break;
     case 1:
       g.draw(Assets.banana, (int) fruit.x, (int) fruit.y);
       break;
     case 2:
       g.draw(Assets.basaha, (int) fruit.x, (int) fruit.y);
       break;
     case 3:
       g.draw(Assets.sandia, (int) fruit.x, (int) fruit.y);
       break;
     case 4:
       g.draw(Assets.peach, (int) fruit.x, (int) fruit.y);
       break;
     case 5:
       g.draw(Assets.boom, (int) fruit.x, (int) fruit.y);
       break;
   }
   return;
 }
Esempio n. 11
0
 protected void drawBorder(GLEx g, float x, float y) {
   if (this._textureBox != null) {
     g.draw(_textureBox, x, y);
   }
 }
Esempio n. 12
0
  // 绘制玩家手中的牌
  public void paint(GLEx canvas) {
    //	System.out.println("id:" + playerId);
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();

    int row;
    int col;

    // 当玩家是NPC时,竖向绘制,扑克牌全是背面
    if (paintDirection == CardsType.direction_Vertical) {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      LTexture backImage = Game.getImage("card_bg");

      src.set(0, 0, backImage.getWidth(), backImage.getHeight());
      des.set(
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) (top * Game.SCALE_VERTICAL),
          (int) ((left + 40) * Game.SCALE_HORIAONTAL),
          (int) ((top + 60) * Game.SCALE_VERTICAL));
      RectF.Range rectF = new RectF.Range(des);
      canvas.rect(rectF, 5, 5, paint);
      canvas.drawBitmap(backImage, src, des, paint);

      // 显示剩余牌数
      paint.setStyle(Style.FILL);
      paint.setColor(LColor.white);
      paint.setTextSize((int) (20 * Game.SCALE_HORIAONTAL));
      canvas.drawText(
          "" + cards.length,
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) ((top + 80) * Game.SCALE_VERTICAL),
          paint);

    } else {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      for (int i = 0; i < cards.length; i++) {
        row = CardsManager.getImageRow(cards[i]);
        col = CardsManager.getImageCol(cards[i]);
        cardImage = Game.getImage(CardImage.cardImages[row][col]);
        int select = 0;
        if (cardsFlag[i]) {
          select = 10;
        }
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select) * Game.SCALE_VERTICAL),
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }
Esempio n. 13
0
  public void draw(GLEx g, int x, int y, float mouseX, float mouseY) {
    if (this.max > 0) {

      LFont oldFont = g.getFont();
      int oldColor = g.color();

      g.setFont(this.font);
      int fontSize = font.getSize();

      // 如果没有设置背景,则绘制
      if (bgTexture == null) {
        g.setColor(this.listColor);
        g.fillRect(x, y, getWidth(), getHeight());
        g.setColor(255, 255, 255);
        g.drawRect(x, y, getWidth(), getHeight());
      } else {
        g.draw(bgTexture, x, y, getWidth(), getHeight());
      }

      this.drawNum = ((getHeight() - 10) / fontSize);
      this.loop = 0;
      this.selectList = -1;

      for (int i = this.scrollList; i < this.drawNum + this.scrollList; i++) {
        if (i >= this.num) break;
        this.drawX = (x + 5);
        this.drawY = (y + 5 + this.loop * fontSize);

        if (!this.scrollBarDrag) {
          if ((mouseY > this.drawY)
              && (mouseY <= this.drawY + fontSize)
              && (mouseX > this.drawX)
              && (mouseX < this.drawX + getWidth())) {
            this.selectList = i;
          }
        }

        // 计算是否选中当前行
        if (!this.lengthCheck[i]) {
          this.lengthCheck[i] = true;
          if (this.name[i] != null) {
            while (font.stringWidth(this.name[i]) > getWidth()) {
              this.name[i] = this.name[i].substring(0, this.name[i].length() - 1);
            }
          }
        }

        if ((this.selectList == i) || ((this.useHold) && (this.hold == i))) {
          if ((this.useHold) && (this.hold == i)) {
            g.setColor(255, 255, 0);
            g.fillRect(x + 1, this.drawY, getWidth() - 1, fontSize);
            g.setColor(LColor.black);
            drawString(g, this.name[i], this.drawX, this.drawY);
            this.hold = -1;
          }
          // 选中指定列时
          if (this.selectList == i) {
            if (choiceTexture == null) {
              g.setColor(this.choiceStringBoxColor);
              g.fillRect(x + 1, this.drawY, getWidth() - 2, fontSize + 2);
            } else {
              g.draw(this.choiceTexture, x + 2, this.drawY, getWidth() - 2, fontSize + 2);
            }
            g.setColor(this.choiceStringColor);
            drawString(g, this.name[i], this.drawX, this.drawY);
          }
        } else {
          g.setColor(this.color[i]);
          drawString(g, this.name[i], this.drawX, this.drawY);
        }

        this.loop += 1;
      }

      this.scrollBarX = (x + getWidth() + 1);

      this.scrollBarHeight_max = (getHeight() - this.scrollButtonHeight * 2);

      if ((this.drawNum < this.num) && (this.drawNum > 0)) {
        this.scrollBarHeight = (this.scrollBarHeight_max / this.num / this.drawNum);
        this.scrollBarHeight = (this.scrollBarHeight_max * this.drawNum / this.num);
        if (this.scrollBarHeight < 8) this.scrollBarHeight = 8;

        this.scrollBarY = (y + this.scrollButtonHeight + 1);
        this.scrollBarY +=
            (this.scrollBarHeight_max - this.scrollBarHeight)
                * this.scrollList
                / (this.num - this.drawNum);
      } else {
        this.scrollBarHeight = this.scrollBarHeight_max;
        this.scrollBarY = (y + this.scrollButtonHeight + 1);
      }

      if (this.scrollBarDrag) {
        if (mouseY < this.scrollBarY + this.scrollBarHeight / 3) {
          for (int i = 0; i < 5; i++) {
            if (this.scrollList <= 0) break;
            this.scrollList -= 1;
          }
        }

        if (mouseY > this.scrollBarY + this.scrollBarHeight * 2 / 3) {
          for (int i = 0; i < 5; i++) {
            if (this.scrollList >= this.num - this.drawNum) break;
            this.scrollList += 1;
          }
        }
      }

      if (SysTouch.isDrag()) {
        if ((mouseX > this.scrollBarX)
            && (mouseX <= this.scrollBarX + this.scrollButtonWidth)
            && (mouseY > y + this.scrollButtonHeight)
            && (mouseY < y + getHeight() - this.scrollButtonHeight)) {
          this.scrollBarDrag = true;
        }
      } else {
        this.scrollBarDrag = false;
      }

      if (scrollTexture == null) {
        if (this.scrollBarDrag) {
          g.setColor(0, 255, 255);
        } else {
          g.setColor(255, 255, 255);
        }
        g.fillRect(this.scrollBarX, this.scrollBarY, this.scrollButtonWidth, this.scrollBarHeight);
      } else {
        g.draw(
            this.scrollTexture,
            this.scrollBarX,
            this.scrollBarY,
            this.scrollButtonWidth,
            this.scrollBarHeight);
      }

      this.scrollButtonX = (x + getWidth());
      this.scrollButtonY = y;

      if (scrollFlagATexture == null) {
        if (this.scrollUpButtonON) {
          g.setColor(LColor.gray);
        } else {
          g.setColor(LColor.black);
        }
        g.fillRect(
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth,
            this.scrollButtonHeight);
        g.setColor(255, 255, 255);
        this.px[0] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 6);
        this.px[1] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 2);
        this.px[2] = (this.scrollButtonX + 1 + this.scrollButtonWidth * 5 / 6);
        this.py[0] = (this.scrollButtonY + 1 + this.scrollButtonHeight * 5 / 6);
        this.py[1] = (this.scrollButtonY + 1 + this.scrollButtonHeight / 6);
        this.py[2] = (this.scrollButtonY + 1 + this.scrollButtonHeight * 5 / 6);
        g.fillPolygon(this.px, this.py, 3);
      } else {
        g.draw(
            this.scrollFlagATexture,
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth - 1,
            this.scrollButtonHeight - 1);
      }

      this.scrollUpButtonON = false;
      if ((!this.scrollBarDrag)
          && isFocusable()
          && (mouseX > this.scrollButtonX)
          && (mouseX <= this.scrollButtonX + this.scrollButtonWidth)
          && (mouseY > this.scrollButtonY)
          && (mouseY < this.scrollButtonY + this.scrollButtonHeight)) {
        if (this.scrollList > 0) {
          this.scrollList -= 1;
        }
        this.scrollUpButtonON = true;
      }
      this.scrollButtonX = (x + getWidth());
      this.scrollButtonY = (y + getHeight() - this.scrollButtonHeight);
      this.scrollDownButtonON = false;
      if ((!this.scrollBarDrag)
          && isFocusable()
          && (mouseX > this.scrollButtonX)
          && (mouseX <= this.scrollButtonX + this.scrollButtonWidth)
          && (mouseY > this.scrollButtonY)
          && (mouseY < this.scrollButtonY + this.scrollButtonHeight)) {
        if (this.scrollList < this.num - this.drawNum) {
          this.scrollList += 1;
        }
        this.scrollDownButtonON = true;
      }
      if (scrollFlagBTexture == null) {
        if (this.scrollDownButtonON) {
          g.setColor(LColor.gray);
        } else {
          g.setColor(LColor.black);
        }
        g.fillRect(
            this.scrollButtonX + 1,
            this.scrollButtonY - 1,
            this.scrollButtonWidth,
            this.scrollButtonHeight);
        g.setColor(LColor.white);
        this.px[0] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 6);
        this.px[1] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 2);
        this.px[2] = (this.scrollButtonX + 1 + this.scrollButtonWidth * 5 / 6);
        this.py[0] = (this.scrollButtonY - 1 + this.scrollButtonHeight / 6);
        this.py[1] = (this.scrollButtonY - 1 + this.scrollButtonHeight * 5 / 6);
        this.py[2] = (this.scrollButtonY - 1 + this.scrollButtonHeight / 6);
        g.fillPolygon(this.px, this.py, 3);
      } else {
        g.draw(
            this.scrollFlagBTexture,
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth - 1,
            this.scrollButtonHeight - 1);
      }
      g.setFont(oldFont);
      g.setColor(oldColor);
    }
  }
Esempio n. 14
0
 private void drawString(GLEx g, String str, int x, int y) {
   g.drawString(str, x, y - 5);
 }