Beispiel #1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var ballTexture = Content.Load <Texture2D>(ASSET_NAME_BALL);

            _ball = new BallEntity(ballTexture, new Vector2(BALL_POS_X, BALL_POS_Y));

            _ballManager = new BallManager(_ball);

            var groundTexture = Content.Load <Texture2D>(ASSET_NAME_GROUND);

            _groundManager = new GroundManager(groundTexture, _ball, _entityManager);

            _ballInputController = new BallInputController(_ball);

            _scoreBoardFont = Content.Load <SpriteFont>(ASSET_NAME_SCORE_BOARD_FONT);
            _scoreBoard     = new ScoreBoardEntity(_scoreBoardFont, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), _ball);

            var wallTexture = Content.Load <Texture2D>(ASSET_NAME_WALL);

            _wallManager = new WallManager(wallTexture, _ball, _scoreBoard, _entityManager);

            _coinPickupSoundEffect = Content.Load <SoundEffect>(ASSET_NAME_COIN_PICKUP);

            _rotatingCoinAnimation = new TextureAnimation();

            _coin0 = Content.Load <Texture2D>(ASSET_NAME_COIN_0);
            _coin1 = Content.Load <Texture2D>(ASSET_NAME_COIN_1);
            _coin2 = Content.Load <Texture2D>(ASSET_NAME_COIN_2);
            _coin3 = Content.Load <Texture2D>(ASSET_NAME_COIN_3);
            _coin4 = Content.Load <Texture2D>(ASSET_NAME_COIN_4);

            _rotatingCoinAnimation.AddFrame(_coin0, ROTATING_COIN_ANIMATION_FRAME_DURATION);
            _rotatingCoinAnimation.AddFrame(_coin1, ROTATING_COIN_ANIMATION_FRAME_DURATION * 2);
            _rotatingCoinAnimation.AddFrame(_coin2, ROTATING_COIN_ANIMATION_FRAME_DURATION * 3);
            _rotatingCoinAnimation.AddFrame(_coin3, ROTATING_COIN_ANIMATION_FRAME_DURATION * 4);
            _rotatingCoinAnimation.AddFrame(_coin4, ROTATING_COIN_ANIMATION_FRAME_DURATION * 5);

            _rotatingCoinAnimation.Play();

            _coinManager = new CoinManager(_coin0, _ball, _scoreBoard, _entityManager, _coinPickupSoundEffect,
                                           _rotatingCoinAnimation);



            _entityManager.AddEntity(_ball);
            _entityManager.AddEntity(_ballManager);
            _entityManager.AddEntity(_groundManager);
            _entityManager.AddEntity(_scoreBoard);
            _entityManager.AddEntity(_wallManager);
            _entityManager.AddEntity(_coinManager);

            _groundManager.Initialize();
        }
Beispiel #2
0
        private void load(TextureStore store)
        {
            string lane = HitObject.Lane == LanedHitLane.Air ? "air" : "ground";

            normalAnimation.AddFrames(new[] { store.Get($"Minion/pippidon_{lane}_0"), store.Get($"Minion/pippidon_{lane}_0") });
            hitAnimation.AddFrame(store.Get($"Minion/pippidon_{lane}_hit"));
        }
Beispiel #3
0
        private void load(ISampleStore samples)
        {
            Anchor   = Anchor.CentreLeft;
            Origin   = Anchor.Centre;
            Position = new Vector2(120.0f, .0f);

            animation = new TextureAnimation
            {
                Origin = Anchor.Centre,
                Anchor = Anchor.Centre,
            };

            animation.AddFrame(textures.Get("redbird-upflap"), 200.0f);
            animation.AddFrame(textures.Get("redbird-downflap"), 200.0f);
            animation.AddFrame(textures.Get("redbird-midflap"), 200.0f);

            AddInternal(animation);
            AddInternal(flapSound = new DrawableSample(samples.Get("wing.ogg")));

            Size  = animation.Size;
            Scale = new Vector2(0.45f);
        }
        public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, string animationSeparator = "-")
        {
            const double default_frame_time = 1000 / 60d;

            Texture texture;

            Texture getFrameTexture(int frame) => source.GetTexture($"{componentName}{animationSeparator}{frame}");

            TextureAnimation animation = null;

            if (animatable)
            {
                for (int i = 0;; i++)
                {
                    if ((texture = getFrameTexture(i)) == null)
                    {
                        break;
                    }

                    if (animation == null)
                    {
                        animation = new TextureAnimation
                        {
                            DefaultFrameLength = default_frame_time,
                            Repeat             = looping
                        }
                    }
                    ;

                    animation.AddFrame(texture);
                }
            }

            if (animation != null)
            {
                return(animation);
            }

            if ((texture = source.GetTexture(componentName)) != null)
            {
                return new Sprite
                       {
                           Texture = texture
                       }
            }
            ;

            return(null);
        }
    }
}
        public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, bool applyConfigFrameRate = false, string animationSeparator = "-")
        {
            Texture texture;

            if (animatable)
            {
                var textures = getTextures().ToArray();

                if (textures.Length > 0)
                {
                    var animation = new TextureAnimation
                    {
                        DefaultFrameLength = getFrameLength(source, applyConfigFrameRate, textures),
                        Repeat             = looping,
                    };

                    foreach (var t in textures)
                    {
                        animation.AddFrame(t);
                    }

                    return(animation);
                }
            }

            // if an animation was not allowed or not found, fall back to a sprite retrieval.
            if ((texture = source.GetTexture(componentName)) != null)
            {
                return new Sprite {
                           Texture = texture
                }
            }
            ;

            return(null);

            IEnumerable <Texture> getTextures()
            {
                for (int i = 0; true; i++)
                {
                    if ((texture = source.GetTexture($"{componentName}{animationSeparator}{i}")) == null)
                    {
                        break;
                    }

                    yield return(texture);
                }
            }
        }
Beispiel #6
0
        private Drawable getAnimation(string componentName, bool animatable, bool looping, string animationSeparator = "-")
        {
            Texture texture;

            Texture getFrameTexture(int frame) => GetTexture($"{componentName}{animationSeparator}{frame}");

            TextureAnimation animation = null;

            if (animatable)
            {
                for (int i = 0;; i++)
                {
                    if ((texture = getFrameTexture(i)) == null)
                    {
                        break;
                    }

                    if (animation == null)
                    {
                        animation = new TextureAnimation
                        {
                            DefaultFrameLength = default_frame_time,
                            Repeat             = looping
                        }
                    }
                    ;

                    animation.AddFrame(texture);
                }
            }

            if (animation != null)
            {
                return(animation);
            }

            if ((texture = GetTexture(componentName)) != null)
            {
                return new Sprite {
                           Texture = texture
                }
            }
            ;

            return(null);
        }