Exemple #1
0
void					GameCore::processPacket(GamerInfo* client,
								IClientPacket<ClientUDPCommand>* packet)
{
  switch (packet->getCommandType())
    {
    case CAUTH_UDP:
      setAlive(client, packet);
      authGamer(client, packet);
      break;
    case FIRE:
      setAlive(client, packet);
      gamerTryShoot(client, packet);
      break;
    case SEND_MOVE:
      setAlive(client, packet);
      gamerMove(client, packet);
      break;
    case ALIVE:
      setAlive(client, packet);
      break;
    case DISCONNECT:
      gamerDisconnect(client, packet);
      break;
    default:
      break;
    }
}
Monster::Monster(const TYPE_OF_CHARACTER_ID &type, const position &newpos, SpawnPoint *spawnpoint)
    : Character(),lastTargetPosition(position(0,0,0)),lastTargetSeen(false), spawn(spawnpoint), monstertype(type) {
    setId(MONSTER_BASE + counter++ % (NPC_BASE-MONSTER_BASE));
    setAlive(true);
    setMonsterType(type);
    setPosition(newpos);
}
Exemple #3
0
void RigidBlock::onB2PositionChanged()
{
    setAlive(true);

    m_polyBody->SetTransform(b2Vec2(m_position.x/PTM_RATIO, m_position.y/PTM_RATIO), 0.0f);
    //tryLaunchParticle(m_position);
}
Character::Character(const appearance &appearance) : effects(this), waypoints(this), _world(World::get()), _appearance(appearance), attributes(ATTRIBUTECOUNT) {
    setAlive(true);
    for (int i = 0; i < MAX_BODY_ITEMS + MAX_BELT_SLOTS; ++i) {
        characterItems[ i ].reset();
    }

    attributes[strength] = Attribute(0, MAXATTRIB);
    attributes[dexterity] = Attribute(0, MAXATTRIB);
    attributes[constitution] = Attribute(0, MAXATTRIB);
    attributes[agility] = Attribute(0, MAXATTRIB);
    attributes[intelligence] = Attribute(0, MAXATTRIB);
    attributes[perception] = Attribute(0, MAXATTRIB);
    attributes[willpower] = Attribute(0, MAXATTRIB);
    attributes[essence] = Attribute(0, MAXATTRIB);
    attributes[hitpoints] = Attribute(0, MAXHPS);
    attributes[mana] = Attribute(0, MAXMANA);
    attributes[foodlevel] = Attribute(0, MAXFOOD);
    attributes[sex] = Attribute(0);
    attributes[age] = Attribute(0);
    attributes[weight] = Attribute(0);
    attributes[height] = Attribute(0);
    attributes[attitude] = Attribute(0);
    attributes[luck] = Attribute(0);

    backPackContents = nullptr;

    magic.type = MAGE;
    magic.flags[ MAGE ] = 0x00000000;
    magic.flags[ PRIEST ] = 0x00000000;
    magic.flags[ BARD ] = 0x00000000;
    magic.flags[ DRUID ] = 0x00000000;
}
Exemple #5
0
void Hero::InitHero(ALLEGRO_BITMAP *image)
{
	setHealth(50);
	setMana(100);

	GameObject::init((mTotalWidth/2),(mTotalHeight/2 + 300), 0, 0, 0, 0, 10, 10);

	setID(PLAYER);
	setHeroNumber(0);

	setAlive(true);
	setCollideable(true);
	setDirection(DOWN);

	maxFrame = 5;
	curFrame = 1;
	frameWidth = 30;
	frameHeight = 30;
	animationColumns = 3;
	animationRow = 4;

	if (image != NULL)
		Hero::image = image;

}
Exemple #6
0
void Bubble::update()
{
	int nextY = getPositionY() - this->jumpStepY;
	int nextX = getX( nextY );
	setPosition( CCPoint( nextX, nextY ) );
	if ( getPositionY() < ( - this->size.height/2 ) )
		setAlive( false );
}
Exemple #7
0
void Poolable::free()
{
    if (isAlive())
    {
        setAlive(false);
        onFree();
    }
}
Exemple #8
0
void Button::release() {
	Sprite::~Sprite();
	if(image_normal!=NULL)
		image_normal->Release();
	if(image_pressed!=NULL)
		image_pressed->Release();
	setAlive(false);
}
Exemple #9
0
void Poolable::alloc()
{
    if (!isAlive())
    {
        onAlloc();
        setAlive(true);
    }
}
Exemple #10
0
void Monster::Collided(int objectID)
{
	if(objectID == BULLET)
	{
		loseHealth();
		if(getHealth() <= 0)
			setAlive(false);
	}
}
void DamageHitBox::update(SubLevel* subLevel_p) {
    mCurrentAnimation_p->updateAnimation();

    if( mQueDisable )
        setEnabled(false);

    if( mCurrentAnimation_p->endOfAnimation() )
        setAlive( false );

}
Exemple #12
0
bool RigidBlock::setBlockPosition(cocos2d::CCPoint position)
{
    setAlive(true);

	m_position = position;

	m_polyBody->SetTransform(b2Vec2(m_position.x/PTM_RATIO, m_position.y/PTM_RATIO), 0.0f);

    return true;
}
Exemple #13
0
void Hero::Collided(int objectID)
{
	/*if(objectID == BULLET)
		loseHealth();*/
	if (objectID == ENEMY || objectID == DRAGON || objectID == FIREBALL)
	{
		loseHealth();
		if(getHealth() <= 0)
			setAlive(false);
	}
}
HumanoidCombatComponent::HumanoidCombatComponent(objectCombat settings) {

	setMaxHP(settings.maxHP);
	setHP(settings.maxHP);

	setDamage(settings.damage);
	setAttackRange(settings.attackRange);
	setAttackSpeed(settings.attackSpeed);
	setAlive(true);
	setMarkedForRemoval(false);

}
Exemple #15
0
bool Enemy::getDamaged(int damage){
  if(currentHP>damage){
      currentHP-=damage;
      return false;
    }else{
      currentHP=0;
       setAlive(false);
      return true;

    }

}
Exemple #16
0
void object::initAllToZero()
{
	setX(0);
	setY(0);
	setSpeedX(0);
	setSpeedY(0);
	setDirX(0);
	setDirY(0);
	setAlive(false);
	setCollidable(false);
	setSpeed(0);
	setAngle(0);
}
Exemple #17
0
int RThread::start(void *arg, ru32 stackSize, ru32 mode) {
    OSA_RESULT res = -1;

    m_arg = arg;
    res = osa_t_create(&m_handle, RThread_thread_func, this,
                       stackSize, mode);
    if( res != 0 ) {
        m_handle = 0;
        setAlive(0);
    }

    return res;
}
Exemple #18
0
XiYangYang::XiYangYang() : Role ("xiyangyang.csb", "xiyangyang_body_0"){
	/*bodyX = 17.57f;
	bodyY = 30.46f;*/
	isRunning = false;
	isJump = false;
	isJumpSec = false;
	isAlive = true; // 设置
	setAlive(true);
	setSpeed(8.0f); // 设置默认的地图速度
	setScale(0.5f);
	setSize(230, 350);
	setDefualtPositon();
	run();
}
Exemple #19
0
bool RigidBlock::initWithConfigNode(xml_node<> *node)
{
    m_size = CCSizeMake( atoi(node->first_attribute("Width")->value()), atoi(node->first_attribute("Height")->value()));
    m_texture = cocos2d::CCTextureCache::sharedTextureCache()->addImage(node->first_attribute("Texture")->value());
    m_position = ccp(0, 0);
    
    createBody();
    initRenderData();

    setAlive(false);

    //this->scheduleUpdate();
    return true;
}
void DynamicObject::move()
{
	float posX = getPosition()->getX();
	float speed = getSpeed();

	if (direction == LEFT)
	{
		if (posX <= leftMoveBound)
		{
			setPosition(rightMoveBound, getPosition()->getY(), getPosition()->getZ());
			setAlive(false);
		}
		else setPosition(getPosition()->getX() - getSpeed(), getPosition()->getY(), getPosition()->getZ());
	}
	else if (direction == RIGHT)
	{
		if (posX >= rightMoveBound)
		{
			setPosition(leftMoveBound, getPosition()->getY(), getPosition()->getZ());
			setAlive(false);
		}
		else setPosition(getPosition()->getX() + getSpeed(), getPosition()->getY(), getPosition()->getZ());
	}
}
Exemple #21
0
object::object(float x, float y, float speedX, float speedY, int dirX, int dirY, int boundX,
	int boundY, char *bitmapPath, bool alive, bool collidable)
{
	setX(x);
	setY(y);
	setSpeedX(speedX);
	setSpeedY(speedY);
	setDirX(dirX);
	setDirY(dirY);
	setBoundX(boundX);
	setBoundY(boundY);
	setImage(bitmapPath);
	setValuesFromBitmap();
	setAlive(alive);
	setCollidable(collidable);
}
Exemple #22
0
void Player::init(ALLEGRO_BITMAP* img){

	BaseObj::init(50,300,2,2,1,1,32,48);
	setAlive(true);
	setId(PLAYER);
	score = 0;
	mf=4;
	cf=0;
	fw=32;
	fh=48;
	ac=4;
	ad=1;
	ar=0;
	fd=4;
	if(img!=NULL)
		image = img;

}
Exemple #23
0
void Monster::initMonster(ALLEGRO_BITMAP *image, ALLEGRO_FONT *Font)
{
	mTotalHeight = widthHeight(1);
	mTotalWidth = widthHeight(0);
	setHealth(100);
	spriteSize = 30;
	maxFrame = 4;
	animationColumns = 4;
	animationRow = 0;
	if (image != NULL)
	{
		Monster::image = image;
	}

	if (Font != NULL)
	{
		Monster::mFont = Font;
	}

	x = (mTotalWidth/4) + rand() % 700;
	if(x < (mTotalWidth / 4) + 15)
		x = (mTotalWidth / 4) + 15;
	if (x > ((mTotalWidth / 4) + sWIDTH) - 15)
		x = ((mTotalWidth / 4) + sWIDTH) - 15;
	y = (mTotalHeight/8) +rand() % 700;
	if(y < (mTotalHeight / 8) - 15)
		x = (mTotalHeight / 8) - 15;
	if (x > ((mTotalHeight / 8) + sHEIGHT) + 15)
		x = ((mTotalHeight / 8) + sHEIGHT) + 15;

	GameObject::init(x,y, 1, 1, 0, 0, 20, 20);
	mFont = Font;
	setID(ENEMY);

	setAlive(true);
	setCollideable(true);

	curFrame = 0;

	frameWidth = spriteSize;
	frameHeight = spriteSize;
}
void RMessagePassing::release(void)
{
    // stop connecting thread
    setAlive(0);
    wait(10);
    kill();

    // release node map
    m_nodeMap.release();

    // close socket
    m_socket.close();

    // clear message queue
    clearMsg();

    // clear nodes
    m_nodeMe     = NULL;
    m_nodeMaster = NULL;
}
Exemple #25
0
bool RigidBlock::initWithPointSize(CCPoint point, CCSize size, void *parm)
{
    //Add code for config support.
    //now we get the size and other parm from (void* parm) the xml_node<> *node
    xml_node<>* node = (xml_node<> *)parm;
    m_size = CCSizeMake( atoi(node->first_attribute("Width")->value()), atoi(node->first_attribute("Height")->value()));
    m_position = point;

    m_texture = cocos2d::CCTextureCache::sharedTextureCache()->addImage(node->first_attribute("Texture")->value());
	/*m_position = point;
	m_size	= size;*/
	//this->setTag(TagHelper::Instance()->getBlockTag());

	createBody();
	initRenderData();
	
	setAlive(false);

	return true;
}
Exemple #26
0
	void Bullit:: move(){
		setXPos(getXPos()+getSpeed()*cos(getDirectionGoing()*PI/180));
		setYPos(getYPos()+getSpeed()*sin(getDirectionGoing()*PI/180));

		//glTranslatef(getX()+getW()/2,getY()+getH()/2,0.0);
		//glRotatef(getDirectionGoing()-90,0.0,0.0,1.0);
		//glTranslatef(-getX()-getW()/2,-getY()-getH()/2,0.0);

		//setYPos(getYPos()+getSpeed());

		setDistance(getDistance()+getSpeed());
		if(getDistance()>=1000){
			setAlive(false);
			setXPos(3000);
			setYPos(3000);
		}
		setVertices();

		glTranslatef(getXPos()+width/2,getYPos()+height/2,0.0);
		glRotatef(getDirectionGoing()-90,0.0,0.0,1.0);
		glTranslatef(-getXPos()-width/2,-getYPos()-height/2,0.0);
	}
