www.pudn.com > PG20101.zip > Battle.h
//
// 執行戰鬥
//
// Copyright (c) 2000-2001 Chihiro.SAKAMOTO (HyperWorks)
//
#ifndef __battle_h__
#define __battle_h__
#include "Action.h"
#include "Misc.h"
#include "Character.h"
class CMainWin;
//
// 戰鬥類別
//
class CBattleAction: public CAction {
protected:
// 狀態
enum {
STATUS_NONE,
STATUS_MOVE,
STATUS_ANIME,
} ;
enum {
NONE = 0, // 一般地點
RESTRICTED_AREA = 1 << 0, // 禁區
PLAYER = 1 << 1, // 有其他遊戲者
ENEMY = 1 << 2, // 有敵人
OBJECT = 1 << 3, // 有東西在
MOVEDIST = 1 << 4, // 有移動範圍的游標
ATTACKDIST = 1 << 5, // 有攻擊範圍的游標
} ;
enum {
TIMER_MOVE_ID = 1000,
TIMER_MOVE_TIME = 50,
} ;
class MapData {
public:
MapData()
{
sprite = 0;
type = 0;
dist = 0;
}
bool ChkMove(int _dist)
{
return type == CBattleAction::NONE
|| ((type & CBattleAction::MOVEDIST) != 0 && dist < _dist);
}
public:
CMapSprite *sprite; // 地圖上的sprite
unsigned char type; // 地圖上好像有什麼東西?
char dist; // 移動、攻擊的距離(作業用)
} ;
friend class MapData;
class MoveAnime {
public:
MoveAnime(CCharacter *_character, int _action)
{
action = _action;
character = _character;
count = 0;
}
int action;
int count;
CCharacter *character;
} ;
public:
CBattleAction(CMainWin *win, CAction *oldAction);
~CBattleAction();
virtual void KeyDown(UINT key);
virtual bool TimedOut(int timerId);
bool Init();
protected:
void DrawMap(CImage *image, const CRect &rect);
void DrawMap(CImage *image);
void SetCursor(CPoint point);
void ClearCursor();
void DrawCursor();
void AddSprite(CSprite *s);
void RemoveSprite(CSprite *s);
void RedrawSprite(CSprite *s);
void FindDist(int x, int y, int dist, bool first=true);
void AddDistCursor(int x, int y, int dist, int type);
void ClearDistCursor();
void MovePlayer(CCharacter *character, CPoint point);
void MoveCharacter(int x, int y, int dist, CCharacter *character);
void StartAnime();
void UpdateRect(const CRect &rect);
protected:
CDrawImage *ViewImage;
CImage MapImage;
CImage Cursor;
CImage Player;
CImage Enemy;
MapData *_map_data;
MapData **map_data;
CSize MapSize;
CRect MapRect;
int status;
// 地圖游標的顯示位置
CPoint CursorPos;
// 選擇行動的人物資訊
CPoint SelPos;
CCharacter *SelChar;
list player_list; // 遊戲者
list enemy_list; // 敵人
list cursor_list;
CMapSprite CursorSprite;
list anime;
class mapcomp: public binary_function {
public:
result_type operator()(first_argument_type x, second_argument_type y) const
{
return *x < *y;
}
} ;
typedef set mapset;
mapset sprite; // 所有sprite的清單
} ;
inline void CBattleAction::UpdateRect(const CRect &rect)
{
DrawMap(ViewImage, rect);
Parent->InvalidateRect(&rect);
}
#endif