Ejemplo n.º 1
0
        internal TaggedAnimationClip[] GetAnimationClips(Avatar avatar)
        {
            var defaultAvatar = DestinationAvatar;

            return(AnimationLibrary.Where(
                       clip => clip.GetSourceAvatar(defaultAvatar) == avatar).ToArray());
        }
Ejemplo n.º 2
0
 private void animate_normal()
 {
     AnimationLibrary.AnimateBrush(
         ((x) => this.Background = x),
         ((SolidColorBrush)this.Background).Color,
         BaseColor.Color,
         TimeSpan.FromSeconds(0.15));
 }
Ejemplo n.º 3
0
    public static AnimationLibrary Get()
    {
        if (instance == null)
        {
            instance = new AnimationLibrary();
        }

        return instance;
    }
Ejemplo n.º 4
0
        private void animate_active()
        {
            var test = ((SolidColorBrush)this.Background).Color;

            AnimationLibrary.AnimateBrush(
                ((x) => this.Background = x),
                ((SolidColorBrush)this.Background).Color,
                ActiveColor.Color,
                TimeSpan.FromSeconds(0.15));
        }
Ejemplo n.º 5
0
        public Entity(string animationResource, Vector2 startPos)
        {
            this.animationResource = animationResource;
            this.position          = startPos;

            animationLibrary = JellyJam.animations;
            frameLength      = DEFAULT_FRAME_LENGTH;
            frameIndex       = 0;
            currentAction    = DEFAULT_CURRENT_ACTION;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to Draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            animations   = new AnimationLibrary(Content);
            musicLibrary = new MusicLibrary(Content);
            saltCircle   = Content.Load <Texture2D>("sprites/select_circle");

            font = Content.Load <SpriteFont>("fonts/arial");

            musicLibrary.play(MusicLibrary.HEROIC_DEMISE);
        }
