Example #1
0
 private void Shop_Load(object sender, EventArgs e)
 {
     InitialCostum = new PictureBox
     {
         Name      = Outfit.Initial,
         BackColor = Color.Transparent,
         Image     = LevelsImages.initial4,
         Location  = new Point(150, 100),
         Size      = new Size(230, 230),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     GrandsonCostum = new PictureBox
     {
         Name      = Outfit.GrandSon,
         BackColor = Color.Transparent,
         Image     = LevelsImages.grandson2,
         Location  = new Point(450, 100),
         Size      = new Size(230, 230),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     GentlemanCostum = new PictureBox
     {
         Name      = Outfit.Gentleman,
         BackColor = Color.Transparent,
         Image     = LevelsImages.gentle3,
         Location  = new Point(150, 400),
         Size      = new Size(230, 230),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     BatmanCostum = new PictureBox
     {
         Name      = Outfit.JustBatman,
         BackColor = Color.Transparent,
         Image     = LevelsImages.batman4,
         Location  = new Point(450, 400),
         Size      = new Size(230, 230),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     FancyGuyCostum = new PictureBox
     {
         Name      = Outfit.FancyGuy,
         BackColor = Color.Transparent,
         Image     = LevelsImages.guy5,
         Location  = new Point(300, 700),
         Size      = new Size(230, 230),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     MainCharacter = new PictureBox
     {
         Name      = Program.World.Player.OutfitName,
         BackColor = Color.Transparent,
         Image     = Helpers.OutfitToFileMap[Program.World.Player.OutfitName],
         Location  = new Point(1100, 120),
         Size      = new Size(750, 750),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     Menu = new PictureBox
     {
         Name      = "1",
         BackColor = Color.Transparent,
         Image     = LevelsImages.ShopMenu,
         Location  = new Point(30, 830),
         Size      = new Size(200, 200),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     Money = new PictureBox
     {
         Name      = "2",
         BackColor = Color.Transparent,
         Image     = LevelsImages.money,
         Location  = new Point(1650, 5),
         Size      = new Size(120, 120),
         SizeMode  = PictureBoxSizeMode.Zoom
     };
     MoneyCount = new Label
     {
         BackColor = Color.Transparent,
         Location  = new Point(1780, 37),
         Size      = new Size(150, 150),
         Text      = Program.World.Player.Money.ToString(),
         ForeColor = Color.White,
         FlatStyle = FlatStyle.Flat,
         Font      = new Font("Arial", 20, FontStyle.Bold)
     };
     Condition = new Button
     {
         BackColor = Color.FromArgb(255, 239, 172),
         Location  = new Point(1355, 870),
         Size      = new Size(200, 80),
         Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]],
         ForeColor = Color.Black,
         FlatStyle = FlatStyle.Flat,
         Font      = new Font("Arial", 18, FontStyle.Bold)
     };
     Menu.Click += (sender, args) =>
     {
         string str = JsonConvert.SerializeObject(Program.World.Player);
         File.WriteAllText("./Game.json", str);
         string str2 = JsonConvert.SerializeObject(BigShop);
         File.WriteAllText("./Game2.json", str2);
         var levelMap = new LevelMap(GetLevels, BigShop);
         levelMap.Show();
         Close();
     };
     InitialCostum.Click += (sender, args) =>
     {
         MainCharacter.Name  = Outfit.Initial;
         MainCharacter.Image = Helpers.OutfitToFileMap[Outfit.Initial];
         Condition.Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]];
     };
     GrandsonCostum.Click += (sender, args) =>
     {
         MainCharacter.Name  = Outfit.GrandSon;
         MainCharacter.Image = Helpers.OutfitToFileMap[Outfit.GrandSon];
         Condition.Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]];
     };
     GentlemanCostum.Click += (sender, args) =>
     {
         MainCharacter.Name  = Outfit.Gentleman;
         MainCharacter.Image = Helpers.OutfitToFileMap[Outfit.Gentleman];
         Condition.Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]];
     };
     BatmanCostum.Click += (sender, args) =>
     {
         MainCharacter.Name  = Outfit.JustBatman;
         MainCharacter.Image = Helpers.OutfitToFileMap[Outfit.JustBatman];
         Condition.Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]];
     };
     FancyGuyCostum.Click += (sender, args) =>
     {
         MainCharacter.Name  = Outfit.FancyGuy;
         MainCharacter.Image = Helpers.OutfitToFileMap[Outfit.FancyGuy];
         Condition.Text      = ConditionOutfit[BigShop.StateOfOutfits[MainCharacter.Name]];
     };
     Condition.Click += (sender, args) =>
     {
         if (Condition.Text == "Купить")
         {
             if (Program.World.Player.Money >= BigShop.PriceOfOutfit[MainCharacter.Name])
             {
                 DialogResult result = MessageBox.Show("Вы действительно хотите приобрести данный комплект?", "Подтверждение покупки", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (result == DialogResult.Yes)
                 {
                     BigShop.AfterPurchase(MainCharacter.Name);
                     Program.World.Player.AfterPurchase(MainCharacter.Name, BigShop.PriceOfOutfit[MainCharacter.Name]);
                     Condition.Text  = "Выбрать";
                     MoneyCount.Text = Program.World.Player.Money.ToString();
                     string str = JsonConvert.SerializeObject(Program.World.Player);
                     File.WriteAllText("./Game.json", str);
                     string str2 = JsonConvert.SerializeObject(BigShop);
                     File.WriteAllText("./Game2.json", str2);
                 }
             }
             else
             {
                 MessageBox.Show("Недостаточно монет для покупки", "Мало денег", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             Program.World.Player.OutfitName = MainCharacter.Name;
             Program.World.pictureBox1.Image = Helpers.OutfitToFileMap[MainCharacter.Name];
         }
     };
     Controls.Add(MainCharacter);
     Controls.Add(InitialCostum);
     Controls.Add(GrandsonCostum);
     Controls.Add(GentlemanCostum);
     Controls.Add(BatmanCostum);
     Controls.Add(FancyGuyCostum);
     Controls.Add(Menu);
     Controls.Add(Money);
     Controls.Add(MoneyCount);
     Controls.Add(Condition);
 }
Example #2
0
        public ThiefWorld(Character player)
        {
            var sp = new SoundPlayer();

            sp.Stream = Properties.Resources.didjulja_gorod_velikogo_knjazhestva;
            sp.PlayLooping();
            Program.World         = this;
            this.Player           = player;
            WindowState           = FormWindowState.Maximized;
            BackgroundImage       = Properties.Resources._3;
            Size                  = MaximumSize;
            DoubleBuffered        = true;
            BackgroundImageLayout = ImageLayout.Stretch;
            StartPosition         = FormStartPosition.CenterScreen;
            label                 = new Label()
            {
                Location = new Point(40, 40),
                Text     = "Дорогой друг, не стоило воровать то, в чем ты не разбираешься. Ты украл магический артефакт, наказывающий людей за их злодеяния, " +
                           "перенося в другие миры. Ты попал в свой собственный мир, если попробуешь что-нибудь украсть, то сразу умрешь." +
                           " Единственный способ заработать деньги и выбраться из другого мира - это прохождение уровней. Успехов!",
                ForeColor = Color.Black,
                Font      = new Font("Tahoma", 12),
                Size      = new Size(750, 200),
                TextAlign = ContentAlignment.MiddleCenter,
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 239, 172)
            };

            button = new Button
            {
                Location  = new Point(1641, 40),
                Text      = "Помощь",
                Font      = new Font("Tahoma", 16, FontStyle.Bold),
                Size      = new Size(180, 110),
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 239, 172)
            };

            pictureBox1 = new PictureBox
            {
                BackColor = Color.Transparent,
                Image     = Helpers.OutfitToFileMap[Program.World.Player.OutfitName],
                Location  = new Point(26, 279),
                Size      = new Size(400, 575),
                SizeMode  = PictureBoxSizeMode.Zoom
            };

            button.Click += (sender, args) =>
            {
                var information = new Information();
                information.Show();
            };

            button2 = new Button
            {
                Location  = new Point(1641, 60 + button.Size.Height),
                Text      = "Выйти",
                Font      = button.Font,
                FlatStyle = FlatStyle.Flat,
                Size      = button.Size,
                BackColor = Color.FromArgb(255, 239, 172)
            };
            button3 = new Button
            {
                Location  = new Point(800, 450),
                Text      = "Продолжить игру",
                Font      = new Font("Tahoma", 14, FontStyle.Bold),
                FlatStyle = FlatStyle.Flat,
                Size      = new Size(220, 150),
                BackColor = Color.FromArgb(255, 239, 172)
            };

            button4 = new Button
            {
                Location  = new Point(1040, 450),
                Text      = "Начать заново",
                Font      = new Font("Tahoma", 14, FontStyle.Bold),
                FlatStyle = FlatStyle.Flat,
                Size      = new Size(220, 150),
                BackColor = Color.FromArgb(255, 239, 172)
            };

            button2.Click += (sender, args) =>
            {
                string str = JsonConvert.SerializeObject(Program.World.Player);
                File.WriteAllText("./Game.json", str);
                Close();
            };

            button3.Click += (sender, args) =>
            {
                if (!File.Exists("Game.json"))
                {
                    File.Create("./ Game.json");
                }
                string    str  = File.ReadAllText("./Game.json");
                Character play = JsonConvert.DeserializeObject <Character>(str);
                if (play == null)
                {
                    play = new Character("Leo");
                }
                Program.World.Player = play;
                Program.LevelsGet.Level1.Complete = Program.World.Player.LevelPointsAndComplete[1].Item1;
                Program.LevelsGet.Level2.Complete = Program.World.Player.LevelPointsAndComplete[2].Item1;
                Program.LevelsGet.Level3.Complete = Program.World.Player.LevelPointsAndComplete[3].Item1;
                Program.LevelsGet.Level4.Complete = Program.World.Player.LevelPointsAndComplete[4].Item1;
                Program.LevelsGet.Level5.Complete = Program.World.Player.LevelPointsAndComplete[5].Item1;
                Program.LevelsGet.Level1.ChangePointsAfterDeserealize(Program.World.Player.LevelPointsAndComplete[1].Item2);
                Program.LevelsGet.Level2.ChangePointsAfterDeserealize(Program.World.Player.LevelPointsAndComplete[2].Item2);
                Program.LevelsGet.Level3.ChangePointsAfterDeserealize(Program.World.Player.LevelPointsAndComplete[3].Item2);
                Program.LevelsGet.Level4.ChangePointsAfterDeserealize(Program.World.Player.LevelPointsAndComplete[4].Item2);
                Program.LevelsGet.Level5.ChangePointsAfterDeserealize(Program.World.Player.LevelPointsAndComplete[5].Item2);
                string str1;
                if (!File.Exists("Game2.json"))
                {
                    File.Create("./ Game2.json");
                    str1 = "";
                }
                else
                {
                    str1 = File.ReadAllText("./Game2.json");
                }
                ShopOutfit play1 = JsonConvert.DeserializeObject <ShopOutfit>(str1);
                if (play1 == null)
                {
                    play1 = new ShopOutfit();
                }
                LevelMap newForm = new LevelMap(Program.LevelsGet, play1);
                newForm.Show();
            };
            button4.Click += (sender, args) =>
            {
                File.WriteAllText("./Game.json", "null");
                File.WriteAllText("./Game2.json", "null");
                Program.World.Player = new Character("Leo");
                Program.LevelsGet    = new Levels();
                LevelMap newForm = new LevelMap(Program.LevelsGet, new ShopOutfit());
                newForm.Show();
            };

            Load += (sender, args) => OnSizeChanged(EventArgs.Empty);
            Controls.Add(button);
            Controls.Add(button2);
            Controls.Add(button3);
            Controls.Add(button4);
            Controls.Add(label);
            Controls.Add(pictureBox1);
        }
