Exemplo n.º 1
0
        private int GetLayer(AnimationTypes type)
        {
            switch (type)
            {
            case AnimationTypes.Walk:
            case AnimationTypes.Face:
                return(1);

            case AnimationTypes.Run:
                return(1);

            case AnimationTypes.Block:
                return(2);

            case AnimationTypes.Hit:
                return(2);

            case AnimationTypes.Attack:
                return(3);

            case AnimationTypes.Death:
                return(99);

            default:
                return(0);
            }
        }
Exemplo n.º 2
0
        private AnimationClip GetAnimationClip(AnimationTypes type)
        {
            switch (type)
            {
            case AnimationTypes.Walk:
            case AnimationTypes.Face:
                return(WalkAnimations.GetRandom());

            case AnimationTypes.Run:
                return(RunAnimations.GetRandom());

            case AnimationTypes.Block:
                return(BlockAnimations.GetRandom());

            case AnimationTypes.Hit:
                return(HitAnimations.GetRandom());

            case AnimationTypes.Attack:
                return(AttackAnimations.GetRandom());

            case AnimationTypes.Death:
                return(DeathAnimations.GetRandom());

            default:
                return(IdleAnimations.GetRandom());
            }
        }
Exemplo n.º 3
0
        public static bool AnimateControl(Form control, int msec, AnimationTypes flags)
        {
            bool success = false;

            if (control.Visible)
            {
                flags |= AnimationTypes.HIDE;
            }

            if ((AnimationTypes.HIDE & flags) == AnimationTypes.HIDE)
            {
                flags ^= AnimationTypes.HIDE;
            }
            // Are we a top level control
            if (control.TopLevelControl == control)
            {
                flags |= AnimationTypes.ACTIVATE;
            }

            success = AnimateWindow(control.Handle, msec, (int)flags);
            if (success)
            {
                //control.Visible = !control.Visible;
                control.Show();
            }

            return(success);
        }
Exemplo n.º 4
0
 public QForm()
 {
     this.color           = Color.White;
     this.moveModes       = MoveModes.Whole;
     this.rectangle       = new Rectangle(5, 5, 0x10, 0x10);
     this.captionHeight   = 20;
     this.font            = new Font("宋体", 10f);
     this.captionColor    = Color.Black;
     this.point           = new Point();
     this.haloColor       = Color.White;
     this.haloSize        = 5;
     this.textShowModes   = TextShowModes.Halo;
     this.drawIcon        = true;
     this.opacity         = 1.0;
     this.graphicsPath    = new GraphicsPath();
     this.animation       = new Animation();
     this.enableAnimation = true;
     this.animationTypes  = AnimationTypes.FadeinFadeoutEffect;
     this.timer           = new System.Windows.Forms.Timer();
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
     if (base.DesignMode)
     {
         base.SetStyle(ControlStyles.ResizeRedraw, true);
     }
     base.UpdateStyles();
     this.InitializeComponent();
 }
Exemplo n.º 5
0
 public static void takeDamage(int damage = 1, bool damageEvenIfInvulnerable = false)
 {
     if (invulnerable && !damageEvenIfInvulnerable)
     {
         return;
     }
     if (healthPoints <= 0)
     {
         return;
     }
     healthPoints -= damage;
     SoundEffects.PlayerHurt.Play();
     GameStats.hitsCount++;
     if (healthPoints <= 0)
     {
         currentAnimation = AnimationTypes.die;
         healthPoints     = 0;
         GameStats.deathsCount++;
     }
     else
     {
         invulnerable = true;
         elapsedInvulnerabilityTime = 0;
     }
 }
Exemplo n.º 6
0
            // Methods
            public void Read(BINAReader reader)
            {
                // Read the data
                uint lineType = reader.ReadUInt32();
                uint padding1 = reader.ReadUInt32();

                ulong nameOffset = reader.ReadUInt64();
                ulong padding2   = reader.ReadUInt64();

                UnknownFloat1 = reader.ReadSingle();
                byte firstCharacter  = reader.ReadByte();
                byte firstAnim       = reader.ReadByte();
                byte secondCharacter = reader.ReadByte();
                byte secondAnim      = reader.ReadByte();

                TalkingCharacter = reader.ReadUInt64();

                // Parse it
                if (nameOffset != 0)
                {
                    Name = reader.GetString((uint)nameOffset + reader.Offset);
                }

                LineType            = (LineTypes)lineType;
                FirstCharacter      = (CharacterTypes)firstCharacter;
                FirstCharAnimation  = (AnimationTypes)firstAnim;
                SecondCharacter     = (CharacterTypes)secondCharacter;
                SecondCharAnimation = (AnimationTypes)secondAnim;
            }