Ejemplo n.º 7
0
        public override void CreateCosmeticChildren(ComponentManager Manager)
        {
            base.CreateCosmeticChildren(Manager);

            var spriteSheet = new SpriteSheet("mana-lamp", 32);

            List <Point> frames = new List <Point>
            {
                new Point(0, 0),
                new Point(2, 0),
                new Point(1, 0),
                new Point(2, 0)
            };

            var lampAnimation = AnimationLibrary.CreateAnimation(spriteSheet, frames, "ManaLampAnimation");

            lampAnimation.Loops = true;

            var sprite = AddChild(new AnimatedSprite(Manager, "sprite", Matrix.Identity, false)
            {
                LightsWithVoxels = false,
                OrientationType  = AnimatedSprite.OrientMode.YAxis,
            }) as AnimatedSprite;

            sprite.AddAnimation(lampAnimation);
            sprite.AnimPlayer.Play(lampAnimation);
            sprite.SetFlag(Flag.ShouldSerialize, false);

            // This is a hack to make the animation update at least once even when the object is created inactive by the craftbuilder.
            sprite.AnimPlayer.Update(new DwarfTime());

            AddChild(new LightEmitter(Manager, "light", Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero, 255, 8)
            {
                HasMoved = true
            }).SetFlag(Flag.ShouldSerialize, false);

            AddChild(new GenericVoxelListener(Manager, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -1.0f, 0.0f), (changeEvent) =>
            {
                if (changeEvent.Type == VoxelChangeEventType.VoxelTypeChanged && changeEvent.NewVoxelType == 0)
                {
                    Die();
                }
            })).SetFlag(Flag.ShouldSerialize, false);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Removes the TaggedAnimationClip that corresponds to the supplied AnimationClip from the asset
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>true if the clip was found and removed, false otherwise</returns>
        public bool RemoveAnimationClip(AnimationClip clip)
        {
            if (clip == null)
            {
                throw new ArgumentNullException("clip");
            }

            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            Undo.RecordObject(this, string.Format("Remove Animation Clip {0}", clip.name));

            int removed = AnimationLibrary.RemoveAll((TaggedAnimationClip tagged) => { return(tagged.AnimationClipGuid == clipGuid); });

            if (removed > 0)
            {
                MarkDirty();
            }

            return(removed > 0);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates and adds a new TaggedAnimationClip in the asset from an AnimationClip
        /// </summary>
        /// <completionlist cref=""/>
        /// <param name=clip>AnimationClip to use. Must be an asset on disk</param>
        /// <exception cref="System.ArgumentNullException">Thrown if argument clip is null</exception>
        /// <exception cref="System.ArgumentException">Thrown if argument clip no an asset on disk</exception>
        /// <returns>Returns the TaggedAnimationClip created from the supplied AnimationClip</returns>
        internal TaggedAnimationClip AddAnimationClip(AnimationClip clip)
        {
            if (clip == null)
            {
                throw new ArgumentNullException("clip");
            }

            TaggedAnimationClip taggedAnimationClip = null;

            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            if (!clipGuid.IsSet())
            {
                throw new ArgumentException("argument \"clip\" must be an asset on the disk");
            }

            //Don't add existing AnimationClip to library
            if (AnimationLibrary.Any((TaggedAnimationClip taggedClip) => { return(taggedClip.AnimationClipGuid == clipGuid); }))
            {
                return(null);
            }

            try
            {
                taggedAnimationClip = TaggedAnimationClip.BuildFromClip(clip, this, ETagImportOption.Import);
            }
            catch (InvalidOperationException)
            {
                throw new ArgumentException("argument \"clip\" must be an asset on disk");
            }

            Undo.RecordObject(this, string.Format("Add Animation Clip {0}", clip.name));
            AnimationLibrary.Add(taggedAnimationClip);
            taggedAnimationClip.DataChanged += MarkDirty;

            MarkDirty();
            return(taggedAnimationClip);
        }
Ejemplo n.º 10
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GumSkin);
            GuiRoot.MousePointer  = new Gui.MousePointer("mouse", 4, 0);
            GuiRoot.RootItem.Font = "font8";

            int w = System.Math.Min(GuiRoot.RenderData.VirtualScreen.Width - 256, 550);
            int h = System.Math.Min(GuiRoot.RenderData.VirtualScreen.Height - 256, 300);
            int x = GuiRoot.RenderData.VirtualScreen.Width / 2 - w / 2;
            int y = System.Math.Max(GuiRoot.RenderData.VirtualScreen.Height / 2 - h / 2, 280);

            int bgx = x - 258;
            int bgy = y - 128;

            DialogueContext.SpeechBubble = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect      = new Rectangle(bgx + 258, bgy, w + 50, 128),
                Border    = "speech-bubble-reverse",
                Font      = "font16",
                TextColor = Color.Black.ToVector4()
            });

            var bg = GuiRoot.RootItem.AddChild(new Widget()
            {
                Border = "border-dark",
                Rect   = new Rectangle(bgx, bgy, 258, 258)
            });


            DialogueContext.ChoicePanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect       = new Rectangle(x, y, w, h),
                Border     = "border-fancy",
                AutoLayout = AutoLayout.DockFill
            });

            SpeakerAnimation                 = AnimationLibrary.CreateAnimation(DialogueContext.Envoy.OwnerFaction.Race.TalkAnimation);
            SpeakerAnimationPlayer           = new AnimationPlayer(SpeakerAnimation);
            DialogueContext.SpeakerAnimation = SpeakerAnimationPlayer;


            SpeakerWidget = bg.AddChild(new Widget()
            {
                Background  = new TileReference(SpeakerAnimation.SpriteSheet.AssetName, 0),
                AutoLayout  = AutoLayout.DockFill,
                MinimumSize = new Point(256, 256),
                Rect        = new Rectangle(bgx, bgy - 5, 256, 256)
            });

            DialogueContext.Politics = World.Diplomacy.GetPolitics(
                DialogueContext.PlayerFaction, DialogueContext.Envoy.OwnerFaction);
            DialogueContext.World = World;

            if (!DialogueContext.Politics.HasMet)
            {
                DialogueContext.Politics.HasMet = true;

                DialogueContext.Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                {
                    Change      = 0.0f,
                    Description = "we just met",
                    Duration    = new TimeSpan(1, 0, 0, 0),
                    Time        = World.Time.CurrentDate
                });
            }

            DialogueContext.EnvoyName = TextGenerator.GenerateRandom(Datastructures.SelectRandom(DialogueContext.Envoy.OwnerFaction.Race.NameTemplates).ToArray());

            DialogueContext.Transition(DialogueTree.ConversationRoot);

            IsInitialized = true;
            base.OnEnter();
        }
