📄 game.h
字号:
// Game.h: interface for the CGame class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GAME_H__07851B10_3E6D_45EF_A8B8_DF96C179301D__INCLUDED_)
#define AFX_GAME_H__07851B10_3E6D_45EF_A8B8_DF96C179301D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _FOR_BETA_ // defined by Tiger
#define _COIN_SHOWING // for removing coin in debug mode Milo 02-28
#include "..\System\gfx.h"
#include "..\System\bufreader.h"
#include "..\System\File.h"
#include "def.h"
#include "Match.h" // Added by ClassView
#include "ui.h" // Added by ClassView
#include "DataManager.h" // Added by ClassView
#include "menu.h"
#include "cplayer.h"
#include "..\System\sound.h"
class CEngine;
class CSound;
class CKeyinput;
class CFont;
class CScene;
class CMatch;
class CUI;
const int DISPLAY_BOARD_HEIGHT = 38;
const int SCORE_BOARD_DOWN = 0;
const int SCORE_BOARD_UP = 1;
const int SCORE_BOARD_HIDE = 2;
const int SCORE_BOARD_WITHOUT = 3;
const int POWER_BAR_ADJUST = 1;
const int POWER_BAR_SHRINK = 2;
const int GENERAL_REC_SEEK = 10 * (2 * MAX_NAME_LENGTH + 4)+ 6;
const int SAVE_DATA_LENGTH=414;
//// << ===============================================================
//// 2005.1.11 YI WEN HU
// save info
const int SAVE_NONE=-1;
const int SAVE_SUCCESS=0;
const int SAVE_CREATE_ERROR=1;
const int SAVE_READ_ERROR=2;
//// game state
const int GS_MENU=0;
const int GS_LOADING=1;
const int GS_MATCH=2;
const int GS_END=3;
const int GS_STORYMODE=4;
const int GS_CAMERAVIEW_LOADING=5;
const int GS_CAMERAVIEW=6;
const int GS_LEVEL_INTRODUCTION=7;
const int GS_ONLINE_LOADING=8;
//// match state
const int MS_MATCH_INIT=10;
const int MS_DELIVERY_INIT=11;
const int MS_DELIVERY=12;
//const int MS_SCOREDISPLAY=13;
const int MS_VS_SCORE=14;
const int MS_BONUS_SCORE=15;
const int MS_BONUS_WATING=16;
//const int MS_STORY_BONUS_SCORE=16;
const int MS_DELIVERY_SCOREBOARD=17;
const int MS_DELIVERY_END=18;
const int MS_RESULT_ANI=19;
const int MS_MATCH_RESULT_SCOREBOARD=20;
const int MS_MATCH_END=21;
const int MS_MATCH_EXIT=22;
const int MS_QUICK_PRESHOW=23;
const int MS_QUICK_POSTSHOW=24;
const int MS_MONEY_RESULT=25;
const int MS_BONUS_MONEY_BET=26;
const int MS_MATCH_DRAW=27;
const int MS_ONLINE_WAIT=28;
const int MS_ONLINE_USER_STATES=29;
const int MS_ONLINE_USER_RANKING=30;
const int MS_ONLINE_ERROR=31;
//// story mode state
const int SMS_MODE_INIT=30;
const int SMS_LEVEL_LOADING=31;
const int SMS_LEVEL_INTRODUCTION=32;
const int SMS_LEVEL_PRE_TALK=33;
const int SMS_LEVEL_MATCH=34;
const int SMS_LEVEL_MATCH_RESULT_ANI=35;
//const int SMS_LEVEL_BONUS=36;
//const int SMS_LEVEL_BONUS_RESULT_ANI=37;
const int SMS_LEVEL_END=38;
const int SMS_MODE_END=39;
const int SMS_MODE_EXIT=40;
const int SMS_CONTINUE=41;
// mode
const int MODE_QUICK=1;
const int MODE_FREE=2;
const int MODE_BONUS=3;
const int MODE_STORY=4;
const int MODE_CAMERA=5;
const int MODE_STORY_CONTINUE=6;
const int MODE_ONLINE=7;
// unlock info
const int UNLOCK_CAMERAVIEW_TIME = 5;
const int UNLOCK_NICO_TIME = 10;
const int UNLOCK_RAY_TIME = 20;
// online wait state
const int ONLINE_MAX_OVERTIME_COUNTER=1;
const int ONLINE_MAX_OVERTIME_TIME=60*2;
const int ONLINE_STATE_GAME =0;
const int ONLINE_STATE_SEND_DATA =1;
const int ONLINE_STATE_RECEIVE_DATA =2;
const int ONLINE_STATE_GAME_PREPARED =3;
const int ONLINE_STATE_NOT_ONLINE =4;
const int ONLINE_STATE_GAME_END =5;
enum saveType{
SAVE_OPTION=1,
SAVE_STORY=2,
SAVE_MONEY=4,
SAVE_GENERAL=7,
SAVE_WITHOUT_EXIT = 16,
SAVE_EXIT = 32,
SAVE_PLAYER_CHANGE = 64
};
//////////////////////////////////////////////////////////////////////////
// for the money system //
//////////////////////////////////////////////////////////////////////////
enum moneyUpdateState{
matchUpdateNormal=1,
matchUpdateSpare,
matchUpdateStrike,
matchUpdateBet,
matchUpdateBetResult,
};
// for the money system
const int TOTAL_BALL =6;
const int TOTAL_PLAYER =6;
const int TOTAL_SUIT =3;
const int TOTAL_UPDATE =3;
const boolean INIT_BALL_STATUS[TOTAL_BALL]={// the init ball can select
true,true,false,false,false,true
};
const boolean INIT_PLAY_STATUS[TOTAL_PLAYER]={// the init player can select
true,true,false,false,false,false
};
const boolean INIT_SUIT_STATUS[TOTAL_SUIT]={// the init suit can select
true,true,false
};
//MONEY_UNLOCK_SUIT
const int MONEY_UNLOCK[3][6] ={
{//the money upper limit to unlock the ball
0,0,10000,100000,200000,0
},
{//the money upper limit to unlock the players
0,0,10000,20000,60000,150000
},
{//the money upper limit to unlock the third suit
25000,50000,100000,200000,500000,1000000
}
};
const int SHIFT_LOCK_BALL =0;
const int SHIFT_LOCK_CHARACTER =1;
const int SHIFT_LOCK_SUIT =2;
const int MONEY_SCORE = 100;
const int MONEY_SPARE = 1000;
const int MONEY_STRIKE = 2000;
const int MONEY_MAX = 999999999;
const int MONEY_WINBONUS =1000;
const int STATE_MONEY_RESULT =0;
const int STATE_MONEY_RESULT_DONE =1;
const int STATE_MONEY_UNLOCK =2;
const int STATE_MONEY_UNLOCK_DONE =3;
const int STATE_MONEY_ASK_RETRY =4;
const int STATE_MONEY_END =5;
const int BET_MONEY_INCREMENT[]={
50,100,200,500
};
const int BET_MONEY_lIMIT[]={
1000,2000,5000,10000
};
const int BET_MONEY_LEVEL_INCREMENT_MAPPING[]={
8,14,20,29
};
const int BET_MONEY_LEVEL_lIMIT_MAPPING[]={
8,14,20,29
};
struct MoneySys {
long totalMoney; // the total money you have
boolean unlockedBall[TOTAL_BALL]; //all the ball you can choose
boolean unlockedCharacters[TOTAL_PLAYER]; // all the characters you can choose
boolean unlockedSuits[TOTAL_SUIT][TOTAL_PLAYER]; // all the suit you can choose
int newUnlock; // to indicate an unlock is occurs. bit 0- ball; bit 1- character; bit 2-suit
int unlockedItem[TOTAL_UPDATE]; // the new unlocked items
short currScore; // score you have won in the current match
short currStrikeCount; // strikes you achieved in the current match
short currSpareCount; // spares you achieved in the current match
short currOpStrikeCount;
short currOpSpareCount;
int currScoreMoney; // score money you have won in the current match
int currStrikeMoney; // strikes money you achieved in the current match
int currSpareMoney; // spares money you achieved in the current match
int winBonus; // win bonus for the quick mode and vs computer
int currBet; // money you have bet on the challenges
short currCoin; // coins you have gotten in the match(reservation for the future)
};
//// >> ===============================================================
class CGame :public CGameBase
{
public:
CGame(CEngine * pEngine);
~CGame();
virtual void update();
virtual void paint();
void input();
void testCheatCode(int key);
CUI *GetUI() { return m_pUI; };
bool IsShowHint(){return m_bIsShowHint;};
void SetIsShowHint(bool isShow) { m_bIsShowHint = isShow;};
int GetDrawCount() { return m_iDrawCount;};
void SetDrawCount(int count){ m_iDrawCount = count;};
int GetPause() { return m_pause;};
void SetVibateOn(char isVibOn) {m_pEngine->GetSound()->SetVibOn(isVibOn);};
CScene *GetScene() { return m_pScene;};
CMatch *GetMatch() { return m_pMatch;};
int GetTitleType() { return m_iTitleType;};
CDataManager* GetDataManager() const { return m_pDataManager; }
void SetPlayerStatus(int playerStatus) { m_iPlayerStatus = playerStatus;};
public:
// int m_temState;
int m_LastTick;
int m_LastTime;
int m_fpsStart;
int m_Time[8];
int m_TimeTick;
int m_isSuspend;
public:
CMenu* m_pMenu;
////////////////////////////////////////////private functions
private:
void drawRoundDelivery();
CDataManager *m_pDataManager;
CMatch *m_pMatch;
CUI * m_pUI;
CScene* m_pScene;
bool m_pause;
bool m_bSetSceneStage;
int m_iRollingTime[2];
int m_iPlayerStatus; // the player's stage on Saving
// story mode
private:
int m_iSaveDone;
int m_iCurSound;
void matchInit();
int m_iDrawCount;
bool m_bIsShowHint;
int m_iTitleType;
bool m_bContinueStory;// indicate if i choose the continue to start the storymode game
public:
void resumeMIDI();
void pauseMIDI();
void ReleaseLocalResource();
bool loadGeneralRecord(int LoadStory=0);
int saveGeneralRecord(saveType type, int firstTime=0);
int m_saveFlag;
void initGeneralRecord();
void saveStoryInfo(int iExit=1);
void loadStoryInfo();
bool m_SaveBallCanSel[BALL_COUNT];
bool m_SaveBonusCanSel[BONUS_COUNT];
bool m_SavePlayerCanSel[PLAYER_COUNT];
bool m_SaveClothCanSel[PLAYER_COUNT][CLOTH_COUNT];
bool m_SaveBallIconCanSel[BALLICON_COUNT];
bool m_SaveLaneCanSel[LANE_COUNT];
bool m_SaveLaneCanView[LANE_COUNT];
int m_chcode;
bool m_SaveStoryPassed;
bool m_SaveCanContinue;
byte m_SavePlayerId;
byte m_SaveStageIndex;
byte m_SaveCurPlayer;
byte m_SavePlayerRound[2]; //current round of the match
byte m_SavePlayerBall[2];
byte m_SavePlayerBallIcon[2];
short m_SavePlayerPinMode[2];
byte m_SavesmCoinPassed;// add by sunfishfine, fix bug 4194
byte m_SaveGameFinish;
byte m_SaveDrawCount;
byte m_SavePlayerClothesID[2];
ScoreInfo m_SaveScores[2];
byte m_SaveIsDraw;// add by sunfishfine
int m_UnlockCoinLimit[6];
int m_SaveQMFinishTime;
bool m_SaveCanCamView;
bool m_SaveCoinPassed[10][4];
//// << ===============================================================================
////2005.1.11 YI WEN HU
public:
int m_GameState;
int m_StoryModeState;
int m_MatchState;
int m_step; // for loading
bool m_storySave;
void UpdateStoryMode();
void UpdateMatch();
int UpdateMenu(); // return 0, still menu state; return -1, exit; return >0, goto match state
void InitGameState(){m_GameState=GS_MENU;}
void InitStoryState(){m_StoryModeState=SMS_MODE_INIT;}
void InitMatchState(){m_MatchState=MS_MATCH_INIT;}
bool Loading(int step, int info=0); // if finished, return true, otherwise return false
// seePlayer: true, see player; false, see competitor
int getTalkCamera(int laneId, int sentenceIndex, int sentsentenceCount, bool seePlayer);
void forContinueStory();
void unlockPlayer();
// void unlockCloth();
void unlockBallIcon();
void unlockLane();
void unlockLaneView();
void clearStoryModeContinue();
public:
void PaintInPause();
void CoinUnlock(); // call at the end of a match, to
//unlock a bonus or ball if passed.
void CoinRandomPos(Vector4s* pos, int info); // get random position for coin
void CoinNextUnlock(); // set next unlock coin
void CoinNextFunc(); // set next function coin
void CoinSetUnlock();
//// >> ===============================================================================
// for the money system
public:
MoneySys m_money;
int m_counterForMoney;
int m_moneyState;// the state for money result display
bool bRetryState; // ask retry after money result, true: yes, false: no
public:
void moneyInit(); //init the money system
void moneyMatchInit(MoneySys& ms); //clear the money struct when match init
void moneySave(); // save the money
void moneyLoad(); //load the money
boolean checkMoneyUnlock(MoneySys& ms); // check the money and unlock the system
void updateMoneyUnlock(MoneySys& ms);// update and active the money unlock in the game and save these unlocks
void updateTotalMoney(MoneySys& ms,int mount);// update the total money
void updateStrike(MoneySys& ms, moneyUpdateState mus,bool ishuman);// update the strike and spare after delivery
void updateBet(MoneySys& ms, moneyUpdateState mus, int betMoney, boolean win=false);// update the bet info
void calculateMoney(MoneySys& ms, int score,bool bAddToTotal=true);// calculate the total money you earned
void exchange2PlayerData(MoneySys& ms, int score);// change 2 player data
int removeOneUnlock(MoneySys& ms);// remove the first new unlock item
boolean getFirstUnlock(MoneySys& ms,int& type, int& id);// get the first new unlocked item
boolean onlyOneUnlockToShow(MoneySys& ms);// true if there is only one unlocked item to show
//////////////////////////////////////////////////////////////////////////
// online
//////////////////////////////////////////////////////////////////////////
public :
bool m_bOnlineMode;// indicate now is online mode
bool m_bOverTime;// over time
int m_overtimeCounter;
long m_onlineTimer;
long m_lastTime;
bool m_connected;
bool m_bGameOver;
int m_errorID;
int m_onlineGameState;
void isGameFinish();
void InitOnlineMode();// online mode init
void onlineClear(){m_bOnlineMode=false;m_onlineGameState=ONLINE_STATE_NOT_ONLINE;};
void OnlineDeliveryReset();// reset the online mode when turn to next delivery
boolean OnlineAutoConfirm();// auto input the key for the player in order to insure the player can go on
bool isOvertimeFull(){return m_overtimeCounter>ONLINE_MAX_OVERTIME_COUNTER;}
void OnlineTimerTick();
void resetTimer(){m_onlineTimer=0;m_lastTime=GETUPTIMEMS();};
void onlineStateUpdate();
void onlineStateChange(int state,int * score=NULL);
void dealWithOverTime();
void dealWithNetWorkError(int state,int error);
void drawOnlineTimer(CUI * pUI);
};
#endif // !defined(AFX_GAME_H__07851B10_3E6D_45EF_A8B8_DF96C179301D__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -