Exemplo n.º 1
0
 public void GetPropertyTest()
 {
     form = new Form1();
     Player p = new Player(10, 5, 0, 0, 50, 50, form);
     Assert.IsTrue(p.pos_y is int);
     Assert.IsTrue(p.getObjectImage() is Image);
 }
Exemplo n.º 2
0
 public void MoveTest()
 {
     form = new Form1();
     Player gameObject = new Player(health, speed_x, x, y, width, height, form);
     gameObject.changeDirections(Keys.Down, true);
     gameObject.Move();
     int new_x = gameObject.pos_x;
     int new_y = gameObject.pos_y;
     Console.WriteLine("Old y = {0}, and new y = {1}", y, new_y);
     Assert.IsTrue(new_x != x || new_y != y);
 }
Exemplo n.º 3
0
        public Enemy(int pos_x, int pos_y, int width, int height, int speed_x, int speed_y, int damage, int health, List<GameObject> props, Form1 form)
            : base(pos_x, pos_y, width, height, speed_x, speed_y, damage, health, form)
        {
            Type = ObjectType.ENEMY;

            foreach(GameObject player in props)
            {
                if(player.Type.Equals(ObjectType.PLAYER))
                {
                    player1 = (Player)player;
                }

            }
        }
Exemplo n.º 4
0
        public void Handle(List<GameObject> game_objects, Form1 game_Form,string levelslug)
        {
            // gets an XML file from a specific directory
            this.Parse(levelslug);
            // parser fills the variable list data

            // for each item in var data
            foreach (List<string> item in data)
            {
                if (item[0] == "player")
                {
                    //create new object
                    player1 = new Player(Int32.Parse(item[1]), Int32.Parse(item[2]), Int32.Parse(item[3]), Int32.Parse(item[4]), Int32.Parse(item[5]), Int32.Parse(item[6]), game_Form);
                    //Adds object to the list
                    game_objects.Add(player1);
                }
                if (item[0] == "finish")
                {
                    //create new object
                    finish1 = new Finish(Int32.Parse(item[1]), Int32.Parse(item[2]), Int32.Parse(item[3]), Int32.Parse(item[4]), game_Form);
                    //Adds object to the list
                    game_objects.Add(finish1);
                }
                if (item[0] == "enemy")
                {
                    //create new object
                    Enemy_Following enemy = new Enemy_Following(Int32.Parse(item[3]), Int32.Parse(item[4]), Int32.Parse(item[2]), game_objects, game_Form);
                    //Adds object to the list
                    game_objects.Add(enemy);
                }
                if (item[0] == "bolt")
                {
                    //create new object
                    Bolt bolt = new Bolt(Int32.Parse(item[3]), Int32.Parse(item[4]), game_objects, game_Form);
                    //Adds object to the list
                    game_objects.Add(bolt);
                }
                if (item[0] == "water")
                {
                    //create new object
                    Puddle water = new Puddle(Int32.Parse(item[3]), Int32.Parse(item[4]), game_objects, game_Form);
                    //Adds object to the list
                    game_objects.Add(water);
                }
                if (item[0] == "logs")
                {
                    //create new object
                    Pile_of_Logs logs = new Pile_of_Logs(Int32.Parse(item[3]), Int32.Parse(item[4]), game_objects, game_Form);
                    //Adds object to the list
                    game_objects.Add(logs);
                }
                if (item[0] == "static")
                {
                    //create new object
                    Wall wall = new Wall(Int32.Parse(item[1]), Int32.Parse(item[2]), game_Form);
                    //Adds object to the list
                    game_objects.Add(wall);
                }

            }
        }