Example #1
0
 public void SetShouldChangeMap(string mapName, string spawnPointName,
                                PlayerCharacter.ChangeMapInformation playerCharacterInformation)
 {
     if (shouldChangeMapName != null)
     {
         return;
     }
     shouldChangeMapName                       = mapName;
     shouldChangeMapSpawnPointName             = spawnPointName;
     shouldChangeMapPlayerCharacterInformation = playerCharacterInformation;
 }
Example #2
0
        void MapChangeRegion_ObjectIn(Entity entity, MapObject obj)
        {
            if (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.SetShouldChangeMap(mapName, spawnPointName,
                                                      playerCharacterInformation);
            }
        }
Example #3
0
        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 )
                {
                    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 )
                    {
                        SpawnPoint spawnPoint = null;
                        if( shouldChangeMapSpawnPointName != null )
                        {
                            spawnPoint = Entities.Instance.GetByName( shouldChangeMapSpawnPointName )
                                as SpawnPoint;
                            if( spawnPoint == null )
                            {
                                Log.Error( "GameWorld: SpawnPoint with name \"{0}\" is not defined.",
                                    shouldChangeMapSpawnPointName );
                            }
                        }

                        Unit unit;
                        if( spawnPoint != null )
                            unit = ServerOrSingle_CreatePlayerUnit( player, spawnPoint );
                        else
                            unit = ServerOrSingle_CreatePlayerUnit( player );

                        if( shouldChangeMapPlayerCharacterInformation != null )
                        {
                            PlayerCharacter playerCharacter = (PlayerCharacter)unit;
                            playerCharacter.ApplyChangeMapInformation(
                                shouldChangeMapPlayerCharacterInformation, spawnPoint );
                        }
                        else
                        {
                            if( unit != null )
                            {
                                intellect.LookDirection = SphereDir.FromVector(
                                    unit.Rotation.GetForward() );
                            }
                        }
                    }
                }
            }

            shouldChangeMapName = null;
            shouldChangeMapSpawnPointName = null;
            shouldChangeMapPlayerCharacterInformation = null;
        }
Example #4
0
        public void SetShouldChangeMap( string mapName, string spawnPointName,
			PlayerCharacter.ChangeMapInformation playerCharacterInformation )
        {
            if( shouldChangeMapName != null )
                return;
            shouldChangeMapName = mapName;
            shouldChangeMapSpawnPointName = spawnPointName;
            shouldChangeMapPlayerCharacterInformation = playerCharacterInformation;
        }
Example #5
0
        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)
                {
                    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)
                    {
                        SpawnPoint spawnPoint = null;
                        if (shouldChangeMapSpawnPointName != null)
                        {
                            spawnPoint = Entities.Instance.GetByName(shouldChangeMapSpawnPointName)
                                         as SpawnPoint;
                            if (spawnPoint == null)
                            {
                                Log.Error("GameWorld: SpawnPoint with name \"{0}\" is not defined.",
                                          shouldChangeMapSpawnPointName);
                            }
                        }

                        Unit unit;
                        if (spawnPoint != null)
                        {
                            unit = ServerOrSingle_CreatePlayerUnit(player, spawnPoint);
                        }
                        else
                        {
                            unit = ServerOrSingle_CreatePlayerUnit(player);
                        }

                        if (shouldChangeMapPlayerCharacterInformation != null)
                        {
                            PlayerCharacter playerCharacter = (PlayerCharacter)unit;
                            playerCharacter.ApplyChangeMapInformation(
                                shouldChangeMapPlayerCharacterInformation, spawnPoint);
                        }
                        else
                        {
                            if (unit != null)
                            {
                                intellect.LookDirection = SphereDir.FromVector(
                                    unit.Rotation.GetForward());
                            }
                        }
                    }
                }
            }

            shouldChangeMapName                       = null;
            shouldChangeMapSpawnPointName             = null;
            shouldChangeMapPlayerCharacterInformation = null;
        }