// 获取当前主角相对于敌方的方向 RelativeDirection Enemy::getActorRD() { RelativeDirection rd = RD_NONE; // 主角的x坐标 大于 敌方的x坐标 if (getActorPos().x > getPosition().x) { rd = RD_RIGHT; } else if (getActorPos().x < getPosition().x) { rd = RD_LEFT; } return rd; }
// 更新敌人的位置 void Enemy::updatePos() { log("Enemy::updatePos"); Point actorPos = getActorPos(); Point enemyPos = getPosition(); updateFaceDir(); /*log("actorPos.y = %f", actorPos.y); log("enemyPos.y = %f", enemyPos.y);*/ if (fabs(actorPos.y - enemyPos.y) < 20) { } // 敌人的纵坐标 大于 主角的纵坐标 if (fabs(actorPos.y - enemyPos.y) > 20 && enemyPos.y > actorPos.y) { log("enemy go down"); downFloor(); } // 主角的纵坐标 大于 敌人的纵坐标 else if (fabs(actorPos.y - enemyPos.y) > 20 && enemyPos.y < actorPos.y) { log("enemy go up"); upFloor(); } }
// 判断主角与敌方是否在同一个地板 bool Enemy::isInOneFloor() { if (fabs(getActorPos().y - getPosition().y) < 20) { return true; } return false; }
// 自动发射子弹 void Enemy::updateFireBullet() { log("Enemy::updateFireBullet"); Point actorPos = getActorPos(); Point currentPos = getPosition(); Point dist = actorPos - currentPos; if (fabs(dist.y) < 12) { fireBullet(); } }
void Room::muddaUseAlienDevice() { assert(_roomIndex >= 0 && _roomIndex <= 5); const int deviceObjectIndices[] = { // Each room's object index for the explosion is different 9, // MUDD0 13, // MUDD1 11, // MUDD2 11, // MUDD3 9, // MUDD4 11 // MUDD5 }; _awayMission->disableInput = true; _awayMission->crewDirectionsAfterWalk[OBJECT_KIRK] = DIR_S; loadActorStandAnim(OBJECT_KIRK); Common::Point pos = getActorPos(OBJECT_KIRK); loadActorAnimC(deviceObjectIndices[_roomIndex], "s4cbxp", pos.x, 10, &Room::muddaFiredAlienDevice); playVoc("EXPLO3"); }