//-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public Animation()
 {
     this.frames		= new List<AnimationFrame>();
     this.duration	= 0;
     this.nextStrip	= null;
     this.loopMode	= LoopMode.Repeat;
 }
 public Animation(LoopMode loopMode)
 {
     this.frames		= new List<AnimationFrame>();
     this.duration	= 0;
     this.nextStrip	= null;
     this.loopMode	= loopMode;
 }
 //-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public TileDoor()
 {
     animationOpen	= GameData.ANIM_TILE_DOOR_OPEN;
     animationClose	= GameData.ANIM_TILE_DOOR_CLOSE;
     openCloseSound	= GameData.SOUND_DUNGEON_DOOR;
     Graphics.SyncPlaybackWithRoomTicks = false;
 }
        private float timer; // The playback time in ticks.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public AnimationPlayer()
        {
            animation		= null;
            subStrip		= null;
            subStripIndex	= 0;
            isPlaying		= false;
            timer			= 0.0f;
        }
Exemple #5
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public Reward()
 {
     this.id				= "";
     this.animation		= null;
     this.message		= "";
     this.hasDuration	= false;
     this.isCollectibleWithItems	= false;
 }
Exemple #6
0
        // Create an effect that plays an animation and then dissapears
        public Effect(Animation animation)
            : this()
        {
            destroyTimer = -1;
            destroyOnAnimationComplete = true;

            Graphics.PlayAnimation(animation);
        }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public PlayerHoldSwordState()
 {
     this.weaponAnimation	= null;
     this.nextState			= null;
     this.equipSlot			= 0;
     this.chargeTimer		= 0;
     this.direction			= Directions.Right;
 }
        public Animation(Sprite sprite)
        {
            this.frames		= new List<AnimationFrame>();
            this.duration	= 0;
            this.nextStrip	= null;
            this.loopMode	= LoopMode.Repeat;

            this.frames.Add(new AnimationFrame(0, 0, sprite));
        }
Exemple #9
0
 public RewardRupee(string id, int amount, string message, Animation animation)
 {
     this.id				= id;
     this.animation		= animation;
     this.message		= message;
     this.hasDuration	= true;
     this.holdType		= RewardHoldTypes.Raise;
     this.isCollectibleWithItems	= true;
 }
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public PlayerHoldSwordState()
 {
     weaponAnimation	= GameData.ANIM_SWORD_HOLD;
     nextState		= null;
     weapon			= null;
     chargeTimer		= 0;
     direction		= Directions.Right;
     playerTool		= null;
 }
        private float timer; // The playback time in ticks.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public AnimationPlayer()
        {
            sprite			= null;
            animation		= null;
            subStrip		= null;
            subStripIndex	= 0;
            isPlaying		= false;
            timer			= 0.0f;
            speed			= 1.0f;
        }
Exemple #12
0
 //-----------------------------------------------------------------------------
 // Constructors
 //-----------------------------------------------------------------------------
 public Reward()
 {
     this.id				= "";
     this.animation		= null;
     this.message		= "";
     this.hasDuration	= false;
     this.isCollectibleWithItems	= false;
     this.onlyShowMessageInChest = false;
     this.soundBounce			= null;
 }
Exemple #13
0
        // Create an effect that plays an animation and then dissapears
        public Effect(Animation animation, DepthLayer depthLayer, bool updateOnRoomPaused = false)
            : this()
        {
            destroyTimer = -1;
            destroyOnAnimationComplete = true;

            Graphics.PlayAnimation(animation);
            Graphics.DepthLayer = depthLayer;

            this.UpdateOnRoomPaused = updateOnRoomPaused;
        }
