Vector2 velocity; //current veloctity of the enemy #endregion Fields #region Constructors /// <summary> /// Constructor for the Enemy class, creates a new object of type Enemy. /// </summary> /// <param name="level">current level object</param> /// <param name="position">starting position of the enemy sprite</param> /// <param name="spriteSet">string representing the enemy type to create</param> /// <param name="enemyTextures">earray containing the enemy animation textures</param> /// <param name="walkLeft">should the enemy walk left?</param> public Enemy(Level level, Vector2 position, String spriteSet, Texture2D[] enemyTextures, bool walkLeft) { switch (spriteSet) //switch to the required enemy type and initialise it { case "Armour": this.enemyType = EnemyType.Armour; armour = new Armour(); this.textureStart = armour.textureStart; this.value = armour.value; this.speed = armour.speed; break; case "Body": this.enemyType = EnemyType.Body; body = new Body(); this.textureStart = body.textureStart; this.value = body.value; this.speed = body.speed; break; case "Robe": this.enemyType = EnemyType.Robe; robe = new Robe(); this.textureStart = robe.textureStart; this.value = robe.value; this.speed = robe.speed; break; } this.level = level; //initialise the level object this.position = position; //initialise the starting position of the enemy if (walkLeft) //if the enemy is to walk left this.direction = FaceDirection.Left; //set directional state to left else //if the enemy is to walk right this.direction = FaceDirection.Right; //set directional state to right this.enemyTextures = enemyTextures; //initialise the array of enemy textures active = true; //enemy is currently active (i.e. running) deactiveLimit = 0; //the enemy has been deactivated for 0 iterations defeated = false; //enemy is not yet defeated //load the remaining enemy content LoadContent(); }
/// <summary> /// Constructs an instance of player. /// </summary> /// <param name="level">current level object</param> /// <param name="position">start position of player</param> public Player(Level level, Vector2 position) { flip = SpriteEffects.None; this.level = level; this.position = position; }