/// <summary>Load the level.</summary>
    public void LoadTiles(string path)
    {
        this.path = path;
        List <string> textlines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine(); // first row of the level

        width = line.Length;                              // calculated level width
        while (line != null)
        {
            // read all lines
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        height = textlines.Count - 2;

        // add the hint
        GameObjectList hintfield = new GameObjectList(100);

        Add(hintfield);
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); // hint background

        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); // hint text

        hintText.Text     = textlines[textlines.Count - 2];                // last line in the level descriptor
        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); // timeout

        Add(hintTimer);

        TimerGameObject timer = new TimerGameObject(101, "timer");

        timer.Position = new Vector2(25, 30);
        timer.TimeLeft = TimeSpan.FromSeconds(double.Parse(textlines[textlines.Count - 1]));
        Add(timer);

        // construct the level
        TileField tiles = new TileField(height, width, 1, "tiles");

        Add(tiles);
        // tile dimentions
        tiles.CellWidth = 72;
        cellWidth       = 72;

        tiles.CellHeight = 55;
        cellHeight       = 55;

        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < height; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
        }
    }
示例#2
0
    public override void Reset()
    {
        base.Reset();
        VisibilityTimer hintTimer = this.Find("hintTimer") as VisibilityTimer;

        hintTimer.StartVisible();
    }
示例#3
0
    public override void Reset()
    {
        base.Reset();
        VisibilityTimer hintTimer = Find("hintTimer") as VisibilityTimer;

        hintTimer.StartVisible();
        (GameWorld.Find("bullets") as GameObjectList).RemoveEverything();
    }
    public JewelJamGameWorld(JewelJam game)
    {
        // store a reference to the game
        this.game = game;

        // add the background
        SpriteGameObject background = new SpriteGameObject("spr_background");

        Size = new Point(background.Width, background.Height);
        AddChild(background);

        // add a "playing field" parent object for the grid and all related objects
        GameObjectList playingField = new GameObjectList();

        playingField.LocalPosition = new Vector2(85, 150);
        AddChild(playingField);

        // add the grid to the playing field
        JewelGrid grid = new JewelGrid(GridWidth, GridHeight, CellSize);

        playingField.AddChild(grid);

        // add the row selector to the playing field
        playingField.AddChild(new RowSelector(grid));

        // add a background sprite for the score object
        SpriteGameObject scoreFrame = new SpriteGameObject("spr_scoreframe");

        scoreFrame.LocalPosition = new Vector2(20, 20);
        AddChild(scoreFrame);

        // add the object that displays the score
        ScoreGameObject scoreObject = new ScoreGameObject();

        scoreObject.LocalPosition = new Vector2(270, 30);
        AddChild(scoreObject);

        // add the moving jewel cart
        jewelCart = new JewelCart(new Vector2(410, 230));
        AddChild(jewelCart);

        // add the help button
        helpButton = new SpriteGameObject("spr_button_help");
        helpButton.LocalPosition = new Vector2(1270, 20);
        AddChild(helpButton);

        // add combo images with visibility timers attached to them
        timer_double = AddComboImageWithTimer("spr_double");
        timer_triple = AddComboImageWithTimer("spr_triple");

        // add the various overlays
        titleScreen    = AddOverlay("spr_title");
        gameOverScreen = AddOverlay("spr_gameover");
        helpScreen     = AddOverlay("spr_frame_help");

        // start at the title screen
        GoToState(GameState.TitleScreen);
    }
示例#5
0
    public void LoadTiles(string path)
    {
        //Haalt de tekst uit tekstfile
        int width;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine();
        width = line.Length;
        while (line != null)
        {
            textlines.Add(line);
            line = fileReader.ReadLine();
        }

        //Tijdslimiet i wordt afgelezen uit tekstfile
        int i = int.Parse(textlines[textlines.Count - 1]);
        SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100, "timerBackground");
        timerBackground.Position = new Vector2(10, 10);
        this.Add(timerBackground);
        TimerGameObject timer = new TimerGameObject(i, 101, "timer");
        timer.Position = new Vector2(25, 30);
        this.Add(timer);

        int height = textlines.Count - 2;

        //Creëert het speelveld
        TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles");

        //Plaatst de hintbutton
        GameObjectList hintfield = new GameObjectList(100, "hintfield");
        this.Add(hintfield);
        string hint = textlines[textlines.Count - 2];
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1, "hint_frame");
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2, "hintText");
        hintText.Text = hint;
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer");
        this.Add(hintTimer);

        //Vult het speelveld met de goede tiles
        this.Add(tiles);
        tiles.CellWidth = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < textlines.Count - 2; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }

        levelwidth = width * tiles.CellWidth;
        levelheight = height * tiles.CellHeight;
    }
