My Project
 
Loading...
Searching...
No Matches
level.h
Go to the documentation of this file.
1#pragma once
2
3#include "bundlable.h"
4#include "plant.h"
5#include <vector>
6#include <map>
7#include <set>
8#include "typedefine.h"
9
10class Scene;
11class Char;
12class Blob;
13class Mob;
14class Heap;
15class Item;
16
17class Level :public Bundlable{
18public:
26 static const int WIDTH = 32;
27 static const int HEIGHT = 32;
28 static const int LENGTH = WIDTH * HEIGHT;
29
30 static const int NEIGHBOURS4[];
31 static const int NEIGHBOURS8[];
32 static const int NEIGHBOURS9[];
33
34protected:
35 static const float TIME_TO_RESPAWN;
36
37 static bool pitRoomNeeded;
38 static bool weakFloorCreated;
39
40private:
41 static const std::string TXT_HIDDEN_PLATE_CLICKS;
42
43 static const std::string MAP;
44 static const std::string VISITED;
45 static const std::string MAPPED;
46 static const std::string ENTRANCE;
47 static const std::string EXIT;
48 static const std::string HEAPS;
49 static const std::string PLANTS;
50 static const std::string MOBS;
51 static const std::string BLOBS;
52
53 void buildFlagMaps();
54 int getWaterTile(int pos);
55 void cleanWalls();
56public:
57 static bool resizingNeeded;
58 static int loadedMapSize;
59
60 std::vector<int> map;
61 std::vector<bool> visited;
62 std::vector<bool> mapped;
63
64 static std::vector<bool> fieldOfView;
65
66 static std::vector<bool> passable;
67 static std::vector<bool> losBlocking;
68 static std::vector<bool> flamable;
69 static std::vector<bool> secret;
70 static std::vector<bool> solid;
71 static std::vector<bool> avoid;
72 static std::vector<bool> water;
73 static std::vector<bool> pit;
74
75 static std::vector<bool> discoverable;
76
78
80
82 int exit;
83
88
89 int color1;
90 int color2;
91
92 Level();
93 virtual ~Level();
94 void create();
95 void clear();
96
97 int pitCell();
99 int adjustPos(int pos);
100
101 virtual std::string tilesTex() { return ""; }
102 virtual std::string waterTex() { return ""; }
103
104 void reset();
105
106 std::vector<bool> updateFieldOfView(Char* c);
107
108 static int distance(int a, int b);
109
110 int tunnelTile();
111
112 int randomDestination();
113 static bool adjacent(int a, int b);
114 void mobPress(Mob* mob);
115
116 static void set(int cell, int terrain);
117 Heap* drop(Item* item, int cell);
118 void uproot(int pos);
119 Plant* plant(Plant::Seed* seed, int pos);
120 void press(int cell, Char* ch);
121 void destroy(int pos);
122 String tileName(int tile);
123 String tileDesc(int tile);
124protected:
125 virtual bool build() = 0;
126 virtual void decorate() = 0;
127 virtual void createMobs() = 0;
128 virtual void createItems() = 0;
129
130public:
131 void addVisuals(Scene* scene);
132 virtual int nMobs() { return 0; }
133};
Definition blob.h:9
Definition char.h:9
Definition typedefine.h:41
Definition typedefine.h:16
Definition heap.h:11
Definition item.h:15
virtual void createItems()=0
void clear()
Definition level.cpp:235
static std::vector< bool > losBlocking
Definition level.h:67
static std::vector< bool > fieldOfView
Definition level.h:64
virtual void decorate()=0
static int loadedMapSize
Definition level.h:58
static std::vector< bool > passable
Definition level.h:66
virtual ~Level()
Definition level.cpp:164
int entrance
Definition level.h:81
String tileName(int tile)
Definition level.cpp:709
static std::vector< bool > water
Definition level.h:72
static const int WIDTH
Definition level.h:26
static bool pitRoomNeeded
Definition level.h:37
Feeling feeling
Definition level.h:79
static const int NEIGHBOURS4[]
Definition level.h:24
void addVisuals(Scene *scene)
Definition level.cpp:852
int adjustPos(int pos)
Definition level.cpp:266
virtual int nMobs()
Definition level.h:132
int exit
Definition level.h:82
int randomRespawnCell()
Definition level.cpp:257
Heap * drop(Item *item, int cell)
Definition level.cpp:489
std::vector< bool > updateFieldOfView(Char *c)
Definition level.cpp:281
static bool resizingNeeded
Definition level.h:57
int color2
Definition level.h:90
Level()
Definition level.cpp:154
int tunnelTile()
Definition level.cpp:388
virtual std::string waterTex()
Definition level.h:102
void create()
Definition level.cpp:169
static std::vector< bool > avoid
Definition level.h:71
Feeling
Definition level.h:19
@ WATER
Definition level.h:22
@ CHASM
Definition level.h:21
@ GRASS
Definition level.h:23
@ NONE
Definition level.h:20
static int distance(int a, int b)
Definition level.cpp:379
std::vector< bool > mapped
Definition level.h:62
virtual bool build()=0
static const int NEIGHBOURS9[]
Definition level.h:26
static std::vector< bool > pit
Definition level.h:73
HashSet< Mob * > mobs
Definition level.h:84
int viewDistance
Definition level.h:77
std::vector< bool > visited
Definition level.h:61
HashMap< int, Heap * > heaps
Definition level.h:86
static const int NEIGHBOURS8[]
Definition level.h:25
static bool adjacent(int a, int b)
Definition level.cpp:403
void mobPress(Mob *mob)
Definition level.cpp:409
static const int LENGTH
Definition level.h:28
static const float TIME_TO_RESPAWN
Definition level.h:35
static std::vector< bool > discoverable
Definition level.h:75
int pitCell()
Definition level.cpp:252
static std::vector< bool > secret
Definition level.h:69
static void set(int cell, int terrain)
Definition level.cpp:474
HashMap< int, Plant * > plants
Definition level.h:87
void reset()
Definition level.cpp:271
String tileDesc(int tile)
Definition level.cpp:798
virtual void createMobs()=0
virtual std::string tilesTex()
Definition level.h:101
static bool weakFloorCreated
Definition level.h:38
int randomDestination()
Definition level.cpp:393
void destroy(int pos)
Definition level.cpp:685
static std::vector< bool > solid
Definition level.h:70
void uproot(int pos)
Definition level.cpp:559
static std::vector< bool > flamable
Definition level.h:68
static const int HEIGHT
Definition level.h:27
Plant * plant(Plant::Seed *seed, int pos)
Definition level.cpp:564
int color1
Definition level.h:89
HashMap< std::string, Blob * > blobs
Definition level.h:85
std::vector< int > map
Definition level.h:60
void press(int cell, Char *ch)
Definition level.cpp:580
Definition mob.h:9
Definition plant.h:16
Definition plant.h:13
std::string String
Definition typedefine.h:8