public void ComparetoTest()
 {
     bool expected = false;
     Location loc1 = new Location(3, 4);
     Location loc2 = new Location(4, 5);
     bool actual = loc1.Compareto(loc2);
     Assert.AreEqual(expected, actual);
 }
示例#2
0
 //krijgt de afstand tussen 2 locaties
 public double Distanceto(Location location)
 {
     int xb = location.X;
     int yb = location.Y;
     int horz = Math.Abs(x - xb);
     int vert = Math.Abs(y- yb);
     return Math.Sqrt(horz * horz + vert * vert);
 }
 public void MoveTest()
 {
     bool expected = true;
     Location loc1 = new Location(3, 4);
     Location loc2 = new Location(4, 5);
     loc1.Move(1, 1);
     bool actual = loc1.Compareto(loc2);
     Assert.AreEqual(expected, actual);
 }
        public void DistancetoTest()
        {
            double expected = 5;
            Location loc1 = new Location(0, 0);
            Location loc2 = new Location(4, 3);

            double result = loc1.Distanceto(loc2);
            Assert.AreEqual(expected, result);
        }
示例#5
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));

            }
        }
示例#6
0
        private TileType type; // huidige type van tile

        #endregion Fields

        #region Constructors

        public Tile(Location init, TileType type, Boolean solid, Image texture, Level level)
        {
            //variabelen initalizeren
            this.level = level;
            this.solid = solid;
            this.texture = texture;
            this.pos = init;
            this.type = type;
            this.tilesize = 32;
        }
示例#7
0
 //properties geven
 public FloorTile(Location init, Level level)
     : base(init, TileType.floor, false, Properties.Resources.floor_tile_texture, level)
 {
 }
示例#8
0
 //properties geven
 public WallTile(Location init, Level level)
     : base(init, TileType.wall, true, Properties.Resources.Wall, level)
 {
 }
示例#9
0
 //vergelijken methode
 public bool Compareto(Location second)
 {
     if(this.X==second.X && this.Y == second.Y) { return true; } else { return false;}
 }
示例#10
0
 public Location(Location location)
 {
     x = location.x;
     y = location.y;
 }
示例#11
0
        //level uit xdocument aan het laden
        public void load(XDocument xdoc)
        {
            //variablen initalizeren
            game.keyboard.releaseAllKeys();
            XmlReader xml = xdoc.CreateReader();
            xml.MoveToAttribute(1);
            rand = new Random();
            entities = new ArrayList();
            Location start = new Location(0, 0);
            int width = 0, height = 0;

            //    xml. lezen
            while (xml.Read())
            {
                //checked of hij bij de size requirements zit
                if (xml.NodeType == XmlNodeType.Element && xml.Name == "Size")
                {

                    xml.ReadToFollowing("Width");
                    width = xml.ReadElementContentAsInt();

                    height = xml.ReadElementContentAsInt();
                    //tiles inilzation
                    tiles = new Tile[width][];
                    for (int y = 0; y < width; y++)
                    {
                        //vertical cells are initialized
                        tiles[y] = new Tile[height];
                    }

                    //alles standaart floortiles
                    for (int x = 0; x < tiles.Length; x++)
                    {
                        for (int y = 0; y < tiles[x].Length; y++)
                        {
                            tiles[x][y] = new FloorTile(new Location(x, y), this);
                        }
                    }

                }
                //checked of hij anders hij de tiles zit
                else if (xml.NodeType == XmlNodeType.Element)
                {
                    //kriigt de tile naam
                    String name = xml.Name;
                    //krijgt de tile positie
                    int x = Convert.ToInt32(xml.GetAttribute("x"));
                    int y = Convert.ToInt32(xml.GetAttribute("y"));
                    //switched tussen de types tiles and zet ze op de goeie positie
                    switch (name)
                    {
                        case "Muur":
                            tiles[x][y] = new WallTile(new Location(x, y), this);
                            break;
                        case "Vloer":
                            tiles[x][y] = new FloorTile(new Location(x, y), this);
                            break;
                        case "Shrek":
                            tiles[x][y] = new ShrekTile(new Location(x, y), Properties.Resources.floor_tile_texture, this);
                            break;
                        case "Kid":
                            tiles[x][y] = new StartTile(new Location(x, y), Properties.Resources.floor_tile_texture, this);
                            start = new Location(x, y);
                            break;
                        case "Grunt":
                            entities.Add(new Grunt(new Location(x, y), this));
                            break;
                        case "Illuminatie":
                            entities.Add(new Illuminatie(new Location(x, y), this));
                            break;
                    }
                }
            }
            speler = new Player(start, this);
        }
示例#12
0
 public ShrekTile(Location init, Image floor, Level level)
     : base(init, TileType.shrek, false, Properties.Resources.dank_shrek, level)
 {
     this.floor = floor;
 }
示例#13
0
 //properties geven
 public StartTile(Location init, Image floor, Level level)
     : base(init, TileType.floor, false, Properties.Resources.floor_tile_texture, level)
 {
     this.floor = floor;
 }