Пример #1
0
 public ImageModel(GameMap map, string ImageFile, int X, int Y)
 {
     this.form        = map.form;
     this.map         = map;
     Image            = Image.FromFile("../../" + ImageFile);
     this.X           = X;
     this.Y           = Y;
     CurrentAnimation = new Animation();
 }
Пример #2
0
        public Button CreateLevelButton(Point buttonLocation, int number)
        {
            var buttonLevelSize = new Size(100, 100);
            var button          = new Button()
            {
                Size                  = buttonLevelSize,
                Location              = buttonLocation,
                BackgroundImage       = Image.FromFile("../../images/Menu/LevelIcon/" + number + ".png"),
                BackgroundImageLayout = ImageLayout.Stretch
            };

            button.MouseClick += (sender, args) =>
            {
                var myForm = new MyForm(this, Levels.Levels[number]);
                myForm.ShowDialog();
            };
            return(button);
        }
Пример #3
0
        public GameMap(MyForm form, Lavel lavel)
        {
            this.form = form;
            Width     = lavel.Background[0].Length;
            Height    = lavel.Background.Count;
            BackMap   = new Background[Width, Height];
            ItemsMap  = new IItems[Width, Height];
            Heroes    = new List <MovableBase>();

            //Заполнение фона
            BackMap.Foreach((x, y) => { BackMap[x, y] = MapDecoder.background[lavel.Background[y][x]]; });

            //Заполнение объектами
            Action <char, int, int> AddItem = (c, x, y) => { ItemsMap[x, y] = MapDecoder.item[c](); };

            lavel.Items.Foreach((x, y) =>
            {
                var item = lavel.Items[y][x];
                switch (item)
                {
                case 'S': AddItem(item, x, y); break;
                }
            });

            //Заполнение мобами
            Action <char, int, int> AddHero = (c, x, y) => { Heroes.Add(MapDecoder.hero[c](this, x, y)); };

            lavel.Mobs.Foreach((x, y) =>
            {
                var hero = lavel.Mobs[y][x];
                switch (hero)
                {
                case 'R': AddHero(hero, x, y); break;
                }
            });

            if (Heroes.Count == 0)
            {
                throw new Exception("No heroes on the map");
            }
        }