Exemplo n.º 7
0
        public Animatable(float b, float e, int duration, AnimationTypes type, bool keep)
        {
            ended = false;
            OnEnd = null;

            this.b         = b;
            this.c         = b;
            this.e         = e;
            this.startTick = Program.Tick;
            this.duration  = duration;
            this.keep      = keep;
            this.type      = type;

            this.startTick = Program.Tick;

            if (keep)
            {
                Program.OnUpdate += update;
            }
            else if (Program.SyncUpdate)
            {
                Program.OnUpdateAnimation += update;
            }
            else
            {
                this.ended = true;
                this.c     = e;
            }
        }
Exemplo n.º 8
0
 public GameAnimation(Transform AnimatedObject, AnimationTypes Type, Vector3 TargetPosition, Quaternion TargetRotation, float TimeLeft)
 {
     this.AnimatedObject = AnimatedObject;
     this.Type = Type;
     this.TargetPosition = TargetPosition;
     this.TargetRotation = TargetRotation;
     this.TimeLeft = TimeLeft;
 }
Exemplo n.º 9
0
//---------------------------------------------------------------------------------------
//This is what kicks the attack off
        private void triggerAttack()
        {
            AnimationState = AnimationTypes.Walking;
            CurrentState   = State.MovingToAttack;
//Turn off the health bars when moving, we don't need to display it and it's visually nicer
            HealthBarSurround.enabled = false;
            HealthBar.enabled         = false;
        }
Exemplo n.º 10
0
    // ------------------------------------------------------------------------------------------------------------
    // ----


    private void SetCurrentAnimation(AnimationTypes animationName)
    {
        // Put this check on the server so we don't send network traffic every frame, from every skeleton
        if (!this._animation.IsPlaying(animationName.ToString()))
        {
            RpcSetCurrentAnimation(animationName);
        }
    }
Exemplo n.º 11
0
 public void SetAnimation(AnimationTypes _animation)
 {
     if (currentAnimation == _animation)
     {
         return;
     }
     animations[(int)currentAnimation].ResetFrames();
     currentAnimation = _animation;
 }
Exemplo n.º 12
0
        void RunHideStoryboard(Grid grid, AnimationTypes animation)
        {
            if (grid == null)
            {
                return;
            }

            Storyboard storyboard;

            switch (animation)
            {
            case AnimationTypes.SlideHorizontal:
                storyboard = XamlReader.Load(SlideHorizontalOutStoryboard) as Storyboard;
                break;

            case AnimationTypes.Slide:
                storyboard = XamlReader.Load(SlideDownStoryboard) as Storyboard;
                break;

            case AnimationTypes.Fade:
                storyboard = XamlReader.Load(FadeOutStoryboard) as Storyboard;
                break;

            case AnimationTypes.Fast:
                storyboard = XamlReader.Load(FastOutStoryboard) as Storyboard;
                break;

            default:
                storyboard = XamlReader.Load(SwivelOutStoryboard) as Storyboard;
                break;
            }

            try
            {
                if (storyboard == null)
                {
                    return;
                }

                storyboard.Completed += HideStoryboardCompleted;

                foreach (var t in storyboard.Children)
                {
                    Storyboard.SetTarget(t, grid);
                }

                storyboard.Begin();
            }
            catch (Exception)
            {
                // chances are user nav'ed away
                // attempting to be extremely robust here
                // if this fails, go straight to complete
                // and attempt to remove it from the visual tree
                HideStoryboardCompleted(null, null);
            }
        }
Exemplo n.º 13
0
 public Combo()
 {
     ListNextCombo     = new List <Combo>();
     ListInputChoice   = new List <InputChoice>();
     ComboName         = "";
     AnimationName     = "";
     AnimationType     = AnimationTypes.FullAnimation;
     CurrentInputIndex = 0;
     ComboRotationType = ComboRotationTypes.None;
 }
