コード例 #1
0
ファイル: MyCharacter.cpp プロジェクト: zhouyige/3drpgdemo
void MyCharacter::Onlyupdate() 
{

	if(ball) ball->update();
	if(m_pMagic_Mgr) m_pMagic_Mgr->update();


	 //角色的状态更新武器显示  比如站着,就把手上的武器隐藏,背上的显示
	 m_weapon_mgr->update(getState());
	//UpdateByProperty();

	 if(property.target.X==0 &&property.target.Y==0 &&property.target.Z==0)
	  isArrived=true;

	if(!isArrived){
		//已挂就不能动了
		if(property.isDeath) return;

		property.pos=m_charClothMgr->getPosition();

		vector2df p1;
		p1.X=m_charClothMgr->getPosition().X;
		p1.Y=m_charClothMgr->getPosition().Z;

		vector2df p2;
		p2.X=property.target.X;
		p2.Y=property.target.Z;

		//已到达
		//f32 len=m_charClothMgr->getPosition().getDistanceFrom(	property.target) ;
		f32 len=p1.getDistanceFrom(p2);

		if( len< 4){
			m_charClothMgr->setPosition(property.target);
			property.pos=property.target;

			isArrived=true;

			property.target=vector3df(0,0,0);
			idle(false); 
			if(isMain==false) printf("其他角色已到达!\n");
		} 
		else 
		{ 
			// printf("距离:%3.1f\n",len);
			//未到达
			isArrived=false;
			faceTarget(	property.target); 
			if(isMain==false) printf("其他角色run!\n");
			run(true);
			moveto(m_charClothMgr->getRootNode(), core::vector3df(0,0,fSpeed)); 
		} 

		return;
	}



}
コード例 #2
0
ファイル: MyCharacter.cpp プロジェクト: zhouyige/3drpgdemo
void MyCharacter::move() 
{ 

	 //已挂就不能动了
	  if(property.isDeath) return;

	  property.pos=m_charClothMgr->getPosition();

  
		 //已到达
	 //    f32 len=m_charClothMgr->getPosition().getDistanceFromSQ(	property.target) ;
		 vector2df p1;
		 p1.X=m_charClothMgr->getPosition().X;
		 p1.Y=m_charClothMgr->getPosition().Z;

		 vector2df p2;
		 p2.X=property.target.X;
		 p2.Y=property.target.Z;

		 //已到达
		 //f32 len=m_charClothMgr->getPosition().getDistanceFrom(	property.target) ;
		 f32 len=p1.getDistanceFrom(p2);

		  if(isfollow && len< 12){
				
			    isArrived=true;
				
				property.target=vector3df(0,0,0);
                idle(false); 

		 }
		 else    if (len< 2.0 ) 
         { 
			 m_charClothMgr->setPosition(property.target);
			 property.pos=property.target;

			    isArrived=true;
				
				property.target=vector3df(0,0,0);
                idle(false); 
				setState(cIdle); 

         } 
         else 
         { 
			// printf("距离:%3.1f\n",len);
			    //未到达
				isArrived=false;
                faceTarget(	property.target); 

				run(true);
                moveto(m_charClothMgr->getRootNode(), core::vector3df(0,0,fSpeed)); 
         } 
   
} 
コード例 #3
0
ファイル: MyCharacter.cpp プロジェクト: zhouyige/3drpgdemo
void MyCharacter::attack(vector3df attackpos,eAttacktype attackType) 
{ 
	  //已挂就不能动了
	  if(property.isDeath) return;

	  if(monster==0) {
		 readyAttack(true);
		  isfollow=false;
		  return;
	  }

	  setState( cAttack);

	  	 //用时
		u32 usetime=timer->getRealTime()-lastattacktime;
		if(usetime<800) {
			return;
		}
		else lastattacktime=timer->getRealTime();
        

		 //面向目标
		 faceTarget(attackpos); 

         switch (attackType) 
         { 
                 case eAttacktype::PowerAttack : 
                 {        
					 m_charClothMgr->Animate(ANIMATION_SPEED,102,120,true);
					 break;
                 }        
  
                 case eAttacktype::MagicAttack: 
                 {       
					 m_charClothMgr->Animate(ANIMATION_SPEED+2,120,128,true);
					 break;
                 }
  
         } 

		 

		 //及时更新状态到服务器   
		 ReoprtToServer();


		 //怪物遭受角色攻击, property.Attack是角色攻击力
		if(monster) monster->UnderAttack( property.Attack+package.weaponparam2);

}
コード例 #4
0
ファイル: TextureImpl.cpp プロジェクト: mrzzzrm/Deliberation2
void TextureImpl::texImage2DAllFaces(const TextureBinary * binary) const
{
    for (auto f = 0u; f < numFaces; f++)
    {
        auto * binarySurface = binary ? &binary->surface(f) : nullptr;

        gl::glTexImage2D(faceTarget(type, f),
                         0,
                         (gl::GLint)format.glInternalFormat(),
                         binarySurface ? binarySurface->width() : width,
                         binarySurface ? binarySurface->height() : height,
                         0,
                         format.glFormat(),
                         format.glType(),
                         binarySurface ? binarySurface->data() : nullptr);
    }
}
コード例 #5
0
void MoveScript::runScripts()
{
    if(useFaceTarget)
    {
        faceTarget();
    }
    if(useGlobalRotate)
    {
        globalRotate();
    }
    if(useLocalRotate)
    {
        localRotate();
    }
    if(useLocalTrans)
    {
        localTrans();
    }
    if(useGlobalTrans)
    {
        globalTrans();
    }
    if(useSetScale)
    {
        setScale();
    }
    if(useLimitedTrans)
    {
        localTransLimited();
    }
    if(useFollowPlayer)
    {
        followPlayer();
    }
    if(useBulletTrans)
    {
        bulletTranslation();
    }

}
コード例 #6
0
ファイル: enemy.cpp プロジェクト: lumidify/blobandconquer
void doEnemies()
{
	bool helpless;
	float fallSpeed;
	
	for (Unit *unit = (Unit*)entityManager->enemyList.getFirstElement() ; unit != NULL ; unit = (Unit*)unit->next)
	{
		self = unit;
		
		//self->riding = NULL;
		
		bbManager->removeBox(unit);
		
		// final battle...
		if (unit->contentType & CONTENTS_PLAYERCLIP)
		{
			unit->health = 0;
			unit->flags |= EF_DEAD;
		}

		if (unit->health <= 0)
		{
			if (unit->flags & EF_DEAD)
			{
				if (!unit->referenced)
				{
					if (player->target == unit)
					{
						player->target = NULL;
					}
				
					unit = (Unit*)unit->previous;
					entityManager->enemyList.remove(unit->next);
					
					if (entityManager->enemyList.getSize() == 0)
					{
						fireTriggers("ANY_ENEMY", TRIGGER_TYPE_ALL_ENEMIES_KILLED);
					}
					
					continue;
				}
				else
				{
					unit->referenced = false;
				}
				
				continue;
			}
			else if (!(unit->flags & EF_DYING))
			{
				unit->die();
				
				if (!unit->dead)
				{
					fireTriggers(unit->getName(), TRIGGER_TYPE_ENTITY_KILLED);
					fireTriggers("ANY_ENEMY", TRIGGER_TYPE_ENTITY_KILLED);
					unit->dead = true;
				}
				
				unit->flags |= EF_DYING;
				
				if (!(unit->flags & EF_STATIC))
				{
					unit->flags |= EF_BOUNCES;
				}
				
				addBloodParticle(unit->position.x, unit->position.y, unit->position.z);
				
				if (unit->contentType & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))
				{
					debug(("%s drowned...\n", unit->getName()));
				}
			}
		}
		
		if ((unit->spawnedIn) && (unit->lastPlayerSighting >= 6000) && (!unit->referenced))
		{
			addTeleportParticles(unit->position);
			unit = (Unit*)unit->previous;
			entityManager->enemyList.remove(unit->next);
			continue;
		}
		
		if (unit->target != NULL)
		{
			unit->target->referenced = true;
		}
		
		if (unit->owner != NULL)
		{
			unit->owner->referenced = true;
		}
		
		unit->referenced = false;

		helpless = (unit->helpless > 0);

		if ((!game->allStatic) && (game->cutsceneType != CUTSCENE_INGAME))
		{
			if ((!helpless) || (unit->health < 1))
			{
				if (unit->performNextAction(engine->getTimeDifference(TD_LOGIC)))
				{
					if (unit->action != NULL)
					{
						unit->action();
					}
				}
			}
		}

		if (game->cutsceneType != CUTSCENE_INGAME)
		{
			unit->think(engine->getTimeDifference(TD_LOGIC));
		}
		
		if (unit->flags & (EF_TELEPORTING|EF_VANISHED))
		{
			continue;
		}
		
		if (withinViewableRange(unit))
		{
			entityManager->addEntityToDrawList(unit);
			
			if (unit->flags & EF_WEIGHTLESS)
			{
				addGravUnitParticles(unit, GLColor::purple, GLColor::blue);
			}
		}
		
		if ((unit->liquidLevel > 1) && (!(unit->flags & EF_SWIMS)))
		{
			if ((unit->definition->type == NME_DARK_BLOB) && (unit->health > 0))
			{
				generalUnitVanish(player->position, Math::rrand(300, 400));
				continue;
			}
			else if (unit->health > 0)
			{
				unit->applyDamage(RAND_MAX, DAMAGE_SPECIAL);
			}
		}

		// was helpless but now isn't - Stop sliding!
		if ((helpless) && (unit->helpless <= 0))
		{
			if ((unit->flags & EF_ONGROUND) || (!(unit->contentType & CONTENTS_SOLID)) || (unit->flags & EF_WEIGHTLESS))
			{
				unit->totalCurrentDamage = 0;
				unit->rotation.set(0, 0, 0);
				unit->flags &= ~EF_BOUNCES;
			}
			else
			{
				unit->helpless = 1;
			}
		}

		unit->applyGravity(engine->getTimeDifference(TD_LOGIC));
		
		keepUnitAwayFromEdges(unit);

		fallSpeed = unit->realVelocity.z;
		
		if (fallSpeed <= FALL_DAMAGE_ACCEL)
		{
			unit->helpless = 5;
			unit->flags |= EF_BOUNCES;
		}
		
		// don't let swimming blobs move too quickly
		if ((unit->flags & EF_SWIMS) && (unit->liquidLevel == 2))
		{
			Math::limit(&unit->velocity.x, -0.1, 0.1);
			Math::limit(&unit->velocity.y, -0.1, 0.1);
			Math::limit(&unit->velocity.z, -0.1, 0.1);
		}
		
		moveEntity(unit);
		
		if ((fallSpeed <= FALL_DAMAGE_ACCEL) && (unit->velocity.z > FALL_DAMAGE_ACCEL) && (unit->contentType & CONTENTS_SOLID))
		{
			unit->velocity.z = 1.0;
			fallSpeed = fabs(fallSpeed * 1.5);
			
			if (!(unit->flags & EF_DYING))
			{
				unit->applyDamage(fallSpeed, DAMAGE_SPECIAL);
				unit->shield = -2.5;
				audio->playSound(SND_HIT, CH_ANY, camera->getSoundDistance(unit->position));
				debug(("%s took %.2f damage from fall [%s]\n", unit->getName(), fallSpeed, unit->position.toString()));
			}
			else
			{
				unit->health = -100;
				unit->flags |= EF_DYING;
			}
		}
		
		if ((unit->position.z < bsp->minCords.z) && (unit->health > 0))
		{
			printf("WARNING: Enemy '%s' fell out of map at %s\n", unit->getName(), unit->position.toString());
			printf("Map Mins: %s\n", bsp->minCords.toString());
			printf("Map Maxs: %s\n", bsp->maxCords.toString());
			printf("On Ground = %ld\n", (unit->flags & EF_ONGROUND));
			printf("Velocity = %s\n", unit->velocity.toString());
			unit->health = -100;
			unit->flags |= EF_DEAD;
			continue;
			#if DEV
			exit(1);
			#endif
		}
		
		if (unit->flags & EF_ONFIRE)
		{
			addOnFireParticles();
		}
		
		bbManager->addBox(unit);
		
		if ((unit->definition->type == NME_DARK_BLOB) && (unit->health > 0))
		{
			Math::limit(&unit->helpless, 0, 25);
		}
		
		if ((unit->flags & EF_ALWAYS_FACE) && (unit->health > 0))
		{
			if ((!unit->helpless) && (unit->target != NULL))
			{
				faceTarget(unit);
			}
		}
	}
}
コード例 #7
0
ファイル: awesome_boss.c プロジェクト: carriercomm/edgar
static void teleportWait()
{
    int i;
    Target *t;

    setEntityAnimation(self, "STAND");

    if (player.health <= 0)
    {
        self->thinkTime--;

        if (self->thinkTime <= 0)
        {
            self->x = self->startX;
            self->y = self->startY;

            self->flags &= ~NO_DRAW;

            addParticleExplosion(self->x + self->w / 2, self->y + self->h / 2);

            playSoundToMap("sound/common/spell", -1, self->x, self->y, 0);

            self->action = &teleportIn;

            facePlayer();

            self->head->mental--;
        }
    }

    else if (self->target->health <= 0)
    {
        self->thinkTime--;

        if (self->thinkTime <= 0)
        {
            self->x = self->target->x;

            t = getTargetByName((prand() % 2 == 0) ? "AWESOME_TARGET_LEFT" : "AWESOME_TARGET_RIGHT");

            if (t == NULL)
            {
                showErrorAndExit("Awesome Boss cannot find target");
            }

            self->y = t->y;

            faceTarget();

            self->thinkTime = 60;

            self->flags &= ~NO_DRAW;

            addParticleExplosion(self->x + self->w / 2, self->y + self->h / 2);

            playSoundToMap("sound/common/spell", -1, self->x, self->y, 0);

            self->action = &healPartner;

            self->touch = &entityTouch;

            self->dirY = 0;

            self->head->mental--;
        }
    }

    else if (self->head->health == self->head->maxHealth)
    {
        if (self->head->mental == self->head->damage && self->head->targetY <= 0)
        {
            if (self->head->damage == 2)
            {
                t = getTargetByName((int)self->endX % 2 == 0 ? "AWESOME_TARGET_LEFT" : "AWESOME_TARGET_RIGHT");

                self->x = t->x;
                self->y = t->y;

                self->action = superSpearAttackInit;
            }

            else
            {
                switch (self->head->targetX)
                {
                case 0:
                    self->thinkTime = 30 * self->endX;

                    self->mental = 5;

                    self->action = &superDropAttackInit;

                    self->flags |= FLY;

                    self->dirY = 0;
                    break;

                default:
                    t = getTargetByName(self->endX <= 2 ? "AWESOME_TARGET_LEFT" : "AWESOME_TARGET_RIGHT");

                    self->x = t->x;
                    self->y = t->y;

                    self->endY = 1;

                    /* The other one will stand behind their partner */

                    if (self->endX == 2 || self->endX == 4)
                    {
                        self->x += self->endX == 2 ? -24 : 24;

                        self->endY = 0;
                    }

                    self->action = superFireballAttackInit;
                    break;
                }
            }
        }
    }

    else if (self->active == TRUE)
    {
        self->thinkTime--;

        if (self->thinkTime <= 0)
        {
            i = prand() % 2;

            switch (i)
            {
            case 0:
                self->action = &fireballAttackInit;
                break;

            default:
                self->action = &dropAttackInit;
                break;
            }

            setEntityAnimation(self, "STAND");

            self->dirY = 0;

            self->head->mental--;
        }
    }

    checkToMap(self);
}