Ajout commentaires et destructeurs

This commit is contained in:
Amaury
2020-05-04 15:18:20 +02:00
parent e3d43d638a
commit 806b37890d
4 changed files with 85 additions and 36 deletions

View File

@ -3,56 +3,68 @@
#include <Texture.hpp>
#include <string>
#include "MobsCorpACorpIA.h"
GestionCollision::GestionCollision(GestionMobs* m, GestionPlayer* p, GestionTerrain* t) : gMobs(m), gPlayer(p), gTerrain(t)
{
}
std::vector<MobsIA*> GestionCollision::CheckCollisonSol()
{
std::vector<MobsIA*> mobs_collision;
/*for (MobsIA* m : gMobs->mobs)
{
Vector2 pos = m->get_transform().get_origin();
Vector2 size = m->get_transform().get_scale();
for (StaticBody2D* elem : gTerrain->elems_terrains)
{
if (elem->get_transform().get_origin().y > pos.x) {
Godot::print("Mob touche");
mobs_collision.push_back(m);
}
}
}*/
/**
* <summary>Test des collisions entre les entit<69>s et le sol</summary>
*/
void GestionCollision::CheckCollisonSol()
{
Vector2 posPlayer = gPlayer->get_transform().get_origin();
Vector2 taille_Player = ((Sprite*)gPlayer->get_children()[0])->get_texture().ptr()->get_size();
bool player_touch = false;
bool player_touch_temp = false;
for (StaticBody2D* elem : gTerrain->elems_terrains)
{
//R<>cuperation des donn<6E>es de position de l'elem
Vector2 posTerrain = elem->get_transform().get_origin();
Vector2 taille_Sol = ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size();
//Test collision avec le sol et le player
if (!player_touch_temp) // Si player ne touche pas encore
if (posTerrain.y - (taille_Sol.y) < posPlayer.y
&& posTerrain.y > posPlayer.y
&& posTerrain.x - (taille_Sol.x / 2) < posPlayer.x + taille_Player.x / 4
&& posTerrain.x + (taille_Sol.x / 2) > posPlayer.x - taille_Player.x / 4) //Test de si touche
player_touch_temp = true;
//Test collision de chaque mobs avec le sol
for (KinematicBody2D* m : gMobs->mobs)
{
Vector2 pos = m->get_transform().get_origin();
Vector2 size = ((Sprite*)elem->get_children()[0])->get_texture().ptr()->get_size();
MobsCorpACorpIA* m_cast = (MobsCorpACorpIA*) m;
if (posTerrain.y - (taille_Sol.y) < posPlayer.y
&& posTerrain.y > posPlayer.y
&& posTerrain.x - (taille_Sol.x / 2) < posPlayer.x + taille_Player.x / 4
&& posTerrain.x + (taille_Sol.x / 2) > posPlayer.x - taille_Player.x / 4) {
player_touch = true;
break;
if (posTerrain.y - (taille_Sol.y) < pos.y
&& posTerrain.y > pos.y
&& posTerrain.x - (taille_Sol.x / 2) < pos.x + size.x / 4
&& posTerrain.x + (taille_Sol.x / 2) > pos.x - size.x / 4) {
Godot::print("Mob touche");
m_cast->on_ground = true;
}
}
}
gPlayer->on_ground = player_touch;
return mobs_collision;
gPlayer->on_ground = player_touch_temp;
}
std::vector<MobsIA*> GestionCollision::CheckCollisonMur()
/**
* <summary>Test des collisions entre les entit<69>s et les murs</summary>
*/
void GestionCollision::CheckCollisonMur()
{
return std::vector<MobsIA*>();
}
std::vector<MobsIA*> GestionCollision::CheckCollisonToit()
/**
* <summary>Test des collisions entre les entit<69>s et les plafonds</summary>
*/
void GestionCollision::CheckCollisonToit()
{
return std::vector<MobsIA*>();
}