Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Shared.Stage = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            // instantiate all scenes
            startScene = new StartScene(this, spriteBatch);
            this.Components.Add(startScene);

            actionScene = new ActionScene(this, spriteBatch);
            this.Components.Add(actionScene);

            helpScene = new HelpScene(this, spriteBatch);
            this.Components.Add(helpScene);

            highScoreScene = new HighScoreScene(this, spriteBatch);
            this.Components.Add(highScoreScene);

            aboutScene = new AboutScene(this, spriteBatch);
            this.Components.Add(aboutScene);

            gameOverScene = new GameOverScene(this, spriteBatch);
            this.Components.Add(gameOverScene);

            // show start scene
            startScene.Show();
        }
Ejemplo n.º 2
0
        private bool AddScene(string[] Command)
        {
            //добавляет "сцены"
            bool prevadd = false;

            if (tmpScene.StringsCount != 0) //если в сцене есть строки
            {
                //tmpScene.StringsHeight = tmpScene.StringsCount * SpaceHeight;
                //добавляем предыдущую сцену в список
                Scenes.Add(tmpScene);
                prevadd = true;
            }

            //разбираем команду и создаем следующую сцену
            int   pause_timeout = 0;
            int   draw_timeout  = 0;
            Color back_color    = DefaultBackColor;

            // интервал таймера прорисовки для сцены (меньше - быстрее)
            if (Command.Length >= 2)
            {
                Command[1] = Command[1].Trim();
                if (!string.IsNullOrEmpty(Command[1]))
                {
                    try
                    {
                        draw_timeout = Convert.ToInt32(Command[1]);
                    }
                    catch
                    {
                        ErrorMessage = "Wrong Draw Timeout (ms)";
                        return(false);
                    }
                }
            }

            //пауза в центре "экрана" (ms)
            if (Command.Length >= 3)
            {
                Command[2] = Command[2].Trim();
                if (!string.IsNullOrEmpty(Command[2]))
                {
                    try
                    {
                        pause_timeout = Convert.ToInt32(Command[2]);
                    }
                    catch
                    {
                        ErrorMessage = "Wrong Pause Timeout (ms)";
                        return(false);
                    }
                }
            }

            //цвет фона
            if (Command.Length >= 4)
            {
                if (!FromRGBAString(Command[3], ref back_color))
                {
                    return(false);
                }
            }

            //создаем следующую сцену
            tmpScene = new AboutScene();
            tmpScene.PauseTimeout = pause_timeout; //устанавливаем параметры
            tmpScene.DrawTimeout  = draw_timeout;
            tmpScene.BackColor    = back_color;

            if (prevadd)       //предыдущая сцена была добавлена
            {
                SceneNumber++; //инкреминируем номер для следующей сцены
            }

            return(true);
        }
Ejemplo n.º 3
0
        //тест на правильность скрипта
        //загрузка скрипта и данных
        public bool LoadScript(string drawscript)
        {
            ScriptLoaded = false;
            //обнуляем счетчики для номера сцены и создаем новую
            SceneNumber           = 0;
            tmpScene              = new AboutScene();
            tmpScene.BackColor    = DefaultBackColor; //параметры по умолчанию для 1 сцены
            tmpScene.DrawTimeout  = DefaultDrawTimeout;
            tmpScene.PauseTimeout = 0;

            //проверяем, есть ли скрипт вообще
            if (string.IsNullOrEmpty(drawscript))
            {
                ErrorMessage = "No data";
                return(false);
            }
            string[] buf = drawscript.Split('\n');
            if (buf.Length < 2)
            {
                ErrorMessage = "No data";
                return(false);
            }

            int num = 0;

            foreach (string s in buf)
            {
                num++;
                string Command = s.Trim(); //убираем граничные пробелы
                int    comment = Command.IndexOf("~");
                if (comment != -1)         //убираем комментарии (c тильды)
                {
                    Command = Command.Substring(0, comment);
                }
                Command = Command.Trim(); //убираем граничные пробелы
                //и последнюю точку с запятой, если она есть
                if (Command.EndsWith(";"))
                {
                    Command = Command.Substring(0,
                                                Command.Length - 1);
                }

                Command = Command.Trim(); //опять убираем пробелы
                if (Command == string.Empty)
                {
                    continue;                          //пропускаем пустые строки
                }
                //разбиваем команду на составляющие части
                string[] cmdbuf = Command.Split(';');
                cmdbuf[0] = cmdbuf[0].Trim();
                cmdbuf[0] = cmdbuf[0].ToLowerInvariant();

                switch (cmdbuf[0])
                {
                case "addfont":
                {
                    if (!AddFont(cmdbuf))
                    {
                        ErrorMessage = ErrorMessage + " in string " + num.ToString();
                        return(false);
                    }
                }; break;

                case "addstring":
                {
                    if (!AddString(cmdbuf))
                    {
                        ErrorMessage = ErrorMessage + " in string " + num.ToString();
                        return(false);
                    }
                }; break;

                case "scene":
                {
                    if (!AddScene(cmdbuf))
                    {
                        ErrorMessage = ErrorMessage + " in string " + num.ToString();
                        return(false);
                    }
                }; break;

                default:
                {
                    ErrorMessage = "Unknow command in string " + num;
                    return(false);
                };
                }
            }

            AddScene(new string[] { "scene" }); //добавляем последнюю сцену
            ScriptLoaded = true;
            return(true);
        }