示例#6
0
    public override void Reset()
    {
        base.Reset();
        VisibilityTimer hintTimer = Find("hintTimer") as VisibilityTimer;

        hintTimer.StartVisible();
        //Reset camera
        camera.Reset();
    }
示例#7
0
        private void AddPlayingField(List <string> gridRows, int gridWidth, int gridHeight)
        {
            GameObjectList playingField = new GameObjectList();

            Vector2 gridSize = new Vector2(gridWidth * TileWidth, gridHeight * TileHeight);

            playingField.Position = new Vector2(600, 420) - gridSize / 2.0f;

            tiles          = new Tile[gridWidth, gridHeight];
            animalsOnTiles = new Animal[gridWidth, gridHeight];

            for (int y = 0; y < gridHeight; y++)
            {
                string row = gridRows[y];
                for (int x = 0; x < gridWidth; x++)
                {
                    char symbol = ' ';
                    if (x < row.Length)
                    {
                        symbol = row[x];
                    }

                    AddTile(x, y, symbol);
                    AddAnimal(x, y, symbol);
                }
            }

            for (int y = 0; y < gridHeight; y++)
            {
                for (int x = 0; x < gridWidth; x++)
                {
                    playingField.AddChild(tiles[x, y]);
                }
            }

            for (int y = 0; y < gridHeight; y++)
            {
                for (int x = 0; x < gridWidth; x++)
                {
                    if (animalsOnTiles[x, y] != null)
                    {
                        playingField.AddChild(animalsOnTiles[x, y]);
                    }
                }
            }

            hintArrow.Visible = false;
            playingField.AddChild(hintArrow);
            hintTimer = new VisibilityTimer(hintArrow);
            playingField.AddChild(hintTimer);

            selector = new MovableAnimalSelector();
            playingField.AddChild(selector);

            AddChild(playingField);
        }
示例#8
0
    public void LoadTiles(string path)
    {
        List <string> textLines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine();
        int           width      = line.Length;

        while (line != null)
        {
            textLines.Add(line);
            line = fileReader.ReadLine();
        }
        TileField      tiles     = new TileField(textLines.Count - 1, width, 1, "tiles");
        int            height    = textLines.Count - 1;
        GameObjectList hintField = new GameObjectList(100);

        Add(hintField);
        string           hint      = textLines[textLines.Count - 2];
        SpriteGameObject hintFrame = new LockedSpriteGameObject("Overlays/spr_frame_hint", 1);

        hintField.Position = new Vector2((GameEnvironment.Screen.X - hintFrame.Width) / 2, 10);
        hintField.Add(hintFrame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2);

        hintText.Text     = textLines[textLines.Count - 2];
        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintField.Add(hintText);
        int timerTime = int.Parse(textLines[textLines.Count - 1]);

        timer.SetTime = timerTime;
        VisibilityTimer hintTimer = new VisibilityTimer(hintField, 1, "hintTimer");

        Add(hintTimer);

        Add(tiles);
        tiles.CellWidth  = 72;
        tiles.CellHeight = 55;
        this.width       = width * tiles.CellWidth;
        this.height      = height * tiles.CellHeight;
        for (int x = 0; x < width; x++)
        {
            Tile t = new Tile();
            tiles.Add(t, x, 0);
        }
        for (int x = 0; x < width; ++x)
        {
            for (int y = 1; y < textLines.Count - 1; ++y)
            {
                Tile t = LoadTile(textLines[y - 1][x], x, y);
                tiles.Add(t, x, y);
            }
        }
    }
    /// <summary>Load the level.</summary>
    public void LoadTiles(string path)
    {
        this.path = path;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine(); // first row of the level
        width = line.Length; // calculated level width
        while (line != null)
        {
            // read all lines
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        height = textlines.Count - 2;

        // add the hint
        GameObjectList hintfield = new GameObjectList(100);
        Add(hintfield);
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); // hint background
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); // hint text
        hintText.Text = textlines[textlines.Count - 2]; // last line in the level descriptor
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); // timeout
        Add(hintTimer);

        TimerGameObject timer = new TimerGameObject(101, "timer");
        timer.Position = new Vector2(25, 30);
        timer.TimeLeft = TimeSpan.FromSeconds(double.Parse(textlines[textlines.Count - 1]));
        Add(timer);

        // construct the level
        TileField tiles = new TileField(height, width, 1, "tiles");
        Add(tiles);
        // tile dimentions
        tiles.CellWidth = 72;
        cellWidth = 72;

        tiles.CellHeight = 55;
        cellHeight = 55;
        
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < height; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
    }
