Ejemplo n.º 1
0
        private Tile[][] tiles; //Array of all the tiles in the game

        #endregion Fields

        #region Constructors

        //veroudere constructor
        public Level(Location gridsize, Location s, Location e, Game game, int size = 32)
        {
            this.game = game;
            //Setup of the gridsize
            gridSize = new Location(gridsize.X + 2, gridsize.Y + 2); //gridsize wordt vergroot met twee voor muren
            //horizontal rows are initialized
            tiles = new Tile[gridSize.X][];
            for (int y = 0; y < gridSize.X; y++)
            {
                //vertical cells are initialized
                tiles[y] = new Tile[gridSize.Y];

            }

            //initiate start and end point
            start = s;
            eind = e;

            //setting up the floorplan
            for (int xloc = 0; xloc < gridSize.X; xloc++)
            {
                for (int yloc = 0; yloc < gridSize.Y; yloc++)
                {
                    if (yloc == 0 || yloc == gridSize.Y - 1 || xloc == 0 || xloc == gridSize.X - 1)
                    {
                        tiles[xloc][yloc] = new WallTile(new Location(xloc, yloc), this);   //assign the outer walls
                    }
                    else
                    {
                        //assign floor
                        tiles[xloc][yloc] = new FloorTile(new Location(xloc, yloc), this);
                    }

                    if (new Location(xloc, yloc).Compareto(start))
                    {
                        //assign start location
                        tiles[xloc][yloc] = new StartTile(new Location(xloc, yloc), Properties.Resources.floor_tile_texture, this);
                    }
                    if (new Location(xloc, yloc).Compareto(eind))
                    {
                        //assign end location
                        tiles[xloc][yloc] = new ShrekTile(new Location(xloc, yloc), Properties.Resources.floor_tile_texture, this);
                    }
                }
            }
            rand = new Random();

            speler = new Player(Start, this);
            entities = new ArrayList();
            for (int i = 0; i < 3; i++)
            {
                entities.Add(new Grunt(new Location(rand.Next(gridsize.X), rand.Next(gridsize.Y)), this));
                entities.Add(new Illuminatie(new Location(rand.Next(gridsize.X), rand.Next(gridsize.Y)), this));

            }
        }
Ejemplo n.º 2
0
        //constructor
        public Loop(Main window, int targetUps, Boolean fpsLock, int maxFps)
        {
            //Console.WriteLine(window.GPanel.Visible);
            //stelt alle variablen in
            this.window = window;
            //window.GPanel.
            window.Paint += this.render;

            this.targetUps = targetUps;
            this.fpsLock = fpsLock;
            this.maxFps = maxFps;
            //intalizeerd het spel
            game = new Game(this);
            //initalizeerd de gameloop thraed en start hem op de methode init();
            t = new Thread(init);
            t.Priority = ThreadPriority.Highest;
            t.TrySetApartmentState(ApartmentState.MTA);
            t.Start();
        }
Ejemplo n.º 3
0
 //level uit xmlreader laden
 public Level(XmlReader xml, Game game)
 {
     this.game = game;
     this.file = XDocument.Load(xml);
     load(file);
 }
Ejemplo n.º 4
0
 //level uit xdocumetn laden
 public Level(XDocument xdoc, Game game)
 {
     this.game = game;
     this.file = xdoc;
     load(xdoc);
 }
Ejemplo n.º 5
0
 private static void Main()
 {
     var game = new Game();
     game.Run();
 }
Ejemplo n.º 6
0
 private void init()
 {
     game = new Game();
     running = true;
     run();
 }
Ejemplo n.º 7
0
 //constructor
 public ExitGame(Game game)
 {
     this.game = game;
     InitializeComponent();
 }