Example #3
0
        public Sublevel(Level level, ShopOutfit shop)
        {
            Difficalty            = 1;
            Load                 += (sender, args) => StartTimer();
            WindowState           = FormWindowState.Maximized;
            BackgroundImage       = Properties.Resources.Level_Background;
            Size                  = MaximumSize;
            DoubleBuffered        = true;
            BackgroundImageLayout = ImageLayout.Stretch;
            StartPosition         = FormStartPosition.CenterScreen;
            button3.Enabled       = false;
            button4.Enabled       = false;
            var labelCentr = new Label
            {
                Location  = new Point(1040, 300),
                Size      = new Size(700, 50),
                Text      = "Выберите уровень сложности:",
                FlatStyle = FlatStyle.Flat,
                Font      = new Font("Tahoma", 14, FontStyle.Bold),
                BackColor = Color.Transparent
            };
            var buttonCentr1 = new Button
            {
                Location  = new Point(1150, 400),
                Size      = new Size(170, 80),
                Text      = "Легко",
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.Transparent,
                Font      = new Font("Tahoma", 14, FontStyle.Bold)
            };

            buttonCentr1.Click += (sender, args) =>
            {
                button3.Enabled = false;
                button4.Enabled = false;
                Difficalty      = 1;
                Clear();
            };
            var buttonCentr2 = new Button
            {
                Location  = new Point(1150, 500),
                Size      = buttonCentr1.Size,
                Text      = "Средне",
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.Transparent,
                Font      = new Font("Tahoma", 14, FontStyle.Bold)
            };

            buttonCentr2.Click += (sender, args) =>
            {
                button3.Enabled = false;
                button4.Enabled = false;
                Difficalty      = 2;
                Clear();
            };
            var buttonCentr3 = new Button
            {
                Location  = new Point(1150, 600),
                Size      = buttonCentr1.Size,
                Text      = "Сложно",
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.Transparent,
                Font      = new Font("Tahoma", 14, FontStyle.Bold)
            };

            buttonCentr3.Click += (sender, args) =>
            {
                button3.Enabled = false;
                button4.Enabled = false;
                Difficalty      = 3;
                Clear();
            };
            var labelCentr2 = new Label
            {
                Location  = new Point(1050, 750),
                Size      = new Size(700, 50),
                Text      = @"И нажмите на кнопку ""Примеры""",
                FlatStyle = FlatStyle.Flat,
                Font      = new Font("Tahoma", 14, FontStyle.Bold),
                BackColor = Color.Transparent
            };

            Controls.Add(buttonCentr2);
            Controls.Add(labelCentr);
            Controls.Add(labelCentr2);
            Controls.Add(buttonCentr3);
            Controls.Add(buttonCentr1);
            extraButtons.Add(buttonCentr1);
            extraButtons.Add(buttonCentr2);
            extraButtons.Add(buttonCentr3);
            extraLabels.Add(labelCentr);
            extraLabels.Add(labelCentr2);

            var button = new Button
            {
                Location  = new Point(40, 40),
                Text      = "Выйти",
                Font      = new Font("Tahoma", 16, FontStyle.Bold),
                Size      = new Size(180, 110),
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 255, 192)
            };

            button.Click += (sender, args) =>
            {
                Level.ChangePoints();
                Program.World.Player.ChangePointsAndCompleteLevel(Level.LevelNumber, Level.Points);
                Program.World.Player.AfterSublevel(Level.Points);
                Level.ChangeConditionOfLevel();
                switch (Level.LevelNumber)
                {
                case 1:
                    Program.LevelsGet.Level1.ChangeConditionAndPointsOfLevel(Level.Points);
                    break;

                case 2:
                    Program.LevelsGet.Level2.ChangeConditionAndPointsOfLevel(Level.Points);
                    break;

                case 3:
                    Program.LevelsGet.Level3.ChangeConditionAndPointsOfLevel(Level.Points);
                    break;

                case 4:
                    Program.LevelsGet.Level4.ChangeConditionAndPointsOfLevel(Level.Points);
                    break;

                case 5:
                    Program.LevelsGet.Level5.ChangeConditionAndPointsOfLevel(Level.Points);
                    break;
                }
                string str = JsonConvert.SerializeObject(Program.World.Player);
                File.WriteAllText("./Game.json", str);
                var newForm = new LevelMap(Program.LevelsGet, shop);
                newForm.Show();
                Close();
            };

            var button22 = new Button
            {
                Location  = new Point(40, 220),
                Text      = "Примеры",
                Font      = new Font("Tahoma", 16, FontStyle.Bold),
                Size      = new Size(390, 120),
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 255, 192)
            };

            Level = level;
            var mathExamples = Level.MathExamples;
            var sequences    = Level.Sequences;
            var issue        = Level.Issue;

            button22.Click += (sender, args) =>
            {
                button22.Enabled = false;
                button3.Enabled  = false;
                button4.Enabled  = false;
                Clear();
                GetEx(0, Difficalty - 1, true);
            };

            button3 = new Button
            {
                Location  = new Point(40, 380),
                Text      = "Последовательность",
                Font      = new Font("Tahoma", 16, FontStyle.Bold),
                Size      = new Size(390, 120),
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 255, 192)
            };
            button3.Click += (sender, args) =>
            {
                button3.Enabled  = false;
                button22.Enabled = false;
                button4.Enabled  = false;
                Clear();
                GetIs(0);
            };

            button4 = new Button
            {
                Location  = new Point(40, 540),
                Text      = "Загадка",
                Font      = new Font("Tahoma", 16, FontStyle.Bold),
                Size      = new Size(390, 120),
                FlatStyle = FlatStyle.Flat,
                BackColor = Color.FromArgb(255, 255, 192)
            };
            button4.Click += (sender, args) =>
            {
                button4.Enabled  = false;
                button22.Enabled = false;
                button3.Enabled  = false;
                Clear();
                var needIssue = issue.GetIssue();
                var label     = new Label
                {
                    Location  = new Point(ClientSize.Width / 2 - 155, 300),
                    Size      = new Size(900, 200),
                    Text      = "Отгадайте загадку: " + needIssue.Item1,
                    FlatStyle = FlatStyle.Flat,
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font("Tahoma", 10, FontStyle.Bold),
                    BackColor = Color.Transparent
                };
                var box = new TextBox
                {
                    Location  = new Point(ClientSize.Width / 2 + 340, 600),
                    Size      = new Size(180, 300),
                    BackColor = Color.White,
                    Font      = new Font("Tahoma", 12, FontStyle.Bold)
                };
                var button2 = new Button
                {
                    Location  = new Point(ClientSize.Width / 2 + 550, 600),
                    Size      = new Size(130, 60),
                    Text      = "Ответить",
                    FlatStyle = FlatStyle.Flat,
                    BackColor = Color.Transparent,
                    Font      = new Font("Tahoma", 10, FontStyle.Bold)
                };
                button2.Click += (sender, args) =>
                {
                    var answer = box.Text;
                    box.Enabled     = false;
                    box.Text        = ToRussian[Level.Issue.CompareResult(needIssue.Item1, answer)];
                    button2.Enabled = false;
                };
                Controls.Add(button2);
                Controls.Add(label);
                Controls.Add(box);
                extraButtons.Add(button2);
                extraLabels.Add(label);
                extraBox.Add(box);
            };
            label1 = new Label
            {
                Location  = new Point(1100, 60),
                Font      = new Font("Tahoma", 18, FontStyle.Bold),
                Size      = new Size(290, 100),
                FlatStyle = FlatStyle.Flat,
                Padding   = new Padding(60, 35, 5, 5),
                BackColor = Color.FromArgb(255, 255, 192)
            };


            Controls.Add(label1);
            Controls.Add(button);
            Controls.Add(button22);
            Controls.Add(button3);
            Controls.Add(button4);
        }