Пример #1
0
 public void AddAnimation(string name, int frames, int row, AnimationClass animation)
 {
     Rectangle[] artSource = new Rectangle[frames];
     for (int i = 0; i < frames; i++)
     {
         artSource[i] = new Rectangle(i * width, row * height, width, height);
     }
     animation.Frames    = frames;
     animation.artSource = artSource;
     Animations.Add(name, animation);
 }
Пример #2
0
        public AnimationClass Copy()
        {
            AnimationClass copy = new AnimationClass();

            copy.artSource     = artSource;
            copy.color         = color;
            copy.origin        = origin;
            copy.rotation      = rotation;
            copy.scale         = scale;
            copy.spriteEffect  = spriteEffect;
            copy.loopAnimation = loopAnimation;
            copy.Frames        = Frames;
            return(copy);
        }
Пример #3
0
        protected override void LoadContent()
        {
            /*                   CHARACTER AND ENEMY CONTENT                  */



            Enemies   = new List <Enemy>();
            Fireballs = new List <AnimatedSprite>();
            AnimationClass animated = new AnimationClass();

            //Constructor (Name, Texture, Frames, Rows)

            Sara               = new Hero("Sara", Content.Load <Texture2D>("sara_move_rows"), 5, 6);
            Demon              = new Enemy("Demon", Content.Load <Texture2D>("Demon_Walk"), 4, 2);
            Demon1             = new Enemy("Demon", Content.Load <Texture2D>("Demon_Walk"), 4, 2);
            Demon2             = new Enemy("Demon", Content.Load <Texture2D>("Demon_Walk"), 4, 2);
            Sorcerer           = new Enemy("Sorcerer", Content.Load <Texture2D>("Sorcerer_Cast"), 6, 1);
            Dragon             = new Dragon("Dragon", Content.Load <Texture2D>("Dragon_Move_S"), 8, 4);
            sorcererFireball   = new AnimatedSprite("Sorc_Fireball", Content.Load <Texture2D>("Dragon_Fireball"), 4, 4);
            dragonFireball     = new AnimatedSprite("Dragon_Fireball", Content.Load <Texture2D>("Dragon_Fireball"), 4, 4);
            saraFireball       = new AnimatedSprite("Sara_Fireball", Content.Load <Texture2D>("Dragon_Fireball"), 4, 4);
            saraFireball.alive = false;


            Enemies.Add(Demon);
            Enemies.Add(Demon1);
            Enemies.Add(Demon2);
            Enemies.Add(Sorcerer);
            Enemies.Add(Dragon);

            Fireballs.Add(sorcererFireball);
            Fireballs.Add(dragonFireball);
            Fireballs.Add(saraFireball);

            //Add Animations (Dictionary Sting Key, Frames, Row of Animation, AnimationClass)
            Sara.AddAnimation("Left", 5, 0, animated.Copy());
            Sara.AddAnimation("Right", 3, 1, animated.Copy());
            Sara.AddAnimation("Down", 5, 2, animated.Copy());
            Sara.AddAnimation("Up", 5, 3, animated.Copy());
            Sara.AddAnimation("Scared", 5, 4, animated.Copy());
            Sara.AddAnimation("Sad", 5, 5, animated.Copy());
            Demon.AddAnimation("Down", 4, 0, animated.Copy());
            Demon.AddAnimation("Up", 4, 1, animated.Copy());
            Demon1.AddAnimation("Down", 4, 0, animated.Copy());
            Demon1.AddAnimation("Up", 4, 1, animated.Copy());
            Demon2.AddAnimation("Down", 4, 0, animated.Copy());
            Demon2.AddAnimation("Up", 4, 1, animated.Copy());
            Sorcerer.AddAnimation("Cast", 6, 0, animated.Copy());
            Dragon.AddAnimation("Up", 8, 0, animated.Copy());
            Dragon.AddAnimation("Down", 8, 1, animated.Copy());
            Dragon.AddAnimation("Left", 8, 2, animated.Copy());
            Dragon.AddAnimation("Right", 8, 3, animated.Copy());
            sorcererFireball.AddAnimation("Right", 4, 0, animated.Copy());
            dragonFireball.AddAnimation("Left", 4, 1, animated.Copy());
            saraFireball.AddAnimation("Right", 4, 0, animated.Copy());
            saraFireball.AddAnimation("Left", 4, 1, animated.Copy());
            saraFireball.AddAnimation("Up", 4, 2, animated.Copy());
            saraFireball.AddAnimation("Down", 4, 3, animated.Copy());
            //Set Animation
            Sara.Animation             = "Right";
            Sorcerer.Animation         = "Cast";
            Demon.Animation            = "Down";
            Demon1.Animation           = "Down";
            Demon2.Animation           = "Down";
            Dragon.Animation           = "Down";
            sorcererFireball.Animation = "Right";
            dragonFireball.Animation   = "Left";
            saraFireball.Animation     = "Right";


            //Set Movement (Minimum X, Minimum Y, Maximum X, Maximum Y, Speed)
            Sara.speed             = 3.0f;
            sorcererFireball.speed = 5.0f;
            dragonFireball.speed   = -5.0f;
            Demon.SetEnemyMovement(0, 0, 0, 347, 1.5f);
            Demon1.SetEnemyMovement(0, 0, 0, 347, 1.25f);
            Demon2.SetEnemyMovement(0, 0, 0, 347, 1.5f);
            Sorcerer.SetEnemyMovement(0, 0, 500, 0, 0);
            Dragon.SetEnemyMovement(0, 0, 0, 320, 2.5f);

            Sara.position             = new Vector2(30, 690);
            Demon.position            = new Vector2(158, 2);
            Demon1.position           = new Vector2(159 + Demon.width, 2);
            Demon2.position           = new Vector2(160 + (Demon.width * 2), 2);
            Sorcerer.position         = new Vector2(25, 510);
            Dragon.position           = new Vector2(924, 5);
            sorcererFireball.position = new Vector2(Sorcerer.position.X + Sorcerer.width, 530);
            dragonFireball.position   = new Vector2(Dragon.position.X - (dragonFireball.width / 2), Dragon.position.Y + 10);


            //Set Health and Damage
            Sara.Set_Health_Damage(300, 1);
            Demon.Set_Health_Damage(10000, 150);
            Demon1.Set_Health_Damage(10000, 150);
            Demon2.Set_Health_Damage(10000, 150);
            Sorcerer.Set_Health_Damage(3, 100);
            Dragon.Set_Health_Damage(15, 300);
            sorcererFireball.Set_Health_Damage(0, 50);
            dragonFireball.Set_Health_Damage(10000, 100);
            saraFireball.Set_Health_Damage(0, 1);



            //Set Frames Per Second (1 Second / Value = Interval)
            Sara.FramesPerSecond             = 10;
            Demon.FramesPerSecond            = 8;
            Demon1.FramesPerSecond           = 8;
            Demon2.FramesPerSecond           = 8;
            Sorcerer.FramesPerSecond         = 2;
            Dragon.FramesPerSecond           = 8;
            sorcererFireball.FramesPerSecond = 12;
            dragonFireball.FramesPerSecond   = 12;
            saraFireball.FramesPerSecond     = 12;

            Sara.loopAnimation             = true;
            Demon.loopAnimation            = true;
            Demon1.loopAnimation           = true;
            Demon2.loopAnimation           = true;
            Sorcerer.loopAnimation         = true;
            Dragon.loopAnimation           = true;
            sorcererFireball.loopAnimation = true;
            dragonFireball.loopAnimation   = true;
            saraFireball.loopAnimation     = true;



            /*                   WORLD AND BARRIER CONTENT                  */


            totalTime    = Content.Load <SpriteFont>("TotalTime");
            timePosition = new Vector2(0, 745);
            music        = Content.Load <Song>("bg_music");
            MediaPlayer.Play(music);             //<=== UN-COMMENT FOR MUSIC TO PLAY ====
            Barriers = new List <Rectangle>();

            //Constructor (Name, Texture, Frames, Rows)
            spriteBatch = new SpriteBatch(GraphicsDevice);

            background = new SpriteManager("background", Content.Load <Texture2D>("Background"), 1, 1);
            health_bar = new AnimatedSprite("health_bar", Content.Load <Texture2D>("Health_Bar"), 1, 1);
            beach      = new AnimatedSprite("beach", Content.Load <Texture2D>("Beach"), 6, 1);

            outL = new Rectangle(-100, 0, 100, 768);
            outR = new Rectangle(1024, 0, 100, 768);
            outT = new Rectangle(0, -100, 1024, 100);
            outB = new Rectangle(0, 768, 1024, 100);

            mapLeft   = new Rectangle(0, 0, 25, 768);
            mapRight  = new Rectangle(1014, 0, 10, 768);
            mapTop    = new Rectangle(0, 0, 1024, 5);
            mapBottom = new Rectangle(0, 743, 1024, 25);

            beachBarrier = new Rectangle(832, 544, 192, 224);
            beachWall    = new Rectangle(644, 525, 188, 4);

            platformLeft        = new Rectangle(658, 0, 15, 290);
            platformBottomLeft  = new Rectangle(673, 288, 175, 10);
            platformBottomRight = new Rectangle(949, 288, 80, 10);

            boulderTop    = new Rectangle(752, 68, 163, 43);
            boulderBottom = new Rectangle(752, 183, 163, 48);

            middleWallTop   = new Rectangle(132, 448, 528, 2);
            middleWallLeft  = new Rectangle(132, 448, 345, 54);
            middleWallRight = new Rectangle(555, 448, 105, 54);

            bottomWallBottom = new Rectangle(0, 640, 740, 4);
            bottomWallLeft   = new Rectangle(0, 589, 270, 55);
            bottomWallRight  = new Rectangle(341, 589, 239, 55);

            cornerTreeLeft  = new Rectangle(660, 453, 49, 70);
            cornerTreeRight = new Rectangle(680, 490, 58, 36);

            cageLeftTop     = new Rectangle(132, 0, 47, 105);
            cageLeftBottom  = new Rectangle(132, 238, 47, 210);
            cageBottom      = new Rectangle(155, 355, 370, 5);
            cageRightTop    = new Rectangle(506, 262, 47, 190);
            cageRightBottom = new Rectangle(506, 0, 47, 105);

            Barriers.Add(outT);
            Barriers.Add(outB);
            Barriers.Add(outR);
            Barriers.Add(outL);
            Barriers.Add(mapLeft);
            Barriers.Add(mapRight);
            Barriers.Add(mapTop);
            Barriers.Add(mapBottom);
            Barriers.Add(beachBarrier);
            Barriers.Add(beachWall);
            Barriers.Add(platformLeft);
            Barriers.Add(platformBottomLeft);
            Barriers.Add(platformBottomRight);
            Barriers.Add(boulderTop);
            Barriers.Add(boulderBottom);
            Barriers.Add(middleWallTop);
            Barriers.Add(middleWallLeft);
            Barriers.Add(middleWallRight);
            Barriers.Add(bottomWallBottom);
            Barriers.Add(bottomWallLeft);
            Barriers.Add(bottomWallRight);
            Barriers.Add(cornerTreeLeft);
            Barriers.Add(cornerTreeRight);
            Barriers.Add(cageLeftTop);
            Barriers.Add(cageLeftBottom);
            Barriers.Add(cageBottom);
            Barriers.Add(cageRightTop);
            Barriers.Add(cageRightBottom);
            //Add Animations (Dictionary String Key, Number of Frames, Row of Animation, Animation Class)
            background.AddAnimation("Background", 1, 0, animated.Copy());
            beach.AddAnimation("Beach", 6, 0, animated.Copy());
            health_bar.AddAnimation("Health", 1, 0, animated.Copy());

            //Set Animation
            background.Animation = "Background";
            beach.Animation      = "Beach";
            health_bar.Animation = "Health";

            //Set Locations
            beach.position      = new Vector2(832, 544);
            health_bar.position = new Vector2(5, 5);

            //Enable Animation Loop
            beach.loopAnimation = true;

            //Set Frames Per Second (1 Second / Value = Interval)
            beach.FramesPerSecond = 4;
        }