Exemplo n.º 1
0
        public void DrawGameScreen(leveldata level, ReturnInput input)
        {
            int squaresize = 1;

            if ((width / level.x_num) > height / level.y_num)
            {
                squaresize = height / level.y_num;
            }
            else
            {
                squaresize = width / level.x_num;
            }

            squaresize   = ConvertInt(squaresize);
            gamescreen_x = ConvertInt(level.x_num * squaresize);
            gamescreen_y = ConvertInt(level.y_num * squaresize);

            level.realsize = new Size(gamescreen_x, gamescreen_y);

            level.realposition = ConvertPosition(new Position((width - gamescreen_x) / 2, (height - gamescreen_y) / 2));

            Size tilesize = new Size(squaresize, squaresize);

            foreach (Tile tile in level.positions)
            {
                tile.real_position = ConvertPosition(new Position((level.realposition.x) + tile.position.x * tilesize.x, (level.realposition.y) + tile.position.y * tilesize.y));
                tile.real_size     = tilesize;

                DrawTile(tile);
            }
        }
Exemplo n.º 2
0
        public void HandleHighlights(ReturnInput input, bool controllsenabled)
        {
            Vector2 vector2 = input.cursor;

            foreach (Tile tile in positions)
            {
                if (vector2.X > tile.real_position.x && vector2.Y > tile.real_position.y &&
                    vector2.X < tile.real_position.x + tile.real_size.x && vector2.Y < tile.real_position.y + tile.real_size.y && controllsenabled && gamemanager.SelectedTile == gamemanager.EmptyTile)
                {
                    tile.MouseOn();
                }
                else
                {
                    tile.MouseOff();
                }
            }
        }
Exemplo n.º 3
0
 public Game_Manager(Platform current_platform, Drawvisitor drawvisitor, iInputhandler inputhandler)
 {
     this.EmptyTile = new Tile(this, new Position(-1, -1), false);
     this.drawvisitor = drawvisitor;
     this.level = new leveldata(this, Dificulty.normal);
     this.inputhandler = inputhandler;
     latestinput = inputhandler.getinput();
     this.SelectedTile = EmptyTile;
     this.selectionbuttons = new SelectionButtons(this);
     this.current_platform = current_platform;
     if (this.current_platform == Platform.windows)
     {
         SelectionButtonsEnabled = false;
     }
     else
     {
         SelectionButtonsEnabled = true;
     }
 }
Exemplo n.º 4
0
        public void Update(float dt, ReturnInput input)
        {
            if (gamemanager.SelectedTile != gamemanager.EmptyTile)
            {
                if (gamemanager.ClickCooldown <= 0)
                {
                    this.mark_highlighted = (gamemanager.isIntersecting(real_mark_position, real_mark_size, input.cursor));
                    this.open_highlighted = (gamemanager.isIntersecting(real_open_position, real_open_size, input.cursor));
                }

                this.openvisible = !gamemanager.SelectedTile.marked;

                if (input.clicktype == ClickTypes.open && gamemanager.ClickCooldown <= 0)
                {
                    if (this.mark_highlighted)
                    {
                        gamemanager.SelectedTile.Mark();
                        gamemanager.SelectedTile        = gamemanager.EmptyTile;
                        gamemanager.TileControllEnabled = true;
                        gamemanager.increaseclickcooldown();
                    }
                    else if (this.open_highlighted)
                    {
                        gamemanager.SelectedTile.Open();
                        gamemanager.SelectedTile        = gamemanager.EmptyTile;
                        gamemanager.TileControllEnabled = true;
                        gamemanager.increaseclickcooldown();
                    }
                    else
                    {
                        gamemanager.TileControllEnabled = true;
                        gamemanager.SelectedTile        = gamemanager.EmptyTile;
                    }
                }
            }
            else
            {
            }
        }
Exemplo n.º 5
0
        public void Update(float dt)
        {
            if (ClickCooldown > 0) { ClickCooldown -= dt; } else { ClickCooldown = 0; }
            if (EndingLevelCooldown > 0) { EndingLevelCooldown -= dt; } else { EndingLevelCooldown = 0; }

            latestinput = inputhandler.getinput();

            HandleInputs();
            selectionbuttons.Update(dt, latestinput);
            
            if (level != null)
            {
                level.Update(dt);

                if (EndingLevel)
                {
                    if (EndingLevelCooldown <= 0)
                    { 
                        if (level.OnBomb(3f, dt))
                        {
                            NewLevel();
                        }
                    }
                }
                else if (level.CheckIfDone())
                {
                    NewLevel();
                }
            }

            if (latestinput.navigation == NavigationType.exit)
            {
                this.Exit = true;
            }

        }
Exemplo n.º 6
0
 public void Draw(Drawvisitor drawvisitor, ReturnInput input)
 {
     drawvisitor.DrawGameScreen(this, input);
 }