Exemple #1
0
 public Knight(AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
     int expLevel, int strength, int defense, Vector2 speed, List<Vector2> patrolTargets, MainCharacter mainCharacter,
     GameplayScreen gameplayScreen)
     : base(sprite, position, hitPoints, manaPoints, expLevel, strength, defense, speed,
     patrolTargets, mainCharacter, gameplayScreen)
 {
 }
Exemple #2
0
 /// <summary>
 /// Constructor 2
 /// </summary>
 /// <param name="sprite">The animation sprite of the character</param>
 /// <param name="position">The position of the character on the map</param>
 /// <param name="numCoins">The number of coins the character starts off </param>
 /// <param name="speed">The movement speed of the character.</param>
 /// <param name="gameplayScreen">The gameplay screen for the game.</param>
 public Character(AnimatedSprite sprite, Vector2 position, int numCoins, Vector2 speed, GameplayScreen gameplayScreen)
 {
     this.CharacterSprite = sprite;
     this.Position = position;
     this.numCoins = numCoins;
     this.speed = speed;
     this.gameplayScreen = gameplayScreen;
 }
Exemple #3
0
        public EnemyCharacter(AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
            int expLevel, int strength, int defense, Vector2 speed,
            List<Vector2> patrolTargets, MainCharacter mainCharacter, GameplayScreen gameplayScreen)
            : base(sprite, position, hitPoints, manaPoints, expLevel, strength, defense, speed, gameplayScreen)
        {
            this.patrolTargets = patrolTargets;
            this.PlayerCharacter = mainCharacter;

            DirectionStuckIn = MoveDirection.None;
            UnstickAttempts = 0;
            randomMover = new Random();

            currentState = EnemyState.Patrol;
            currentTarget = patrolTargets[0];
        }
        public CombatableCharacter(AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
            int expLevel, int strength, int defense, Vector2 speed, GameplayScreen gameplayScreen)
            : base(sprite, position, speed, gameplayScreen)
        {
            this.HitPoints = hitPoints;
            this.ManaPoints = manaPoints;
            this.ExpLevel = expLevel;
            this.Strength = strength;
            this.Defense = defense;
            IsInPain = false;

            TextureData =
                new Color[CharacterSprite.Texture.Width * CharacterSprite.Texture.Height];
            CharacterSprite.Texture.GetData(TextureData);
        }
Exemple #5
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="name">Name of the main character.</param>
 /// <param name="sprite">The animated sprite object for the main chracter.</param>
 /// <param name="position">The initial position of the character.</param>
 /// <param name="hitPoints">The number of hitpoints (life) the character has</param>
 /// <param name="manaPoints">The number of mana points the character has</param>
 /// <param name="expLevel">The number of EXP to level up</param>
 /// <param name="strength">The strength attribute</param>
 /// <param name="defense">The defense attribute</param>
 /// <param name="speed">The movement speed of the character</param>
 /// <param name="gameplayScreen">The gameplay screen for the game.</param>
 public MainCharacter(String name, AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
     int expLevel, int strength, int defense, Vector2 speed, GameplayScreen gameplayScreen)
     : base(sprite, position, hitPoints, manaPoints, expLevel, strength, defense, speed, gameplayScreen)
 {
     this.Name = name;
 }
Exemple #6
0
        public List<EnemyCharacter> GetEnemies(String mapFilename, MainCharacter mainCharacter, GameplayScreen gameplayScreen)
        {
            var mapXML = XElement.Load(game.Content.RootDirectory + "\\" + mapFilename + ".tmx");
            var objectElements = mapXML.Elements("objectgroup").Elements().ToList();

            List<EnemyCharacter> enemies = new List<EnemyCharacter>();
            foreach (var obj in objectElements)
            {
                string type = null;
                if (obj.Attribute("type") != null)
                {
                    type = obj.Attribute("type").Value.ToString().ToLower();
                }
                if (type != null && type.Equals("enemy"))
                {
                    var properties = obj.Elements("properties").Elements().ToList();
                    string name = obj.Attribute("name").Value.ToString().ToLower();

                    // default attributes
                    int hp = 100;
                    int mp = 100;
                    int xp = 0;
                    int strength = 10;
                    int defense = 10;

                    int xcoord = Convert.ToInt32(obj.Attribute("x").Value);
                    int ycoord = Convert.ToInt32(obj.Attribute("y").Value);
                    foreach (var prop in properties)
                    {
                        string propName = prop.Attribute("name").ToString().ToLower();
                        switch (propName)
                        {
                            case "strength":
                                strength = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "hp":
                                hp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "mp":
                                mp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "defense":
                                defense = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "xp":
                                xp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                        }
                    }

                    switch (name.ToLower())
                    {
                        case "knight":
                            Texture2D knightTexture = game.Content.Load<Texture2D>(@"Characters\charchip01-2-1");
                            Point knightTextureFrameSize = new Point(32, 32);
                            int knightCollisionOffset = 0;
                            Point knightInitialFrame = new Point(1, 0);
                            Point knightSheetSize = new Point(3, 4);
                            Vector2 knightSpeed = new Vector2(1, 1);
                            Vector2 initialKnightPos = new Vector2(xcoord, ycoord);

                            AnimatedSprite knightSprite = new AnimatedSprite(
                                knightTexture, knightTextureFrameSize, knightCollisionOffset, knightInitialFrame, knightSheetSize);

                            List<Vector2> knightTargets = new List<Vector2>() {
                                new Vector2(xcoord - 100, ycoord), new Vector2(xcoord + 100, ycoord) };

                            EnemyCharacter knightEnemy = new Knight(knightSprite, initialKnightPos, hp, mp, xp,
                                strength, defense, knightSpeed, knightTargets, mainCharacter, gameplayScreen);

                            Texture2D knightSwordTexture = game.Content.Load<Texture2D>(@"Attacks\small_sword");
                            int knightSwordMsPerFrame = 16;
                            float knightSwordScale = 0.4f;
                            Vector2 knightSwordRotationPoint = new Vector2(7, 150);

                            SwordSprite knightSwordSprite = new SwordSprite(knightSwordTexture, knightSwordMsPerFrame, knightSwordScale,
                                knightSwordRotationPoint, knightEnemy);
                            knightEnemy.Sword = knightSwordSprite;

                            enemies.Add(knightEnemy);

                            break;
                    }
                }
            }

            return enemies;
        }
Exemple #7
0
 /// <summary>
 /// Constructor 1
 /// </summary>
 /// <param name="sprite">The animation sprite of the character</param>
 /// <param name="position">The position to place the character</param>
 /// <param name="speed">The movement speed of the character</param>
 /// <param name="gameplayScreen">The gameplay screen for the game.</param>
 public Character(AnimatedSprite sprite, Vector2 position, Vector2 speed, GameplayScreen gameplayScreen)
     : this(sprite, position, 0, speed, gameplayScreen)
 {
 }
 public NonPlayableCharacter(AnimatedSprite sprite, Vector2 position, Vector2 speed, GameplayScreen gameplayScreen)
     : base(sprite, position, speed, gameplayScreen)
 {
 }