Exemplo n.º 14
0
        public Combo(string Path)
        {
            FileStream   FS = new FileStream("Content/Triple Thunder/Combos/" + Path + ".ttc", FileMode.Open, FileAccess.Read);
            BinaryReader BR = new BinaryReader(FS, Encoding.UTF8);

            ComboName         = Path;
            AnimationName     = BR.ReadString();
            AnimationType     = (AnimationTypes)BR.ReadInt32();
            ComboRotationType = (ComboRotationTypes)BR.ReadByte();
            InstantActivation = BR.ReadBoolean();

            int ListNextComboCount = BR.ReadInt32();

            ListNextCombo = new List <Combo>(ListNextComboCount);
            ListStart     = new List <int>(ListNextComboCount);
            ListEnd       = new List <int>(ListNextComboCount);

            for (int C = 0; C < ListNextComboCount; C++)
            {
                string NextComboName = BR.ReadString();
                int    Start         = BR.ReadInt32();
                int    End           = BR.ReadInt32();
                Combo  NextCombo;

                if (NextComboName != ComboName)
                {
                    NextCombo = new Combo(NextComboName);
                }
                else
                {
                    NextCombo = this;
                }

                ListStart.Add(Start);
                ListEnd.Add(End);
                NextCombo.Owner = Owner;

                int ListInputChoiceCount = BR.ReadInt32();
                NextCombo.ListInputChoice = new List <InputChoice>(ListInputChoiceCount);
                for (int I = 0; I < ListInputChoiceCount; I++)
                {
                    InputChoice NewInputChoice = new InputChoice();
                    NewInputChoice.AttackInput    = (AttackInputs)BR.ReadByte();
                    NewInputChoice.MovementInput  = (MovementInputs)BR.ReadByte();
                    NewInputChoice.NextInputDelay = BR.ReadInt32();
                    NextCombo.ListInputChoice.Add(NewInputChoice);
                }

                ListNextCombo.Add(NextCombo);
            }

            BR.Close();
            FS.Close();
        }
Exemplo n.º 15
0
 public void StartAnimation(RectTransform tf0, RectTransform tf1, float dur, System.Action cb = null)
 {
     this.reset    = true;
     this.duration = dur;
     this.tf0      = tf0;
     this.tf1      = tf1;
     SetOrigin();
     this.enabled  = true;
     this.animType = AnimationTypes.Move;
     //Debug.Break ();
     StartCoroutine(StartAnimationImpl(0f, cb));
 }
Exemplo n.º 16
0
    private void RpcSetCurrentAnimation(AnimationTypes animationName)
    {
        if (this._animation == null)
        {
            this._animation = this.GetComponent <Animation>();
        }

        if (!this._animation.IsPlaying(animationName.ToString()))
        {
            this._animation.Play(animationName.ToString(), PlayMode.StopSameLayer);
        }
    }
Exemplo n.º 17
0
        public void SendAnimationHash(int animationHash, AnimationTypes type, float value = -1)
        {
            if (serverConnection != null && serverConnection.IsConnected())
            {
                var msg = CreateMessage((byte)MessageID.AnimationHash);

                msg.Write(animationHash);
                msg.Write((int)type);
                msg.Write(value);

                serverConnection.Broadcast(msg, MessagePriority.Immediate, MessageReliability.Unreliable, MessageChannel.Default);
            }
        }
 public void AssignBehavior(GameObject obj, AnimationTypes behavior)
 {
     if (behavior == AnimationTypes.None)
     {
         var rb = obj.AddComponent <Rigidbody>();
         rb.useGravity = true;
     }
     else
     {
         var animator = obj.AddComponent <Animator>();
         animator.runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load(GetAnimationResourceLoadString(behavior), typeof(RuntimeAnimatorController)));
     }
 }
Exemplo n.º 19
0
 public void StartScaleAnimation(float scale0, float scale1, float dur, float wait, Tween.TweenTypes tweenType = Tween.TweenTypes.easeInOutSine, System.Action cb = null)
 {
     //Debug.Break ();
     this.reset     = true;
     this.tweenType = tweenType;
     this.duration  = dur;
     this.scale0    = scale0;
     this.scale1    = scale1;
     this.tf1       = this.GetComponent <RectTransform> ();
     this.animType  = AnimationTypes.Scale;
     SetOrigin();
     this.enabled = true;
     StartCoroutine(StartAnimationImpl(wait, cb));
 }
