Ejemplo n.º 1
0
static void touch(Entity *other)
{
	int remaining, total;
	Entity *temp;

	if (strcmpignorecase(other->name, self->requires) == 0)
	{
		if (other->type == PROJECTILE)
		{
			temp = self;

			self = other;

			self->die();

			self = temp;
		}

		/* Don't toggle if a timer */

		if (self->maxThinkTime != 0 && self->thinkTime != 0)
		{
			self->thinkTime = self->maxThinkTime;

			return;
		}

		total = 0;

		remaining = self->maxThinkTime == 0 ? countSiblings(self, &total) : 0;

		self->active = self->active == TRUE ? FALSE : TRUE;

		if (remaining == 0)
		{
			setEntityAnimation(self, self->active == FALSE ? "STAND" : "WALK");

			activateEntitiesWithRequiredName(self->objectiveName, self->active);

			self->thinkTime = self->maxThinkTime;

			if (self->maxThinkTime != 0)
			{
				self->endX = playSoundToMap("sound/common/tick", -1, self->x, self->y, -1);
			}

			else if (total > 0)
			{
				setInfoBoxMessage(30, 255, 255, 255, _("Complete"), remaining);
			}
		}

		else
		{
			setEntityAnimation(self, self->active == FALSE ? "STAND" : "WALK");

			setInfoBoxMessage(30, 255, 255, 255, _("%d more to go..."), remaining);
		}

		playSoundToMap("sound/common/switch", -1, self->x, self->y, 0);
	}
}
Ejemplo n.º 2
0
void EnemyFactory::createEnemy( TiXmlNode *enemyNode)
{
    TiXmlNode *node;
    TiXmlElement *elem;
    
    LPathManager &lpm = *LPathManagerS::instance();

    LEnemy *enemy = new LEnemy();

    elem = enemyNode->ToElement();
    enemy->spawnTime = strToFloat( elem->Attribute("spawnTime"));
    EnemyType enemyType = eSimpleEnemy;
    if( elem->Attribute("type"))
	enemyType = (EnemyType)strToInt(elem->Attribute("type"));

    node = enemyNode->FirstChild("Model");
    elem = node->ToElement();
    enemy->modelName = elem->Attribute("Name");
    
    node = enemyNode->FirstChild("SpawnPoint");
    elem = node->ToElement();
    enemy->spawnPoint.x = strToFloat( elem->Attribute("x"));
    enemy->spawnPoint.y = strToFloat( elem->Attribute("y"));
    enemy->spawnPoint.z = strToFloat( elem->Attribute("z"));
    
    node = enemyNode->FirstChild("Home");
    elem = node->ToElement();
    enemy->home.x = strToFloat( elem->Attribute("x"));
    enemy->home.y = strToFloat( elem->Attribute("y"));
    enemy->home.z = strToFloat( elem->Attribute("z"));

    node = enemyNode->FirstChild("EntryPath");
    elem = node->ToElement();
    enemy->entry = lpm.getPath( elem->Attribute("Name"));

    node = enemyNode->FirstChild("IdlePath");
    elem = node->ToElement();
    enemy->idle = lpm.getPath( elem->Attribute("Name"));

    node = enemyNode->FirstChild("AttackPath");
    enemy->numAttackPaths = countSiblings( node, "AttackPath");
    enemy->attack = new LPath*[ enemy->numAttackPaths];
    for( int i=0; i< enemy->numAttackPaths; i++)
    {
	elem = node->ToElement();
	enemy->attack[ i] = lpm.getPath( elem->Attribute("Name"));
	node = node->NextSibling( "AttackPath");
    }

    node = enemyNode->FirstChild("RetreatPath");
    enemy->numRetreatPaths = countSiblings( node, "RetreatPath");
    enemy->retreat = new LPath*[ enemy->numRetreatPaths];
    for( int i=0; i< enemy->numRetreatPaths; i++)
    {
	elem = node->ToElement();
	enemy->retreat[ i] = lpm.getPath( elem->Attribute("Name"));
	node = node->NextSibling( "RetreatPath");
    }

    switch( enemyType)
    {
	default:
	case eSimpleEnemy:
	    new SimpleEnemy( enemy);
	    break;
	case eBoss1:
	    new Boss1Enemy( enemy);
	    break;
    }
}