package sysu.androidclub.campusrichman.scene;
import java.util.ArrayList;
import java.util.Random;
import java.util.Stack;
import sysu.androidclub.campusrichman.GameEndScene;
import sysu.androidclub.campusrichman.R;
import sysu.androidclub.campusrichman.events.Event;
import sysu.androidclub.campusrichman.events.PlayerGradeChange;
import sysu.androidclub.campusrichman.events.PlayerSetHistoryMark;
import sysu.androidclub.campusrichman.events.PlayerStateChangeEvent;
import sysu.androidclub.campusrichman.events.SystemAnswerQuestion;
import sysu.androidclub.campusrichman.events.SystemGridViewEvent;
import sysu.androidclub.campusrichman.events.SystemInteractEvent;
import sysu.androidclub.campusrichman.events.SystemOneButtonDigEvent;
import sysu.androidclub.campusrichman.events.SystemToastEvent;
import sysu.androidclub.campusrichman.events.SystemTouchEvent;
import sysu.androidclub.campusrichman.events.SystemTwoButtonDigEvent;
import sysu.androidclub.campusrichman.mainlogic.Logicmain;
import sysu.androidclub.campusrichman.map.Map;
import sysu.androidclub.campusrichman.map.MapTileInfo;
import sysu.androidclub.campusrichman.player.Player;
import sysu.androidclub.campusrichman.utils.BasicInfo;
import sysu.androidclub.campusrichman.utils.Coordinate;
import sysu.androidclub.campusrichman.wigets.Card;
import sysu.androidclub.campusrichman.wigets.Dice;
import sysu.androidclub.campusrichman.wigets.GameEndDataPackage;
import sysu.androidclub.campusrichman.wigets.MissionMenu;
import sysu.androidclub.campusrichman.wigets.ReceiveMissionMenu;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnCancelListener;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsoluteLayout;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
/**.
* :,,
* .
* @author ,,,
* @version 0.0.1 2010-7-10
* 0.0.2 2010-7-19
*
* Event mEEvent
* 0.0.3 2010-7-22
* ,,
* 0.0.4 2010-7-25
*
*/
public class Scene extends View{
//Handler,
//
class RefreshHandler extends Handler {
public void handleMessage(Message msg) {
//
Scene.this.update();
//,
Scene.this.invalidate();
}
public void sleep(long delayMillis) {
//(,)
this.removeMessages(0);
//
sendMessageDelayed(obtainMessage(0), delayMillis);
}
}
/**
*
*/
static private boolean isNowMyBout = false;
//Handler
private RefreshHandler mRedrawHandler=new RefreshHandler();
//
private final Paint mPaint=new Paint();
/**
*
*/
private Bitmap[] trees;
/**
* 2010-8-28
*
*/
private Bitmap background;
/**
*
*/
private Bitmap infoboard;
/**
*
*/
private Bitmap cardicon;
/**
* 2010-7-27
*
* @author RR
*/
private Bitmap[][][] players;
/**
*
*/
private Bitmap playersHead[];
/**
* 2010-7-27
*
* @author RR
*/
private Bitmap[] dice;
/**
* 2010-7-27
*
* @author RR
*/
private Bitmap[] map;
/**
*
*/
private Question[] question;
/**
*
*/
int count = 0;
/**
*
*/
int mark;
int answer;
private Bitmap darkBitmap;
int[] choice;
long updateDelay=40;
MissionMenu missionmenu;
ReceiveMissionMenu receivemissionmenu;
/**
* 2010-7-29
*
* @author RR
*/
private Bitmap[] mapElements;
int mapOffsetX;
int mapOffsetY;
/**
*2010-7-27
*
*/
//
//Map mMap;
//
//Player mPlayer;
//
//int mPlayerNumber;
//
//Dice mDice;
//
//Queue<Event> mEventQueue;
//
//Queue<Player> mPlayerQueue;
//,null
/**
* 2010-7-26
*
* @author RR
*/
ArrayList<Event> mSystemEventList;
/**
* 2010-7-26
*
* @author RR
*/
Logicmain sceneLogic;
/**.
* ,,.
* @param context
* Activitythis.
* @param map
* .
* @param playergroup
* .
* @param playernumber
* .
* @param dice
* .
* @author ,,
* @version 0.0.1 2010-7-10
* 0.0.2 2010-7-19
*
* Event me
* 0.0.3 2010-7-22
* ,.
* 0.1.0 2010-7-27
*
*/
public Scene(Context context,Logicmain logicmain) {
super(context);
mSystemEventList=new ArrayList<Event>();
sceneLogic = logicmain;
missionmenu = new MissionMenu();
missionmenu.initBitmap(getResources());
receivemissionmenu = new ReceiveMissionMenu();
receivemissionmenu.initBitmap(getResources());
background = BitmapFactory.decodeResource(this.getResources(), R.drawable.scence);
infoboard = BitmapFactory.decodeResource(this.getResources(), R.drawable.infoboard);
cardicon = BitmapFactory.decodeResource(this.getResources(), R.drawable.cardicon);
//
players = new Bitmap[4][4][4];
// players[0] = BitmapFactory.decodeResource(this.getResources(), R.drawable.player1);
//players[1] = BitmapFactory.decodeResource(this.getResources(), R.drawable.player2);
//players[2] = BitmapFactory.decodeResource(this.getResources(), R.drawable.player3);
//players[3] = BitmapFactory.decodeResource(this.getResources(), R.drawable.player4);
players[0][Player.MOVING_DOWN][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_front0);
players[0][Player.MOVING_DOWN][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_front1);
players[0][Player.MOVING_DOWN][2] =players[0][Player.MOVING_DOWN][0];
players[0][Player.MOVING_DOWN][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_front3);
players[0][Player.MOVING_UP][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_back0);
players[0][Player.MOVING_UP][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_back1);
players[0][Player.MOVING_UP][2] =players[0][Player.MOVING_UP][0];
players[0][Player.MOVING_UP][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_back3);
players[0][Player.MOVING_LEFT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_left0);
players[0][Player.MOVING_LEFT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_left1);
players[0][Player.MOVING_LEFT][2] =players[0][Player.MOVING_LEFT][0];
players[0][Player.MOVING_LEFT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_left3);
players[0][Player.MOVING_RIGHT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_right0);
players[0][Player.MOVING_RIGHT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_right1);
players[0][Player.MOVING_RIGHT][2] =players[0][Player.MOVING_RIGHT][0];
players[0][Player.MOVING_RIGHT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_right3);
players[1][Player.MOVING_DOWN][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_front0);
players[1][Player.MOVING_DOWN][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_front1);
players[1][Player.MOVING_DOWN][2] =players[1][Player.MOVING_DOWN][0];
players[1][Player.MOVING_DOWN][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_front3);
players[1][Player.MOVING_UP][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_back0);
players[1][Player.MOVING_UP][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_back1);
players[1][Player.MOVING_UP][2] =players[1][Player.MOVING_UP][0];
players[1][Player.MOVING_UP][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_back3);
players[1][Player.MOVING_LEFT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_left0);
players[1][Player.MOVING_LEFT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_left1);
players[1][Player.MOVING_LEFT][2] =players[1][Player.MOVING_LEFT][0];
players[1][Player.MOVING_LEFT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_left3);
players[1][Player.MOVING_RIGHT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_right0);
players[1][Player.MOVING_RIGHT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_right1);
players[1][Player.MOVING_RIGHT][2] =players[1][Player.MOVING_RIGHT][0];
players[1][Player.MOVING_RIGHT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_right3);
players[2][Player.MOVING_DOWN][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_front0);
players[2][Player.MOVING_DOWN][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_front1);
players[2][Player.MOVING_DOWN][2] =players[2][Player.MOVING_DOWN][0];
players[2][Player.MOVING_DOWN][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_front3);
players[2][Player.MOVING_UP][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_back0);
players[2][Player.MOVING_UP][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_back1);
players[2][Player.MOVING_UP][2] =players[2][Player.MOVING_UP][0];
players[2][Player.MOVING_UP][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_back3);
players[2][Player.MOVING_LEFT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_left0);
players[2][Player.MOVING_LEFT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_left1);
players[2][Player.MOVING_LEFT][2] =players[2][Player.MOVING_LEFT][0];
players[2][Player.MOVING_LEFT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_left3);
players[2][Player.MOVING_RIGHT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_right0);
players[2][Player.MOVING_RIGHT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_right1);
players[2][Player.MOVING_RIGHT][2] =players[2][Player.MOVING_RIGHT][0];
players[2][Player.MOVING_RIGHT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_right3);
players[3][Player.MOVING_DOWN][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_front0);
players[3][Player.MOVING_DOWN][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_front1);
players[3][Player.MOVING_DOWN][2] =players[3][Player.MOVING_DOWN][0];
players[3][Player.MOVING_DOWN][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_front3);
players[3][Player.MOVING_UP][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_back0);
players[3][Player.MOVING_UP][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_back1);
players[3][Player.MOVING_UP][2] =players[3][Player.MOVING_UP][0];
players[3][Player.MOVING_UP][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_back3);
players[3][Player.MOVING_LEFT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_left0);
players[3][Player.MOVING_LEFT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_left1);
players[3][Player.MOVING_LEFT][2] =players[3][Player.MOVING_LEFT][0];
players[3][Player.MOVING_LEFT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_left3);
players[3][Player.MOVING_RIGHT][0] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_right0);
players[3][Player.MOVING_RIGHT][1] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_right1);
players[3][Player.MOVING_RIGHT][2] =players[3][Player.MOVING_RIGHT][0];
players[3][Player.MOVING_RIGHT][3] =BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_right3);
playersHead = new Bitmap[4];
playersHead[0] = BitmapFactory.decodeResource(this.getResources(), R.drawable.f1_head);
playersHead[1] = BitmapFactory.decodeResource(this.getResources(), R.drawable.f2_head);
playersHead[2] = BitmapFactory.decodeResource(this.getResources(), R.drawable.m1_head);
playersHead[3] = BitmapFactory.decodeResource(this.getResources(), R.drawable.m2_head);
dice = new Bitmap[6];
dice[0] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number1);
dice[1] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number2);
dice[2] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number3);
dice[3] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number4);
dice[4] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number5);
dice[5] = BitmapFactory.decodeResource(this.getResources(), R.drawable.number6);
map = new Bitmap[ Map.xmlfile.mapSourseDatas.size()+4];
do {
int i=0;
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.grasss);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.grasss);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.lot);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.tree);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road4);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.road5);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.basketball);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.brick);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.card);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.hospital);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.stop0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.stop1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.lamp);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.happy_more);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.indoor_pool);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.laboratory_building);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.public_notice);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.teaching_building);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.basketball);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water4);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water5);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water6);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water6);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water7);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.water8);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.administration_building0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.administration_building1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.design_and_communication_school0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.design_and_communication_school1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.dorm0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.dorm1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym4);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.gym5);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.hills0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.hills1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.hills2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.hills3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library4);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.library5);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.school_of_management0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.school_of_management1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.software_and_ist0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.software_and_ist1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii0);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii1);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii2);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii3);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii5);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii6);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii7);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.torii4);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.roadblock);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.banana);
map[i++] = BitmapFactory.decodeResource(this.getResources(), R.drawable.roadblock2);
} while (false);
trees = new Bitmap[4];
trees[0] = BitmapFactory.decodeResource(getResources(), R.drawable.tree00);
trees[1] = BitmapFactory.decodeResource(getResources(), R.drawable.tree01);
trees[2] = BitmapFactory.decodeResource(getResources(), R.drawable.tree02);
/**
*
*/
question = new Question[75];
for (int i = 0; i < 75; i++)
question[i] = new Question();
int r;
int title;
r = R.array.one;
title = R.string.titleone;
//
for (int i = 1; i < 75; i++,r++,title++ )
{
question[i].id = r;
question[i].title = title;
}
//
question[0].answer = 0;
question[1].answer = 1;
question[2].answer = 2;
question[3].answer = 3;
question[4].answer = 0;
question[5].answer = 1;
question[6].answer = 2;
question[7].answer = 0;
question[8].answer = 3;
question[9].answer = 2;
question[10].answer = 0;
question[11].answer = 2;
question[12].answer = 1;
question[13].answer = 1;
question[14].answer = 0;
question[15].answer = 1;
question[16].answer = 2;
question[17].answer = 1;
question[18].answer = 1;
question[19].answer = 0;
question[20].answer = 3;
question[21].answer = 2;
question[22].answer = 1;
question[23].answer = 3;
question[24].answer = 0;
question[25].answer = 1;
question[26].answer = 1;
question[27].answer = 2;
question[28].answer = 2;
question[29].answer = 1;
question[30].answer = 2;
question[31].answer = 0;
question[32].answer = 0;
question[33].answer = 3;
question[34].answer = 3;
question[35].answer = 0;
question[36].answer = 1;
question[37].answer = 0;
question[38].answer = 2;
question[39].answer = 2;
question[40].answer = 1;
question[41].answer = 0;
question[42].answer = 0;
question[43].answer = 1;
question[44].answer = 2;
question[45].answer = 0;
question[46].answer = 2;
question[47].answer = 0;
question[48].answer = 1;
question[49].answer = 3;
question[50].answer = 3;
question[51].answer = 1;
question[52].answer = 2;
question[53].answer = 0;
question[54].answer = 2;
question[55].answer = 3;
question[56].answer = 0;
question[57].answer = 3;
question[58].answer = 1;
question[59].answer = 0;
question[60].answer = 1;
question[61].answer = 2;
question[62].answer = 0;
question[63].answer = 0;
question[64].answer = 3;
question[65].answer = 0;
question[66].answer = 2;
question[67].answer = 3;
question[68].answer = 0;
question[69].answer = 1;
question[70].answer = 2;
question[71].answer = 0;
question[72].answer = 3;
question[73].answer = 2;
question[74].answer = 1;
mark = 0;
//,
update();
}
/**.
* .
* @author ,,
* @version 0.0.1 2010-7-10
* 0.0.2 2010-7-22
* ,.
* 0.0.3 2010-7-25
*
* 0.0.4 2010-7-29
*
*/
public void onDraw(Canvas canvas) {
//
canvas.drawBitmap(background, 0,0, mPaint);
super.onDraw(canvas);
//
Player currentpPlayer = sceneLogic.getCurrentPlayer();
//
MapTileInfo currentMap = sceneLogic.getMapLogic().getMap();
//
int tileNumX = BasicInfo.screenXSize/BasicInfo.tileSizeX;
int tileNumY = BasicInfo.screenYSize/BasicInfo.tileSizeY;
//
Coordinate currentplayerPos =currentpPlayer.getMapCoordinate();
//(0,0)
//
mapOffsetX=currentplayerPos.x*BasicInfo.tileSizeX-(BasicInfo.screenXSize-BasicInfo.tileSizeX)/2;
mapOffsetY=currentplayerPos.y*BasicInfo.tileSizeY-(BasicInfo.screenYSize-BasicInfo.tileSizeY)/2;
//
//
int tileOffestX = ((mapOffsetX+BasicInfo.tileSizeX*20)%BasicInfo.tileSizeX+currentpPlayer.getOffsetX());
int tileOffestY = ((mapOffsetY+BasicInfo.tileSizeY*20)%BasicInfo.tileSizeY+currentpPlayer.getOffsetY());
//
//
Coordinate realTilePostmp = new Coordinate();
int playercolor[] = {Color.BLUE,Color.GREEN,Color.RED,Color.YELLOW};
boolean isshow= false;
for (int j = currentplayerPos.y-tileNumY/2-2; j < currentplayerPos.y+tileNumY/2+3; j++) {
for (int i = currentplayerPos.x-tileNumX/2-2; i < currentplayerPos.x+tileNumX/2+3; i++) {
//
realTilePostmp.x=(i-currentplayerPos.x)*BasicInfo.tileSizeX-tileOffestX+(BasicInfo.screenXSize-2*BasicInfo.tileSizeX)/2+25;
realTilePostmp.y=(j-currentplayerPos.y)*BasicInfo.tileSizeY-tileOffestY+(BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2+30;
//
if (i>=0&&j>=0&&i<currentMap.getXsize()&&j<currentMap.getYsize()) {
canvas.drawBitmap(map[currentMap.tileLayer[j][i]], realTilePostmp.x, realTilePostmp.y, mPaint);
if( currentMap.MaskLayer[j][i]!=0)
{
canvas.drawBitmap(map[currentMap.MaskLayer[j][i]], realTilePostmp.x, realTilePostmp.y, mPaint);
}
}
//
if (i>=0&&j>=0&&i<currentMap.getXsize()&&j<currentMap.getYsize()&¤tMap.getBuildingLayer()[j][i].show!=-1) {
//canvas.drawBitmap(mapElements[currentMap.getBulidingLayer()[i][j].show], realTilePostmp.x, realTilePostmp.y, mPaint);
//mPaint.setTextSize(40);
//mPaint.setColor(playercolor[currentMap.getBulidingLayer()[i][j].owner]);
//canvas.drawText(currentMap.getBulidingLayer()[i][j].level+"", realTilePostmp.x, realTilePostmp.y+30, mPaint);
canvas.drawBitmap(trees[currentMap.getBuildingLayer()[j][i].level - 1], realTilePostmp.x, realTilePostmp.y, mPaint);
}
//Log
//if (currentpPlayer.getMapCoordinate().x==j && currentpPlayer.getMapCoordinate().y==i && currentpPlayer.getPlayerRounte().size()!=0) {
// isshow = true;
// Log.v("YY", "("+mapOffsetX+","+mapOffsetY+")"+":"+"("+tileOffestX+","+tileOffestY+")"+":"+"("+currentpPlayer.getOffsetX()+","+currentpPlayer.getOffsetY()+")"+":"+"("+currentpPlayer.getmovingState()+":"+currentpPlayer.getMapCoordinate().x+","+currentpPlayer.getMapCoordinate().y+"->"+currentpPlayer.getPlayerRounte().get(0).x+","+currentpPlayer.getPlayerRounte().get(0).y+")"+":"+"("+realTilePostmp.x+","+realTilePostmp.y+")\r\n");
//}
}
}
//
//
/**
*
*/
int Textx = 0;
int Texty = 400;
int count = 0;
Stack<Integer> playerTurn = new Stack<Integer>();
int playerId = currentpPlayer.getId()+1;
while ((playerId=playerId%(sceneLogic.getPlayers().length))!=currentpPlayer.getId()) {
Log.v("ID", playerId+"");
playerTurn.push(playerId);
playerId++;
}
for (Player player : sceneLogic.getPlayers()) {
Coordinate playerPos = player.getMapCoordinate();
if (player.getPlayerState()!=Player.FAILED&¤tpPlayer.getPlayerState()!=Player.MOVING) {
canvas.drawBitmap(players[player.getMajor()][player.getmovingState()][0],
(playerPos.x-currentplayerPos.x)*BasicInfo.tileSizeX-tileOffestX+(BasicInfo.screenXSize-2*BasicInfo.tileSizeX)/2+20,
(playerPos.y-currentplayerPos.y)*BasicInfo.tileSizeY-tileOffestY+(BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2-15,
mPaint);
}
}
while (!playerTurn.isEmpty()) {
playerId = playerTurn.pop();
Player player = sceneLogic.getPlayers()[playerId];
}
/* for (Player player :sceneLogic.getPlayers()) {
// mPaint.setTextSize(20);
//mPaint.setColor(playercolor[player.getId()]);
Coordinate playerPos = player.getMapCoordinate();
//canvas.drawText("Player"+player.getId()+" Money :"+player.getMoney()+" Grade :"+player.getGrade(), Textx, Texty+count*25, mPaint);
count++;
if (player.getId()!=currentpPlayer.getId()&¤tpPlayer.getPlayerState()!=Player.MOVING) {
//
canvas.drawBitmap(players[player.getMajor()][player.getmovingState()][0],
(playerPos.x-currentplayerPos.x)*BasicInfo.tileSizeX-tileOffestX+(BasicInfo.screenXSize-2*BasicInfo.tileSizeX)/2+20,
(playerPos.y-currentplayerPos.y)*BasicInfo.tileSizeY-tileOffestY+(BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2-15,
mPaint);
}else {
//
if (isshow) {
Log.v("RRRRRR", player.getMajor()+" "+player.getmovingState()+" "+player.playerInfo.picState);
isshow = false;
}
}
}*/
canvas.drawBitmap(players[currentpPlayer.getMajor()][currentpPlayer.getmovingState()][currentpPlayer.playerInfo.picState],
(currentplayerPos.x-currentplayerPos.x)*BasicInfo.tileSizeX-tileOffestX+(BasicInfo.screenXSize-2*BasicInfo.tileSizeX)/2+currentpPlayer.getOffsetX()+20,
(currentplayerPos.y-currentplayerPos.y)*BasicInfo.tileSizeY-tileOffestY+(BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2+currentpPlayer.getOffsetY()-15,
mPaint);
//if (isshow) {
//Log.v("YY", ""+((currentplayerPos.y-currentplayerPos.y)*BasicInfo.tileSizeY-tileOffestY+(BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2+currentpPlayer.getOffsetY()-15));
//}
//
Dice currentDice = sceneLogic.getDice();
canvas.drawBitmap(dice[currentDice.showState],currentDice.coordinate.x ,currentDice.coordinate.y,mPaint);
//
if ( currentDice.diceNum == 2)
canvas.drawBitmap(dice[currentDice.showState2],currentDice.coordinate2.x ,currentDice.coordinate2.y,mPaint);
//
canvas.drawBitmap( cardicon,
sceneLogic.getCard().coordinate.x ,sceneLogic.getCard().coordinate.y,mPaint);
//
canvas.drawBitmap(infoboard, 0,0, mPaint);
canvas.drawBitmap(playersHead[currentpPlayer.getMajor()], 0, 0, mPaint);
//
mPaint.setTextSize(30);
canvas.drawText(new Integer((int)currentpPlayer.getMoney()).toString(), BasicInfo.screenXSize/2- 85, 45, mPaint);
canvas.drawText(new Double(currentpPlayer.getGrade()).toString(), BasicInfo.screenXSize/2- 85, 80, mPaint);
canvas.drawText(new Integer((int)currentpPlayer.getRP()).toString(), BasicInfo.screenXSize/2- 85, 115, mPaint);
canvas.drawBitmap(missionmenu.iconbitmap, missionmenu.missionbutton.x, missionmenu.missionbutton.y, mPaint);
missionmenu.onDraw(canvas, currentpPlayer);
receivemissionmenu.onDraw(canvas, currentpPlayer);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
//touch
if (event.getAction() ==MotionEvent.ACTION_UP) {
missionmenu.isTouched(event, sceneLogic.getCurrentPlayer());
receivemissionmenu.isTouched(event, sceneLogic.getCurrentPlayer(), sceneLogic);
if (missionmenu.status == -1 && receivemissionmenu.status == ReceiveMissionMenu.NOTSHOWING)
{
SystemTouchEvent tmp = new SystemTouchEvent((int)(event.getX()), (int)(event.getY()),
((BasicInfo.screenXSize-2*BasicInfo.tileSizeX)/2-(mapOffsetX%BasicInfo.tileSizeX)),
((BasicInfo.screenYSize-2*BasicInfo.tileSizeY)/2-(mapOffsetY%BasicInfo.tileSizeY)),
(sceneLogic.getCurrentPlayer()).getMapCoordinate(),
(sceneLogic.getMapLogic()).getRoute(),
(sceneLogic.getMapLogic()).getRouteLength());
mSystemEventList.add(tmp);
}
}
return true;
}
/**.
*
* .
* @author ,,,,
* @version 0.0.1 2010-7-10
* 0.0.2 2010-7-19
*
* meEventupdateEvent
*
* playerdiceupdate
* 0.0.3 2010-7-22
* if
* 0.0.4 2010-7-22
* ,
* 0.1.0 2010-7-26
* SystemInteract
*/
public void update() {
long start = System.currentTimeMillis();
//
ArrayList<SystemInteractEvent> tmpList = sceneLogic.update(mSystemEventList);
//
mSystemEventList.clear();
//
for (final SystemInteractEvent systemInteractEvent : tmpList) {
switch (systemInteractEvent.subtype) {
case Event.SYSTEM_INTERACT_SUB_ONE_BUTTON_DIG:
final Dialog oneButtonDialog = new Dialog(getContext());
oneButtonDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
LinearLayout layout = new LinearLayout( getContext());
layout.setLayoutParams( new LayoutParams(240, 200));
layout.setOrientation( LinearLayout.VERTICAL);
layout.setBackgroundResource(R.drawable.dialogbackground);
TextView oneButtonDialogTextView = new TextView(layout.getContext());
oneButtonDialogTextView.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT) );
oneButtonDialogTextView.setText(((SystemOneButtonDigEvent)systemInteractEvent).msg);
oneButtonDialogTextView.setTextSize(24);
oneButtonDialogTextView.setTextColor( Color.WHITE);
layout.addView( oneButtonDialogTextView);
//DialogButton oneButtonDialogConfirmButton = new DialogButton(layout.getContext(), "");
//oneButtonDialogConfirmButton.set
TextView oneButtonDialogConfirmButton = new TextView( layout.getContext());
oneButtonDialogConfirmButton.setBackgroundResource(R.drawable.buttonbackground);
oneButtonDialogConfirmButton.setText(((SystemOneButtonDigEvent)systemInteractEvent).buttonText);
oneButtonDialogConfirmButton.setTextSize(18);
oneButtonDialogConfirmButton.setTextColor(Color.YELLOW);
oneButtonDialogConfirmButton.setWidth(((SystemOneButtonDigEvent)systemInteractEvent).buttonText.length()*18 );
oneButtonDialogConfirmButton.setGravity( Gravity.CENTER);
/*
//DialogButton oneButtonDialogConfirmButton = new DialogButton(layout.getContext(),"" );
ImageView oneButtonDialogConfirmButton = new ImageView( layout.getContext());
oneButtonDialogConfirmButton.setScaleType(ImageView.ScaleType.CENTER);
Canvas oneButtonDialogConfirmButtonCanvas = new Canvas();
Paint oneButtonDialogConfirmButtonPaint = new Paint();
oneButtonDialogConfirmButtonCanvas.clipRect(0, 0, 50, 40);
oneButtonDialogConfirmButtonCanvas.drawBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.buttonbackground), 0, 0, oneButtonDialogConfirmButtonPaint);
oneButtonDialogConfirmButtonPaint.setTextSize(40);
oneButtonDialogConfirmButtonPaint.setColor(Color.YELLOW);
//oneButtonDialogConfirmButtonCanvas.drawText(((SystemOneButtonDigEvent)systemInteractEvent).buttonText, 40, 30, oneButtonDialogConfirmButtonPaint);
oneButtonDialogConfirmButton.draw(oneButtonDialogConfirmButtonCanvas);*/
oneButtonDialogConfirmButton.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
oneButtonDialogConfirmButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
mSystemEventList.clear();
ArrayList<Event> okEventList = ((SystemOneButtonDigEvent)systemInteractEvent).okEventList;
for (Event okEvent : okEventList)
mSystemEventList.add(okEvent);
oneButtonDialog.dismiss();
}
});
/*
//oneButtonDialogConfirmButton.setImageResource( R.drawable.confirmbutton);
oneButtonDialogConfirmButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
mSystemEventList.clear();
ArrayList<Event> okEventList = ((SystemOneButtonDigEvent)systemInteractEvent).okEventList;
for (Event okEvent : okEventList)
mSystemEventList.add(okEvent);
oneButtonDialog.dismiss();
}
});
*/
layout.setGravity( Gravity.CENTER);
layout.addView( oneButtonDialogConfirmButton);
oneButtonDialog.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
mSystemEventList.clear();
ArrayList<Event> okEventList = ((SystemOneButtonDigEvent)systemInteractEvent).okEventList;
for (Event okEvent : okEventList)
mSystemEventList.add(okEvent);
}
});
oneButtonDialog.setContentView(layout);
oneButtonDialog.show();
/*
Dialog digo=new AlertDialog
.Builder(getContext())
.setMessage(((SystemOneButtonDigEvent)systemInteractEvent).msg)
.setNeutralButton(((SystemOneButtonDigEvent)systemInteractEvent).buttonText,
new DialogInterface.OnClickListener() {
//
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//
mSystemEventList.clear();
ArrayList<Event> okEventList = ((SystemOneButtonDigEvent)systemInteractEvent).okEventList;
for (Event okEvent : okEventList)
mSystemEventList.add(okEvent);
}
})
.setOnCancelListener(
new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
mSystemEventList.clear();
ArrayList<Event> okEventList = ((SystemOneButtonDigEvent)systemInteractEvent).okEventList;
for (Event okEvent : okEventList)
mSystemEventList.add(okEvent);
}
})
.create();
digo.show();
*/
break;
case Event.SYSTEM_INTERACT_SUB_TWO_BUTTON_DIG:
final Dialog twoButtonDialog = new Dialog(getContext());
twoButtonDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
LinearLayout twoButtonDialogLayout = new LinearLayout( getContext());
twoButtonDialogLayout.setLayoutParams( new LayoutParams(240, 400));
twoButtonDialogLayout.setOrientation( LinearLayout.VERTICAL);
twoButtonDialogLayout.setBackgroundResource(R.drawable.dialogbackground);
TextView twoButtonDialogTextView = new TextView(twoButtonDialogLayout.getContext());
twoButtonDialogTextView.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams .WRAP_CONTENT) );
twoButtonDialogTextView.setText(((SystemTwoButtonDigEvent)systemInteractEvent).msg);
twoButtonDialogTextView.setTextSize(24);
twoButtonDialogTextView.setTextColor( Color.WHITE);
twoButtonDialogLayout.addView( twoButtonDialogTextView);
LinearLayout twoButtonDialogLayout_ButtonsLayout = new LinearLayout( twoButtonDialogLayout.getContext());
twoButtonDialogLayout_ButtonsLayout.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
twoButtonDialogLayout_ButtonsLayout.setOrientation( LinearLayout.HORIZONTAL);
TextView twoButtonDialogConfirmButton = new TextView( twoButtonDialogLayout_ButtonsLayout.getContext());
twoButtonDialogConfirmButton.setBackgroundResource(R.drawable.buttonbackground);
twoButtonDialogConfirmButton.setTextSize(18);
twoButtonDialogConfirmButton.setTextColor(Color.YELLOW);
twoButtonDialogConfirmButton.setWidth(((SystemTwoButtonDigEvent)systemInteractEvent).buttonYesText.length()*18 );
twoButtonDialogConfirmButton.setText(((SystemTwoButtonDigEvent)systemInteractEvent).buttonYesText);
twoButtonDialogConfirmButton.setGravity( Gravity.CENTER);
twoButtonDialogConfirmButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
//
//
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).yesEvent);
twoButtonDialog.dismiss();
}
});
twoButtonDialogLayout_ButtonsLayout.addView(twoButtonDialogConfirmButton);
TextView twoButtonDialogCancelButton = new TextView( twoButtonDialogLayout_ButtonsLayout.getContext());
twoButtonDialogCancelButton.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
twoButtonDialogCancelButton.setBackgroundResource(R.drawable.buttonbackground);
twoButtonDialogCancelButton.setTextSize(18);
twoButtonDialogCancelButton.setTextColor(Color.YELLOW);
twoButtonDialogCancelButton.setWidth(((SystemTwoButtonDigEvent)systemInteractEvent).buttonNoText.length()*18 );
twoButtonDialogCancelButton.setGravity( Gravity.CENTER);
twoButtonDialogCancelButton.setText(((SystemTwoButtonDigEvent)systemInteractEvent).buttonNoText);
twoButtonDialogCancelButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).noEvent);
twoButtonDialog.dismiss();
}
});
twoButtonDialogLayout_ButtonsLayout.addView( twoButtonDialogCancelButton);
twoButtonDialogLayout.addView( twoButtonDialogLayout_ButtonsLayout);
twoButtonDialog.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).noEvent);
}
});
twoButtonDialogLayout.setGravity( Gravity.CENTER);
twoButtonDialog.setContentView(twoButtonDialogLayout);
twoButtonDialog.show();
/*
Dialog dig=new AlertDialog
.Builder(getContext())
.setMessage(((SystemTwoButtonDigEvent)systemInteractEvent).msg)
.setPositiveButton(((SystemTwoButtonDigEvent)systemInteractEvent).buttonYesText,
new DialogInterface.OnClickListener() {
//
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).yesEvent);
}
})
.setNegativeButton(((SystemTwoButtonDigEvent)systemInteractEvent).buttonNoText,
new DialogInterface.OnClickListener() {
//
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).noEvent);
}
})
.setOnCancelListener(
new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
mSystemEventList.clear();
mSystemEventList.add(((SystemTwoButtonDigEvent)systemInteractEvent).noEvent);
}
})
.create();
dig.show();
*/
break;
case Event.SYSTEM_INTERACT_SUB_TOAST:
Toast toast = Toast.makeText(getContext(),((SystemToastEvent)systemInteractEvent).msg,Toast.LENGTH_SHORT);
//GameToast toast = new GameToast(getContext(), ((SystemToastEvent)systemInteractEvent).msg);
View textView = toast.getView();
LinearLayout lay = new LinearLayout(getContext());
lay.setOrientation(LinearLayout.VERTICAL);
ImageView view = new ImageView(getContext());
Bitmap bitmap ;
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
bitmap = bitmap.createScaledBitmap(bitmap, 200, 200, true);
view.setImageBitmap(bitmap);
lay.addView(view);
lay.addView(textView);
toast.setView(lay);
toast.show();
break;
case Event.SYSTEM_INTERACT_SUB_SHOWINGMISSION:
receivemissionmenu.status = ReceiveMissionMenu.SHOWING;
break;
//
case Event. SYSTEM_INTERACT_EXIT:
final GameEndDataPackage end = new GameEndDataPackage(sceneLogic);
Dialog a =new AlertDialog
.Builder(getContext())
.setMessage(end.getMessage())
.setPositiveButton("", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
int[] playerId=new int[end.playersnum];
double[] mark=new double[end.playersnum];
for (int i=0;i<end.playersnum;i++)
{
playerId[i]=end.playersinfo[i].playerId;
mark[i]=end.playersinfo[i].mark;
}
Intent intent=new Intent();
Bundle bundle=new Bundle();
bundle.putIntArray("playerId", playerId);
bundle.putDoubleArray("mark", mark);
intent.putExtras(bundle);
intent.setClass(getContext(),GameEndScene.class);
getContext().startActivity(intent);
((Activity)getContext()).finish();
}
}).create();
a.show();
break;
//
case Event.SYSTEM_INTERACT_SUB_ANSWERQUEST:
Random random = new Random();
int num;
int range = 50;
int add = 1;
if (((SystemAnswerQuestion)systemInteractEvent).missionkind == Event.SYSTEM_INTERACT_SUB_ANSWERQUEST_SYSUHISTORY)
{
add = 51;
range = 24;
}
boolean repeat = true;
//
if (count == 0)
{
choice = new int[((SystemAnswerQuestion)systemInteractEvent).num];
choice[0] = random.nextInt(range) + add;
for (int i = 1; i < choice.length; i++)
{
num = random.nextInt(range) + add;
//
while (repeat)
{
for (int j = 0; j < i; j++)
{
if(num == choice[j])
{
num = random.nextInt(range) + add;
repeat = true;
break;
}
if (j == i - 1)
{ repeat = false;break;}
}
}
choice[i] = num ;
repeat = true;
}
}
//
AlertDialog dia = new AlertDialog.Builder(getContext()).setIcon(1)
.setTitle(question[choice[count]].title)
.setSingleChoiceItems(question[choice[count]].id, 0, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
answer = whichButton;
/* User clicked on a radio button do some stuff */
}
})
.setPositiveButton("", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if (answer == question[choice[count]].answer )
mark += 10;
count++;
if (count != ((SystemAnswerQuestion)systemInteractEvent).num)
mSystemEventList.add( new SystemAnswerQuestion( ((SystemAnswerQuestion)systemInteractEvent).missionkind, ((SystemAnswerQuestion)systemInteractEvent).num) );
else
{
//
if (((SystemAnswerQuestion)systemInteractEvent).missionkind == Event.SYSTEM_INTERACT_SUB_ANSWERQUEST_FINALEXAM)
{
ArrayList<Event> tmp = new ArrayList<Event>();
tmp.add(new PlayerStateChangeEvent(Event.MAP, Event.CURRENT_PLAYER, Player.END));
String msg = "" + mark / 10 + "" + 0.05 * mark +"";
tmp.add(new PlayerGradeChange(Event.SYSTEM, Event.CURRENT_PLAYER, 0.05 * mark));
mSystemEventList.add(new SystemOneButtonDigEvent(Event.MAP, tmp, msg, "") );
count = 0;
mark = 0;
}
//
if ( ((SystemAnswerQuestion)systemInteractEvent).missionkind == Event.SYSTEM_INTERACT_SUB_ANSWERQUEST_SYSUHISTORY )
{
ArrayList<Event> tmp = new ArrayList<Event>();
tmp.add(new PlayerSetHistoryMark(Event.SYSTEM, Event.CURRENT_PLAYER, mark));
tmp.add(new PlayerStateChangeEvent(Event.MAP, Event.CURRENT_PLAYER, Player.END));
String msg = "" + mark / 10 + "";
mSystemEventList.add(new SystemOneButtonDigEvent(Event.MAP, tmp, msg, "") );
count = 0;
mark = 0;
}
}
/* User clicked Yes so do some stuff */
}
}).create();
dia.show();
break;
case Event.SYSTEM_INTERACT_SUB_GRIDVIEW:
{
//
final Dialog dialog = new Dialog(getContext(),android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
AbsoluteLayout absoluteLayout=new AbsoluteLayout(getContext());
absoluteLayout.setBackgroundResource(R.drawable.cardmenubackground);
GridView gridView = new GridView(getContext());
gridView.setNumColumns(GridView.AUTO_FIT);
gridView.setGravity(Gravity.CENTER_HORIZONTAL);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setVerticalSpacing(2);
gridView.setHorizontalSpacing(0);
gridView.setColumnWidth(125);
gridView.setAdapter( new ImageAdapter( gridView.getContext(),((SystemGridViewEvent)systemInteractEvent).pictureIds));
gridView.setOnItemClickListener( new OnItemClickListener(){
public void onItemClick( AdapterView<?> parent, View v, int position, long id){
ArrayList<Event> tmp = new ArrayList<Event>();
tmp.add(((SystemGridViewEvent)systemInteractEvent).events.get(position));
sceneLogic.addtoGlobalEventList(tmp);
dialog.cancel();
}
});
absoluteLayout.addView(gridView,new AbsoluteLayout.LayoutParams(380, 400, 50, 193));
Button cancelButton = new Button( dialog.getContext());
cancelButton.setBackgroundResource(R.drawable.cardmenureturn);
cancelButton.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
mSystemEventList.add( new PlayerStateChangeEvent(Event.MAP, Event.CURRENT_PLAYER, Player.READY));
dialog.dismiss();
sceneLogic.getCard().state = Card.Button_Ready;
}
});
absoluteLayout.addView( cancelButton,new AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT, AbsoluteLayout.LayoutParams.WRAP_CONTENT, 70, 690));
//LayoutParams lp = new LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT );
dialog.setContentView(absoluteLayout);
// dialog.addContentView(gridView, lp );
//dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//dialog.setTitle("");
dialog.show();
break;
}
default:
break;
}
}
//SystemEvent
//
tmpList.clear();
//
/*if (mSystemEvent!=null)
{
//,
if(mDice.getState()==Dice.DICE_UNLOCKED && mPlayer.getState()==Player.PLAYER_READY)
{
//
mEventQueue.offer(mSystemEvent);
}
//,
mSystemEvent=null;
}
//,
EventDispatcher.dispatchEvent(
this,
mMap,
mPlayer,
mDice,
mEventQueue,
mPlayerQueue);
//
mPlayer.update();
//
mDice.update();
//
mMap.update();
//,handleMessage*/
//
long end = System.currentTimeMillis();
if (end-start<updateDelay) {
mRedrawHandler.sleep(updateDelay-(end-start));
}
else {
mRedrawHandler.sleep(0);
}
}
/**.
* .
* @param systemevent
* .
* @author
* @version 0.0.1 2010-7-22
*/
/*public void setEvent (Event systemevent){
mSystemEvent=systemevent;
}*/
private Coordinate getMapDarwingStartTile(Player currentPlayer)
{
Coordinate startTile = new Coordinate();
startTile.x = currentPlayer.getMapCoordinate().x-(BasicInfo.screenXSize/BasicInfo.tileSizeX)/2;
startTile.y = currentPlayer.getMapCoordinate().y-(BasicInfo.screenYSize/BasicInfo.tileSizeY)/2;
return startTile;
}
private int generateTileOffset(int TileNum,int Offset,int x)
{
if (TileNum%2==1) {
return 1;
}else if(TileNum%2==0&&Offset<=x/2)
{
return 0;
}else if(TileNum%2==0&&Offset>x/2)
{
return 1;
}
return 0;
}
static public boolean isMyBout()
{
return isNowMyBout;
}
static public void changeBoutState( boolean state)
{
isNowMyBout = state;
}
}
class ImageAdapter extends BaseAdapter
{
private Context mContext;
private ArrayList<Integer> mpictures;
public ImageAdapter ( Context c, ArrayList<Integer> pictures )
{
mContext = c;
mpictures = pictures;
}
public Object getItem(int position )
{
return position;
}
public int getCount ()
{
return mpictures.size();
}
public long getItemId( int position)
{
return position;
}
public View getView( int position, View convertView, ViewGroup parent)
{
ImageView imageView = new ImageView( mContext);
// imageView.setImageResource( mPlayer.getCards()[ Card.getCardViewId( position ) ]);
imageView.setImageResource( mpictures.get(position));
imageView.setLayoutParams( new GridView.LayoutParams(125,127));
imageView.setScaleType( ImageView.ScaleType.FIT_CENTER);
return imageView;
}
}
class Question
{
int title;
int id;
int answer;
public Question()
{
title = 0;
id = 0;
answer = 0;
}
}
|