Exemple #14
0
        public RewardItem(string id, string itemID, int level, RewardHoldTypes holdType, string message, Animation animation)
        {
            this.id				= id;
            this.animation		= animation;
            this.message		= message;
            this.hasDuration	= true;
            this.holdType		= holdType;
            this.isCollectibleWithItems	= true;

            this.itemID			= itemID;
            this.level			= level;
        }
        public Animation(Animation copy)
        {
            frames		= new List<AnimationFrame>();
            nextStrip	= null;
            duration	= copy.duration;
            loopMode	= copy.loopMode;

            for (int i = 0; i < copy.frames.Count; i++)
                frames.Add(new AnimationFrame(copy.frames[i]));
            if (copy.nextStrip != null)
                nextStrip = new Animation(copy.nextStrip);
        }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public JumpMonster()
        {
            color			= MonsterColor.Red;
            MaxHealth		= 1;
            ContactDamage	= 1;

            moveSpeed		= 1.0f;
            stopTime		= new RangeI(30, 60);
            jumpSpeed		= new RangeF(3, 3);
            stopAnimation	= GameData.ANIM_MONSTER_ZOL;
            jumpAnimation	= GameData.ANIM_MONSTER_ZOL_JUMP;

            syncAnimationWithDirection = false;
        }
        //-----------------------------------------------------------------------------
        // Constructor
        //-----------------------------------------------------------------------------
        public ItemShield()
        {
            this.id				= "item_shield";
            this.name			= new string[] { "Wooden Shield", "Iron Shield", "Mirror Shield" };
            this.description	= new string[] { "A small shield.", "A large shield.", "A reflective shield." };
            this.maxLevel		= Item.Level3;
            this.flags			= ItemFlags.UsableWhileJumping | ItemFlags.UsableWithSword | ItemFlags.UsableWhileInHole;

            this.sprite = new Sprite[] {
                GameData.SPR_ITEM_ICON_SHIELD_1,
                GameData.SPR_ITEM_ICON_SHIELD_2,
                GameData.SPR_ITEM_ICON_SHIELD_3
            };

            shieldAnimation = GameData.ANIM_PLAYER_SHIELD;
            shieldBlockAnimation = GameData.ANIM_PLAYER_SHIELD_BLOCK;
        }
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public Projectile()
        {
            EnablePhysics(PhysicsFlags.Flying);

            syncAnimationWithAngle		= false;
            syncAnimationWithDirection	= false;

            owner			= null;
            eventCollision	= null;
            eventLand		= null;
            angle			= 0;
            direction		= 0;

            crashAnimation	= null;
            bounceOnCrash	= false;

            projectileType = ProjectileType.Physical;
        }
Exemple #19
0
        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        public TileData()
        {
            type				= null;
            size				= Point2I.One;
            flags				= TileFlags.Default;
            spriteList			= new SpriteAnimation[0];
            spriteAsObject		= new SpriteAnimation();
            breakAnimation		= null;
            collisionModel		= null;
            sheetLocation		= Point2I.Zero;
            tileset				= null;
            properties			= new Properties();

            properties.Set("id", "")
                .SetDocumentation("ID", "", "", "The id used to refer to this tile.", true, false);
            properties.Set("sprite_index", 0)
                .SetDocumentation("Sprite Index", "sprite_index", "", "The current sprite in the sprite list to draw.", true, true);
        }
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------
        public override void OnLevelUp()
        {
            if (level == Item.Level1) {
                shieldAnimation			= GameData.ANIM_PLAYER_SHIELD;
                shieldBlockAnimation	= GameData.ANIM_PLAYER_SHIELD_BLOCK;
            }
            else {
                shieldAnimation			= GameData.ANIM_PLAYER_SHIELD_LARGE;
                shieldBlockAnimation	= GameData.ANIM_PLAYER_SHIELD_LARGE_BLOCK;
            }

            if (isEquipped) {
                if (isShieldBlocking)
                    Player.MoveAnimation = shieldBlockAnimation;
                else
                    Player.MoveAnimation = shieldAnimation;
            }
        }
        //-----------------------------------------------------------------------------
        // 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
        }
Exemple #22
0
        public TileData(TileData copy)
            : this()
        {
            type				= copy.type;
            size				= copy.size;
            flags				= copy.flags;
            spriteList			= new SpriteAnimation[copy.spriteList.Length];
            spriteAsObject		= new SpriteAnimation(copy.spriteAsObject);
            breakAnimation		= copy.breakAnimation;
            collisionModel		= copy.collisionModel;
            sheetLocation		= copy.sheetLocation;
            tileset				= copy.tileset;
            properties			= new Properties();

            properties.Merge(copy.properties, true);

            for (int i = 0; i < spriteList.Length; i++)
                spriteList[i] = new SpriteAnimation(copy.spriteList[i]);
        }