Exemple #27
0
void LightPoint::onCollision(PhysicalEntity* entityCollidedWith_p, const sf::FloatRect& intersection) {
	//don't do anything if not enabled
	if(getEnabled() == false)
		return;

	//don't do anything if not colliding with player
	auto player_p = dynamic_cast<Player*>(entityCollidedWith_p);
	if(player_p == nullptr)
		return;

	//destroy self if only supposed to be activated once
	if(mOnce)
		setAlive(false);

	//get the highest light level; the light points, or the players
	auto playerLightLevel = player_p->getCurrentLightLevel();
	auto newLightLevel = std::max(mLightLevel, playerLightLevel);

	//adjust light level
	auto adjustLightLevel = newLightLevel - playerLightLevel;
	player_p->adjustCurrentLightLevel(adjustLightLevel);
}
Exemple #28
0
void Player::kill() {
    setAlive(false);
    incNDeaths();
}
void PlaneState::updateState(const Basic::Component* const actor)
{
   const Simulation::AirVehicle* airVehicle = dynamic_cast<const Simulation::AirVehicle*>(actor);
   setAlive(false);
   if (airVehicle != nullptr && airVehicle->isActive()) {
      setAltitude(airVehicle->getAltitude());
      setAlive(airVehicle->getMode() == Simulation::Player::ACTIVE);
      setHeading(airVehicle->getHeading());
      setPitch(airVehicle->getPitch());
      setRoll(airVehicle->getRoll());
      osg::Vec3d angularVels = airVehicle->getAngularVelocities();
      setRollRate(angularVels.x());
      setPitchRate(angularVels.y());
      setYawRate(angularVels.z());
      setTracking(false);
      setTargetTrack(MAX_TRACKS);  // 0 is a valid target track, use MAX_TRACKS to
                                   // signal "no tgt track"
      setSpeed(airVehicle->getCalibratedAirspeed());
      setNumEngines(airVehicle->getNumberOfEngines());
      setIncomingMissile(false);
      setMissileFired(false);

      // determine if we have a missile to fire
#if 1
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores == nullptr || stores->getNextMissile() == nullptr) {
         // either we have no SMS, or we have no more missile
         setMissileFired(true);
      }
      else {
         // we have an sms, and we have a missile available
         // loop through player list and attempt to find out if one of our missiles is active
         // if there is an active missile, then for the time being, we do not have a missile to fire
         const Simulation::Simulation* sim = airVehicle->getSimulation();
         const Basic::PairStream* players = sim->getPlayers();
         bool finished = false;
         for (const Basic::List::Item* item = players->getFirstItem(); item != nullptr && !finished; item = item->getNext()) {
            // Get the pointer to the target player
            const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
            const Simulation::Player* player = static_cast<const Simulation::Player*>(pair->object());
            if (player->isMajorType(Simulation::Player::WEAPON) && (player->isActive() || player->isMode(Simulation::Player::PRE_RELEASE)) && (player->getSide() == airVehicle->getSide())) {
               // our side has a weapon on-the-way/in-the-air;
               setMissileFired(true);
               finished=true;
            }
         }
      }
#else
      // this state class has no way to determine whether we've fired a missile other than checking to see if sms is out of missiles to fire.
      // which means, it will fire all its missiles at first target.
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores != 0) {
         const Simulation::Missile* wpn = stores->getNextMissile();
         if (!wpn)
            setMissileFired(true);
      }
      else {
         // we have no SMS, we can't fire a missile;
         setMissileFired(true);
      }
