-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCVillager.cpp
79 lines (71 loc) · 1.9 KB
/
CVillager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stdafx.h"
#include "Resource.h"
#include <mmsystem.h>
#include <ddraw.h>
#include "gamelib.h"
#include <set>
#include "CResourceCenter.h"
#include "CUnit.h"
#include "CDialog.h"
#include "CVillager.h"
#include "CBuildStable.h"
#include "CBuildTownCenter.h"
#include "CBuildBarrack.h"
#include "CBuildArchery.h"
#include "mygame.h"
namespace game_framework {
CVillager::CVillager(){
bmp=CBitmapCollection::GetBitmapCollection()->GetBitmap(SPRITES_UNITS_VILLAGER);
icon=CBitmapCollection::GetBitmapCollection()->GetBitmap(ICON_UNITS_VILLAGER);
//bmp = new CMovingBitmap();
//bmp->LoadBitmapA("Bitmaps/Sprites/Units/Villager/villager.bmp",0);
//icon=new CMovingBitmap();
//icon->LoadBitmapA("Bitmaps/Icons/Units/villager_male.bmp",-1);
iconDialog.pic=*icon;
moveSpeed=8;
atkSpeed = 30;
atkGridRange=1;
hp = 25;
this->maxHp = 25;
targetRange = 5;
isAttackable = true;
isCollectable=false;
isRepairable=false;
}
CVillager::~CVillager(){
bmp=NULL;
icon=NULL;
}
void CVillager::Collect(){
if(collectCount++>=20){
collectCount=0;
CResourceTable table = target.Sprite()->ResourceTable();
resourceTable = resourceTable+table;
player->ResourceTable() += table;
target.Sprite()->OnCollected(this);
}
}
void CVillager::Repair(){
if(repairCount++>=20){
repairCount=0;
target.Sprite()->OnRepaired(this);
}
}
void CVillager::FunctionDialogComposite()
{
CScreenDialog* sd = CScreenDialog::GetScreenDialog();
CBuildTownCenter* btc = new CBuildTownCenter();
btc->SetSprite(this);
sd->FunctionDialog()->AddSubDialog(btc);
CBuildBarrack* bb = new CBuildBarrack();
bb->SetSprite(this);
sd->FunctionDialog()->AddSubDialog(bb);
CBuildStable* bs = new CBuildStable();
bs->SetSprite(this);
sd->FunctionDialog()->AddSubDialog(bs);
CBuildArchery* ba = new CBuildArchery();
ba->SetSprite(this);
sd->FunctionDialog()->AddSubDialog(ba);
TRACE("V\n");
}
}