Example #1
0
        // Constructor
        /// <summary>
        /// Create a new Player object
        /// </summary>
        /// <param name="location">The location to draw the Player at when it's
        /// first instantiated</param>
        /// <param name="healthBarBackground">The background texture of this
        /// Player's health bar</param>
        /// <param name="healthBarForeground">The foreground texture of this
        /// Player's health bar (the overlay texture)</param>
        public Player(Vector2 location, Texture2D healthBarBackground,
                      Texture2D healthBarForeground) : base(playerSprite, location,
                                                            PLAYER_HEALTH, PLAYER_SPEED, 0.1, healthBarBackground,
                                                            healthBarForeground, font)
        {
            o_position.Width  = 25;
            o_position.Height = 50;

            frames[IDLE_FRAME] = new Rectangle(spriteSheet.Width - 561, 0, 561, 900);
            frames[JUMP_FRAME] = new Rectangle(spriteSheet.Width - 1913 - 610, 0, 605, 900);
            frames[2]          = new Rectangle(spriteSheet.Width - 561 - 640, 0, 561, 900);
            frames[3]          = new Rectangle(0, 0, 823, 901);

            walkIndicies = new int[2] {
                2, 0
            };
            attackIndicies = new int[5] {
                0, 1, 3, 1, 0
            };

            b_position = new Rectangle(
                (int)location.X,
                (int)location.Y,
                FRAME_SIZE / BATTLE_PROPORTION,
                FRAME_SIZE / BATTLE_PROPORTION);

            B_LocX = location.X;
            B_LocY = location.Y;

            damage           = PLAYER_DAMAGE;
            damageCycleIndex = 2;

            // Create the QuickTimeEvent for this Player
            quickTimeEvent = new QuickTimeEvent(new List <ActivationFunction>
            {
                ExtraDamage, NextAttackFrame
            }, Keys.E, PLAYER_TIMER);

            jumpSpeed        = 4;
            jumpAcceleration = 17;
            above            = new Rectangle(this.O_X, this.O_Y - 11, this.O_Width, 10);
            below            = new Rectangle(this.O_X, this.O_Y + this.O_Height, this.O_Width, 10);
            right            = new Rectangle(this.O_X + this.O_Width, this.O_Y, 10, this.O_Height);
            left             = new Rectangle(this.O_X - 11, this.O_Y, 10, this.O_Height);
        }
Example #2
0
        //protected double coolDownTimer; // The dodge cooldown timer. Color should change while dodging, return to normal after, and ability to dodge again returns after cooldown


        // Properties


        // Constructor
        /// <summary>
        /// Create a new Enemy
        /// </summary>
        /// <param name="spriteSheet">All sprites for this Enemy in a single
        /// image. Must have (an) idle, walking, and attack frame(s).</param>
        /// <param name="location">The base location of this Enemy when they are
        /// instantiated</param>
        /// <param name="health">The maximum health value for this Enemy
        /// </param>
        /// <param name="speed">The value used to determine the chronological
        /// order of attack during battles. Lower numbers have higher priority.
        /// </param>
        /// <param name="timePerFrame">The time that a frame of animation draws
        /// for before advancing to the next frame</param>
        /// <param name="healthBarBackground">The background texture of the
        /// health bar texture for this Enemy</param>
        /// <param name="healthBarForeground">The foreground texture of the
        /// health bar texture for this Enemy (the overlay)</param>
        /// <param name="healthFont">The font of the text in the health bar
        /// </param>
        /// <param name="state">The current CharacterState of this Enemy when
        /// it's initiated</param>
        /// <param name="direction">Whether this Enemy should be
        /// instantiated facing right or left</param>
        public Enemy(Texture2D spriteSheet, Vector2 location,
                     int health, int speed, Texture2D healthBarBackground,
                     Texture2D healthBarForeground, SpriteFont healthFont,
                     double timePerFrame     = 0.1,
                     CharacterState state    = CharacterState.o_idle,
                     CharDirection direction = CharDirection.left) : base(spriteSheet,
                                                                          location, health, speed, timePerFrame, healthBarBackground,
                                                                          healthBarForeground, healthFont, state, direction)
        {
            frames = new Dictionary <int, Rectangle>(3);

            frames[IDLE_FRAME] = new Rectangle(0, 0, FRAME_SIZE, FRAME_SIZE);
            frames[1]          = new Rectangle(FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE);
            frames[2]          = new Rectangle(2 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE);

            walkIndicies = new int[2]
            {
                0, 2
            };
            attackIndicies = new int[5]
            {
                0, 1, 2, 1, 0
            };
            damageCycleIndex = 3;

            o_position.Width  = 50;
            o_position.Height = 50;

            b_position = new Rectangle(
                (int)location.X,
                (int)location.Y,
                FRAME_SIZE / BATTLE_PROPORTION,
                FRAME_SIZE / BATTLE_PROPORTION);

            B_LocX = location.X;
            B_LocY = location.Y;

            // Create the QuickTimeEvent for this Enemy
            //quickTimeTimer = BASE_ENEMY_TIMER;
            quickTimeEvent = new QuickTimeEvent(NullifyDamage,
                                                Microsoft.Xna.Framework.Input.Keys.Q, BASE_ENEMY_TIMER);

            //coolDownTimer = 0;
        }
