Beispiel #1
0
 /// <summary>
 /// Обработка нажатия на "начать заново"
 /// </summary>
 void retryGame_Click(object sender, EventArgs e)
 {
     player.backpack.Clear();
     if (failed)
     {
         Button resumeGame = new Button(buttonTexture, storage.PullFont("menufont"), "Продолжить");
         menu.Items.Insert(0, resumeGame);
         resumeGame.Click += new EventHandler(resumeGame_Click);
     }
     failed = false;
     player.backpack.Clear();
     PrintAdvice(currentLvl);
 }
Beispiel #2
0
 /// <summary>
 /// Обработка нажатия на "новая игра"
 /// </summary>
 void newGame_Click(object sender, EventArgs e)
 {
     Button resumeGame = new Button(buttonTexture, storage.PullFont("menufont"), "Продолжить");
     Button retryGame = new Button(buttonTexture, storage.PullFont("menufont"), "Начать заново");
     resumeGame.Click += new EventHandler(resumeGame_Click);
     retryGame.Click += new EventHandler(retryGame_Click);
     menu.Items.RemoveAt(0);
     menu.Items.Insert(0, resumeGame);
     menu.Items.Insert(1, retryGame);
     gameState = GameState.Advice;
     currentLvl = 1;
     failed = false;
     player.backpack.Clear();
     PrintAdvice(currentLvl);
 }
Beispiel #3
0
 /// <summary>
 /// Обработка нажатия на "уровень"
 /// </summary>
 void button_Click(object sender, EventArgs e, int num)
 {
     if (menuLvl.IsLvlFinished(num-1))
     {
         player.backpack.Clear();
         if (failed)
         {
             Button resumeGame = new Button(buttonTexture, storage.PullFont("menufont"), "Продолжить");
             menu.Items.Insert(0, resumeGame);
             resumeGame.Click += new EventHandler(resumeGame_Click);
         }
         failed = false;
         currentLvl = num+1;
         player.backpack.Clear();
         PrintAdvice(currentLvl);
         //levelLoader.CreateLevel(currentLvl);
         //gameState = GameState.Game;
     }
 }
Beispiel #4
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);

            // настройка хранилища
            storage.TexturesLoader = Content.Load<Texture2D>;
            storage.FontLoader = Content.Load<SpriteFont>;

            // загрузка всех текстур из заданной папки
            // !!! пока, обязательно указывать CONTENT/
            storage.LoadTexture2DFolder("Content/Textures");
            storage.LoadTexture2DFolder("Content/players");
            storage.LoadTexture2DFolder("Content/advices");
            storage.PushFont("font", Content.Load<SpriteFont>("myFont1"));
            storage.PushFont("menufont", Content.Load<SpriteFont>("menufont"));

            // выбираем все возможные номера уровней
            storage.GetLevelNumbers();

            xmlCoreMissionLoader = Content.Load<XMLCoreMissionLoader>("lvls/tasks/mission_description1");
            foreach (XMLExpressionTarger st in xmlCoreMissionLoader.expressions) {
                toDraw.Add("Key point: " + st.point);
                toDraw.Add("Name: " + st.name + ", EXP: " + st.expression);
            }

            // инициализируем нового игрока
            Rectangle plaerPosition = new Rectangle(120, 120, LevelLoader.SizePeople, LevelLoader.SizePeople);
            player = new Player(storage.Pull2DTexture("player"), storage.Pull2DTexture("player_run"), storage.Pull2DTexture("player_run_goriz"), plaerPosition, this, camera);

            this.levelLoader = new LevelLoader(this, player, storage, camera);

            player.setLinkLevelLoader(levelLoader); // передадим игроку ссылку на загрузчик уровней

            maxLvl = storage.GetMaxLevelNumber();

            // стоит проверять существование уровня
            /*if (storage.IsExist(1))
            {
                levelLoader.CreateLevel(1);
                currentLvl = 1;
            }
            else
                levelLoader.CreateLevel(maxLvl);*/

            menuFont = storage.PullFont("menufont");

            inventory = storage.Pull2DTexture("inventory");
            menuButton = new Button(new Vector2(screenWidth - 40, 0), storage.Pull2DTexture("menu_active"), storage.PullFont("menufont"),new Vector2(0.6f,0.8f), "меню");
            menuButton.Click += new EventHandler(menuButton_Click);
            cursor = new Cursor(storage.Pull2DTexture("cursor"), storage.Pull2DTexture("pointer"));

            buttonTexture = storage.Pull2DTexture("button");
            LoadMenu();
            LoadLvlMenu();
        }
Beispiel #5
0
 /// <summary>
 /// Загрузка главного меню
 /// </summary>
 public void LoadMenu()
 {
     menu.font = menuFont;
     menu.LoadCursor(cursor);
     menu.logo = storage.Pull2DTexture("logo");
     Button exitGame = new Button(buttonTexture, menuFont, "Выход");
     Button newGame = new Button(buttonTexture, menuFont, "Новая игра");
     Button chooseGame = new Button(buttonTexture, menuFont, "Выбрать уровень");
     exitGame.Click += new EventHandler(exitGame_Click);
     newGame.Click += new EventHandler(newGame_Click);
     chooseGame.Click += new EventHandler(chooseGame_Click);
     menu.Items.Add(newGame);
     menu.Items.Add(chooseGame);
     menu.Items.Add(exitGame);
 }
Beispiel #6
0
 /// <summary>
 /// Загрузка меню выбора уровня
 /// </summary>
 public void LoadLvlMenu()
 {
     menuLvl.LoadTextures(storage.Pull2DTexture("open"), storage.Pull2DTexture("close"), menuFont);
     menuLvl.LoadCursor(cursor);
     for (int i = 0; i < 8; i++)
     {
         Button button = new Button(buttonTexture, menuFont, "Уровень " + (i + 1));
         int num = i;
         button.Click += delegate(object sender, EventArgs e) { button_Click(sender, e, num); };
         menuLvl.Items.Add(button);
     }
     //Button next = new Button(buttonTexture, menuFont, "вперед");
     //Button previous = new Button(buttonTexture, menuFont, "назад");
     Button back = new Button(buttonTexture, menuFont, "в меню");
     back.Click += new EventHandler(back_Click);
     //previous.Click += new EventHandler(previous_Click);
     //next.Click += new EventHandler(next_Click);
     //menuLvl.next = next;
     //menuLvl.previous = previous;
     menuLvl.back = back;
 }