#endif

      //const Basic::String* playerName = airVehicle->getName();
      // DH - DOES NOT COMPILE WITH CONST -- ????
      Simulation::AirVehicle* airVehicleX = const_cast<Simulation::AirVehicle*>(airVehicle);
      const Basic::Pair* sensorPair = airVehicleX->getSensorByType(typeid(Simulation::Radar));

      if (sensorPair != nullptr) {
         const Simulation::Radar* radar = static_cast<const Simulation::Radar*>(sensorPair->object());
         if (radar != nullptr) {
            const Simulation::TrackManager* trackManager = radar->getTrackManager();
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = trackManager->getTrackList(trackList, 50);

            for (int trackIndex = nTracks -1; trackIndex >= 0; trackIndex--) {
               setHeadingToTracked(trackIndex, trackList[trackIndex]->getRelAzimuth());
               setPitchToTracked(trackIndex, trackList[trackIndex]->getElevation());
               setDistanceToTracked(trackIndex, trackList[trackIndex]->getRange());

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }
               setTracking(true);
               setNumTracks(nTracks);

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Player* target = trackList[trackIndex]->getTarget();
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }

      const Simulation::OnboardComputer* oc = airVehicle->getOnboardComputer();
      if (oc != nullptr) {
         const Simulation::TrackManager* rtm = oc->getTrackManagerByType(typeid(Simulation::RwrTrkMgr));
         if(rtm !=nullptr) {
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = rtm->getTrackList(trackList, 50);
            int newTracks = 0;
            for (unsigned int trackIndex = 0; trackIndex < nTracks; trackIndex++) {
               Simulation::Player* target = trackList[trackIndex]->getTarget();
               bool alreadyTracked = false;
               for (unsigned int currTracks = 0; currTracks>getNumTracks(); currTracks++) {
                  // tracks are the same if the associated players are the same
                  if(trackList[currTracks]->getTarget()==target) {
                     alreadyTracked = true;
                     break;
                  }
               }

               if (!alreadyTracked && (getNumTracks() + newTracks) < MAX_TRACKS) {
                  int newTrackIndex = getNumTracks() + newTracks;
                  newTracks++;
                  setHeadingToTracked(newTrackIndex, trackList[trackIndex]->getRelAzimuth());
                  setPitchToTracked(newTrackIndex, trackList[trackIndex]->getElevation());
                  setDistanceToTracked(newTrackIndex, trackList[trackIndex]->getRange());
                  setTracking(true);

                  // update numTracks to new sum of radar + rwr tracks
                  setNumTracks(getNumTracks()+newTracks);
               }

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }
   }
   BaseClass::updateState(actor);
}
Exemple #30
0
void Bullet::takeDamage(int gameTime)
{
    setAlive(false);
    setDeathTime(gameTime);
}