示例#10
0
    public void LoadTiles(string path)
    {
        List <string> textLines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine();
        int           width      = line.Length;

        while (line != null)
        {
            textLines.Add(line);
            line = fileReader.ReadLine();
        }


        TileField tiles = new TileField(textLines.Count - 2, width, 1, "tiles");  //initialize news Tile

        GameObjectList hintField = new GameObjectList(100);

        Add(hintField);
        time = double.Parse(textLines[textLines.Count - 1]);             //laatste regel van de txt bestanden en leest dit als tijd
        string           hint      = textLines[textLines.Count - 2];
        SpriteGameObject hintFrame = new SpriteGameObject("Overlays/spr_frame_hint", 1);

        hintFrame.CameraFollow = false;
        hintField.Position     = new Vector2((GameEnvironment.Screen.X - hintFrame.Width) / 2, 10);
        hintField.Add(hintFrame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2);

        hintText.Text     = textLines[textLines.Count - 2];             //
        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintField.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintField, 1, "hintTimer");

        Add(hintTimer);

        Add(tiles);
        tiles.CellWidth  = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < textLines.Count - 2; ++y)
            {
                Tile t = LoadTile(textLines[y][x], x, y);
                tiles.Add(t, x, y);
            }
        }
        LevelSize = new Vector2(tiles.CellWidth * width, tiles.CellHeight * (textLines.Count - 1));
    }
示例#11
0
    VisibilityTimer AddComboImageWithTimer(string spriteName)
    {
        // create and add the image
        SpriteGameObject image = new SpriteGameObject(spriteName);

        image.Visible       = false;
        image.LocalPosition = new Vector2(800, 400);
        AddChild(image);

        // create and add the timer, with that image as its target
        VisibilityTimer timer = new VisibilityTimer(image);

        AddChild(timer);

        return(timer);
    }
示例#12
0
    public void LoadTiles(string path)
    {
        int width;
        List<string> textlines = new List<string>();
        StreamReader fileReader = new StreamReader(path);
        string line = fileReader.ReadLine();
        width = line.Length;
        while (line != null)
        {
            textlines.Add(line);
            line = fileReader.ReadLine();
        }
        TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles");

        GameObjectList hintfield = new GameObjectList(100);
        this.Add(hintfield);
        string hint = textlines[textlines.Count - 1];
        SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1);
        hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10);
        hint_frame.Meebewegen();
        hintfield.Add(hint_frame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2);
        hintText.Text = textlines[textlines.Count - 2];
        hintText.Position = new Vector2(120, 25);
        hintText.Color = Color.Black;
        hintfield.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer");
        this.Add(hintTimer);

        GameObject.lvltimer = Convert.ToDouble(textlines[textlines.Count - 1]); // de laatste lijn in de textfile heeft de tijd

        this.Add(tiles);
        tiles.CellWidth = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
            for (int y = 0; y < textlines.Count - 2; ++y)
            {
                Tile t = LoadTile(textlines[y][x], x, y);
                tiles.Add(t, x, y);
            }
    }
示例#13
0
    public void LoadTiles(string path)
    {
        List <string> textLines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine();
        int           width      = line.Length;

        while (line != null)
        {
            textLines.Add(line);
            line = fileReader.ReadLine();
        }

        GameObjectList hintField = new GameObjectList(100);

        Add(hintField);
        string           hint      = textLines[textLines.Count - 1];
        SpriteGameObject hintFrame = new SpriteGameObject("Overlays/spr_frame_hint", 100);

        hintField.Position = new Vector2((GameEnvironment.Screen.X - hintFrame.Width) / 2, 10);
        hintField.Add(hintFrame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 100);

        hintText.Text     = textLines[textLines.Count - 1];
        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintField.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintField, 1, "hintTimer");

        Add(hintTimer);

        SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100);

        timerBackground.Position = new Vector2(10, 10);
        Add(timerBackground);

        int timerlineoffset = 0;

        if (int.TryParse(textLines[textLines.Count - 2], out int timerlength))
        {
            TimerGameObject timer = new TimerGameObject(101, "timer", timerlength);
            timer.Position = new Vector2(25, 30);
            Add(timer);
            timerlineoffset = 1;
        }
        else
        {
            TimerGameObject timer = new TimerGameObject(101, "timer");
            timer.Position = new Vector2(25, 30);
            Add(timer);
        }

        TileField tiles = new TileField(textLines.Count - (1 + timerlineoffset), width, 1, "tiles");

        Add(tiles);
        tiles.CellWidth  = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < textLines.Count - (1 + timerlineoffset); ++y)
            {
                Tile t = LoadTile(textLines[y][x], x, y);
                tiles.Add(t, x, y);
            }
        }
    }