Exemplo n.º 20
0
 public void StartAlphaAnimation(float v0, float v1, float _duration, float wait, Tween.TweenTypes _tweenType, System.Action cb = null)
 {
     this.reset     = true;
     this.tweenType = _tweenType;
     this.duration  = _duration;
     this.scale0    = v0;
     this.scale1    = v1;
     this.tf1       = this.GetComponent <RectTransform> ();
     this.tf1.gameObject.AddMissingComponent <CanvasGroup>().alpha = v0;
     this.animType = AnimationTypes.AlphaAnimation;
     SetOrigin();
     this.enabled = true;
     this.gameObject.SetActive(true);
     StartCoroutine(StartAnimationImpl(wait, cb));
 }
Exemplo n.º 21
0
 public void StartBezierAnimation(RectTransform target, RectTransform tf0, RectTransform tf1, float dur, System.Action cb = null, Tween.TweenTypes tweenType = Tween.TweenTypes.easeInOutSine)
 {
     this.reset     = true;
     this.tweenType = tweenType;
     this.duration  = dur;
     this.target    = target;
     this.tf0       = tf0;
     this.tf1       = tf1;
     finalPos       = tf1.position;
     SetOrigin();
     this.enabled  = true;
     this.animType = AnimationTypes.MoveBezier;
     //Debug.Break ();
     StartCoroutine(StartAnimationImpl(0f, cb));
 }
        public Animation(Texture texture, float frameRate, params IntRect[] frameRects)
        {
            SpriteSheet = texture;
            MaxFrames   = frameRects.Length;
            Frames      = new Frame[MaxFrames];
            for (int i = 0; i < Frames.Length; i++)
            {
                Frames[i] = new Frame(SpriteSheet, frameRects[i]);
            }

            AnimationType = AnimationTypes.Forward;

            FrameRate = frameRate;
            ResetFrameDur();
        }
Exemplo n.º 23
0
 public void _StartAnimateValue(float v0, float v1, float dur, float wait, Tween.TweenTypes tweenType, System.Action onBegin, System.Action <float> onUpdate, System.Action onEnd)
 {
     this.reset     = true;
     this.tweenType = tweenType;
     this.duration  = dur;
     this.scale0    = v0;
     this.scale1    = v1;
     this.tf1       = this.GetComponent <RectTransform> ();
     this.animType  = AnimationTypes.AnimateValue;
     OnUpdateValue  = onUpdate;
     SetOrigin();
     this.enabled = true;
     onBegin();
     StartCoroutine(StartAnimationImpl(wait, onEnd));
 }
Exemplo n.º 24
0
        public static void Init()
        {
            return;

            // SHORTCUTS
            foreach (var data in Shortcuts)
            {
                AnimationTypes.RegisterShortcut(data.Key, data.Value);
            }

            // GETTER SETTERS
            foreach (var data in GetterSetterHash)
            {
                AnimationTypes.RegisterGetterSetter(data.Key, data.Value);
            }
        }
Exemplo n.º 25
0
    private byte GetIndexByName(AnimationTypes animType)
    {
        List <byte> posibleIndexToReturn = new List <byte>();

        for (byte i = 0; i < animacion.Length; i++)
        {
            if (animacion[i].animationType == animType)
            {
                posibleIndexToReturn.Add(i);
            }
        }
        if (posibleIndexToReturn.Count > 0)
        {
            return(posibleIndexToReturn[UnityEngine.Random.Range(0, posibleIndexToReturn.Count)]);
        }
        throw new Exception("Tipo de la animacion no existe paps");
    }
Exemplo n.º 26
0
 public SimpleWeapon(BinaryReader BR, string OwnerName, string WeaponPath, bool IsCharacterAnimation, Dictionary <string, BaseSkillRequirement> DicRequirement,
                     Dictionary <string, BaseEffect> DicEffects, Dictionary <string, AutomaticSkillTargetType> DicAutomaticSkillTarget)
     : base(BR, OwnerName, WeaponPath, DicRequirement, DicEffects, DicAutomaticSkillTarget)
 {
     if (IsCharacterAnimation)
     {
         AnimationType = AnimationTypes.FullAnimation;
     }
     else
     {
         AnimationType         = AnimationTypes.PartialAnimation;
         ComboRotationType     = ComboRotationTypes.RotateAroundWeaponSlot;
         HoldingAnimationName  = "Triple Thunder/" + WeaponPath + "/Holding";
         ShootingAnimationName = "Triple Thunder/" + WeaponPath + "/Shooting";
         ReloadAnimationName   = "Triple Thunder/" + WeaponPath + "/Reloading";
     }
 }
