Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public EffectUsedItem(Sprite sprite)
            : base()
        {
            // Create an animation of the sprite rising with two key-frames.
            Sprite spr1 = new Sprite(sprite);
            spr1.DrawOffset += new Point2I(-sprite.SourceRect.Width / 2, -12);
            Sprite spr2 = new Sprite(sprite);
            spr2.DrawOffset += new Point2I(-sprite.SourceRect.Width / 2, -20);

            Animation animation = new Animation(LoopMode.Reset);
            animation.AddFrame(0, 8, spr1);
            animation.AddFrame(8, 20, spr2);

            // Play the animation.
            destroyTimer = -1;
            destroyOnAnimationComplete = true;
            Graphics.PlayAnimation(animation);
            Graphics.DepthLayer = DepthLayer.EffectCling; // TODO: proper depth layer for EffectUsedItem
        }
Ejemplo n.º 2
0
        public AnimationBuilder MakeFlicker(int alternateDelayTicks, bool startOn = true)
        {
            Animation newAnimation = new Animation();

            for (int i = 0; i < animation.Frames.Count; i++)  {
                AnimationFrame frame = animation.Frames[i];

                int beginSection	= frame.StartTime / (alternateDelayTicks * 2);
                int endSection		= frame.EndTime / (alternateDelayTicks * 2);
                if (frame.EndTime % (alternateDelayTicks * 2) == 0)
                    endSection--;

                for (int section = beginSection; section <= endSection; section++) {
                    int t = section * alternateDelayTicks * 2;

                    if (frame.StartTime < t + alternateDelayTicks && frame.EndTime > t) {
                        AnimationFrame newFrame = new AnimationFrame();
                        newFrame.Sprite		= frame.Sprite;
                        newFrame.StartTime	= Math.Max(frame.StartTime, t);
                        newFrame.Duration	= Math.Min(frame.EndTime, t + alternateDelayTicks) - newFrame.StartTime;
                        newAnimation.AddFrame(newFrame);
                    }
                }
            }

            animation.Frames = newAnimation.Frames;
            return this;
        }
        //-----------------------------------------------------------------------------
        // Animations Loading
        //-----------------------------------------------------------------------------
        private static void LoadAnimations()
        {
            Resources.LoadAnimations("Animations/animations.conscript");

            // Create gale effect animation.
            SpriteSheet sheet = Resources.GetSpriteSheet("color_effects");
            ANIM_EFFECT_SEED_GALE = new Animation();
            for (int i = 0; i < 12; i++) {
                int y = 1 + (((5 - (i % 4)) % 4) * 4);
                ANIM_EFFECT_SEED_GALE.AddFrame(i, 1, new Sprite(
                    GameData.SHEET_COLOR_EFFECTS, ((i % 6) < 3 ? 4 : 5), y, -8, -8));
            }
            Resources.SetResource("effect_seed_gale", ANIM_EFFECT_SEED_GALE);

            ANIM_COLOR_CUBE_ROLLING_ORIENTATIONS = new Animation[6, 4];
            string[] orientations = { "blue_yellow", "blue_red", "yellow_red", "yellow_blue", "red_blue", "red_yellow" };
            string[] directions = { "right", "up", "left", "down" };

            for (int i = 0; i < 6; i++) {
                for (int j = 0; j < 4; j++) {
                    ANIM_COLOR_CUBE_ROLLING_ORIENTATIONS[i, j] = Resources.GetResource<Animation>("color_cube_" + orientations[i] + "_" + directions[j]);
                }
            }

            IntegrateResources<Animation>("ANIM_");

            ANIM_EFFECT_SEEDS = new Animation[5];
            ANIM_EFFECT_SEEDS[(int) SeedType.Ember]		= ANIM_EFFECT_SEED_EMBER;
            ANIM_EFFECT_SEEDS[(int) SeedType.Scent]		= ANIM_EFFECT_SEED_SCENT;
            ANIM_EFFECT_SEEDS[(int) SeedType.Gale]		= ANIM_EFFECT_SEED_GALE;
            ANIM_EFFECT_SEEDS[(int) SeedType.Pegasus]	= ANIM_EFFECT_SEED_PEGASUS;
            ANIM_EFFECT_SEEDS[(int) SeedType.Mystery]	= ANIM_EFFECT_SEED_MYSTERY;
        }