Пример #1
0
        /// <summary>Creates a new Hovertank game.</summary>
        /// <param name="sys">The system.</param>
        public Hovertank(Sys sys)
        {
            _sfxPlayer = sys.SfxPlayer;
            _display = new Display();
            _picCache = new PicCache(NUMCHUNKS);

            _sys = sys;

            // as: string replacements
            _strings = sys.Strings;
            _strings.Initialise(this);

            // If the config file GAME.HOV exists use it for game modifications
            string modFileName = "GAME." + EXTENSION;
            if(sys.FileExists(modFileName))
            {
                Config config = new Config(Encoding.ASCII);
                config.Read(new MemoryStream(sys.FileReadAllBytes(modFileName)));

                if(string.CompareOrdinal(config.ID, "Hovertank3D.Game") == 0)
                {
                    // as: string replacements
                    for(int i = 0; i < Strings.Identifiers.Length; i++)
                    {
                        string identifier = Strings.Identifiers[i];
                        string replacementText = config.GetString(identifier, null);
                        if(replacementText != null)
                            _strings[i] = replacementText;
                   }

                    // Level time limits
                    for(int i = 0; i < 20; i++)
                    {
                        levmin[i] = (short) config.GetInt32("levmin" + i, 0, 9, levmin[i]);
                        levsec[i] = (short) config.GetInt32("levsec" + i, 0, 59, levsec[i]);
                    }

                    // Warp colors
                    for(int i = 0; i < cyclecolors.Length; i++)
                        cyclecolors[i] = (short) config.GetInt32("cyclecolors" + i, 0, 15, cyclecolors[i]);

                    barColor = (byte) config.GetInt32("barColor", 0, 15, 15);
                }
                else
                {
                    _sys.Log("Unexpected configuration id '" + config.ID + "'!");
                }
            }

            HovDrawInitialise();
            HovLoopInitialise();
        }
Пример #2
0
        /// <summary>Initialises the SfxPlayer.</summary>
        /// <param name="sys">The system.</param>
        /// <param name="soundSystem">The sound system.</param>
        public void Initialise(Sys sys, SoundSystem soundSystem)
        {
            _sys = sys;
            _soundSystem = soundSystem;
            try { _soundSystem.Initialise(); }
            catch(Exception ex)
            {
                _sys.Log("SoundSystem failed to initialise: " + ex.Message);

                // Try to continue with no sound
                _soundSystem = new NullSoundSystem();
                _soundSystem.Initialise();
            }

            SoundSystem.Sound introSound = CreateIntroSound();

            _sampledSounds.Add(introSound);
            _speakerSounds.Add(introSound);
        }