Exemplo n.º 27
0
        static void AnimationStateMachine(float elapsedTime)
        {
            switch (currentAnimation)
            {
            case AnimationTypes.idle:
                animations[(int)AnimationTypes.jump].Reset();
                break;

            case AnimationTypes.die:
                if (!animations[(int)currentAnimation].Active)
                {
                    animations[(int)AnimationTypes.attack].Reset();
                    animations[(int)AnimationTypes.jump].Reset();
                    Game1.currentGameState = Game1.GameStates.dead;
                }
                break;

            case AnimationTypes.attack:
                if (!animations[(int)currentAnimation].Active)
                {
                    animations[(int)AnimationTypes.attack].Reset();
                    animations[(int)AnimationTypes.jump].Reset();
                    currentAnimation = AnimationTypes.idle;
                }
                break;

            case AnimationTypes.jump:
                break;

            case AnimationTypes.wall:
                if (!isOnTheWall)
                {
                    currentAnimation = AnimationTypes.jump;
                }
                break;

            case AnimationTypes.fall:
                animations[(int)AnimationTypes.jump].Reset();
                break;

            case AnimationTypes.walk:
                animations[(int)AnimationTypes.jump].Reset();
                break;
            }
            animations[(int)currentAnimation].Update(elapsedTime);
        }
