Skip to content

Commit

Permalink
Merge pull request #69 from jonylu7/UnitManager_Update
Browse files Browse the repository at this point in the history
local changes
  • Loading branch information
jonylu7 authored May 16, 2024
2 parents 2d1555c + 73e3fb4 commit 3f0d5a7
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 37 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ set(SRC_FILES
${SRC_DIR}/Util/GameObject.cpp
${SRC_DIR}/Util/Renderer.cpp
${SRC_DIR}/Util/Color.cpp
${SRC_DIR}/Util/Animation.cpp
${SRC_DIR}/Util/MissingTexture.cpp


${SRC_DIR}/Display/ImageArray.cpp
${SRC_DIR}/Display/CustomizableImage.cpp
${SRC_DIR}/Display/SpriteSheetAnimation.cpp
${SRC_DIR}/Display/Animation.cpp
${SRC_DIR}/Display/MissingTexture.cpp

${SRC_DIR}/Display/Grid.cpp
${SRC_DIR}/Display/SpriteSheet.cpp

Expand Down Expand Up @@ -152,17 +153,17 @@ set(INCLUDE_FILES
${INCLUDE_DIR}/Util/Keycode.hpp
${INCLUDE_DIR}/Util/SFX.hpp
${INCLUDE_DIR}/Util/BGM.hpp

${INCLUDE_DIR}/Util/Text.hpp
${INCLUDE_DIR}/Util/Transform.hpp
${INCLUDE_DIR}/Util/TransformUtils.hpp
${INCLUDE_DIR}/Util/GameObject.hpp
${INCLUDE_DIR}/Util/Renderer.hpp
${INCLUDE_DIR}/Util/Color.hpp
${INCLUDE_DIR}/Util/Image.hpp
${INCLUDE_DIR}/Util/Animation.hpp
${INCLUDE_DIR}/Util/MissingTexture.hpp


${INCLUDE_DIR}/Display/Animation.hpp
${INCLUDE_DIR}/Display/MissingTexture.hpp
${INCLUDE_DIR}/Display/SpriteSheetAnimation.hpp
${INCLUDE_DIR}/Display/ImageArray.hpp
${INCLUDE_DIR}/Display/CustomizableImage.hpp
Expand Down
2 changes: 1 addition & 1 deletion include/Avatar/Avatar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include "Avatar/AvatarOrder.hpp"
#include "Avatar/Moving.hpp"
#include "Avatar/PathUtility.hpp"
#include "Display/Image.hpp"
#include "Display/SpriteSheet.hpp"
#include "Display/SpriteSheetAnimation.hpp"
#include "Map/MapUtility.hpp"
#include "Mechanics/GameObjectID.hpp"
#include "Selectable.hpp"
#include "Util/Image.hpp"

class Avatar : public Moving,
public AttackAndDamage,
Expand Down
2 changes: 1 addition & 1 deletion include/Display/DrawOverlays.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_DRAWOVERLAYS_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_DRAWOVERLAYS_HPP
#include "Core/Drawable.hpp"
#include "Display/Image.hpp"
#include "Util/Image.hpp"
#include "Util/TransformUtils.hpp"
#include "pch.hpp"
class DrawOverlays : public Core::Drawable {
Expand Down
2 changes: 1 addition & 1 deletion include/Display/Sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_SPRITE_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_SPRITE_HPP
#include "Core/Drawable.hpp"
#include "Display/Image.hpp"
#include "Util/CustomizableImage.hpp"
#include "Util/Image.hpp"
#include "pch.hpp" // IWYU pragma: export

class Sprite : public Core::Drawable {
Expand Down
2 changes: 1 addition & 1 deletion include/Display/SpriteSheetAnimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "Core/Drawable.hpp"

#include "Image.hpp"
#include "Util/Image.hpp"

namespace Util {
/**
Expand Down
2 changes: 1 addition & 1 deletion include/Map/YAMLReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_YAMLREADER_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_YAMLREADER_HPP
#include "Display/Image.hpp"
#include "TerrainConfig.hpp"
#include "Tile.hpp"
#include "Util/Image.hpp"
#include <fstream>
#include <iostream>
#include <yaml-cpp/yaml.h>
Expand Down
10 changes: 6 additions & 4 deletions include/Mechanics/NemesisManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_NEMESISMANAGER_HPP
#include "Map/MapUtility.hpp"
#define ATTACK_RANGE 5

class NemesisManager {
public:
NemesisManager() {}
Expand All @@ -32,11 +32,13 @@ class NemesisManager {
if (ifAvatarHasNemesis(hunter) == false) {
return false;
}
if (hunter.getDistance(m_Nemesis[hunter].getCurrentCell()) <= ATTACK_RANGE) // check with in range
if (hunter->getDistance(m_Nemesis[hunter]->getCurrentCell()) <=
hunter->getWeapon()->getFireRange()) // check with in range
{
return true;
} else {
forceMove(hunter,m_Nemesis[hunter].getCurrentCell());//向目標移動
// forceMove(hunter,
// m_Nemesis[hunter]->getCurrentCell()); // 向目標移動
return false;
}
}
Expand All @@ -49,7 +51,7 @@ class NemesisManager {
hunter->setAvatarOrder(AvatarOrderType::OPEN_FIRE);
prey->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE);
hunter->getAttackAndDamager()->openFireToTarget(prey);
//反擊
// 反擊
prey->setAvatarOrder(AvatarOrderType::OPEN_FIRE);
hunter->setAvatarOrder(AvatarOrderType::TAKEN_DAMAGE);
prey->getAttackAndDamager()->openFireToTarget(prey);
Expand Down
6 changes: 5 additions & 1 deletion include/Mechanics/UnitManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ class UnitManager : public Player {

void spawn(std::shared_ptr<MapClass> m_Map, UnitType unit,
HouseType house) {

if (house == HouseType::ENEMY) {
// m_Enemy->addUnitConstructCount(unit, 1);
} else {
// m_Player->setUnitConstructCount(unit, 1);
}

switch (unit) {
case UnitType::INFANTRY: {
auto avatar = std::make_shared<Infantry>(house);
Expand All @@ -89,12 +91,13 @@ class UnitManager : public Player {
return;
}



avatar->Start(m_StructureManager->getStructureArray()
->getPlayerBarrackCell());
// avatar
// ->setNewDestination(m_StructureManager.getStructureArray().getPlayerWayPointCell());
m_AvatarManager->AppendAvatar(avatar);
break;
}

default: {
Expand Down Expand Up @@ -216,4 +219,5 @@ class UnitManager : public Player {
std::chrono::high_resolution_clock::time_point m_StartTime;
double m_lastElapsed = 0.F;
};

#endif // PRACTICALTOOLSFORSIMPLEDESIGN_UNITMANAGER_HPP
5 changes: 3 additions & 2 deletions include/Scene/Scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "Camera.hpp"
#include "Display/DrawOverlays.hpp"
#include "Display/Grid.hpp"
#include "Display/Image.hpp"
#include "Display/SpriteSheet.hpp"
#include "Map/Map.hpp"
#include "Structure/AdvencePowerPlants.hpp"
Expand All @@ -24,6 +23,7 @@
#include "Structure/WarFactory.hpp"
#include "Structure/WayPoint.hpp"
#include "UI/UI.hpp"
#include "Util/Image.hpp"
#include "Util/Input.hpp"
#include "Util/Keycode.hpp"
#include "Util/Logger.hpp"
Expand All @@ -47,7 +47,8 @@ class Scene {

protected:
std::shared_ptr<MapClass> m_Map = std::make_shared<MapClass>();
std::shared_ptr<CameraClass> m_SceneCamera = std::make_shared<CameraClass>();
std::shared_ptr<CameraClass> m_SceneCamera =
std::make_shared<CameraClass>();
std::shared_ptr<UnitManager> m_GameObjectManager =
std::make_shared<UnitManager>();
std::shared_ptr<UnitManager> m_EnemyObjectManager =
Expand Down
10 changes: 5 additions & 5 deletions include/Structure/Structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_STRUCTURE_HPP
#include "Avatar/AttackAndDamage.hpp"
#include "Display/Image.hpp"
#include "Display/SpriteSheet.hpp"
#include "Display/SpriteSheetAnimation.hpp"
#include "HighLight.h"
#include "Mechanics/GameObjectID.hpp"
#include "Selectable.hpp"
#include "Structure/StructureOrder.hpp"
#include "Util/Image.hpp"

#include "Unit/Health.hpp"
#include "Unit/IHealthable.hpp"
Expand Down Expand Up @@ -70,8 +70,8 @@ class Structure : public Util::GameObject,
virtual void SetSpriteSheet() {
m_StructureSpriteSheet->Start(
"../assets/sprites/Barracks_SpriteSheet.png", 48, 48, 13, 0);
m_SpriteSheetAnimation->initSpriteSheetAnimation(m_StructureSpriteSheet,
false, INTERVAL, false);
m_SpriteSheetAnimation->initSpriteSheetAnimation(
m_StructureSpriteSheet, false, INTERVAL, false);
}

virtual void SetObjectLocation(glm::vec2 location);
Expand All @@ -86,7 +86,7 @@ class Structure : public Util::GameObject,
float getElectricPower() { return this->m_ElectricPower; }
float getBuildingTime() { return this->m_BuildingTime; }
float getBuildingCost() { return this->m_BuildingCost; }
HouseType getHouseType(){return this->m_ID.getHouseType();}
HouseType getHouseType() { return this->m_ID.getHouseType(); }

glm::vec2 GlobalCoordToCellCoord(glm::vec2 globalCoord) {
return glm::vec2(int(globalCoord[0] / CELL_SIZE.x),
Expand Down Expand Up @@ -126,7 +126,7 @@ class Structure : public Util::GameObject,
m_ObjectLocation.y + CELL_SIZE.y};
glm::vec2 m_ObjectLocation = {100, 100};
std::vector<glm::vec2> m_RelativeOccupiedArea = {{0, 0}};

// health
std::shared_ptr<Health> m_Health = std::make_shared<Health>();
// attack and damage
Expand Down
2 changes: 1 addition & 1 deletion include/Structure/WayPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_WAYPOINT_HPP
#include "Display/Image.hpp"
#include "Util/GameObject.hpp"
#include "Util/Image.hpp"
#include "Util/TransformUtils.hpp"
class WayPoint : public Util::GameObject {
private:
Expand Down
2 changes: 1 addition & 1 deletion include/Structure/WayPointStructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_MOVEABLESTRUCTURE_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_MOVEABLESTRUCTURE_HPP
#include "Display/Grid.hpp"
#include "Display/Image.hpp"
#include "Display/Line.hpp"
#include "HighLight.h"
#include "Map/MapUtility.hpp"
#include "Structure/IWayPoint.hpp"
#include "Structure/Structure.hpp"
#include "Util/Image.hpp"
#include "Util/Input.hpp"
#include "Util/Keycode.hpp"
#include "WayPoint.hpp"
Expand Down
8 changes: 0 additions & 8 deletions include/Unit/IOrderable.hpp

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Display/Animation.cpp → src/Util/Animation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Display/Animation.hpp"
#include "Util/Animation.hpp"
#include "Util/Logger.hpp"
#include "Util/Time.hpp"

Expand Down
4 changes: 2 additions & 2 deletions src/Util/Image.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "Display/Image.hpp"
#include "Util/Image.hpp"

#include "pch.hpp"

#include "Core/Texture.hpp"
#include "Core/TextureUtils.hpp"

#include "Display/MissingTexture.hpp"
#include "Util/MissingTexture.hpp"
#include "Util/TransformUtils.hpp"

#include "config.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "SDL_image.h"
#include "Util/Logger.hpp"

#include "Display/MissingTexture.hpp"
#include "Util/MissingTexture.hpp"

SDL_Surface *GetMissingTextureSDLSurface() {
SDL_RWops *rwop = SDL_RWFromConstMem(MISSING_TEXTURE_BASE64_DECODE.data(),
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "Core/Texture.hpp"
#include "Core/TextureUtils.hpp"

#include "Display/Text.hpp"
#include "Util/Logger.hpp"
#include "Util/Text.hpp"
#include "Util/TransformUtils.hpp"

#include "config.hpp"
Expand Down

0 comments on commit 3f0d5a7

Please sign in to comment.