Example #1
0
        public static void RoomActivate(Game.Hero hero1, Game.Hero hero2, Game.Hero hero3)
        {
            Labirint.CELL currentCell = Location;
            switch (Location.Room_type)
            {
            case RoomType.None:
                break;

            case RoomType.Trap:
                Trap.Trap_room_activate(currentCell, hero1, hero2, hero3);
                break;

            case RoomType.Enemy:
                Enemy.Enemy_room_activate(currentCell, hero1, hero2, hero3);
                break;

            case RoomType.Treasure:
                Treasure.Treasure_room_activate(currentCell, hero1, hero2, hero3);
                break;

            default:
                break;
            }
        }
Example #2
0
        public static void Enemy_room_activate(Labirint.CELL currentCell, Game.Hero hero1, Game.Hero hero2, Game.Hero hero3)
        {
            World.labir[currentCell.x, currentCell.y].Room_type = RoomType.None;
            Program.win_enemy = new RenderWindow(new VideoMode((Tile.Tile_Size + 16) * World.World_Size, Tile.Tile_Size * World.World_Size), "Enemy", Styles.None);
            Program.win_enemy.SetVerticalSyncEnabled(true);
            Program.win_enemy.Closed  += Program.Win_enemy_Closed;
            Program.win_enemy.Resized += Program.Win_enemy_Resized;
            Surface     surface     = new Surface(720, 480, Type_of_surface.Svitok_720_480);/// 720.480
            List <Hero> Enemy_squad = new List <Hero>();
            List <Hero> Hero_squad  = new List <Hero>
            {
                hero1, hero2, hero3
            };
            int  random_enemy_squad = randomize_of_room.Next(0, 6);
            Hero skeleton1, skeleton2, skeleton3, Warlock, Golem1, Golem2;
            Text Hp_bar_enemy_1 = new Text("", Content.font, 20);
            Text Hp_bar_enemy_2 = new Text("", Content.font, 20);
            Text Hp_bar_enemy_3 = new Text("", Content.font, 20);

            switch (random_enemy_squad)
            {
            case 0:
                skeleton1 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(360, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(skeleton1.hp), Content.font, 20)
                {
                    Position = new Vector2f(360, 90)
                };
                Enemy_squad.Add(skeleton1);
                break;

            case 1:
                skeleton1 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(240, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(skeleton1.hp), Content.font, 20)
                {
                    Position = new Vector2f(240, 90)
                };
                skeleton2 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(480, 100)
                };
                Hp_bar_enemy_2 = new Text(Convert.ToString(skeleton2.hp), Content.font, 20)
                {
                    Position = new Vector2f(480, 90)
                };
                Enemy_squad.Add(skeleton1);
                Enemy_squad.Add(skeleton2);
                break;

            case 2:
                skeleton1 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(180, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(skeleton1.hp), Content.font, 20)
                {
                    Position = new Vector2f(180, 90)
                };
                skeleton2 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(360, 100)
                };
                Hp_bar_enemy_2 = new Text(Convert.ToString(skeleton2.hp), Content.font, 20)
                {
                    Position = new Vector2f(360, 90)
                };
                skeleton3 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(540, 100)
                };
                Hp_bar_enemy_3 = new Text(Convert.ToString(skeleton3.hp), Content.font, 20)
                {
                    Position = new Vector2f(540, 90)
                };
                Enemy_squad.Add(skeleton1);
                Enemy_squad.Add(skeleton2);
                Enemy_squad.Add(skeleton3);
                break;

            case 3:
                skeleton1 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(180, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(skeleton1.hp), Content.font, 20)
                {
                    Position = new Vector2f(180, 90)
                };
                skeleton2 = new Hero(Hero_class_enum.Skeleton)
                {
                    Position = new Vector2f(540, 100)
                };
                Hp_bar_enemy_2 = new Text(Convert.ToString(skeleton2.hp), Content.font, 20)
                {
                    Position = new Vector2f(540, 90)
                };
                Warlock = new Hero(Hero_class_enum.Warlock)
                {
                    Position = new Vector2f(360, 100)
                };
                Hp_bar_enemy_3 = new Text(Convert.ToString(Warlock.hp), Content.font, 20)
                {
                    Position = new Vector2f(360, 85)
                };
                Enemy_squad.Add(skeleton1);
                Enemy_squad.Add(skeleton2);
                Enemy_squad.Add(Warlock);
                break;

            case 4:
                Golem1 = new Hero(Hero_class_enum.Golem)
                {
                    Position = new Vector2f(360, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(Golem1.hp), Content.font, 20)
                {
                    Position = new Vector2f(360, 90)
                };
                Enemy_squad.Add(Golem1);
                break;

            case 5:
                Golem1 = new Hero(Hero_class_enum.Golem)
                {
                    Position = new Vector2f(240, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(Golem1.hp), Content.font, 20)
                {
                    Position = new Vector2f(240, 90)
                };
                Golem2 = new Hero(Hero_class_enum.Golem)
                {
                    Position = new Vector2f(480, 100)
                };
                Hp_bar_enemy_2 = new Text(Convert.ToString(Golem2.hp), Content.font, 20)
                {
                    Position = new Vector2f(480, 90)
                };
                Enemy_squad.Add(Golem1);
                Enemy_squad.Add(Golem2);
                break;

            case 6:
                Golem1 = new Hero(Hero_class_enum.Golem)
                {
                    Position = new Vector2f(240, 100)
                };
                Hp_bar_enemy_1 = new Text(Convert.ToString(Golem1.hp), Content.font, 20)
                {
                    Position = new Vector2f(240, 90)
                };
                Warlock = new Hero(Hero_class_enum.Warlock)
                {
                    Position = new Vector2f(480, 100)
                };
                Hp_bar_enemy_2 = new Text(Convert.ToString(Warlock.hp), Content.font, 20)
                {
                    Position = new Vector2f(480, 85)
                };
                Enemy_squad.Add(Golem1);
                Enemy_squad.Add(Warlock);
                break;

            default:
                break;
            }
            Surface Sword = new Surface(100, 100, Type_of_surface.Sword)
            {
                Position = new SFML.System.Vector2f(360, 300)
            };
            Surface FireBall = new Surface(100, 100, Type_of_surface.FireBall)
            {
                Position = new SFML.System.Vector2f(180, 300)
            };
            Surface HoliLight = new Surface(100, 100, Type_of_surface.HoliLight)
            {
                Position = new SFML.System.Vector2f(540, 300)
            };
            bool war_atack    = false;
            bool priest_atack = false;
            bool rogue_atack  = false;

            while (Program.win_enemy.IsOpen)
            {
                Program.win_enemy.DispatchEvents();
                Program.win_enemy.Clear(Color.Black);
                Program.win_enemy.Draw(surface);
                Program.win_enemy.Draw(Sword);
                Program.win_enemy.Draw(HoliLight);
                Program.win_enemy.Draw(FireBall);
                foreach (Hero item in Enemy_squad)
                {
                    Program.win_enemy.Draw(item);
                    Text text = new Text(Convert.ToString(item.hp), Content.font, 20)
                    {
                        Position = new Vector2f(item.Position.X, item.Position.Y - 10)
                    };
                    Program.win_enemy.Draw(text);
                }

                for (int i = 0; i < Hero_squad.Count; i++)
                {
                    Text text = new Text(Convert.ToString(Hero_squad[i].hp), Content.font, 20)
                    {
                        Position = new Vector2f(i * 160 + 250, 290)
                    };
                    Program.win_enemy.Draw(text);
                }
                var mousePosition = Mouse.GetPosition(Program.win_enemy);
                if ((mousePosition.X > Sword.Position.X) && (mousePosition.Y > Sword.Position.Y) && (mousePosition.X < Sword.Position.X + 100) && (mousePosition.Y < Sword.Position.Y + 100) && (!priest_atack))
                {
                    if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                    {
                        war_atack    = true;
                        priest_atack = false;
                        rogue_atack  = false;
                    }
                }
                if ((mousePosition.X > FireBall.Position.X) && (mousePosition.Y > FireBall.Position.Y) && (mousePosition.X < FireBall.Position.X + 100) && (mousePosition.Y < FireBall.Position.Y + 100) && (!priest_atack))
                {
                    if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                    {
                        rogue_atack  = true;
                        war_atack    = false;
                        priest_atack = false;
                    }
                }
                if ((mousePosition.X > HoliLight.Position.X) && (mousePosition.Y > HoliLight.Position.Y) && (mousePosition.X < HoliLight.Position.X + 100) && (mousePosition.Y < HoliLight.Position.Y + 100))
                {
                    if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                    {
                        priest_atack = true;
                        war_atack    = false;
                        rogue_atack  = false;
                    }
                }
                if (Enemy_squad.Count != 0)
                {
                    for (int i = 0; i < Enemy_squad.Count; i++)
                    {
                        if ((war_atack) && (mousePosition.X > Enemy_squad[i].Position.X) && (mousePosition.Y > Enemy_squad[i].Position.Y) && (mousePosition.X < Enemy_squad[i].Position.X + 100) && (mousePosition.Y < Enemy_squad[i].Position.Y + 100))
                        {
                            if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                            {
                                Enemy_squad[i].hp -= 30;
                                hero2.hp          -= 10;
                                Console.WriteLine(Enemy_squad[i].hp);
                                if (Enemy_squad[i].hp <= 0)
                                {
                                    Enemy_squad.Remove(Enemy_squad[i]);
                                }
                                war_atack = false;
                            }
                        }
                        if ((rogue_atack) && (mousePosition.X > Enemy_squad[i].Position.X) && (mousePosition.Y > Enemy_squad[i].Position.Y) && (mousePosition.X < Enemy_squad[i].Position.X + 100) && (mousePosition.Y < Enemy_squad[i].Position.Y + 100))
                        {
                            if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                            {
                                Enemy_squad[i].hp -= 30;
                                Console.WriteLine(Enemy_squad[i].hp);
                                hero1.hp -= 20;
                                if (Enemy_squad[i].hp <= 0)
                                {
                                    Enemy_squad.Remove(Enemy_squad[i]);
                                }
                                rogue_atack = false;
                            }
                        }
                        if (priest_atack)
                        {
                            if ((mousePosition.X > Enemy_squad[i].Position.X) && (mousePosition.Y > Enemy_squad[i].Position.Y) && (mousePosition.X < Enemy_squad[i].Position.X + 100) && (mousePosition.Y < Enemy_squad[i].Position.Y + 100))
                            {
                                if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                                {
                                    Enemy_squad[i].hp -= 30;
                                    Console.WriteLine(Enemy_squad[i].hp);
                                    hero3.hp -= 20;
                                    if (Enemy_squad[i].hp <= 0)
                                    {
                                        Enemy_squad.Remove(Enemy_squad[i]);
                                    }
                                    priest_atack = false;
                                    war_atack    = false;
                                    rogue_atack  = false;
                                }
                            }
                            if ((mousePosition.X > Sword.Position.X) && (mousePosition.Y > Sword.Position.Y) && (mousePosition.X < Sword.Position.X + 100) && (mousePosition.Y < Sword.Position.Y + 100))
                            {
                                if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                                {
                                    hero2.hp += 30;
                                    if (hero2.hp > hero2.max_hp)
                                    {
                                        hero2.hp = hero2.max_hp;
                                    }
                                    priest_atack = false;
                                    war_atack    = false;
                                    rogue_atack  = false;
                                }
                            }
                            if ((mousePosition.X > HoliLight.Position.X) && (mousePosition.Y > HoliLight.Position.Y) && (mousePosition.X < HoliLight.Position.X + 100) && (mousePosition.Y < HoliLight.Position.Y + 100))
                            {
                                if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                                {
                                    hero3.hp += 30;
                                    if (hero3.hp > hero3.max_hp)
                                    {
                                        hero3.hp = hero3.max_hp;
                                    }
                                    war_atack   = false;
                                    rogue_atack = false;
                                }
                            }
                            if ((mousePosition.X > FireBall.Position.X) && (mousePosition.Y > FireBall.Position.Y) && (mousePosition.X < FireBall.Position.X + 100) && (mousePosition.Y < FireBall.Position.Y + 100))
                            {
                                if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                                {
                                    hero1.hp += 30;
                                    if (hero1.hp > hero1.max_hp)
                                    {
                                        hero1.hp = hero1.max_hp;
                                    }
                                    priest_atack = false;
                                    war_atack    = false;
                                    rogue_atack  = false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Program.win_enemy.Close();
                    Squad.Location.Room_type = RoomType.None;
                }
                if ((hero1.hp < 0) || (hero2.hp < 0) || (hero3.hp < 0))
                {
                    Program.win_end_game = new RenderWindow(new VideoMode((Tile.Tile_Size + 16) * World.World_Size, Tile.Tile_Size * World.World_Size), "endgame", Styles.None);
                    Program.win_end_game.SetVerticalSyncEnabled(true);
                    Surface game_over = new Surface(720, 480, Type_of_surface.Game_over);
                    while (Program.win_end_game.IsOpen)
                    {
                        Program.win_end_game.DispatchEvents();
                        Program.win_end_game.Clear();
                        Program.win_end_game.Draw(game_over);
                        if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                        {
                            Program.win_end_game.Close();
                            Program.win.Close();
                        }
                        Program.win_end_game.Display();
                    }
                }
                Console.WriteLine(priest_atack + "priest");
                Console.WriteLine(rogue_atack + "rogue");
                Console.WriteLine(war_atack + "war");
                Program.win_enemy.Display();
            }
        }
Example #3
0
        public static void Treasure_room_activate(Labirint.CELL currentCell, Game.Hero hero1, Game.Hero hero2, Game.Hero hero3)
        {
            Surface surface = new Surface(720, 480, Type_of_surface.Svitok_720_480);

            World.labir[currentCell.x, currentCell.y].Room_type = RoomType.None;
            Program.win_treasure = new RenderWindow(new VideoMode((Tile.Tile_Size + 16) * World.World_Size, Tile.Tile_Size * World.World_Size), "treasure", Styles.None);
            Program.win_treasure.SetVerticalSyncEnabled(true);
            Tile[] tiles;
            tiles = new Tile[5];
            Tile[,] tiles_2;
            tiles_2 = new Tile[5, 2];
            Text opend_treasure_alert = new Text("В комнате стоит открытый сундук!", Content.font, 20)
            {
                Position = new SFML.System.Vector2f(100, 150)
            };

            Surface chest = new Surface(100, 100, Type_of_surface.Chest)
            {
                Position = new SFML.System.Vector2f(100, 50)
            };
            Surface button = new Surface(100, 60, Type_of_surface.Open_Button)
            {
                Position = new SFML.System.Vector2f(300, 300)
            };
            int random_treasure = randomize_of_room.Next(3);

            int[] first_matrix       = new int[5];      //это те самые кнопочки для сундука
            int[] first_check_matrix = new int[5];      //зеленый цвет программа не читает
            int[,] second_matrix       = new int[5, 2]; /*называется коментарий кода
                                                         * он может быть двухэтажным
                                                         * трехэтажным и
                                                         * м
                                                         * н
                                                         * о
                                                         * го
                                                         * э
                                                         * т
                                                         * а
                                                         * ж
                                                         * н
                                                         * ы
                                                         * м
                                                         * )))
                                                         * лагаешь
                                                         */
            int[,] second_check_matrix = new int[5, 2];

            for (int i = 0; i < 5; i++)
            {
                first_check_matrix[i] = binary_random.Next(2);
                first_matrix[i]       = 0;
                tiles[i] = new Tile(TileType.treasure_0)
                {
                    Position = new SFML.System.Vector2f(i * Tile.Tile_Size + 260, 200)
                };
            }
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    second_check_matrix[i, j] = binary_random.Next(2);
                    second_matrix[i, j]       = 0;
                    tiles_2[i, j]             = new Tile(TileType.treasure_0)
                    {
                        Position = new SFML.System.Vector2f(i * Tile.Tile_Size + 260, j * Tile.Tile_Size + 200)
                    };
                }
            }
            //int random_stat = randomize_of_stat.Next(5);
            Text alert = new Text("", Content.font, 20)
            {
                Position = new SFML.System.Vector2f(100, 140)
            };;

            Vector2f vextor = new Vector2f(100, 170);

            switch (random_treasure)
            {
            case 0:
                type_of_treasure = Treasure_type.opened;
                int random_stat = randomize_of_stat.Next(5);

                switch (random_stat)
                {
                case 0:
                    hero1.constitution += 1;
                    hero2.constitution += 1;
                    hero3.constitution += 1;
                    alert = new Text("в сундуке лежит свиток повышающий конституцию отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 1:
                    hero1.dexterity += 1;
                    hero2.dexterity += 1;
                    hero3.dexterity += 1;
                    alert            = new Text("в сундуке лежит свиток повышающий ловкость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };

                    break;

                case 2:
                    hero1.intelligece += 1;
                    hero2.intelligece += 1;
                    hero3.intelligece += 1;
                    alert              = new Text("в сундуке лежит свиток повышающий интеллект отряда", Content.font, 20)
                    {
                        Position = vextor
                    };

                    break;

                case 3:
                    hero1.strength += 1;
                    hero2.strength += 1;
                    hero3.strength += 1;
                    alert           = new Text("в сундуке лежит свиток повышающий силу отряда", Content.font, 20)
                    {
                        Position = vextor
                    };

                    break;

                case 4:
                    hero1.wisdom += 1;
                    hero2.wisdom += 1;
                    hero3.wisdom += 1;
                    alert         = new Text("в сундуке лежит свиток повышающий мудрость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };

                    break;

                default:
                    break;
                }
                hero1.hp += 3;
                if (hero1.hp > hero1.max_hp)
                {
                    hero1.hp = hero1.max_hp;
                }
                hero2.hp += 3;
                if (hero2.hp > hero2.max_hp)
                {
                    hero2.hp = hero2.max_hp;
                }
                hero3.hp += 3;
                if (hero3.hp > hero3.max_hp)
                {
                    hero3.hp = hero3.max_hp;
                }
                break;

            case 1:
                int random_stat_2 = randomize_of_stat.Next(5);
                switch (random_stat_2)
                {
                case 0:
                    hero1.constitution += 1;
                    hero2.constitution += 1;
                    hero3.constitution += 1;
                    alert = new Text("в сундуке лежит свиток повышающий конституцию отряда", Content.font, 20)
                    {
                        Position = vextor
                    };

                    break;

                case 1:
                    hero1.dexterity += 1;
                    hero2.dexterity += 1;
                    hero3.dexterity += 1;
                    alert            = new Text("в сундуке лежит свиток повышающий ловкость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 2:
                    hero1.intelligece += 1;
                    hero2.intelligece += 1;
                    hero3.intelligece += 1;
                    alert              = new Text("в сундуке лежит свиток повышающий интеллект отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 3:
                    hero1.strength += 1;
                    hero2.strength += 1;
                    hero3.strength += 1;
                    alert           = new Text("в сундуке лежит свиток повышающий силу отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 4:
                    hero1.wisdom += 1;
                    hero2.wisdom += 1;
                    hero3.wisdom += 1;
                    alert         = new Text("в сундуке лежит свиток повышающий мудрость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                default:
                    break;
                }
                type_of_treasure = Treasure_type.first;
                hero1.hp        += 3;
                if (hero1.hp > hero1.max_hp)
                {
                    hero1.hp = hero1.max_hp;
                }
                hero2.hp += 3;
                if (hero2.hp > hero2.max_hp)
                {
                    hero2.hp = hero2.max_hp;
                }
                hero3.hp += 3;
                if (hero3.hp > hero3.max_hp)
                {
                    hero3.hp = hero3.max_hp;
                }
                break;

            case 2:
                int random_stat_3 = randomize_of_stat.Next(5);
                switch (random_stat_3)
                {
                case 0:
                    hero1.constitution += 1;
                    hero2.constitution += 1;
                    hero3.constitution += 1;
                    alert = new Text("в сундуке лежит свиток повышающий конституцию отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 1:
                    hero1.dexterity += 1;
                    hero2.dexterity += 1;
                    hero3.dexterity += 1;
                    alert            = new Text("в сундуке лежит свиток повышающий ловкость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 2:
                    hero1.intelligece += 1;
                    hero2.intelligece += 1;
                    hero3.intelligece += 1;
                    alert              = new Text("в сундуке лежит свиток повышающий интеллект отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 3:
                    hero1.strength += 1;
                    hero2.strength += 1;
                    hero3.strength += 1;
                    alert           = new Text("в сундуке лежит свиток повышающий силу отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                case 4:
                    hero1.wisdom += 1;
                    hero2.wisdom += 1;
                    hero3.wisdom += 1;
                    alert         = new Text("в сундуке лежит свиток повышающий мудрость отряда", Content.font, 20)
                    {
                        Position = vextor
                    };
                    break;

                default:
                    break;
                }
                type_of_treasure = Treasure_type.second;
                hero1.hp        += 3;
                if (hero1.hp > hero1.max_hp)
                {
                    hero1.hp = hero1.max_hp;
                }
                hero2.hp += 3;
                if (hero2.hp > hero2.max_hp)
                {
                    hero2.hp = hero2.max_hp;
                }
                hero3.hp += 3;
                if (hero3.hp > hero3.max_hp)
                {
                    hero3.hp = hero3.max_hp;
                }
                break;

            default:
                break;
            }
            while (Program.win_treasure.IsOpen)
            {
                Program.win_treasure.DispatchEvents();
                Program.win_treasure.Clear(Color.Black);
                Program.win_treasure.Draw(surface);
                Program.win_treasure.Draw(alert);

                var mousePosition = Mouse.GetPosition(Program.win_treasure);
                if (type_of_treasure == Treasure_type.opened)
                {
                    Program.win_treasure.Draw(chest);
                    Program.win_treasure.Draw(opend_treasure_alert);
                    Program.win_treasure.Draw(button);
                    if ((mousePosition.X > button.Position.X) && (mousePosition.Y > button.Position.Y) && (mousePosition.X < 400) && (mousePosition.Y < 360))
                    {
                        button.rectShape.FillColor = Color.Red;
                        if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                        {
                            Program.win_treasure.Close();
                            Squad.Location.Room_type = RoomType.None;
                        }
                    }
                    else
                    {
                        button.rectShape.FillColor = Color.White;
                    }
                }
                if (type_of_treasure == Treasure_type.first)
                {
                    Text count = new Text(Convert.ToString(Open_chest.Get_check_number(first_matrix, first_check_matrix)), Content.font, 20)
                    {
                        Position = new SFML.System.Vector2f(150, 150)
                    };
                    if (Open_chest.Check_matrix(first_matrix, first_check_matrix))
                    {
                        Program.win_treasure.Draw(button); ///рисуем кнопку
                        if ((mousePosition.X > button.Position.X) && (mousePosition.Y > button.Position.Y) && (mousePosition.X < 400) && (mousePosition.Y < 360))
                        {
                            button.rectShape.FillColor = Color.Red;
                            if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                            {
                                Program.win_treasure.Close();
                                Squad.Location.Room_type = RoomType.None;
                            }
                        }
                        else
                        {
                            button.rectShape.FillColor = Color.White;
                        }
                    }
                    Open_chest.Update(first_matrix, tiles); ///апдейтим
                    for (int i = 0; i < 5; i++)
                    {
                        Program.win_treasure.Draw(tiles[i]);
                    }
                    Program.win_treasure.Draw(count);
                }
                if (type_of_treasure == Treasure_type.second)
                {
                    Text count = new Text(Convert.ToString(Open_chest.Get_check_number(second_matrix, second_check_matrix)), Content.font, 20)
                    {
                        Position = new SFML.System.Vector2f(150, 150)
                    };
                    if (Open_chest.Check_matrix(second_matrix, second_check_matrix))
                    {
                        Program.win_treasure.Draw(button); ///рисуем кнопку
                        if ((mousePosition.X > button.Position.X) && (mousePosition.Y > button.Position.Y) && (mousePosition.X < 400) && (mousePosition.Y < 360))
                        {
                            button.rectShape.FillColor = Color.Red;
                            if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                            {
                                Program.win_treasure.Close();
                                Squad.Location.Room_type = RoomType.None;
                            }
                        }
                        else
                        {
                            button.rectShape.FillColor = Color.White;
                        }
                    }
                    Open_chest.Update(second_matrix, tiles_2); ///апдейтим
                    for (int i = 0; i < 5; i++)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            Program.win_treasure.Draw(tiles_2[i, j]);                    /// рисуем тайлы
                        }
                    }
                    Program.win_treasure.Draw(count);
                }
                Program.win_treasure.Display();
            }
        }
Example #4
0
        public static void Trap_room_activate(Labirint.CELL currentCell, Game.Hero hero1, Game.Hero hero2, Game.Hero hero3)
        {
            Surface surface = new Surface(720, 480, Type_of_surface.Svitok_720_480);/// 720.480

            World.labir[currentCell.x, currentCell.y].Room_type = RoomType.None;
            Program.win_trap = new RenderWindow(new VideoMode((Tile.Tile_Size + 16) * World.World_Size, Tile.Tile_Size * World.World_Size), "trap", Styles.None);
            Program.win_trap.SetVerticalSyncEnabled(true);
            Surface viper_alert = new Surface(100, 57, Type_of_surface.Viper)
            {
                Position = new SFML.System.Vector2f(100, 50)
            };
            Surface skeleton_alert = new Surface(100, 88, Type_of_surface.Skeleton)
            {
                Position = new SFML.System.Vector2f(100, 50)
            };
            Surface spear_alert = new Surface(100, 100, Type_of_surface.Spear)
            {
                Position = new SFML.System.Vector2f(100, 50)
            };
            Surface skull_alert = new Surface(47, 99, Type_of_surface.Skull)
            {
                Position = new SFML.System.Vector2f(100, 35)
            };
            Surface mimic_alert = new Surface(100, 97, Type_of_surface.Mimic)
            {
                Position = new SFML.System.Vector2f(100, 35)
            };
            Surface button = new Surface(100, 60, Type_of_surface.Drop_Button)
            {
                Position = new SFML.System.Vector2f(300, 300)
            };
            Surface ok_button = new Surface(100, 60, Type_of_surface.Ok_Button)
            {
                Position = new SFML.System.Vector2f(450, 300)
            };
            Surface dice_1 = new Surface(170, 120, Type_of_surface.Dice)
            {
                Position = new SFML.System.Vector2f(200, 35),
                Scale    = new SFML.System.Vector2f(0.5f, 0.5f)
            };
            Surface dice_2 = new Surface(170, 120, Type_of_surface.Dice)
            {
                Position = new SFML.System.Vector2f(300, 35),
                Scale    = new SFML.System.Vector2f(0.5f, 0.5f)
            };
            Surface dice_3 = new Surface(170, 120, Type_of_surface.Dice)
            {
                Position = new SFML.System.Vector2f(400, 35),
                Scale    = new SFML.System.Vector2f(0.5f, 0.5f)
            };
            Text viper_text1_alert;
            Text viper_text2_alert;
            Text viper_text3_alert;

            viper_text1_alert = new Text("Сработала ловушка со змеями! ", Content.font, 20);
            viper_text2_alert = new Text("Все члены отряда были укушены!", Content.font, 20);
            viper_text3_alert = new Text("Бросок на телосложение чтобы избежать яда!", Content.font, 20);
            Text spear_text1_alert;
            Text spear_text2_alert;
            Text spear_text3_alert;

            spear_text1_alert = new Text("Сработала ловушка с копьями! ", Content.font, 20);
            spear_text2_alert = new Text("Все члены отряда находятся в зоне поражения!", Content.font, 20);
            spear_text3_alert = new Text("Бросок на ловкость, чтобы уклониться от стрел!", Content.font, 20);
            Text skeleton_text1_alert;
            Text skeleton_text2_alert;
            Text skeleton_text3_alert;

            skeleton_text1_alert = new Text("Сработала ловушка, и скелеты вокруг ожили! ", Content.font, 20);
            skeleton_text2_alert = new Text("Все члены отряда находятся в зоне поражения!", Content.font, 20);
            skeleton_text3_alert = new Text("Бросок на силу, чтобы победить скелетов и не получить \nповреждений!", Content.font, 20);
            Text skull_text1_alert;
            Text skull_text2_alert;
            Text skull_text3_alert;

            skull_text1_alert = new Text("Перед вами повис огненный череп!", Content.font, 20);
            skull_text2_alert = new Text("Он медленно произносит загадку!", Content.font, 20);
            skull_text3_alert = new Text("Бросок на интеллект, чтобы решить загадку \nи не быть укушенным черепом!", Content.font, 20);
            Text mimic_text1_alert;
            Text mimic_text2_alert;
            Text mimic_text3_alert;

            mimic_text1_alert             = new Text("В комнате стоит подозрительный сундук!", Content.font, 20);
            mimic_text2_alert             = new Text("Отряд обсуждает стоит ли его открывать!", Content.font, 20);
            mimic_text3_alert             = new Text("Бросок на мудрость, чтобы распознать мимика!", Content.font, 20);
            viper_text1_alert.Position    = new Vector2f(100, 150);
            viper_text2_alert.Position    = new Vector2f(100, 170);
            viper_text3_alert.Position    = new Vector2f(100, 190);
            spear_text1_alert.Position    = new SFML.System.Vector2f(100, 150);
            spear_text2_alert.Position    = new SFML.System.Vector2f(100, 170);
            spear_text3_alert.Position    = new SFML.System.Vector2f(100, 190);
            skeleton_text1_alert.Position = new SFML.System.Vector2f(100, 150);
            skeleton_text2_alert.Position = new SFML.System.Vector2f(100, 170);
            skeleton_text3_alert.Position = new SFML.System.Vector2f(100, 190);
            skull_text1_alert.Position    = new SFML.System.Vector2f(100, 150);
            skull_text2_alert.Position    = new SFML.System.Vector2f(100, 170);
            skull_text3_alert.Position    = new SFML.System.Vector2f(100, 190);
            mimic_text1_alert.Position    = new SFML.System.Vector2f(100, 150);
            mimic_text2_alert.Position    = new SFML.System.Vector2f(100, 170);
            mimic_text3_alert.Position    = new SFML.System.Vector2f(100, 190);
            int random_trap            = randomize_of_room.Next(5);
            int check1                 = 0;
            int check2                 = 0;
            int check3                 = 0;
            int need_dice_type_value_1 = 0;
            int need_dice_type_value_2 = 0;
            int need_dice_type_value_3 = 0;

            switch (random_trap)
            {
            case 0:
                type_of_trap           = Trap_type.viper;
                need_dice_type_value_1 = hero1.constitution;
                need_dice_type_value_2 = hero2.constitution;
                need_dice_type_value_3 = hero3.constitution;
                check1 = hero1.Check_constitution();
                if (hero1.constitution < check1)
                {
                    hero1.hp -= 10;
                }
                check2 = hero2.Check_constitution();
                if (hero2.constitution < check2)
                {
                    hero2.hp -= 10;
                }
                check3 = hero1.Check_constitution();
                if (hero3.constitution < check3)
                {
                    hero3.hp -= 10;
                }
                break;

            case 1:
                type_of_trap           = Trap_type.spear;
                need_dice_type_value_1 = hero1.dexterity;
                need_dice_type_value_2 = hero2.dexterity;
                need_dice_type_value_3 = hero3.dexterity;
                check1 = hero1.Check_dexterity();
                if (hero1.dexterity < check1)
                {
                    hero1.hp -= 10;
                }
                check2 = hero2.Check_dexterity();
                if (hero2.dexterity < check2)
                {
                    hero2.hp -= 10;
                }
                check3 = hero3.Check_dexterity();
                if (hero3.dexterity < check3)
                {
                    hero3.hp -= 10;
                }
                break;

            case 2:
                type_of_trap           = Trap_type.skeleton;
                need_dice_type_value_1 = hero1.strength;
                need_dice_type_value_2 = hero2.strength;
                need_dice_type_value_3 = hero3.strength;
                check1 = hero1.Check_strength();
                if (hero1.strength < check1)
                {
                    hero1.hp -= 10;
                }
                check2 = hero2.Check_strength();
                if (hero2.strength < check2)
                {
                    hero2.hp -= 10;
                }
                check3 = hero3.Check_strength();
                if (hero3.strength < check3)
                {
                    hero3.hp -= 10;
                }
                break;

            case 3:
                type_of_trap           = Trap_type.skull;
                need_dice_type_value_1 = hero1.intelligece;
                need_dice_type_value_2 = hero2.intelligece;
                need_dice_type_value_3 = hero3.intelligece;
                check1 = hero1.Check_intelligence();
                if (hero1.intelligece < check1)
                {
                    hero1.hp -= 10;
                }
                check2 = hero2.Check_intelligence();
                if (hero2.intelligece < check2)
                {
                    hero2.hp -= 10;
                }
                check3 = hero3.Check_intelligence();
                if (hero3.intelligece < check3)
                {
                    hero3.hp -= 10;
                }
                break;

            case 4:
                type_of_trap           = Trap_type.mimic;
                need_dice_type_value_1 = hero1.wisdom;
                need_dice_type_value_2 = hero2.wisdom;
                need_dice_type_value_3 = hero3.wisdom;
                check1 = hero1.Check_wisdom();
                if (hero1.wisdom < check1)
                {
                    hero1.hp -= 10;
                }
                check2 = hero2.Check_wisdom();
                if (hero2.wisdom < check2)
                {
                    hero2.hp -= 10;
                }
                check3 = hero3.Check_wisdom();
                if (hero3.wisdom < check3)
                {
                    hero3.hp -= 10;
                }
                break;

            default:
                break;
            }
            bool dostup     = false;
            Text dice_bar_1 = new Text(Convert.ToString(check1), Content.font, 25)
            {
                Position = new Vector2f(230, 45)
            };
            Text dice_bar_2 = new Text(Convert.ToString(check2), Content.font, 25)
            {
                Position = new Vector2f(330, 45)
            };
            Text dice_bar_3 = new Text(Convert.ToString(check3), Content.font, 25)
            {
                Position = new Vector2f(430, 45)
            };
            Text need_dice_1 = new Text(Convert.ToString(need_dice_type_value_1), Content.font, 25)
            {
                Position = new Vector2f(230, 95)
            };
            Text need_dice_2 = new Text(Convert.ToString(need_dice_type_value_2), Content.font, 25)
            {
                Position = new Vector2f(330, 95)
            };
            Text need_dice_3 = new Text(Convert.ToString(need_dice_type_value_3), Content.font, 25)
            {
                Position = new Vector2f(430, 95)
            };

            while (Program.win_trap.IsOpen)
            {
                Program.win_trap.DispatchEvents();
                Program.win_trap.Clear(Color.Black);
                Program.win_trap.Draw(surface);
                Program.win_trap.Draw(button);
                Program.win_trap.Draw(dice_1);
                Program.win_trap.Draw(dice_2);
                Program.win_trap.Draw(dice_3);
                Program.win_trap.Draw(need_dice_1);
                Program.win_trap.Draw(need_dice_2);
                Program.win_trap.Draw(need_dice_3);
                var mousePosition = Mouse.GetPosition(Program.win_trap);
                if (type_of_trap == Trap_type.viper)
                {
                    Program.win_trap.Draw(viper_alert);
                    Program.win_trap.Draw(viper_text1_alert);
                    Program.win_trap.Draw(viper_text2_alert);
                    Program.win_trap.Draw(viper_text3_alert);
                }
                if (type_of_trap == Trap_type.spear)
                {
                    Program.win_trap.Draw(spear_alert);
                    Program.win_trap.Draw(spear_text1_alert);
                    Program.win_trap.Draw(spear_text2_alert);
                    Program.win_trap.Draw(spear_text3_alert);
                }
                if (type_of_trap == Trap_type.skeleton)
                {
                    Program.win_trap.Draw(skeleton_alert);
                    Program.win_trap.Draw(skeleton_text1_alert);
                    Program.win_trap.Draw(skeleton_text2_alert);
                    Program.win_trap.Draw(skeleton_text3_alert);
                }
                if (type_of_trap == Trap_type.skull)
                {
                    Program.win_trap.Draw(skull_alert);
                    Program.win_trap.Draw(skull_text1_alert);
                    Program.win_trap.Draw(skull_text2_alert);
                    Program.win_trap.Draw(skull_text3_alert);
                }
                if (type_of_trap == Trap_type.mimic)
                {
                    Program.win_trap.Draw(mimic_alert);
                    Program.win_trap.Draw(mimic_text1_alert);
                    Program.win_trap.Draw(mimic_text2_alert);
                    Program.win_trap.Draw(mimic_text3_alert);
                }
                if ((mousePosition.X > button.Position.X) && (mousePosition.Y > button.Position.Y) && (mousePosition.X < 400) && (mousePosition.Y < 360))
                {
                    button.rectShape.FillColor = Color.Red;
                    if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                    {
                        dostup = true;
                    }
                }
                if (dostup)
                {
                    Program.win_trap.Draw(ok_button);
                    Program.win_trap.Draw(dice_bar_1);
                    Program.win_trap.Draw(dice_bar_2);
                    Program.win_trap.Draw(dice_bar_3);
                    if ((mousePosition.X > ok_button.Position.X) && (mousePosition.Y > ok_button.Position.Y) && (mousePosition.X < 550) && (mousePosition.Y < 360))
                    {
                        ok_button.rectShape.FillColor = Color.Red;
                        if ((Mouse.IsButtonPressed(Mouse.Button.Left)))
                        {
                            Program.win_trap.Close();
                            Squad.Location.Room_type = RoomType.None;
                        }
                    }
                }
                else
                {
                    button.rectShape.FillColor = Color.White;
                }
                if ((hero1.hp < 0) || (hero2.hp < 0) || (hero3.hp < 0))
                {
                    Program.win_end_game = new RenderWindow(new VideoMode((Tile.Tile_Size + 16) * World.World_Size, Tile.Tile_Size * World.World_Size), "endgame", Styles.None);
                    Program.win_end_game.SetVerticalSyncEnabled(true);
                    Surface game_over = new Surface(720, 480, Type_of_surface.Game_over);
                    while (Program.win_end_game.IsOpen)
                    {
                        Program.win_end_game.DispatchEvents();
                        Program.win_end_game.Clear();
                        Program.win_end_game.Draw(game_over);
                        if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
                        {
                            Program.win_end_game.Close();
                            Program.win.Close();
                        }
                        Program.win_end_game.Display();
                    }
                }
                Program.win_trap.Display();
            }
        }