Exemplo n.º 28
0
        private void RunShowStoryboard(Grid grid, AnimationTypes animation)
        {
            if (grid == null)
            {
                return;
            }

            Storyboard storyboard;

            switch (animation)
            {
            case AnimationTypes.SlideHorizontal:
                storyboard           = XamlReader.Load(SlideHorizontalInStoryboard) as Storyboard;
                grid.RenderTransform = new TranslateTransform();
                break;

            case AnimationTypes.Slide:
                storyboard           = XamlReader.Load(SlideUpStoryboard) as Storyboard;
                grid.RenderTransform = new TranslateTransform();
                break;

            case AnimationTypes.Fade:
                storyboard = XamlReader.Load(FadeInStoryboard) as Storyboard;
                break;

            case AnimationTypes.Swivel:
            case AnimationTypes.SwivelHorizontal:
            default:
                storyboard      = XamlReader.Load(SwivelInStoryboard) as Storyboard;
                grid.Projection = new PlaneProjection();
                break;
            }

            if (storyboard != null)
            {
                Page.Dispatcher.BeginInvoke(() =>
                {
                    foreach (var t in storyboard.Children)
                    {
                        Storyboard.SetTarget(t, grid);
                    }

                    storyboard.Begin();
                });
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 在指定的属性上开始创建基于关键帧的动画。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetPropertyPath"></param>
        /// <returns></returns>
        public KeyFrameTransitionAnimationFluentContext <T> AnimateWithKeyFrame <T>(string targetPropertyPath)
        {
            AnimationTypes type = AnimationTypes.NotSupport;

            Enum.TryParse(typeof(T).Name, true, out type);

            AnimationFluentContext result;

            switch (type)
            {
            case AnimationTypes.Single:
                result = new ScalarKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateScalarKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector2:
                result = new Vector2KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector2KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector3:
                result = new Vector3KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector3KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Vector4:
                result = new Vector4KeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateVector4KeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Color:
                result = new ColorKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateColorKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.Quaternion:
                result = new QuaternionKeyFrameTransitionAnimationFluentContext(this, Target.Compositor.CreateQuaternionKeyFrameAnimation(), targetPropertyPath);
                _animations.Add(result);
                return((KeyFrameTransitionAnimationFluentContext <T>)result);

            case AnimationTypes.NotSupport:
            default:
                throw new InvalidOperationException("");
            }
        }
Exemplo n.º 30
0
        public Animatable(Animatable parent)
        {
            ended = false;
            OnEnd = null;

            this.b         = parent.b;
            this.c         = parent.c;
            this.e         = parent.e;
            this.startTick = parent.startTick;
            this.duration  = parent.duration;
            this.type      = parent.type;

            this.keep = false;
            if (Program.SyncUpdate)
            {
                Program.OnUpdateAnimation += update;
            }
        }
Exemplo n.º 31
0
 public static void Reset(Vector2 _position)
 {
     position                   = _position;
     jumpSpeed                  = Vector2.Zero;
     isFacingRight              = true;
     horizontalMovementSpeed    = 0;
     isTouchingTheGround        = false;
     isOnTheWall                = false;
     isOnMovingPlatform         = false;
     canDoubleJump              = true;
     isWallJumping              = false;
     elapsedShotTime            = 0f;
     healthPoints               = maxHealthPoints;
     elapsedInvulnerabilityTime = 0;
     invulnerable               = false;
     alphaValue                 = 1;
     haltInput                  = false;
     currentAnimation           = AnimationTypes.idle;
 }
        public void PlayAnimation(AnimationTypes animationType, float duration)
        {
            #if DEBUG
            System.Diagnostics.Debug.Assert(animationType != AnimationTypes.COUNT, "PlayerAnimationAgent::PlayAnimation cannot play animation type COUNT");
            #endif
            if ( animationType != currentType || !animationPlaying )
            {
                animationPlaying = true;
                currentType = animationType;
                SkinnedRModelInstance modelInstance = actor.modelInstance as SkinnedRModelInstance;
                modelInstance.SetAnimationPlayer(animations[(int)animationType]);
                animations[(int)animationType].Looping = true;
                animations[(int)animationType].playState = AnimationPlayer.PlayState.Play;
                animations[(int)animationType].Rewind();
            }

            if (duration < 0.0f)
                speed = 1.0f;
            else
                speed = animations[(int)animationType].Duration / duration;
        }
Exemplo n.º 33
0
 public Animation(AnimationTypes type, object target, int offset, AnimationFinishedHandler handler, int duration)
     : this(type, target, offset, handler, 0, null, 0)
 {
 }
 public void resetAnimation(AnimationTypes animationType)
 {
     animations[(int)animationType].Rewind();
 }
Exemplo n.º 35
0
		private void RunShowStoryboard(Grid grid, AnimationTypes animation)
		{
			if (grid == null)
				return;

			Storyboard storyboard;
			switch (animation)
			{
				case AnimationTypes.SlideHorizontal:
					storyboard = XamlReader.Load(SlideHorizontalInStoryboard) as Storyboard;
					grid.RenderTransform = new TranslateTransform();
					break;

				case AnimationTypes.Slide:
					storyboard = XamlReader.Load(SlideUpStoryboard) as Storyboard;
					grid.RenderTransform = new TranslateTransform();
					break;
				case AnimationTypes.Fade:
					storyboard = XamlReader.Load(FadeInStoryboard) as Storyboard;
					break;
				case AnimationTypes.Swivel:
				case AnimationTypes.SwivelHorizontal:
				default:
					storyboard = XamlReader.Load(SwivelInStoryboard) as Storyboard;
					grid.Projection = new PlaneProjection();
					break;
			}

			if (storyboard != null)
			{
				Page.Dispatcher.BeginInvoke(() =>
					{
						foreach (var t in storyboard.Children)
							Storyboard.SetTarget(t, grid);

						storyboard.Begin();
					});
			}
		}
Exemplo n.º 36
0
        void RunHideStoryboard(Grid grid, AnimationTypes animation)
        {
            if (grid == null)
                return;

            Storyboard storyboard;

            switch (animation)
            {
                case AnimationTypes.SlideHorizontal:
                    storyboard = XamlReader.Load(SlideHorizontalOutStoryboard) as Storyboard;
                    break;
                case AnimationTypes.Slide:
                    storyboard = XamlReader.Load(SlideDownStoryboard) as Storyboard;
                    break;
                case AnimationTypes.Fade:
                    storyboard = XamlReader.Load(FadeOutStoryboard) as Storyboard;
                    break;
                case AnimationTypes.Swivel:
                case AnimationTypes.SwivelHorizontal:
                default:
                    storyboard = XamlReader.Load(SwivelOutStoryboard) as Storyboard;
                    break;
            }

            try
            {
                if (storyboard != null)
                {
                    storyboard.Completed += HideStoryboardCompleted;

                    foreach (var t in storyboard.Children)
                        Storyboard.SetTarget(t, grid);

                    storyboard.Begin();
                }
            }
            catch (Exception)
            {
                // chances are user nav'ed away
                // attempting to be extremely robust here
                // if this fails, go straight to complete
                // and attempt to remove it from the visual tree
                HideStoryboardCompleted(null, null);
            }
        }
Exemplo n.º 37
0
        private void RunShowStoryboard(UIElement grid, AnimationTypes animation, TimeSpan delay)
        {
            if (grid == null)
                return;

            Storyboard storyboard;
            switch (animation)
            {
                case AnimationTypes.SlideHorizontal:
                    storyboard = XamlReader.Load(SlideHorizontalInStoryboard) as Storyboard;
                    grid.RenderTransform = new TranslateTransform();
                    break;

                case AnimationTypes.Slide:
                    storyboard = XamlReader.Load(SlideUpStoryboard) as Storyboard;
                    grid.RenderTransform = new TranslateTransform();
                    break;
                case AnimationTypes.Fade:
                    storyboard = XamlReader.Load(FadeInStoryboard) as Storyboard;
                    break;
                case AnimationTypes.Swivel:
                case AnimationTypes.SwivelHorizontal:
                default:
                    storyboard = XamlReader.Load(SwivelInStoryboard) as Storyboard;
                    grid.Projection = new PlaneProjection();
                    break;
            }

            if (storyboard != null)
            {
                foreach (var storyboardAnimation in storyboard.Children)
                {
                    if (!(storyboardAnimation is DoubleAnimationUsingKeyFrames))
                        continue;

                    var doubleKey = storyboardAnimation as DoubleAnimationUsingKeyFrames;

                    foreach (var frame in doubleKey.KeyFrames)
                    {
                        frame.KeyTime = KeyTime.FromTimeSpan(frame.KeyTime.TimeSpan.Add(delay));
                    }
                }

                Page.Dispatcher.BeginInvoke(() =>
                {
                    foreach (var t in storyboard.Children)
                        Storyboard.SetTarget(t, grid);

                    storyboard.Begin();
                });
            }
        }
Exemplo n.º 38
0
 private void RunShowStoryboard(UIElement grid, AnimationTypes animation)
 {
     RunShowStoryboard(grid, animation, TimeSpan.MinValue);
 }
Exemplo n.º 39
0
        public Animation(AnimationTypes type, object target, int offset, AnimationFinishedHandler handler, int duration, AnimationCallback callback, int startValue)
        {
            this.type = type;
            this.target = target;
            this.offset = offset;
            this.handler = handler;
            this.duration = duration;

            // timings in ms
            interval = 10;
            timePassed = 0;

            Control c;
            Form f;
            switch (type)
            {
                case AnimationTypes.ResizeHoriz:
                    c = target as Control;
                    if (c == null) return;
                    start = c.Width;
                    end = start + offset;
                    if (this.duration == 0) this.duration = 150;
                    break;
                case AnimationTypes.ResizeVert:
                    c = target as Control;
                    if (c == null) return;
                    start = c.Height;
                    end = start + offset;
                    if (this.duration == 0) this.duration = 150;
                    break;
                case AnimationTypes.FadeIn:
                    f = target as Form;
                    if (f == null) return;
                    start = (int)(f.Opacity * 100);
                    end = start + offset;
                    if (this.duration == 0) this.duration = 250;
                    break;
                case AnimationTypes.FadeOut:
                    f = target as Form;
                    if (f == null) return;
                    start = (int)(f.Opacity * 100);
                    end = start + offset;
                    if (this.duration == 0) this.duration = 2000;
                    break;
                case AnimationTypes.Callback:
                    if (callback == null) return;
                    start = startValue;
                    end = start + offset;
                    if (this.duration == 0) this.duration = 1000;
                    this.callback = callback;
                    break;
                default:
                    return;
            }

            Next();
        }
 public void PauseAnimation()
 {
     currentType = AnimationTypes.COUNT;
     SkinnedRModelInstance modelInstance = actor.modelInstance as SkinnedRModelInstance;
     modelInstance.SetAnimationPlayer(null);
 }
                this._scale = new Vector(1d, 1d);
            }
Exemplo n.º 42
0
        public override void Update(float ms)
        {
            if (Sprites.ContainsKey(CurrentAnimation))
            {
                Sprites[CurrentAnimation].Update(ms);
            }

            if (IsBuilding)
            {
                CurrentAnimation = AnimationTypes.BeingBuilt;
                elapsedBuildTime += ms;
                Health += ((MaxHealth/BuildTime))*ms;
            }
            else
            {
                if (buildOrder.Count > 0)
                {
                    CurrentAnimation = AnimationTypes.Producing;
                }
                else
                {
                    CurrentAnimation = AnimationTypes.Standard;
                }
            }

            if (buildOrder.Count > 0 && stopwatch.IsRunning == false)
            {
                stopwatch.Restart();
            }
        }