EnemyList.cpp
资源名称:g.rar [点击查看]
上传用户:laitongbao
上传日期:2021-02-20
资源大小:8176k
文件大小:2k
源码类别:
射击游戏
开发平台:
Visual C++
- // EnemyList.cpp: implementation of the EnemyList class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "EnemyList.h"
- #include "Playership.h"
- #include "MachineGun.h"
- #include "LaserGun.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- EnemyList::EnemyList()
- {
- this->collision = new CollisionDetector();
- }
- void EnemyList::AddEnemy(Enemy1*enemy)
- {
- list.push_front(enemy);
- }
- void EnemyList::RemoveEnemy(Enemy1*enemy)
- {
- list.remove(enemy);
- }
- void EnemyList::Clear()
- {
- list.clear();
- }
- void EnemyList::DoFrame()
- {
- std::list<Enemy1*>::iterator iter;
- for(iter = list.begin();iter != list.end();++iter)
- {
- Enemy1*enemy = (*iter);
- if(!enemy->alive)
- {
- delete enemy;
- iter = list.erase(iter);
- }
- }
- for(iter = list.begin();iter != list.end();++iter)
- {
- Enemy1*enemy = (*iter);
- //enemy doframe
- enemy->DoFrame();
- //hit test
- if(collision->N_P_Collision(enemy->mesh ,g_pship->gun1->emit,4.f,true))
- enemy->Damage(g_pship->gun1->damage);
- if(collision->N_P_Collision(enemy->mesh ,g_pship->gun2->emit,4.f,true))
- enemy->Damage(g_pship->gun2->damage);
- if(collision->N_P_Collision(g_pship->mesh ,enemy->gun1->emit,4.f,true))
- g_pship->Damage(enemy->gun1->damage);
- if(collision->N_P_Collision(g_pship->mesh ,enemy->gun2->emit,4.f,true))
- g_pship->Damage(enemy->gun2->damage);
- if(TransitionController::GetPosition(enemy->mesh).z < -100.f)
- enemy->alive = false;
- }
- }
- EnemyList::~EnemyList()
- {
- }