示例#14
0
    void AddPlayingField(List <string> gridRows, int gridWidth, int gridHeight)
    {
        // create a parent object for everything
        GameObjectList playingField = new GameObjectList();

        // this playing field should be roughly centered on the screen
        Vector2 gridSize = new Vector2(gridWidth * TileWidth, gridHeight * TileHeight);

        playingField.LocalPosition = new Vector2(600, 420) - gridSize / 2.0f;

        // prepare the grid arrays
        tiles          = new Tile[gridWidth, gridHeight];
        animalsOnTiles = new Animal[gridWidth, gridHeight];

        // load the tiles and animals
        for (int y = 0; y < gridHeight; y++)
        {
            string row = gridRows[y];
            for (int x = 0; x < gridWidth; x++)
            {
                // the row could be too short; if so, pretend there is an empty tile
                char symbol = ' ';
                if (x < row.Length)
                {
                    symbol = row[x];
                }

                // load the non-changing part of the tile
                AddTile(x, y, symbol);

                // load the animal part of the tile, if it exists
                AddAnimal(x, y, symbol);
            }
        }

        // add the tiles to the playing field
        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = 0; x < gridWidth; x++)
            {
                playingField.AddChild(tiles[x, y]);
            }
        }

        // add the animals after that, so that they will be drawn on top
        for (int y = 0; y < gridHeight; y++)
        {
            for (int x = 0; x < gridWidth; x++)
            {
                if (animalsOnTiles[x, y] != null)
                {
                    playingField.AddChild(animalsOnTiles[x, y]);
                }
            }
        }

        // add the hint arrow (so that it will be drawn on top), but make it invisible for now
        hintArrow.Visible = false;
        playingField.AddChild(hintArrow);
        hintTimer = new VisibilityTimer(hintArrow);
        playingField.AddChild(hintTimer);

        // add the animal selector
        selector = new MovableAnimalSelector();
        playingField.AddChild(selector);

        // finally, add the playing field to the level
        AddChild(playingField);
    }
示例#15
0
    public void LoadTiles(string path)
    {
        List <string> textLines  = new List <string>();
        StreamReader  fileReader = new StreamReader(path);
        string        line       = fileReader.ReadLine();
        int           width      = line.Length;

        while (line != null)
        {
            textLines.Add(line);
            line = fileReader.ReadLine();
        }
        TileField tiles = new TileField(textLines.Count - 2, width, 10, "tiles");

        //Store the size of the game
        int height = textLines.Count - 2;

        levelSize = new Vector2(width, height);
        //--------------------------

        GameObjectList hintField = new GameObjectList(100);

        Add(hintField);

        //Plit last textline at "=" and store the time
        string timeLine = textLines[textLines.Count - 1];

        string[] timeStuff = timeLine.Split('=');
        time = double.Parse(timeStuff[1]);
        //--------------------------------------------

        SpriteGameObject hintFrame = new SpriteGameObject("Overlays/spr_frame_hint", 0);

        hintField.Position = new Vector2((GameEnvironment.Screen.X - hintFrame.Width) / 2, 10);
        hintField.Add(hintFrame);
        TextGameObject hintText = new TextGameObject("Fonts/HintFont", 0);

        hintText.Text = textLines[textLines.Count - 2];

        hintText.Position = new Vector2(120, 25);
        hintText.Color    = Color.Black;
        hintField.Add(hintText);
        VisibilityTimer hintTimer = new VisibilityTimer(hintField, 0, "hintTimer"); // Here

        Add(hintTimer);

        //Assign camera
        camera = new Camera(levelSize);

        Add(tiles);
        tiles.CellWidth  = 72;
        tiles.CellHeight = 55;
        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < textLines.Count - 2; ++y)
            {
                Tile t = LoadTile(textLines[y][x], x, y);
                tiles.Add(t, x, y);
            }
        }
    }