Example #3
0
        // Properties


        // Constructor
        /// <summary>
        /// Create a new Ally
        /// </summary>
        /// <param name="spriteSheet">All sprites for this Ally in a single
        /// image. Must have (an) idle, walking, and attack frame(s).</param>
        /// <param name="location">The base location of this Ally when they are
        /// instantiated</param>
        /// <param name="health">The maximum health value for this Ally
        /// </param>
        /// <param name="speed">The value used to determine the chronological
        /// order of attack during battles. Lower numbers have higher priority.
        /// </param>
        /// <param name="timePerFrame">The time that a frame of animation draws
        /// for before advancing to the next frame</param>
        /// <param name="healthBarBackground">The background texture of the
        /// health bar texture for this Ally</param>
        /// <param name="healthBarForeground">The foreground texture of the
        /// health bar texture for this Ally (the overlay)</param>
        /// <param name="healthFont">The font of the text in the health bar
        /// </param>
        /// <param name="state">The current CharacterState of this Ally when
        /// it's initiated</param>
        /// <param name="direction">Whether this Ally should be
        /// instantiated facing right or left</param>
        public Ally(Texture2D spriteSheet, Vector2 location,
                    int health, int speed, Texture2D healthBarBackground,
                    Texture2D healthBarForeground, SpriteFont healthFont,
                    double timePerFrame     = 0.1,
                    CharacterState state    = CharacterState.o_idle,
                    CharDirection direction = CharDirection.right) : base(spriteSheet,
                                                                          location, health, speed, timePerFrame, healthBarBackground,
                                                                          healthBarForeground, healthFont, state, direction)
        {
            frames = new Dictionary <int, Rectangle>(3);

            frames[IDLE_FRAME] = new Rectangle(0, 0, FRAME_SIZE, FRAME_SIZE);
            frames[JUMP_FRAME] = new Rectangle(FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE);
            frames[2]          = new Rectangle(2 * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE);

            walkIndicies = new int[2] {
                0, 2
            };
            attackIndicies = new int[5] {
                0, 1, 2, 1, 0
            };

            o_position.Width  = 25;
            o_position.Height = 50;

            b_position = new Rectangle(
                (int)location.X,
                (int)location.Y,
                FRAME_SIZE / 3,
                FRAME_SIZE / 3);

            // Create the QuickTimeEvent for this Ally
            //quickTimeTimer = BASE_ALLY_TIMER;
            quickTimeEvent = new QuickTimeEvent(
                new List <ActivationFunction> {
                ExtraDamage, NextAttackFrame
            },
                Microsoft.Xna.Framework.Input.Keys.E, BASE_ALLY_TIMER);
        }