예제 #1
0
 /// <summary>
 /// Sets special simulation-settings.
 /// </summary>
 /// <param name="settings">special settings</param>
 public void InitSettings(SimulationSettings settings)
 {
     SimulationSettings.SetCustomSettings(settings);
 }
예제 #2
0
 /// <summary>
 /// Sets a custom set of settings.
 /// </summary>
 /// <param name="settings">custom settings</param>
 public static void SetCustomSettings(SimulationSettings settings)
 {
     settings.RuleCheck();
     customSettings = settings;
     initCustom     = true;
 }
예제 #3
0
        /// <summary>
        /// Initialize the simulation-environment.
        /// </summary>
        /// <param name="config">configuration</param>
        public bool Init(SimulatorConfiguration config)
        {
            // Prepare values
            configuration = config;
            SimulationSettings.SetCustomSettings(config.Settings);
            environment = null;

            // Prepare time-counting
            playerTimes   = new Dictionary <PlayerInfo, long>();
            currentPlayer = null;
            currentArea   = Area.Unknown;

            // Load Playerfiles
            foreach (TeamInfo team in configuration.Teams)
            {
                foreach (PlayerInfo spieler in team.Player)
                {
                    if (spieler is PlayerInfoFiledump)
                    {
                        // Try, to load filedump
                        try
                        {
                            spieler.assembly = Assembly.Load(((PlayerInfoFiledump)spieler).File);
                        }
                        catch (Exception ex)
                        {
                            exception = ex;
                            return(false);
                        }
                    }
                    else if (spieler is PlayerInfoFilename)
                    {
                        // Try, to load filename
                        try
                        {
                            spieler.assembly = Assembly.LoadFile(((PlayerInfoFilename)spieler).File);
                        }
                        catch (Exception ex)
                        {
                            exception = ex;
                            return(false);
                        }
                    }
                    else
                    {
                        exception =
                            new InvalidOperationException(
                                Resource.SimulationCoreHostWrongPlayerInfo);
                        return(false);
                    }

                    // Add player to counter-list
                    // TODO: Need another key for times
                    // playerTimes.Add(spieler, 0);
                }
            }

            // Init environment
            try
            {
                environment             = new SimulationEnvironment();
                environment.AreaChange += umgebung_Verantwortungswechsel;
                environment.Init(configuration);
            }
            catch (Exception ex)
            {
                exception = ex;
                return(false);
            }

            // Everything nice...
            return(true);
        }