コード例 #1
0
        protected override void UpdateAnimations()
        {
            //System.Diagnostics.Debug.WriteLine(Stats.Health);
            if (Animator.IsCompleted)
            {
                actionLock = ActionLock.None;
            }

            if (attackCooldown != 0)
            {
                attackCooldown -= Time.DeltaTime;
            }

            if (actionLock == ActionLock.None)
            {
                string animation = "idle";
                var    loopMode  = SpriteAnimator.LoopMode.Loop;

                if (PlayerNearby())
                {
                    if (distanceSlimeFrontToPlayer != 0)
                    {
                        animation  = "move";
                        actionLock = ActionLock.None;
                        if (distanceSlimeFrontToPlayer > 0)
                        {
                            Animator.FlipX = true;
                        }
                        else
                        {
                            Animator.FlipX = false;
                        }
                    }
                    else if (attackCooldown <= 0)
                    {
                        animation  = "attack";
                        actionLock = ActionLock.Attack;
                        loopMode   = SpriteAnimator.LoopMode.ClampForever;
                        UnitsCurrAnimationHasAttacked.Clear();
                        attackCooldown = attackCooldownDuration;
                    }
                }
                if (animation == "idle")
                {
                    actionLock = ActionLock.None;
                }

                if (!Animator.IsAnimationActive(animation) || (Animator.IsAnimationActive("attack") && Animator.IsCompleted))
                {
                    Animator.Play(animation, loopMode);
                }
            }
        }
コード例 #2
0
        public void InitializeLayout()
        {
            // Layout
            using (var lk = new ActionLock(
                       () => dockPanel.SuspendLayout(true),
                       () => dockPanel.ResumeLayout(true, true)))
            {
                ResourceExplorer.Instance.Show(dockPanel, DockState.DockLeft);
                PreviewWindow.Instance.Show(ResourceExplorer.Instance.Pane, DockPaneAlignment.Bottom, 0.4);
                StartPage.Instance.Show(dockPanel, DockState.Document);

                (new TimelineWindow()).Show(StartPage.Instance.DockPanel, DockState.DockBottom);
            }
        }
コード例 #3
0
        public void InitializeLayout()
        {
            // Layout
            using (var lk = new ActionLock(
                       () => dockPanel.SuspendLayout(true),
                       () => dockPanel.ResumeLayout(true, true)))
            {
                ResourceExplorer.Instance.Show(dockPanel, DockState.DockLeft);
                PreviewWindow.Instance.Show(ResourceExplorer.Instance.Pane, DockPaneAlignment.Bottom, 0.4);
                StartPage.Instance.Show(dockPanel, DockState.Document);
            }

            // Hook up Update Logic
            updateable.Add(ResourceExplorer.Instance);
            updateable.Add(StartPage.Instance);
            updateable.Add(PreviewWindow.Instance);
        }
コード例 #4
0
ファイル: BattleCharacter.cs プロジェクト: xuebai5/ARPG-Game
        public BattleCharacter(
            int configID,
            List <CharacterMagicData> magics,
            GControllor controllor,
            IBattleCharacter view,
            long userID) : base(controllor, view)
        {
            UserID   = userID;
            HP       = 0;
            ConfigID = configID;
            Magics   = magics;
            var enums = Enum.GetValues(typeof(HeroPropertyType));

            foreach (var i in enums)
            {
                var pr    = (HeroPropertyType)i;
                var value = new ComplexValue();
                Properties.Add(pr, value);
            }
            Lock = new ActionLock();

            Lock.OnStateOnchanged += (s, e) => {
                switch (e.Type)
                {
                case ActionLockType.NOMOVE:
                    if (e.IsLocked)
                    {
                        this.View.StopMove();
                    }
                    break;

                case ActionLockType.INHIDEN:
                    view.SetAlpha(e.IsLocked ? 0.5f: 1);
                    break;
                }
            };
        }
コード例 #5
0
        protected override void UpdateAnimations()
        {
            if (Animator.IsCompleted)
            {
                actionLock = ActionLock.None;
            }

            if (Animator.IsCompleted && animationChainer.IsChainableAnimation(Animator.CurrentAnimationName))
            {
                animationChainer.Start(Animator.CurrentAnimationName);
            }

            if (actionLock == ActionLock.None)
            {
                string animation;
                var    loopMode = SpriteAnimator.LoopMode.Loop;

                noGravity = false;

                // normal attack
                if (primaryAttackInput.IsDown && TiledCollisionState.Below)
                {
                    animation = "attack1";
                    if (animationChainer.WithinChainTime())
                    {
                        animation = animationChainer.NextAnimation();
                    }
                    animationChainer.End();
                    actionLock = ActionLock.Attack;
                    loopMode   = SpriteAnimator.LoopMode.ClampForever;
                    UnitsCurrAnimationHasAttacked.Clear();
                }
                // air attack
                else if (primaryAttackInput.IsDown && !TiledCollisionState.Below)
                {
                    animation = "air-attack1";
                    if (animationChainer.WithinChainTime())
                    {
                        animation = animationChainer.NextAnimation();
                    }
                    animationChainer.End();
                    actionLock = ActionLock.Attack;
                    loopMode   = SpriteAnimator.LoopMode.ClampForever;
                    UnitsCurrAnimationHasAttacked.Clear();
                    noGravity = true;
                }
                // jumping
                else if ((TiledCollisionState.Below && jumpInput.IsPressed) || (!TiledCollisionState.Below && Velocity.Y <= 0))
                {
                    animation  = "jump";
                    actionLock = ActionLock.None;
                    loopMode   = SpriteAnimator.LoopMode.ClampForever;
                    if (Velocity.X < 0)
                    {
                        Animator.FlipX = true;
                    }
                    else if (Velocity.X > 0)
                    {
                        Animator.FlipX = false;
                    }
                }
                // falling
                else if (!TiledCollisionState.Below && Velocity.Y > 0)
                {
                    animation  = "fall";
                    actionLock = ActionLock.None;
                    loopMode   = SpriteAnimator.LoopMode.ClampForever;
                    if (Velocity.X < 0)
                    {
                        Animator.FlipX = true;
                    }
                    else if (Velocity.X > 0)
                    {
                        Animator.FlipX = false;
                    }
                }
                // movement
                else if (Velocity.X != 0)
                {
                    animation  = "run";
                    actionLock = ActionLock.None;
                    if (Velocity.X < 0)
                    {
                        Animator.FlipX = true;
                    }
                    else
                    {
                        Animator.FlipX = false;
                    }
                }
                // idle
                else
                {
                    animation  = "idle";
                    actionLock = ActionLock.None;
                }

                if (!Animator.IsAnimationActive(animation))
                {
                    Animator.Play(animation, loopMode);
                }
            }
        }
コード例 #6
0
 public override void Stunned()
 {
     actionLock = ActionLock.Stunned;
     Animator.Play("stunned", SpriteAnimator.LoopMode.ClampForever);
 }