package com.android.sq.ebp.rounds.round1;
import android.content.Context;
import android.graphics.Canvas;
import android.view.MotionEvent;
import com.android.sq.ebp.EBPConstants;
import com.android.sq.ebp.R;
import com.android.sq.ebp.base.DymSprite;
import com.android.sq.ebp.base.PointSprite;
import com.android.sq.ebp.baseround.BaseRound;
/*
* 把绘图方法写在这里,分两部分
* 1.继承自父类BaseRound的方法
* 2.Round自有的各种精灵的绘图
*/
public class Round1 extends BaseRound {
public GameView1 gameView1;
//
public int thiefTotals = 1;
public int wrongTouchTotal = 2;
public DymSprite person;
public boolean isThief_person = false;
//public boolean isTouchable_person = false;
public float personX = 314.5f;
public float personY = 378.0f;
public float personW = 60.0f;
public float personH = 102.0f;
public float personOffX = 21.0f;
public float personOffY = 0.0f;
public DymSprite thief;
public boolean isThief_thief = true;
//public boolean isTouchable_thief = false;
public float thiefX = 418.5f;
public float thiefY = 378.0f;
public float thiefW = 60.0f;
public float thiefH = 102.0f;
public float thiefOffX = -21.0f;
public float thiefOffY = 0.0f;
public PointSprite pSpt = null;
public float pSptX = 20.0f;
public float pSptY = 479.0f;
public float pSptW = 64.0f;
public float pSptH = 64.0f;
public float pSptXOff = 0.0f;
public float pSptYOff = 90.0f;
public float pSptXSpd = 30.0f; //修改
public float pSptYSpd = 277.0f;
public Round1(GameView1 gameView1, Context context) {
super(gameView1, context);
super.setThiefTotal(thiefTotals);
super.setWrongTouchs(wrongTouchTotal);
this.gameView1 = gameView1;
person = new DymSprite(context, isThief_person, //isTouchable_person,
personX, personY, personW, personH,
new int[] {R.drawable.smallman, R.drawable.walkright1, R.drawable.walkright2,
R.drawable.walkright3, R.drawable.walkright4, R.drawable.walkright5,
R.drawable.walkleft1, R.drawable.walkleft2, R.drawable.walkleft3,
R.drawable.walkleft4, R.drawable.walkleft5
}, personOffX, personOffY);
thief = new DymSprite(context, isThief_thief, //isTouchable_thief,
thiefX, thiefY, thiefW, thiefH,
new int[] {R.drawable.smallman, R.drawable.walkleft1, R.drawable.walkleft2,
R.drawable.walkleft3, R.drawable.walkleft4, R.drawable.walkleft5,
R.drawable.walkright1, R.drawable.walkright2, R.drawable.walkright3,
R.drawable.walkright4, R.drawable.walkright5, R.drawable.truebody
}, thiefOffX, thiefOffY);
pSpt = new PointSprite(context, new int[] {R.drawable.redgift}, pSptX, pSptY, pSptW, pSptH, pSptXOff, pSptYOff, pSptXSpd, pSptYSpd);
}
public void drawPerson(Canvas canvas, DymSprite dSprite) {
dSprite.DrawAnimation(canvas);
long curTime = System.currentTimeMillis();
if (dSprite.walkCount == 5 || dSprite.walkCount == 10) { //5 - 当到达右边洞里 | 1 - 当到达左边洞里
reachSide(curTime, dSprite.walkCount, dSprite.isShowTrueBody, dSprite);
} else if (curTime - dSprite.mLastPlayTime > 500) {
dSprite.mPlayID++;
dSprite.walkCount++;
dSprite.aniX += dSprite.personXOff;
dSprite.mLastPlayTime = curTime;
}
}
public void reachSide(long curTime, int Count, boolean isShowTrueBody, DymSprite dSprite) {
//判断收到是否是要show truebody
dSprite.mPlayID = isShowTrueBody ? 11 : 0;
if (!dSprite.reachFlag) {
dSprite.reachFlag = true;
dSprite.reachTime = curTime; //当到达左边洞里,开始计时
} else {
dSprite.frameDelta = curTime - dSprite.reachTime;
if (dSprite.frameDelta > 2000) {
dSprite.personXOff *= -1;
dSprite.aniX += dSprite.personXOff;
dSprite.reachFlag = false;
dSprite.reachTime = 0;
dSprite.walkCount = Count == 5 ? 6 : 1;
dSprite.mPlayID = Count == 5 ? 6 : 1;
dSprite.isShowTrueBody = false;
}
}
}
/*
* 这里注意一个问题,当是READY状态,其他WIN or Lose 是不可能进来的,因为PointSpt会消失
*/
public void drawPointSpt(Canvas canvas) {
if (pSpt != null && pSpt.isRelease) {
if (gameView1.gameStatus == EBPConstants.PLAY) {
pSpt.DrawAnimation(canvas);
isChooseMode(); //如果已经掉出480,说明分数精灵释放完毕,开始进入可选模式
} else if (gameView1.gameStatus == EBPConstants.READY) {
pSpt.DrawFrame(canvas, null);
}
}
}
/*
* 这里是倒数3秒,即0-3,但countInverse是从0开始,因为第一次startGameTime是0,因为在Round1的构造函数中并未初始化它
* 所以第一次计时直接在else中执行了,0不会显示
* 不初始化更好,这样能确保第一次计时的准确性
*/
@Override
public void drawTimeUp(Canvas canvas, int gameStatus) {
//Log.e("BA", "ROUND-1 START TO TIMEUP");
super.drawTimeUp(canvas, gameStatus);
/*
* Change!!!
* 这里是需要每个GameView都需要改的地方,每关的
* --------------------
* 当分数精灵不为空 & 倒数时间到已经结束,可以释放分数精灵
*/
if (pSpt != null && timeUp) {
ti = null; //倒数结束,置空ti对象
pSpt.isRelease = true; //设置分数精灵释放标志位为true
pSpt.startTime = System.currentTimeMillis(); //获取开始释放分数精灵的开始时间,用于暂停时的计算
timeUp = false;
/*
* Change!!! 展示真身,这个可以有修改的余地
* 比如用一个变量整体控制所有需要显示真身的精灵
*/
thief.isShowTrueBody = true;
}
//Log.e("BA", "ROUND-1 END TO TIMEUP");
}
//
public void drawStaticRound(Canvas canvas) {
super.drawGeneralRound(canvas, EBPConstants.READY);
this.drawPointSpt(canvas);
if (person != null) {
person.DrawFrame(canvas, null);
}
if (thief != null) {
thief.DrawFrame(canvas, null);
}
}
public void drawActiveRound(Canvas canvas) {
super.drawGeneralRound(canvas, EBPConstants.PLAY);
this.computeTime(EBPConstants.PLAY);
this.drawPointSpt(canvas);
if (person != null) {
drawPerson(canvas, person);
}
if (thief != null) {
drawPerson(canvas, thief);
}
}
boolean psnIsTouch = false;
boolean thfIsTouch = false;
String tipStr = null;
/*
* pauseBtn
* person和thief只有在play状态下才可以touch
*/
public void onTouch(MotionEvent e) {
if (pauseBtn != null) {
if (pauseBtn.isTouch((int)e.getX(), (int)e.getY())) {
gameView1.gameStatus = EBPConstants.READY;
menuBtn.setBgBmp(menuPauseBgBmp); //设置菜单背景为pause的图片
//Log.e("BA", "ComputeTime, deltaTime = " + deltaTime);
}
}
//只有当精灵进入可选模式,即isOpenChooseMode为true才能进行touch选择
if (isOpenChooseMode) {
psnIsTouch = person.onTouch(e);
if (psnIsTouch && !person.isThief) {
lifes--;
if (isGameLose()) {
menuBtn.setBgBmp(menuLoseBgBmp); //设置菜单背景为lose的图片
}
}
thfIsTouch = thief.onTouch(e);
if (thfIsTouch && thief.isThief) {
thiefTotal--;
gameBonus += 119;
thief = null;
if (isGameWin()) {
menuBtn.setBgBmp(menuWinBgBmp); //设置菜单背景为win的图片
}
}
}
if (pSpt != null) {
if (pSpt.isTouchSprite((int)e.getX(), (int)e.getY())) {
pSpt.isRelease = false;
isChooseMode();
/*
* point++
*/
}
}
}
/*
* 判断是否分数精灵已经消失(即Y大于480,消失于底部)
* 消失,开启可选邪恶精灵模式,即能点击精灵模式
*/
public void isChooseMode() {
if (pSpt != null && !pSpt.isRelease) {
isDispCMIS = true;
startGameTime = System.currentTimeMillis();
pSpt.isRelease = false;
pSpt = null;
}
}
/*
* 获取所耗时间 = 当前这次deltaTime + 暂停前所累计的时间
*/
public boolean isGameWin() {
if (thiefTotal == 0) {
gameView1.gameStatus = EBPConstants.WIN;
gameView1.handler.sendEmptyMessage(EBPConstants.PASS)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android游戏关卡是否已经过关判断设计 (138个子文件)
resources.ap_ 835KB
EvilBatPrj.apk 860KB
proguard.cfg 1KB
EvilBatPrjActivity.class 7KB
Round1.class 7KB
ChooseRoundView.class 5KB
BaseRound.class 4KB
GameView1.class 4KB
Menu.class 4KB
GameMainView.class 4KB
RoundView.class 4KB
GameLoadBar1.class 4KB
DBHelper.class 3KB
Animation.class 3KB
QuitMenu.class 3KB
LoadBar.class 3KB
StaSprite.class 3KB
GameDraw1.class 3KB
SpriteAnimation.class 3KB
ImageButton.class 3KB
R$drawable.class 2KB
PointSprite.class 2KB
RoundDraw.class 2KB
GameMainDrawThread.class 2KB
ChooseRoundDrawThread.class 2KB
DymSprite.class 2KB
EvilBatPrjActivity$1.class 1KB
TimeInversion.class 1KB
EBPConstants.class 1KB
BitmapRes.class 784B
R.class 489B
ActivityCallback.class 433B
R$string.class 427B
R$layout.class 394B
R$attr.class 340B
.classpath 273B
classes.dex 42KB
Round1.java 8KB
EvilBatPrjActivity.java 8KB
BaseRound.java 6KB
Menu.java 5KB
ChooseRoundView.java 5KB
GameMainView.java 4KB
RoundView.java 4KB
R.java 4KB
Animation.java 3KB
QuitMenu.java 3KB
GameView1.java 3KB
GameLoadBar1.java 3KB
GameDraw1.java 3KB
SpriteAnimation.java 3KB
PointSprite.java 3KB
DBHelper.java 2KB
LoadBar.java 2KB
ImageButton.java 2KB
StaSprite.java 2KB
TimeInversion.java 2KB
DymSprite.java 1KB
RoundDraw.java 1KB
EBPConstants.java 1KB
ChooseRoundDrawThread.java 1KB
GameMainDrawThread.java 1KB
ActivityCallback.java 580B
BitmapRes.java 483B
Notice 514B
trefoil.png 700KB
house.png 16KB
chooseround.png 11KB
menuwin.png 11KB
house1.png 11KB
nextround.png 11KB
continu.png 11KB
backmenu.png 10KB
play.png 9KB
pause.png 9KB
restart.png 9KB
yes.png 8KB
no.png 8KB
loadback.png 7KB
fish1.png 7KB
fish4.png 7KB
smallman.png 7KB
fish2.png 6KB
redgift.png 6KB
fish3.png 6KB
truebody.png 6KB
fish5.png 6KB
message.png 6KB
fish8.png 6KB
walkright3.png 5KB
walkright1.png 5KB
walkright5.png 5KB
walkright2.png 5KB
walkright4.png 5KB
fish6.png 5KB
menulose.png 4KB
fish7.png 4KB
bat.png 4KB
icon.png 4KB
num8.png 4KB
共 138 条
- 1
- 2
资源评论
黑人也疯狂
- 粉丝: 7
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功