Ejemplo n.º 11
0
        public override void OnEnter()
        {
            DwarfGame.GumInputMapper.GetInputQueue();


            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);

            var panel = GuiRoot.RootItem.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.FloatCenter,
                MinimumSize = new Point((int)(GuiRoot.RenderData.VirtualScreen.Width * 0.75f), (int)(GuiRoot.RenderData.VirtualScreen.Height * 0.75f)),
                Border      = "border-fancy"
            });

            panel.AddChild(new Widget
            {
                Text       = "Exit Designer",
                Border     = "border-button",
                AutoLayout = AutoLayout.FloatBottomRight,
                OnClick    = (sender, args) => StateManager.PopState()
            });

            SpriteFrame = panel.AddChild(new DwarfCorp.Gui.Widgets.EmployeePortrait
            {
                MinimumSize = new Point(48 * 6, 40 * 6),
                MaximumSize = new Point(48 * 6, 40 * 6),
                AutoLayout  = AutoLayout.DockLeft
            }) as DwarfCorp.Gui.Widgets.EmployeePortrait;

            SpriteFrame.Sprite = new LayeredSprites.LayerStack();
            foreach (Animation animation in AnimationLibrary.LoadNewLayeredAnimationFormat(ContentPaths.dwarf_animations))
            {
                var proxyAnim = SpriteFrame.Sprite.ProxyAnimation(animation);
                proxyAnim.Loops = true;
                Animations.Add(proxyAnim);
            }

            SpriteFrame.AnimationPlayer = new AnimationPlayer();
            SpriteFrame.AnimationPlayer.ChangeAnimation(Animations[0], AnimationPlayer.ChangeAnimationOptions.ResetAndPlay);

            AddSelector(panel, "body");
            AddSelector(panel, "face");
            AddSelector(panel, "nose");
            AddSelector(panel, "beard");
            AddSelector(panel, "hair");
            AddSelector(panel, "tool");
            AddSelector(panel, "hat");
            AddSelector(panel, "minecart");

            var anim = panel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = AutoLayout.DockTop,
                Padding     = new Margin(2, 2, 2, 2)
            });

            anim.AddChild(new Widget
            {
                Text                = "animation",
                MinimumSize         = new Point(64, 0),
                AutoLayout          = AutoLayout.DockLeft,
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Center
            });

            var animCombo = anim.AddChild(new Gui.Widgets.ComboBox
            {
                Items                  = Animations.Select(a => a.Name).ToList(),
                Border                 = "border-thin",
                AutoLayout             = AutoLayout.DockTop,
                OnSelectedIndexChanged = (sender) => SpriteFrame.AnimationPlayer.ChangeAnimation(Animations.First(a => a.Name == (sender as Gui.Widgets.ComboBox).SelectedItem),
                                                                                                 AnimationPlayer.ChangeAnimationOptions.ResetAndPlay),
                ItemsVisibleInPopup = 12,
            }) as Gui.Widgets.ComboBox;

            animCombo.SelectedIndex = animCombo.Items.IndexOf("WalkingFORWARD");

            GuiRoot.RootItem.Layout();

            IsInitialized = true;

            base.OnEnter();
        }
Ejemplo n.º 12
0
 public static void Init()
 {
     AnimationLibray = new AnimationLibrary();
     SFXLibrary      = new SFXLibrary();
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Finds the TaggedAnimationClip that corresponds to the supplied AnimationClip
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>Returns the TaggedAnimationClip associated with the supplied AnimationClip</returns>
        internal TaggedAnimationClip FindTaggedAnimationClip(AnimationClip clip)
        {
            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            return(AnimationLibrary.FirstOrDefault((TaggedAnimationClip taggedClip) => { return taggedClip.AnimationClipGuid == clipGuid; }));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// TaggedAnimationClip that corresponds to the supplied AnimationClip
        /// </summary>
        /// <param name=clip>AnimationClip to use</param>
        /// <returns>Returns the TaggedAnimationClip associated with the supplied AnimationClip</returns>
        public bool ContainsAnimationClip(AnimationClip clip)
        {
            SerializableGuid clipGuid = SerializableGuidUtility.GetSerializableGuidFromAsset(clip);

            return(AnimationLibrary.Any((TaggedAnimationClip taggedClip) => { return taggedClip.AnimationClipGuid == clipGuid; }));
        }
Ejemplo n.º 15
0
 internal TaggedAnimationClip[] GetAnimationClips()
 {
     return(AnimationLibrary.ToArray());
 }
Ejemplo n.º 16
0
 public void AnimateFadeIn(ImageItem item)
 {
     AnimationLibrary.OpacityControl(item, 0, 1, 0.2);
     AnimationLibrary.MoveToTargetX(item, 0, -ActualWidth, 0.2);
 }