Beispiel #1
0
        public void NeedChangeMap( string mapName, string spawnPointName,
			PlayerCharacter.ChangeMapInformation playerCharacterInformation )
        {
            if( needChangeMapName != null )
                return;
            needChangeMapName = mapName;
            needChangeMapSpawnPointName = spawnPointName;
            needChangeMapPlayerCharacterInformation = playerCharacterInformation;
            needChangeMapPreviousMapName = Map.Instance.VirtualFileName;
        }
Beispiel #2
0
        internal void DoActionsAfterMapCreated()
        {
            if (EntitySystemWorld.Instance.IsSingle())
            {
                if (GameMap.Instance.GameType == GameMap.GameTypes.Action ||
                    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)
                            {
                                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;
        }