Exemple #23
0
        //-----------------------------------------------------------------------------
        // Override
        //-----------------------------------------------------------------------------
        public AnimationSR(TemporaryResources resources = null)
        {
            this.resources			= resources;
            this.useTemporary		= resources != null;
            this.animationBuilder	= new AnimationBuilder();

            // SPRITE SHEET.

            AddCommand("SpriteSheet", delegate(CommandParam parameters) {
                SpriteSheet sheet;
                if (useTemporary && resources != null)
                    sheet = resources.GetResource<SpriteSheet>(parameters.GetString(0));
                else
                    sheet = Resources.GetResource<SpriteSheet>(parameters.GetString(0));
                animationBuilder.SpriteSheet = sheet;
            });

            // BEGIN/END.

            AddCommand("Anim", delegate(CommandParam parameters) {
                animationName = parameters.GetString(0);
                animationBuilder.BeginNull();
                animation = null;
            });
            AddCommand("End", delegate(CommandParam parameters) {
                if (animation != null) {
                    animationBuilder.End();
                    if (useTemporary && resources != null)
                        resources.AddResource<Animation>(animationName, animation);
                    else
                        Resources.AddResource<Animation>(animationName, animation);
                }
            });
            AddCommand("SubStrip", delegate(CommandParam parameters) {
                LoopMode loopMode = LoopMode.Repeat;
                if (parameters.GetString(0) == "reset")
                    loopMode = LoopMode.Reset;
                else if (parameters.GetString(0) == "repeat" || parameters.GetString(0) == "loop")
                    loopMode = LoopMode.Repeat;
                else if (parameters.GetString(0) == "clamp")
                    loopMode = LoopMode.Clamp;
                else
                    ThrowParseError("Unknown loop mode '" + parameters.GetString(0) + "' for animation");

                animationBuilder.CreateSubStrip();
                animationBuilder.SetLoopMode(loopMode);
                if (animation == null)
                    animation = animationBuilder.Animation;
            });
            AddCommand("Clone", delegate(CommandParam parameters) {
                if (useTemporary && resources != null && resources.ExistsResource<Animation>(parameters.GetString(0))) {
                    animationBuilder.CreateClone(resources.GetResource<Animation>(parameters.GetString(0)));
                    animation = animationBuilder.Animation;
                }
                if (Resources.ExistsResource<Animation>(parameters.GetString(0))) {
                    animationBuilder.CreateClone(Resources.GetResource<Animation>(parameters.GetString(0)));
                    animation = animationBuilder.Animation;
                }
                else {
                    // ERROR: can't clone nonexistant animation.
                }
            });

            // FRAME BUILDING.

            AddCommand("Add", delegate(CommandParam parameters) {
                if (parameters.GetString(0) == "strip") {
                    animationBuilder.AddFrameStrip(
                        parameters.GetInt(1),
                        parameters.GetPoint(3).X,
                        parameters.GetPoint(3).Y,
                        parameters.GetInt(2),
                        parameters.GetPoint(4, Point2I.Zero).X,
                        parameters.GetPoint(4, Point2I.Zero).Y,
                        parameters.GetPoint(5, new Point2I(1, 0)).X,
                        parameters.GetPoint(5, new Point2I(1, 0)).Y);
                }
                else if (parameters.GetString(0) == "frame") {
                    animationBuilder.AddFrame(
                        parameters.GetInt(1),
                        parameters.GetPoint(2).X,
                        parameters.GetPoint(2).Y,
                        parameters.GetPoint(3, Point2I.Zero).X,
                        parameters.GetPoint(3, Point2I.Zero).Y);
                }
                else if (parameters.GetString(0) == "part") {
                    animationBuilder.AddPart(
                        parameters.GetInt(1),
                        parameters.GetPoint(2).X,
                        parameters.GetPoint(2).Y,
                        parameters.GetPoint(3, Point2I.Zero).X,
                        parameters.GetPoint(3, Point2I.Zero).Y);
                }
                else
                    ThrowParseError("Unknown add type '" + parameters.GetString(0) + "' for animation");
            });
            AddCommand("Insert", delegate(CommandParam parameters) {
                if (parameters.GetString(0) == "strip") {
                    animationBuilder.InsertFrameStrip(
                        parameters.GetInt(1),
                        parameters.GetInt(2),
                        parameters.GetPoint(4).X,
                        parameters.GetPoint(4).Y,
                        parameters.GetInt(3),
                        parameters.GetPoint(5, Point2I.Zero).X,
                        parameters.GetPoint(5, Point2I.Zero).Y,
                        parameters.GetPoint(6, new Point2I(1, 0)).X,
                        parameters.GetPoint(6, new Point2I(1, 0)).Y);
                }
                else if (parameters.GetString(0) == "frame") {
                    animationBuilder.InsertFrame(
                        parameters.GetInt(1),
                        parameters.GetInt(2),
                        parameters.GetPoint(3).X,
                        parameters.GetPoint(3).Y,
                        parameters.GetPoint(4, Point2I.Zero).X,
                        parameters.GetPoint(4, Point2I.Zero).Y);
                }
                else
                    ThrowParseError("Unknown insert type '" + parameters.GetString(0) + "' for animation");
            });

            // MODIFICATIONS.

            AddCommand("MakeQuad", delegate(CommandParam parameters) {
                animationBuilder.MakeQuad();
            });
            AddCommand("MakeDynamic", delegate(CommandParam parameters) {
                animationBuilder.MakeDynamic(
                    parameters.GetInt(0),
                    parameters.GetPoint(1).X,
                    parameters.GetPoint(1).Y);
            });
            AddCommand("Offset", delegate(CommandParam parameters) {
                animationBuilder.Offset(
                    parameters.GetPoint(0).X,
                    parameters.GetPoint(0).Y);
            });
            AddCommand("Flicker", delegate(CommandParam parameters) {
                // FLICKER <alternateDelay> <on/off>

                bool startOn = true;
                if (parameters.GetString(1) == "on")
                    startOn = true;
                else if (parameters.GetString(1) == "off")
                    startOn = false;
                else
                    ThrowParseError("Must be either on or off for flicker start state");

                animationBuilder.MakeFlicker(parameters.GetInt(0), startOn);
            });
        }
