Android Open Source - TheFirstMyth02 Public Tips






From Project

Back to project page TheFirstMyth02.

License

The source code is released under:

MIT License

If you think the Android project TheFirstMyth02 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.game.tip;
/*from  ww w.jav a 2s. c  o m*/
import java.util.ArrayList;
import java.util.List;

import com.game.base.BaseInfo;
import com.game.base.GameChapterBaseSet_Shentan;
import com.game.base.PubSet;
import com.game.commen.EffectName;
import com.game.commen.GetImgCommen;
import com.game.commen.Paintforziti;
import com.game.data.StroyTipData;
import com.game.effect.SpecialEffect;
import com.game.stroy.MainStroy;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.view.MotionEvent;

public class PublicTips {

  public boolean showflag ;
  private String TipUrl = "";
  SpecialEffect dianjixiaoguo;
  private List<StroyTipData> stdlist;
  private int stroyjinduint=0;
  
  public PublicTips(String TipUrl,List<StroyTipData> stdlist,int stroyjinduint) {
    super();
    this.stdlist=stdlist;
    this.TipUrl = TipUrl;
    this.stroyjinduint=stroyjinduint;
    dianjixiaoguo = new SpecialEffect(EffectName.????_????????,
        "effects/tip/dianji/0060-6c69364-", 0, 0, 16, true);
  }

  private int x, y;
  String headurl = "spirit/npc/chijiaodaxian/0329-2073f650-00000.png";
  String buttonurl = "publicimg/qdbt.png";
  String text = "";
  String headname = "";
  String storystr = "";
  String todostr = "";
  int sizemax = 28;// ????????

  Rect rect_dianji_todo;

  public void PublicTips_settext(String text) {
    this.text = text;
  }

  public void PublicTips_headname(String headname) {
    this.headname = headname;
  }

  public void PublicTips_headurl(String headurl) {
    this.headurl = headurl;
  }

  public List<String> strlist;
  int talkline = 0;// ????????

  public void PublicTips_storystr(String storystr) {
    this.storystr = storystr;
    strlist = new ArrayList<String>();
    if ((int) (storystr.length() % sizemax) != 0) {
      talkline = (int) (storystr.length() / sizemax) + 1;
    } else {
      talkline = (int) (storystr.length() / sizemax);
    }
    for (int i = 0; i < talkline; i++) {
      if (i == talkline - 1) {
        strlist.add(storystr.substring(i * sizemax, storystr.length()));
      } else {
        strlist.add(storystr.substring(i * sizemax, (i * sizemax)
            + sizemax));
      }
    }
  }

  public void PublicTips_todo(String todostr) {
    this.todostr = todostr;
  }

  public void myDraw_Tips(Context context, Canvas canvas, Paint paint, int x,
      int y) {
    this.x = x;
    this.y = y;
    Bitmap bmp = null;
    Bitmap bmp_head = null;
    Bitmap bmp_button = null;
    try {
      bmp = GetImgCommen.readBitMap(context, TipUrl);
      bmp_head = GetImgCommen.readBitMap(context, headurl);
      bmp_button = GetImgCommen.readBitMap(context, buttonurl);
      
    } catch (Exception e) {
      // TODO: handle exception
    }

    if (bmp != null && showflag == true) {
      canvas.drawBitmap(bmp, setbmp_showRect(bmp),
          setbmp_weizhiRect(bmp, 0, 0, 0, 0), paint);
      canvas.drawBitmap(bmp_head, setbmp_showRect(bmp_head),
          setbmp_weizhiRect(bmp_head, -300, -130, -300, -130), paint);
      canvas.drawBitmap(bmp_button, setbmp_showRect(bmp_button),
          setbmp_weizhiRect(bmp_button, 270, 67, 270, 67), paint);
      rect_dianji_todo = new Rect();
      rect_dianji_todo = setbmp_weizhiRect(bmp_button, 270, 67, 270, 67);
      if (talkline > 0) {
        for (int i = talkline - 1; i >= 0; i--) {
          canvas.drawText(strlist.get(i).toString() + "",
              setbmp_weizhiRect(bmp, 0, 0, 0, 0).left + 50,
              setbmp_weizhiRect(bmp, 0, 0, 0, 0).top + 120
                  + (i * 24),
              Paintforziti.SetPaint(24, Color.WHITE, Color.BLACK));
        }
      }

      canvas.drawText(headname + "",
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).left + 60,
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).top + 76,
          Paintforziti.SetPaint(24, Color.YELLOW, Color.BLACK));

