Exemple #1
0
        private GameManager()
        {
            if (!log4net.LogManager.GetRepository().Configured)
            {
                using (var reader = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.test_logging_config)))
                    log4net.Config.XmlConfigurator.Configure(reader);

                logger.InfoFormat("{0}{0}{1}{0}BEGINS LOG ON GAME MANAGER CREATION{0}{1}{0}{0}", Environment.NewLine, new String('*', 40));
            }

            if (Properties.Settings.Default.UseDefaultTypeRegistry)
            {
                using (var mem_stream = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.TypeRegistry)))
                {
                    var register = TypeRegister.Load(mem_stream);
                    this.RegisterTypeRegister(register, true);
                }
                logger.Info("Initialized TypeRegister with default template");
            }

            switch (Properties.Settings.Default.ScreenToUse)
            {
            case "TextScreen":
                logger.Info("Starting Text Console as IScreen");
                this.RegisterTypeEntry <IScreen, Controls.TextScreen>(new Controls.TextScreen(), true, true);
                break;

            case "GraphicalScreen":
                logger.Info("Starting GraphicalScreen as IScreen");
                this.RegisterTypeEntry <IScreen, Controls.GraphicalScreen>(new Controls.GraphicalScreen(), true, true);
                break;

            default:
                logger.Warn("NO SCREEN SELECTED - using dummy screen");
                this.RegisterTypeEntry <IScreen, DummyScreen>(new DummyScreen(), true, true);
                break;
            }

            logger.Info("GameManager instance created");
        }
Exemple #2
0
        /// <summary>
        /// Registers an entier TypeRegister with the GameManager
        /// </summary>
        /// <param name="registery"></param>
        /// <param name="overwrite_existing_interface_keys"></param>
        public void RegisterTypeRegister(TypeRegister registery, bool overwrite_existing_interface_keys)
        {
            foreach (var entry in registery.Entries.OrderBy(x => x.CreationIndex))
            {
                if (entry.Value.InterfaceType.Equals(typeof(ICharacter)))
                {
                    var inner = this.GetInstance <ISerializableCharacter>();

                    entry.Value.Instance = new Character(inner);
                }
                else if (entry.Value.InterfaceType.Equals(typeof(ISerializableCharacter)))
                {
                    var target = System.IO.Path.ChangeExtension(Properties.Resources.CharacterFileName, SerializableCharacter.CharacterFileExtension);

                    if (System.IO.File.Exists(target))
                    {
                        entry.Value.Instance = SerializableCharacter.Load(target);
                    }
                }

                this.RegisterTypeEntry(entry.Value, overwrite_existing_interface_keys);
            }
        }
Exemple #3
0
 /// <summary>
 /// Load a TypeRegister from a file
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 public static TypeRegister Load(string file)
 {
     using (var reader = new System.IO.StreamReader(file))
         return(TypeRegister.Load(reader.BaseStream));
 }