Exemple #24
0
 // Ends reading the script.
 protected override void EndReading()
 {
     animation = null;
 }
Exemple #25
0
 // Begins reading the script.
 protected override void BeginReading()
 {
     animation = null;
     animationName = "";
     animationBuilder.SpriteSheet = null;
 }
        // Draw an animation during at the given time stamp and position.
        public void DrawAnimation(Animation animation, int variantID, float time, float x, float y, Color color, float depth = 0.0f)
        {
            if (animation.LoopMode == LoopMode.Repeat) {
            if (animation.Duration == 0)
                time = 0;
            else
                time %= animation.Duration;
            }
            x = GMath.Round(x);
            y = GMath.Round(y);

            for (int i = 0; i < animation.Frames.Count; ++i) {
            AnimationFrame frame = animation.Frames[i];
            if (time < frame.StartTime)
                return;
            if (time < frame.StartTime + frame.Duration || (time >= animation.Duration && frame.StartTime + frame.Duration == animation.Duration))
                DrawSprite(frame.Sprite, variantID, x, y, color, depth);
            }
        }
 // Draw an animation during at the given time stamp and position.
 public void DrawAnimation(Animation animation, int variantID, float time, Vector2F position, Color color, float depth = 0.0f)
 {
     DrawAnimation(animation, variantID, time, position.X, position.Y, color, depth);
 }
 public void PlayAnimation(Animation animation)
 {
     animationPlayer.Play(animation);
 }
 public void SetAnimation(Animation animation)
 {
     animationPlayer.SetAnimation(animation);
 }
 // Draw an animation during at the given time stamp and position.
 public void DrawAnimation(Animation animation, float time, float x, float y, Color color, float depth = 0.0f)
 {
     DrawAnimation(animation, 0, time, x, y, color, depth);
 }