Exemplo n.º 1
0
        //----------------------//------------------------//

        public Player(Texture2D texture) : base(texture)
        {
            // Stand
            CharacterSprite.CreateFrameList("stand", 140);
            CharacterSprite.AddCollider("stand", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("stand", new List <Rectangle>()
            {
                new Rectangle(0, 0, 32, 32),
                new Rectangle(32, 0, 32, 32),
                new Rectangle(64, 0, 32, 32),
                new Rectangle(96, 0, 32, 32),
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            // Stand with hat
            CharacterSprite.CreateFrameList("stand_with_hat", 140);
            CharacterSprite.AddCollider("stand_with_hat", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("stand_with_hat", new List <Rectangle>()
            {
                new Rectangle(128, 192, 32, 64),
                new Rectangle(160, 192, 32, 64),
                new Rectangle(192, 192, 32, 64),
                new Rectangle(224, 192, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            // Walking
            CharacterSprite.CreateFrameList("walking", 120);
            CharacterSprite.AddCollider("walking", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("walking", new List <Rectangle>()
            {
                new Rectangle(128, 0, 32, 32),
                new Rectangle(160, 0, 32, 32),
                new Rectangle(192, 0, 32, 32),
                new Rectangle(224, 0, 32, 32),
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            // Walking with hat
            CharacterSprite.CreateFrameList("walking_with_hat", 220);
            CharacterSprite.AddCollider("walking_with_hat", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("walking_with_hat", new List <Rectangle>()
            {
                new Rectangle(32, 256, 32, 64),
                new Rectangle(64, 256, 32, 64),
                new Rectangle(96, 256, 32, 64),
                new Rectangle(128, 256, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            // Jumping
            CharacterSprite.CreateFrameList("jumping", 0);
            CharacterSprite.AddCollider("jumping", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("jumping", new List <Rectangle>()
            {
                new Rectangle(0, 32, 32, 32)
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            // Sword Attack
            CharacterSprite.CreateFrameList("attack_sword", 70);
            CharacterSprite.AddCollider("attack_sword", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFramesToAttack("attack_sword", 1, 2);
            CharacterSprite.AddFrames("attack_sword", new List <Rectangle>()
            {
                new Rectangle(32, 32, 32, 32),
                new Rectangle(64, 32, 64, 32),
                new Rectangle(128, 32, 64, 32),
                new Rectangle(192, 32, 64, 32)
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            CharacterSprite.AddAttackCollider("attack_sword", new List <List <Rectangle> >()
            {
                new List <Rectangle>()
                {
                },
                new List <Rectangle>()
                {
                    new Rectangle(31, 14, 32, 6)
                },
                new List <Rectangle>()
                {
                    new Rectangle(31, 14, 32, 6)
                }
            }, 64);

            // Aerial Attack
            CharacterSprite.CreateFrameList("attack_aerial", 50);
            CharacterSprite.AddCollider("attack_aerial", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("attack_aerial", new List <Rectangle>()
            {
                new Rectangle(0, 64, 64, 64),
                new Rectangle(64, 64, 64, 64),
                new Rectangle(128, 64, 64, 64),
                new Rectangle(192, 64, 64, 64)
            }, new int[] { 0, 0, -32, -32 }, new int[] { -32, 0, 0, -32 });
            CharacterSprite.AddAttackCollider("attack_aerial", new List <List <Rectangle> >()
            {
                new List <Rectangle>()
                {
                    new Rectangle(25, -21, 27, 21),
                    new Rectangle(31, 0, 25, 27)
                },

                new List <Rectangle>()
                {
                    new Rectangle(32, 25, 21, 27),
                    new Rectangle(5, 31, 27, 25)
                },

                new List <Rectangle>()
                {
                    new Rectangle(-20, 32, 27, 21),
                    new Rectangle(-24, 5, 25, 27)
                },

                new List <Rectangle>()
                {
                    new Rectangle(-21, -20, 21, 27),
                    new Rectangle(0, -24, 27, 25)
                }
            }, 64);
            CharacterSprite.AddFramesToAttack("attack_aerial", 0, 1, 2, 3);

            // Shot Attack
            CharacterSprite.CreateFrameList("attack_shot", 80);
            CharacterSprite.AddCollider("attack_shot", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFramesToAttack("attack_shot", 2);
            CharacterSprite.AddFrames("attack_shot", new List <Rectangle>()
            {
                new Rectangle(0, 128, 32, 32),
                new Rectangle(32, 128, 64, 32),
                new Rectangle(96, 128, 64, 32),
                new Rectangle(160, 128, 64, 32)
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            // Shot Attack Jumping
            CharacterSprite.CreateFrameList("attack_shot_jumping", 50);
            CharacterSprite.AddCollider("attack_shot_jumping", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFramesToAttack("attack_shot_jumping", 3);
            CharacterSprite.AddFrames("attack_shot_jumping", new List <Rectangle>()
            {
                new Rectangle(0, 160, 32, 32),
                new Rectangle(32, 160, 64, 32),
                new Rectangle(96, 160, 64, 32),
                new Rectangle(160, 160, 64, 32)
            }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 0, 0, 0 });

            // Hat Received
            CharacterSprite.CreateFrameList("hat_received", 1000, false);
            CharacterSprite.AddCollider("hat_received", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("hat_received", new List <Rectangle>()
            {
                new Rectangle(0, 192, 32, 64),
                new Rectangle(32, 192, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            // Thumbs up
            CharacterSprite.CreateFrameList("thumbs_up", 140, false);
            CharacterSprite.AddCollider("thumbs_up", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("thumbs_up", new List <Rectangle>()
            {
                new Rectangle(64, 192, 32, 64),
                new Rectangle(96, 192, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            // Looking up
            CharacterSprite.CreateFrameList("looking_up", 140);
            CharacterSprite.AddCollider("looking_up", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("looking_up", new List <Rectangle>()
            {
                new Rectangle(0, 256, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            // Looking up with hat
            CharacterSprite.CreateFrameList("looking_up_with_hat", 140);
            CharacterSprite.AddCollider("looking_up_with_hat", new Rectangle(9, 2, 17, 30));
            CharacterSprite.AddFrames("looking_up_with_hat", new List <Rectangle>()
            {
                new Rectangle(0, 192, 32, 64),
            }, new int[] { 0, 0, 0, 0 }, new int[] { -32, -32, -32, -32 });

            Position = new Vector2(32, 160);

            // Attacks setup
            _attackFrameList = new string[]
            {
                "attack_sword",
                "attack_aerial",
                "attack_shot",
                "attack_shot_jumping"
            };

            AttackCooldown  = 200f;
            _deathTick      = 0.0f;
            _requestRespawn = false;
            _active         = true;
            _keysLocked     = false;

            // Hat drop
            var hatTexture = ImageManager.loadMisc("PeteHat");

            _hatSprite = new AnimatedSprite(hatTexture, new Rectangle[] {
                new Rectangle(0, 0, 96, 64),
                new Rectangle(96, 0, 96, 64),
                new Rectangle(192, 0, 96, 64),
                new Rectangle(288, 0, 96, 64),
                new Rectangle(384, 0, 96, 64),
                new Rectangle(0, 64, 96, 64),
                new Rectangle(96, 64, 96, 64),
                new Rectangle(192, 64, 96, 64),
                new Rectangle(288, 64, 96, 64),
                new Rectangle(384, 64, 96, 64),
            }, 100, Vector2.Zero);
            _hatSprite.Origin = new Vector2(50, 37);

            // Flash texture
            _flashTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            _flashTexture.SetData(new Color[] { Color.White });

            // SEs init
            _aerialAttackSe    = SoundManager.LoadSe("Aerial");
            _normalAttackSe    = SoundManager.LoadSe("Sword");
            _shotEmptyAttackSe = SoundManager.LoadSe("ShotPeteEmpty");
            _footstepSe        = SoundManager.LoadSe("Footstep");
            _hatSe             = SoundManager.LoadSe("Hat");
        }