      canvas.drawText(todostr + "",
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).right - 165,
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).bottom - 56,
          Paintforziti.SetPaint(24, Color.YELLOW, Color.BLACK));

      dianjixiaoguo.myDraw_Effect(PubSet.context, canvas, paint,
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).right - 185,
          setbmp_weizhiRect(bmp, 0, 0, 0, 0).bottom - 66);

      bmp.recycle();

      bmp = null;
    }

  }

  public Rect setbmp_showRect(Bitmap bmp) {
    Rect bmpRect = new Rect();
    int left = 0;
    int top = 0;
    int right = bmp.getWidth();
    int bottom = bmp.getHeight();
    bmpRect.set(left, top, right, bottom);
    return bmpRect;
  }

  public Rect setbmp_weizhiRect(Bitmap bmp, int left, int top, int right,
      int bottom) {
    // ????????????
    Rect dst = new Rect();
    // ????????
    dst.left = (int) x - bmp.getWidth() / 2 + left;
    dst.top = (int) y - bmp.getHeight() / 2 + top;
    dst.right = (int) x + bmp.getWidth() / 2 + right;
    dst.bottom = (int) y + bmp.getHeight() / 2 + bottom;
    return dst;
  }

  public void StroyPlayIng(int flagint,List<StroyTipData> std)
  {
    if(std.get(flagint)!=null)
    {
      PublicTips_headname(std.get(flagint).getStroyName());
      PublicTips_headurl(std.get(flagint).getHeadUrl());
      PublicTips_storystr(std.get(flagint).getStroyInfo());
      PublicTips_todo(std.get(flagint).getTodoInfo());
    }
  }
  boolean dianji = false;
  public boolean onTouch(MotionEvent e) {
    boolean selectflag = false;
    int x = (int) e.getX();
    int y = (int) e.getY();

    if(rect_dianji_todo!=null)
    {
      if (e.getAction() == MotionEvent.ACTION_DOWN && dianji ==false) {
        if (rect_dianji_todo != null) {
          if (x > rect_dianji_todo.left && x < rect_dianji_todo.right
              && y > rect_dianji_todo.top
              && y < rect_dianji_todo.bottom) {
            selectflag = true;
            
            stroyjinduint++;
            if(stdlist.get(stroyjinduint)!=null)
            {
              if(stdlist.get(stroyjinduint).getTodoInfo().equals("????")==true)
              {
                StroyPlayIng(stroyjinduint,stdlist);  
              }
              if(stdlist.get(stroyjinduint).getTodoInfo().equals("??????")==true)
              {
                showflag = false;
              }
            }
            else
            {
              showflag = false;
            }
            
            
          } else {
            selectflag = false;
          }
        }
        dianji = true;
      }
      else if(e.getAction() == MotionEvent.ACTION_UP)
      {
        dianji = false;
      }
    }
    return selectflag;
  }
}




Java Source Code List

.Test.java
com.game.base.BaseInfo.java
com.game.base.GameBackGround.java
com.game.base.GameChapterBaseSet_Shentan.java
com.game.base.GameMap.java
com.game.base.PubSet.java
com.game.commen.AStarMap.java
com.game.commen.AStarNode.java
com.game.commen.AStar.java
com.game.commen.ActionToDo.java
com.game.commen.BitmapTouchChecker.java
com.game.commen.BitmapUtil.java
com.game.commen.Direction.java
com.game.commen.EffectName.java
com.game.commen.GameXmlcommen.java
com.game.commen.GetImgCommen.java
com.game.commen.IrregularButton.java
com.game.commen.MapName.java
com.game.commen.Paintforziti.java
com.game.commen.ToDo.java
com.game.data.BaseInfo.java
com.game.data.RoleData_Main.java
com.game.data.RoleData.java
com.game.data.StroyTipData.java
com.game.effect.SpecialEffect.java
com.game.fengshen.GameActivity.java
com.game.fengshen.GameMainActivity.java
com.game.fengshen.GameView.java
com.game.fengshen.MoveTest.java
com.game.renwu.Objs.java
com.game.renwu.SpiritMain.java
com.game.renwu.Spirit_Main.java
com.game.renwu.Spirit_NPC.java
com.game.renwu.Spirit.java
com.game.renwu.Spiritgirl.java
com.game.stroy.MainStroy.java
com.game.tip.PublicTips.java