Ejemplo n.º 1
0
        public void LoadContent(string _enemy)
        {
            string enemyString = string.Empty;

            switch (_enemy)
            {
            case "e":
                enemyString = "Sprites/Enemies/muffinman";
                break;

            default:
                enemyString = "Sprites/Enemies/muffinman";
                break;
            }
            // Load animated textures.
            Texture2D tex = Level.Content.Load <Texture2D>(enemyString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }
            Animation anim = new Animation();

            anim.LoadAnimation("Walk", 0, new List <int>
            {
                0,
                1
            }, 4, true);
            SpriteAnimations.Add("Walk", anim);
            anim = new Animation();
            anim.LoadAnimation("Dead", 0, new List <int>
            {
                2,
                3,
                4,
                5
            }, 36, false);
            anim.AnimationCallBack(DeadAnimEnd);
            SpriteAnimations.Add("Dead", anim);
            // Calculate bounds within texture size.
            // subtract 10 from width and height to remove a 5px buffer
            // around the enemy.
            int width  = FrameWidth - 10;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 10;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
            SpriteAnimations[currentAnim].ResetPlay();
        }
Ejemplo n.º 2
0
        public void LoadContent(string _collectable)
        {
            string sheetString = string.Empty;

            switch (_collectable)
            {
            case "s":
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.Black;
                break;

            case "S":
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.Gold;
                break;

            default:
                sheetString = "Sprites/Collectables/scribbles";
                colorOffset = Color.White;
                break;
            }
            // Load animated textures.
            Texture2D tex = Level.Content.Load <Texture2D>(sheetString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }
            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int>
            {
                0,
                1,
                2,
                3
            }, 16, true);
            SpriteAnimations.Add("Idle", anim);
            // Calculate bounds within texture size.
            // subtract 4 from height to remove a 2px buffer
            // around the collectable.
            int width  = FrameWidth;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
            SpriteAnimations[currentAnim].ResetPlay();
        }
Ejemplo n.º 3
0
        public void LoadContent(string _collectable)
        {
            string sheetString = string.Empty;

            switch (_collectable)
            {
            case "s":
                sheetString   = "Sprites//Collectable/scribbles";
                colorOffset   = Color.Black;
                pointsAwarded = 500;
                break;

            case "S":
                sheetString   = "Sprites/Collectable/scribbles";
                colorOffset   = Color.Gold;
                pointsAwarded = 1000;
                break;

            default:
                sheetString = "Sprites/Collectable/scribbles";
                colorOffset = Color.White;
                break;
            }

            Texture2D tex = Level.Content.Load <Texture2D>(sheetString);

            if (!SpriteTextures.Contains(tex))
            {
                SpriteTextures.Add(tex);
            }

            Animation anim = new Animation();

            anim.LoadAnimation("Idle", 0, new List <int> {
                0, 1, 2, 3
            }, 16, true);
            SpriteAnimations.Add("Idle", anim);

            int width  = FrameWidth;
            int left   = (FrameWidth - width) / 2;
            int height = FrameHeight - 4;
            int top    = FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);

            SpriteAnimations[currentAnim].ResetPlay();
        }