This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../Include/AISense.hpp" | |
//////////////////////////////////////////////// | |
IAISense::IAISense(IPawn &owner) | |
: m_owner(owner) | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Klasa zmyslu wzroku. | |
class CSightSense | |
: public IAISense | |
{ | |
/* Musimy ponizsze zmienne zrobic prywatne ze wzgledu na koniecznosc walidacji danych. | |
Nie chcemy przeciez, zeby zasieg wzroku byl ujemny albo by pole widzenia bylo wieksze niz 180 stopni. | |
*/ | |
float m_sightDistance; // Zasieg wzroku w pikselach. | |
/* Pole widzenia w stopniach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSightSense::CSightSense(IPawn &owner, const float &sightDistance, const float &sightAngle) | |
: IAISense(owner) | |
{ | |
/* Konstruktor po prostu ustawia poczatkowe wartosci. */ | |
SetSightDistance(sightDistance); | |
SetSightAngle(sightAngle); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////// | |
bool CSightSense::SetSightDistance(const float & sightDistance) | |
{ | |
/* Musimy zapobiedz ustawieniu ujemnego zasiegu wzroku. */ | |
if (sightDistance > 0) | |
{ | |
m_sightDistance = sightDistance; | |
return true; | |
} | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////// | |
IAISense::TQueryActors CSightSense::QueryActors(bool(*filterFunc)(IActor * const)) | |
{ | |
// W tej funkcji wykonujemy od nowa sprawdzenie jacy aktorzy sa w polu widzenia. | |
// Na poczatku musimy porzucic stare wyniki. | |
m_sensedActors.clear(); | |
// Bierzemy liste aktorow ze sceny. | |
auto actors = CGame::Instance().GetLevel()->GetActors(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deklaracja w pliku .hpp | |
// Metoda, ktorej uzyjemy do update-owania zmyslow | |
virtual void Update(const float &deltaTime) override; | |
// Definicja w pliku .cpp | |
void CEnemy::Update(const float & deltaTime) | |
{ | |
// Bardzo wazne! Wykonujemy tez to co wykonuje klasa bazowa! | |
IPawn::Update(deltaTime); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Zwraca kopie tablicy z wszystkimi aktorami w poziomie. */ | |
inline TActorsV GetActors() const { return m_actors; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Main.hpp" | |
namespace SFMLShapes | |
{ | |
/* Funkcja, ktora tworzy wycinek kola o promieniu radius, kacie 2*angle (wartosc angle w lewo i wartosc angle w prawo). | |
vertexCount to ilosc punktow, z ktorych bedzie skladal sie ksztalt. Minimalnie sa to 3 punkty (bardzo slaba dokladnosc, trojkat) | |
*/ | |
sf::ConvexShape GeneratePie(const float &radius, const float &angle, unsigned int vertexCount = 20); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../Include/SFMLShapes.hpp" | |
#include "../Include/Math.hpp" | |
namespace SFMLShapes | |
{ | |
sf::ConvexShape GeneratePie(const float & radius, const float & angle, unsigned int vertexCount) | |
{ | |
/* Nie mozemy utworzyc wycinka kola z mniej niz 3 punktow. | |
Zabezpieczamy przed nierozsadnym uzytkownikiem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IAISense | |
{ | |
/* Tutaj reszta kodu... */ | |
public: | |
/* Ta metoda będzie wyswietlala informacje dla debugowania. | |
Przykladowo bedzie pokazywala dzialanie zmyslu wzroku (obszar widzenia, postrzeganych aktorow itp.) | |
Nie jest to metoda czysto wirtualna (=0) gdyz nie wymagamy, by klasy potomne musialy miec implementacje | |
tej metody. Zostawiamy ja domyslnie po prostu pusta. | |
*/ | |
inline virtual void DrawDebug() { } |