void Monster::fire() { if(isDie() || isOver()) return; Weapon* w = Weapon::create(this); GameManager::getInstance()->monsterLayer->addChild(w, 50); }
//下棋,新落子 bool Go::Point(Cell tmp) { int x = tmp.x; int y = tmp.y; //是否已经有落子 if (!go[x][y].isEmpty()) { return false; } tp.clear(); tp.push_back(tmp); go[x][y] = tmp; Status recheck; if (count % 2) { recheck = s_black; checkcolor = s_write; } else { recheck = s_write; checkcolor = s_black; } checkStarus(x, y);//检查状态是否吃子 if (tp.size() > 1) { //如果吃子:一步之内同形再现? vector<Cell> parent = dropbackup[count - 1]; if (parent.size() == 2 && tp.size() == 2) { if (parent.at(0).equal(tp.at(1)) && parent.at(1).equal(tp.at(0))) { go[x][y].updateStatus(s_empty); return false; } } //确定生效~//清除死子 for (unsigned int i = 1; i < tp.size(); i++) { CellUpdate(tp.at(i), s_empty); } } else { //没吃子时,检查自己是不是挂了 ans = true;//发现empty标记false; die.clear();//先删除上次状态 checkcolor = recheck; isDie(x, y); chearPath(); if (ans) {//本次操作无效 //恢复go[x][y]... go[x][y].updateStatus(s_empty); return false; } } dropbackup.insert(pair<int, vector<Cell> >(count, tp)); count++; return true; //清理死子//保存死子,保存记录,保存用于悔棋。 //上一级需要处理死子GUI变化(PointCheck) }
//检查该点是否无气,并处理 void Go::isDie(int x, int y) { //是否在棋盘上(防止path数组越界。。。) if (path[x][y] || ans == false) { //已经走过(path数组标记),或已经发现气,取消检测 return; } //为空应停止本次检查 if (go[x][y].isEmpty()) { ans = false; } else { Cell ce = go[x][y]; path[x][y] = true;//标记走过,带颜色的点 cpath.push_back(ce);//记录每个标记(空不可标记,会影响后续检查),检查完后清理标记 if (go[x][y].isSameColor(checkcolor)) {//相同颜色,继续拓展 die.push_back(ce);//这样应该是复制一个对象,非引用(后面的函数调用使用修改ce不影响die存放的信息) = = int check[4][2]; prepareExt(x, y, check); for (int i = 0; i < 4; i++) { if (isOnBoard(check[i][0], check[i][1])) { isDie(check[i][0], check[i][1]); } } } } }
void Grenade::update(float ft) { Aware::update(ft); countTime = countTime + ft; if (!isDie() && countTime >= bombTime) //NÃëºó¿ªÊ¼ÒýȼÊÖÁñµ¯ { dead(); } }
void ChsBullet::Signal(std::string strMsg,void *pParam) { if(isDie() == false) { if(strMsg == "hit") { m_pAnim->zeroForces(); SetStatus(FSM_HIT); } } }
void CAIPlayer::Signal(std::string strSignal,void *pParam) { if(!isDie()) { if(strSignal == "hit") { CPlayer *doer = (CPlayer *)pParam; irr::core::vector3df vdodir = doer->getPosition() - getPosition(); vdodir.normalize(); irr::core::vector3df vblowDir(-vdodir.X,0,-vdodir.Z); m_pChracterAnimator->applyImpulse(700.f * vblowDir); m_pChracterAnimator->applyImpulse(70.f * irr::core::vector3df(0,1,0)); SetStatus(FSM_ATTACKED); } } }
//下棋后检查吃子 void Go::checkStarus(int x, int y) { int check[4][2]; prepareExt(x, y, check); //此处4个检查应该互不影响 for (int i = 0; i < 4; i++) { ans = true;//发现empty标记false; die.clear();//先删除上次状态 //不在棋盘时,检查无意义 if (isOnBoard(check[i][0], check[i][1])) { isDie(check[i][0], check[i][1]); chearPath(); //检查玩之后,清理path待下次检查,返回die,ans标记是否有效 if (ans) { for (Cell ce : die) { tp.push_back(ce); } } } } }