diff --git a/TdGame/TdGame.vcxproj b/TdGame/TdGame.vcxproj index fb85356..4c59d99 100644 --- a/TdGame/TdGame.vcxproj +++ b/TdGame/TdGame.vcxproj @@ -134,11 +134,14 @@ + + + diff --git a/TdGame/TdGame.vcxproj.filters b/TdGame/TdGame.vcxproj.filters index 4349838..37728c4 100644 --- a/TdGame/TdGame.vcxproj.filters +++ b/TdGame/TdGame.vcxproj.filters @@ -16,6 +16,9 @@ {f50376ab-e971-4317-8a3c-da0f2703263e} + + {d16b420a-6329-4705-af2a-57caf4eee0e9} + @@ -38,5 +41,14 @@ 头文件 + + 头文件\manager + + + 头文件 + + + 头文件\enemy + \ No newline at end of file diff --git a/TdGame/config_manager.h b/TdGame/config_manager.h new file mode 100644 index 0000000..1302aa7 --- /dev/null +++ b/TdGame/config_manager.h @@ -0,0 +1,107 @@ +#pragma once +#ifndef _CONFIG_MANAGER_H_ +#define _CONFIG_MANAGER_H_ + +#include "map.h" +#include "wave.h" +#include "manager.h" + +#include +#include +#include +#include +#include + +//×÷Ϊȫ¾ÖÊý¾ÝÅäÖÃÖÐÐÄ + +class ConfigManager : public Manager +{ + friend class Manager; + +public: + struct BasicTemplate + { + std::string window_title = u8"´åׯ±£ÎÀÕ½!"; + int window_width = 1280; + int window_height = 720; + }; + + struct PlayerTemplate + { + double speed = 3; + double normal_attack_interval = 0.5; + double normal_attack_damage = 0; + double skill_interval = 10; + double skill_damage = 1; + }; + + struct TowerTemplate + { + double interval[10] = { 1 }; + double damage[10] = { 25 }; + double view_range[10] = { 5 }; + double cost[9] = { 50 }; + double upgrade_cost[9] = { 75 }; + }; + + struct EnemyTemplate + { + double hp = 100; + double speed = 1; + double damage = 1; + double reward_ratio = 0.5; + double recover_interval = 10; + double recover_range = 0; + double recover_intensity = 25; + }; + +public: + Map map; + std::vector wave_list; + + int level_archer = 0;//¹­¼ýÊֵȼ¶ + int level_axeman = 0;//¸«Í·±øµÈ¼¶ + int level_gunner = 0;//ǹ±øµÈ¼¶ + + bool is_game_win =true;//ÓÎÏ·ÊÇ·ñ»ñʤ + bool is_game_over = false;//ÓÎÏ·ÊÇ·ñ½áÊø£¬ºÍÉÏÃæÊÇÁ½¸ö²»Í¬²ãÃæµÄÌõ¼þ£¬ÐèÒª·ÖÎö + SDL_Rect rect_tile_map = { 0 }; + + BasicTemplate basci_template; + PlayerTemplate player_template; + + TowerTemplate archer_template; + TowerTemplate axeman_template; + TowerTemplate gunner_template; + + EnemyTemplate slim_template; + EnemyTemplate king_slim_template; + EnemyTemplate skeleton_template; + EnemyTemplate goblin_template; + EnemyTemplate goblin_priest_template; + + const double num_initial_hp = 10;//·¿ÎݳõʼÉúÃü + const double num_initial_coin = 100;//³õʼ½ð±Ò + const double num_coin_per_prop = 10;//ÿ¸öµÀ¾ß½±Àø½ð±ÒÊý + +public: + //¼ÓÔز¨´ÎÅäÖà + bool load_level_config(const std::string& path) + { + + } + //¼ÓÔØÓÎÏ·ÅäÖà + bool load_game_config(const std::string& path) + { + + } + +protected: + ConfigManager() = default; + + ~ConfigManager() = default; +}; + + +#endif // !_CONFIG_MANAGER_H_ + diff --git a/TdGame/enemy_type.h b/TdGame/enemy_type.h new file mode 100644 index 0000000..07fb959 --- /dev/null +++ b/TdGame/enemy_type.h @@ -0,0 +1,14 @@ +#pragma once +#ifndef _ENEMY_TYPE_H_ +#define _ENEMY_TYPE_H_ + +enum class EnemyType +{ + Slim, + KingSlim, + Skeleton, + Goblin, + GoblinPriest +}; + +#endif diff --git a/TdGame/manager.h b/TdGame/manager.h index f8c7518..e0dc0bc 100644 --- a/TdGame/manager.h +++ b/TdGame/manager.h @@ -2,6 +2,8 @@ #ifndef _MANAGER_H_ #define _MANAGER_H_ +//µ¥ÀýÄ£°åÀà + template class Manager { diff --git a/TdGame/map.h b/TdGame/map.h index 8160c8f..533e9eb 100644 --- a/TdGame/map.h +++ b/TdGame/map.h @@ -79,6 +79,27 @@ public: return tile_map.size();//ÐÐÊýÁ¿£¨¸ß¶È£© } + const TileMap& get_tile_map() const + { + return tile_map; + } + + const SDL_Point& get_idx_home() const + { + return idx_home; + } + + const SpawnerRoutePool& get_idx_spawner_pool() const + { + return spawner_route_pool; + } + + void place_tower(const SDL_Point& idx_tile) + { + tile_map[idx_tile.y][idx_tile.x].has_tower = true; + } + + private: TileMap tile_map; SDL_Point idx_home = { 0 };//·¿Îݵã diff --git a/TdGame/tile.h b/TdGame/tile.h index 00087ca..fa52c88 100644 --- a/TdGame/tile.h +++ b/TdGame/tile.h @@ -21,7 +21,7 @@ struct Tile int terrian = 0; int decoration = -1; int special_flag = -1; - bool has_tower = false; + bool has_tower = false;//ÔËÐÐʱÊý¾Ý Direction direction = Direction::None; }; diff --git a/TdGame/wave.h b/TdGame/wave.h new file mode 100644 index 0000000..e16fd11 --- /dev/null +++ b/TdGame/wave.h @@ -0,0 +1,24 @@ +#pragma once +#ifndef _WAVE_H_ +#define _WAVE_H_ + +#include "enemy_type.h" + +#include + +struct Wave +{ + //ÃèÊöÉú³Éʼþ + struct SpawnEvent + { + double interval = 0; + int spawn_point = 1; + EnemyType enemy_type = EnemyType::Slim;//ÔÚlevel.jsonÎļþÖмû¸ñʽ,²¨´ÎÐòÁÐÅäÖÃÎļþ + }; + + double rewards = 0; + double interval = 0; + std::vector spawn_event_list; +}; + +#endif // !_WAVE_H_