Beispiel #1
0
// our player's already loaded locally, but we've just linked into an age and others there need to be
// told about us
void plAvatarMgr::PropagateLocalPlayer(int spawnPoint)
{
    plKey playerKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey();
    if(playerKey)
    {
        plKey requestor = GetKey();
        bool isPlayer = true;
        bool isLoading = true;
        plLoadAvatarMsg *msg = new plLoadAvatarMsg(playerKey, requestor, 0, isPlayer, isLoading);

        if (spawnPoint >= 0)
        {
            const plSpawnModifier * spawn = GetSpawnPoint(spawnPoint);
            if ( spawn )
            {
                const plSceneObject * spawnObj = spawn->GetTarget(0);
                msg->SetSpawnPoint(spawnObj->GetKey());
            }
        }

        // don't propagate locally. this is only for our peers
        msg->SetBCastFlag(plMessage::kLocalPropagate, false);
        msg->Send();
    } else {
        hsStatusMessage("Tried to propagate non-existent local player.");
    }
}
Beispiel #2
0
void CSkeleton::BuildPathHome()
{

	int nStartNode = GetPathPlanner()->FindClosestNode(GetPosition());
	int nGoalNode = GetPathPlanner()->FindClosestNode(&GetSpawnPoint());

	vector<XMFLOAT3> newPath = GetPathPlanner()->GeneratePath(nStartNode, nGoalNode, false);
	SetNodeOnPath(newPath.size() - 1);

	SetPath(newPath);
}
Beispiel #3
0
int ItemManager::SpawnItem(){
	//とりあえず呼ばれたら追加

	for (int i = 0; i < Maxitem; i++){


		if (iobj[i]){
		
			continue;
		}
		else{}
			GetSpawnPoint(i);
				  std::unique_ptr<Itemclass >obj(new Itemupper(spawnpoint[0], spawnpoint[1]));
				  iobj[i] = std::move(obj);
				  return 1;	
	}
	return 0;
}
/*
==============
idSpawner::SpawnEnt
==============
*/
bool idSpawner::SpawnEnt( void ){
	idDict		args;
	idEntity*	spawnPoint;
	idEntity*	spawnedEnt;
	const char* temp;

	// Find a spawn point to spawn the entity
	spawnPoint = GetSpawnPoint();

	if ( spawnPoint == NULL ){
		return false;
	}

	// No valid spawn types for this point
	temp = GetSpawnType( spawnPoint );
	if ( !temp || !*temp ) {
		gameLocal.Warning ( "Spawner '%s' could not find any valid spawn types for spawn point '%s'", GetName(), spawnPoint->GetName() );
		return false;
	}

	// Build the spawn parameters for the entity about to be spawned
	args.Set( "origin", spawnPoint->GetPhysics()->GetOrigin().ToString() );
	if ( spawnArgs.GetBool( "face_enemy", "0" ) ) {
		idVec3 dir = gameLocal.GetLocalPlayer()->GetPhysics()->GetOrigin() - spawnPoint->GetPhysics()->GetOrigin();
		dir.Normalize();
		args.SetFloat( "angle", dir.ToYaw() );
	} else {
		args.SetFloat( "angle", spawnPoint->GetPhysics()->GetAxis().ToAngles()[ YAW ] );
	}
	args.Set( "classname", temp );	
	args.SetBool( "forceEnemy", spawnArgs.GetBool( "auto_target", "0" ) );
	args.SetInt( "teleport", spawnArgs.GetInt( "teleport", "0" ) );

	// Copy all keywords prefixed with "spawn_" to the entity being spawned.
	CopyPrefixedSpawnArgs( this, "spawn_", args );
	if ( spawnPoint != this ) {
		CopyPrefixedSpawnArgs( spawnPoint, "spawn_", args );
	}

	// Spawn the entity
	if ( !gameLocal.SpawnEntityDef( args, &spawnedEnt ) ) {
		return false;
	}

	// Activate the spawned entity
	spawnedEnt->ProcessEvent( &EV_Activate, this );

	// script function for spawning guys
	//if ( spawnArgs.GetString( "call", "", &temp ) && *temp ) {
	//	gameLocal.CallFrameCommand( this, temp );
	//}

	// script function for the guy being spawned
	//if ( spawnArgs.GetString( "call_spawned", "", &temp ) && *temp ) {
	//	gameLocal.CallFrameCommand( spawnedEnt, temp );
	//}

	// Call all of our callbacks
	//int c;
	//for ( c = callbacks.Num() - 1; c >= 0; c-- ) {
	//	if ( callbacks[ c ].ent ) {
	//		callbacks[ c ].ent->ProcessEvent( idEventDef::FindEvent( callbacks[ c ].event ), this, spawnedEnt );
	//	}
	//}

	// Activate the spawn point entity when an enemy is spawned there and all of its targets
	if ( spawnPoint != this ) {
		spawnPoint->ProcessEvent( &EV_Activate, spawnPoint );
		spawnPoint->ActivateTargets( spawnedEnt );
		
		// One time use on this target?
		if ( spawnPoint->spawnArgs.GetBool( "remove" ) ) {
			spawnPoint->PostEventMS( &EV_Remove, 0 );
		}
	}

	// Increment the total number spawned
	numSpawned++;

	return true;
}
int EnemyManager::SpawnEnemy(){
	if (eobj.size() >= MaxEnemy) 
		return -1;		//例外処理
		
		srand((int)time(NULL));
		GetSpawnPoint(SpawnList[0]);

		int ran;
		if (stageID == Stage1) {
			ran = rand() % 4 + 1;
		}
		else if (stageID == Stage2) {
			ran = rand() % 6 + 1;
		}
//		DebugStringVal("%d", ran, enemyhdc, 100, 40, 20);
		switch (ran) {
		case 1:
		{
			std::unique_ptr<Enemy>obj(new Enemy01(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}
		case 5:
		{
			
			std::unique_ptr<Enemy>obj(new Enemy02(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}
			/*
		case 3:
		{
				  std::unique_ptr<Enemy>obj(new Enemy03(spawnpoint[0], spawnpoint[1]));
				  eobj[i] = std::move(obj);
				  return 1;		}
				  */
		case 6:
		{
			std::unique_ptr<Enemy>obj(new Enemy04(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}

		case 4:
		{
			std::unique_ptr<Enemy>obj(new Enemy05(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}			  
		case 2:
		{
			std::unique_ptr<Enemy>obj(new Enemy06(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}
		case 3:
		{
			std::unique_ptr<Enemy>obj(new Enemy07(spawnpoint[0], spawnpoint[1]));
			obj->EnemyID(SpawnList[0]);
			eobj.push_back(std::move(obj));
			break;
		}

		}//switch
		
		SpawnList.erase(SpawnList.begin());
		return 0;

}