You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.2 KiB

#pragma once
#include "map.h"
#include "mover.h"
#include "fighter.h"
#include "drawer.h"
class Monster
{
private:
int bx;
int by;
Mover mover;
Fighter fighter;
Drawer drawer;
int Find(const Map* map, int px, int py)
{
/* A*算法 寻路 */
/* 等待完善 */
return 0;
}
public:
// 怪物行动总控
void Update(const Map* map, int px, int py, int ppower)
{
/* 寻路 */
int dir;
int power = fighter.GetPower();
if (power < 0)
dir = Find(map, bx, by);
else if (ppower > 0)
dir = -Find(map, px, py);
else
dir = Find(map, px, py);
mover.SetDir(dir);
mover.Move(map);
}
Fighter& GetFighter() { return fighter; }
void Clear()
{
drawer.Clear(mover.GetOldX(), mover.GetOldY());
}
void Draw(IMAGE* floor)
{
/* 将floor加工为foot image */
IMAGE foot;
SetWorkingImage(floor);
int x = mover.GetX();
int y = mover.GetY();
int w = mover.GetW();
int h = mover.GetH();
getimage(&foot, x, y, w, h);
SetWorkingImage(NULL);
drawer.Draw(x, y, &foot);
}
void Init(int x,int y,int s,int w, int h,int r,int c,const IMAGE* img, const IMAGE* img_h,int bx,int by)
{
mover.Init(x, y, s,w,h);
fighter.Init();
drawer.Init(r, c, img, img_h);
this->bx = bx;
this->by = by;
}
};