public void NeedChangeMap(string mapName, string spawnPointName, PlayerCharacter.ChangeMapInformation playerCharacterInformation) { if (needChangeMapName != null) { return; } needChangeMapName = mapName; needChangeMapSpawnPointName = spawnPointName; needChangeMapPlayerCharacterInformation = playerCharacterInformation; needChangeMapPreviousMapName = Map.Instance.VirtualFileName; }
private void MapChangeRegion_ObjectIn(Entity entity, MapObject obj) { if (Enabled && PlayerIntellect.Instance != null && PlayerIntellect.Instance.ControlledObject == obj) { if (EntitySystemWorld.Instance.IsServer()) { Log.Warning("MapChangeRegion: Networking mode is not supported."); return; } PlayerCharacter character = (PlayerCharacter)PlayerIntellect.Instance.ControlledObject; PlayerCharacter.ChangeMapInformation playerCharacterInformation = character.GetChangeMapInformation(this); GameWorld.Instance.NeedChangeMap(mapName, spawnPointName, playerCharacterInformation); } }
private void TransferToAnotherMap(MapObject obj) { if (PlayerIntellect.Instance != null && PlayerIntellect.Instance.ControlledObject == obj) { //change the map and transfer player information to the new map. if (EntitySystemWorld.Instance.IsServer()) { Log.Warning("Teleporter: ChangeMapForPlayer: Networking mode is not supported."); return; } PlayerCharacter character = (PlayerCharacter)PlayerIntellect.Instance.ControlledObject; PlayerCharacter.ChangeMapInformation playerCharacterInformation = character.GetChangeMapInformation(this); GameWorld.Instance.NeedChangeMap(changeMapName, changeMapSpawnObjectName, playerCharacterInformation); } else { //delete object if it is not contolled by the player. obj.SetForDeletion(false); } }
internal void DoActionsAfterMapCreated() { if (EntitySystemWorld.Instance.IsSingle()) { if (GameMap.Instance.GameType == GameMap.GameTypes.Action || GameMap.Instance.GameType == GameMap.GameTypes.TPSArcade || GameMap.Instance.GameType == GameMap.GameTypes.TurretDemo || GameMap.Instance.GameType == GameMap.GameTypes.VillageDemo || GameMap.Instance.GameType == GameMap.GameTypes.PlatformerDemo || GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights) { string playerName = "__SinglePlayer__"; //create Player PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance. ServerOrSingle_GetPlayer(playerName); if (player == null) { player = PlayerManager.Instance.Single_AddSinglePlayer(playerName); } //create PlayerIntellect PlayerIntellect intellect = null; { //find already created PlayerIntellect foreach (Entity entity in World.Instance.Children) { intellect = entity as PlayerIntellect; if (intellect != null) { break; } } if (intellect == null) { intellect = (PlayerIntellect)Entities.Instance.Create("PlayerIntellect", World.Instance); intellect.PostCreate(); player.Intellect = intellect; } //set instance if (PlayerIntellect.Instance == null) { PlayerIntellect.SetInstance(intellect); } } //create unit if (intellect.ControlledObject == null) { MapObject spawnPoint = null; if (!string.IsNullOrEmpty(needChangeMapSpawnPointName)) { spawnPoint = Entities.Instance.GetByName(needChangeMapSpawnPointName) as MapObject; if (spawnPoint == null) { Log.Warning("GameWorld: Object with name \"{0}\" does not exist.", needChangeMapSpawnPointName); } } Unit unit; if (spawnPoint != null) { unit = ServerOrSingle_CreatePlayerUnit(player, spawnPoint); } else { unit = ServerOrSingle_CreatePlayerUnit(player); } if (needChangeMapPlayerCharacterInformation != null) { PlayerCharacter playerCharacter = (PlayerCharacter)unit; playerCharacter.ApplyChangeMapInformation( needChangeMapPlayerCharacterInformation, spawnPoint); } else { if (unit != null) { intellect.LookDirection = SphereDir.FromVector( unit.Rotation.GetForward()); } } } } } needChangeMapName = null; needChangeMapSpawnPointName = null; needChangeMapPlayerCharacterInformation = null; }
public void NeedChangeMap( string mapName, string spawnPointName, PlayerCharacter.ChangeMapInformation playerCharacterInformation ) { if( needChangeMapName != null ) return; needChangeMapName = mapName; needChangeMapSpawnPointName = spawnPointName; needChangeMapPlayerCharacterInformation = playerCharacterInformation; needChangeMapPreviousMapName = Map.Instance.VirtualFileName; }
internal void DoActionsAfterMapCreated() { if( EntitySystemWorld.Instance.IsSingle() ) { if( GameMap.Instance.GameType == GameMap.GameTypes.Action || GameMap.Instance.GameType == GameMap.GameTypes.TPSArcade || GameMap.Instance.GameType == GameMap.GameTypes.TurretDemo || GameMap.Instance.GameType == GameMap.GameTypes.VillageDemo || GameMap.Instance.GameType == GameMap.GameTypes.PlatformerDemo ) { string playerName = "__SinglePlayer__"; //create Player PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance. ServerOrSingle_GetPlayer( playerName ); if( player == null ) player = PlayerManager.Instance.Single_AddSinglePlayer( playerName ); //create PlayerIntellect PlayerIntellect intellect = null; { //find already created PlayerIntellect foreach( Entity entity in World.Instance.Children ) { intellect = entity as PlayerIntellect; if( intellect != null ) break; } if( intellect == null ) { intellect = (PlayerIntellect)Entities.Instance.Create( "PlayerIntellect", World.Instance ); intellect.PostCreate(); player.Intellect = intellect; } //set instance if( PlayerIntellect.Instance == null ) PlayerIntellect.SetInstance( intellect ); } //create unit if( intellect.ControlledObject == null ) { MapObject spawnPoint = null; if( !string.IsNullOrEmpty( needChangeMapSpawnPointName ) ) { spawnPoint = Entities.Instance.GetByName( needChangeMapSpawnPointName ) as MapObject; if( spawnPoint == null ) { if( GameMap.Instance.GameType != GameMap.GameTypes.TPSArcade ) Log.Warning( "GameWorld: Object with name \"{0}\" is not exists.", needChangeMapSpawnPointName ); } } Unit unit; if( spawnPoint != null ) unit = ServerOrSingle_CreatePlayerUnit( player, spawnPoint ); else unit = ServerOrSingle_CreatePlayerUnit( player ); if( needChangeMapPlayerCharacterInformation != null ) { PlayerCharacter playerCharacter = (PlayerCharacter)unit; playerCharacter.ApplyChangeMapInformation( needChangeMapPlayerCharacterInformation, spawnPoint ); } else { if( unit != null ) { intellect.LookDirection = SphereDir.FromVector( unit.Rotation.GetForward() ); } } } } } needChangeMapName = null; needChangeMapSpawnPointName = null; needChangeMapPlayerCharacterInformation = null; }