BombSet.cpp
资源名称:LwGame2.0.rar [点击查看]
上传用户:semy2100
上传日期:2013-01-22
资源大小:3633k
文件大小:7k
源码类别:
射击游戏
开发平台:
Visual C++
- /********************************************************************
- * 空运爆发 *
- * Version 2.0 *
- * 本游戏全部代码由: *
- * 冲天实验室 梁锋 编写 *
- * 邮箱:lenwine@126.com *
- * bbs: http://free2.e-168.cn/lenwind (正在开发中...) *
- **********************************************************************/
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- BombSet::BombSet(Manager *mgr)
- {
- mManager=mgr;
- }
- BombSet::~BombSet()
- {
- list<Bomb*>::iterator bn,en;;
- bn=BombList.begin();
- en=BombList.end();
- while(bn!=en)
- {
- delete *bn;
- bn++;
- }
- }
- //新增子弹
- void BombSet::Firing(Bomb::BOMBSTYLE bombStyle,int x,int y,double memsx,double memsy)
- {
- int i;
- Bomb *bAddBomb;
- switch(bombStyle)
- {
- /************************************************************************/
- /* 定义 长红-004 --------------------------------------Begin*/
- case Bomb::OPERATOR_SHOOT:
- for(i=0;i<4;i++)//这里是我机开机要增加的弹
- {
- bAddBomb=new OperatorShoot(mManager,x-12+8*i,y,memsx,memsy);
- BombList.push_back(bAddBomb);
- }
- break;
- /* 定义 长红-004 --------------------------------------End*/
- /************************************************************************/
- /* 定义 旋风-520 --------------------------------------Begin*/
- case Bomb::OPERATOR_NOSHOOT:
- for(i=0;i<20;i++)
- {
- bAddBomb=new OperatorNoShoot(mManager,x-5+rand()%7,y-5+rand()%7,memsx,memsy,rand()%361);
- BombList.push_back(bAddBomb);
- }
- break;
- /* 定义 旋风-520 --------------------------------------End*/
- /************************************************************************/
- /* 定义 邪神-180 角度------------------------------------------Begin*/
- case Bomb::OPERATOR_ROUND_SHOOT:
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,10);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,30);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,50);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,80);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,90);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,100);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,130);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,150);
- BombList.push_back(bAddBomb);
- bAddBomb=new OperatorRoundShoot(mManager,x,y,memsx,memsy,170);
- BombList.push_back(bAddBomb);
- break;
- /* 定义 邪神-180 角度------------------------------------------End*/
- /************************************************************************/
- /* 定义 小王 ---------------------------------Begin*/
- case Bomb::ENERMY_BOMBO:
- for(i=0;i<3;i++)
- {
- bAddBomb=new EnermyBombO(mManager,x-(18*i),y,memsx,memsy,270);
- BombList.push_back(bAddBomb);
- }
- break;
- /* 定义 小王 ---------------------------------End*/
- /************************************************************************/
- case Bomb::ENERMY_BOMBS:
- bAddBomb=new EnermyBombS(mManager,x-10,y,memsx,memsy,270);
- BombList.push_back(bAddBomb);
- break;
- /************************************************************************/
- case Bomb::ENERMY_BOMBT:
- bAddBomb=new EnermyBombT(mManager,x-5,y,memsx,memsy,225);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombT(mManager,x+5,y,memsx,memsy,315);
- BombList.push_back(bAddBomb);
- break;
- /************************************************************************/
- case Bomb::ENERMY_BOMBF://黑敌机
- for(i=0;i<3;i++){
- bAddBomb=new EnermyBombF(mManager,x+(i-2),y+i+25,memsx,memsy,90*(i+2));
- BombList.push_back(bAddBomb);
- }
- break;
- /**---------------------------------------------------------------------*/
- case Bomb::ENERMY_BOMBG://王
- // for(i=0;i<7;i++)
- // {
- // bAddBomb=new EnermyBombG(mManager,x-rand()%10,y-rand()%10,memsx,memsy,rand()%270);
- // BombList.push_back(bAddBomb);
- // }
- /**
- bAddBomb=new EnermyBombG(mManager,x-5,y,memsx,memsy,225);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombG(mManager,x+5,y,memsx,memsy,315);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombG(mManager,x-5,y,memsx,memsy,215);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombG(mManager,x+5,y,memsx,memsy,325);
- BombList.push_back(bAddBomb);**/
- break;
- /**---------------------------------------------------------------------*/
- case Bomb::ENERMY_BOMBH://没有敌机用。暂时
- bAddBomb=new EnermyBombH(mManager,x-5,y,memsx,memsy,225);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombH(mManager,x+5,y,memsx,memsy,315);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombH(mManager,x-5,y,memsx,memsy,215);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombH(mManager,x+5,y,memsx,memsy,325);
- BombList.push_back(bAddBomb);
- break;
- /**=--------------------------------------------------------------------*/
- case Bomb::ENERMY_BOMBI://黄敌机
- for(i=0;i<7;i++)
- {
- bAddBomb=new EnermyBombI(mManager,x+i+1,y+i,memsx,memsy,180+(i*10));
- BombList.push_back(bAddBomb);
- }
- break;
- /**---------------------------------------------------------------------*/
- case Bomb::ENERMY_BOMBJ:
- bAddBomb=new EnermyBombJ(mManager,x-5,y,memsx,memsy,225);
- BombList.push_back(bAddBomb);
- bAddBomb=new EnermyBombJ(mManager,x+5,y,memsx,memsy,315);
- BombList.push_back(bAddBomb);
- break;
- /**---------------------------------------------------------------------*/
- }
- }
- //返回第一个子弹对象
- Bomb* BombSet::GetOneBomb()
- {
- BombFind=-1;
- BombValue=BombList.size();
- if(BombValue==0)
- return NULL;
- oNowEnermy=BombList.end();
- return GetTwoBomb();
- }
- //返回下一个子弹对象
- Bomb* BombSet::GetTwoBomb()
- {
- BombFind++;
- oNowEnermy++;
- while((BombFind<BombValue)&&((*oNowEnermy)->Work==false))
- {
- delete *oNowEnermy;
- BombValue--;
- oNowEnermy=BombList.erase(oNowEnermy);
- }
- if(oNowEnermy==BombList.end())
- return NULL;
- else
- return *oNowEnermy;
- }
- void BombSet::Update()
- {
- Bomb *bBomb=GetOneBomb();
- while(bBomb)
- {
- bBomb->Update();
- bBomb=GetTwoBomb();
- }
- }