Пример #1
0
        public IEnumerable <Act.Status> HitAndWait(bool loadBar, Func <float> maxProgress,
                                                   Func <float> progress, Action incrementProgress,
                                                   Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null, bool maintainPos = true)
        {
            Vector3 currentPos = Physics.LocalTransform.Translation;

            CurrentCharacterMode = Stats.CurrentClass.AttackMode;
            Sprite.ResetAnimations(CurrentCharacterMode);
            Sprite.PlayAnimations(CurrentCharacterMode);
            var   p_current      = pos();
            Timer incrementTimer = new Timer(1.0f, false);

            while (progress() < maxProgress())
            {
                if (continueHitting != null && !continueHitting())
                {
                    yield break;
                }

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Renderer.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4,
                                         progress() / maxProgress());
                }
                Physics.Active = false;
                Physics.Face(p_current);
                if (Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, p_current))
                {
                    p_current = pos();
                }
                Physics.Velocity = Vector3.Zero;

                if (!String.IsNullOrEmpty(playSound))
                {
                    NoiseMaker.MakeNoise(playSound, AI.Position, true);
                }

                incrementTimer.Update(DwarfTime.LastTime);
                if (incrementTimer.HasTriggered)
                {
                    Sprite.ReloopAnimations(Stats.CurrentClass.AttackMode);
                    incrementProgress();
                }

                if (maintainPos)
                {
                    var matrix = Physics.LocalTransform;
                    matrix.Translation     = currentPos;
                    Physics.LocalTransform = matrix;
                }

                yield return(Act.Status.Running);
            }
            Sprite.PauseAnimations(Stats.CurrentClass.AttackMode);
            CurrentCharacterMode = CharacterMode.Idle;
            Physics.Active       = true;
            yield return(Act.Status.Success);

            yield break;
        }
Пример #2
0
        /// <summary>
        /// Basic Act that causes the creature to wait for the specified time.
        /// Also draws a loading bar above the creature's head when relevant.
        /// </summary>
        public IEnumerable <Act.Status> HitAndWait(float f, bool loadBar, Func <Vector3> pos)
        {
            var waitTimer = new Timer(f, true);

            CurrentCharacterMode = Stats.CurrentClass.AttackMode;
            Sprite.ResetAnimations(CurrentCharacterMode);
            Sprite.PlayAnimations(CurrentCharacterMode);

            while (!waitTimer.HasTriggered)
            {
                waitTimer.Update(DwarfTime.LastTime);

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Renderer.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4, waitTimer.CurrentTimeSeconds / waitTimer.TargetTimeSeconds);
                }

                Physics.Active = false;

                Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos());
                Physics.Velocity = Vector3.Zero;
                Sprite.ReloopAnimations(Stats.CurrentClass.AttackMode);

                yield return(Act.Status.Running);
            }

            Sprite.PauseAnimations(Stats.CurrentClass.AttackMode);
            CurrentCharacterMode = CharacterMode.Idle;
            Physics.Active       = true;

            yield return(Act.Status.Success);

            yield break;
        }
Пример #3
0
        public IEnumerable <Act.Status> HitAndWait(float f, bool loadBar)
        {
            Timer waitTimer = new Timer(f, true);

            CurrentCharacterMode = CharacterMode.Attacking;
            Sprite.ResetAnimations(Creature.CharacterMode.Attacking);
            Sprite.PlayAnimations(Creature.CharacterMode.Attacking);

            CurrentCharacterMode = Creature.CharacterMode.Attacking;

            while (!waitTimer.HasTriggered)
            {
                waitTimer.Update(DwarfTime.LastTime);

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(AI.Position + Vector3.Up, Color.White, Color.Black, 100, 16, waitTimer.CurrentTimeSeconds / waitTimer.TargetTimeSeconds);
                }

                Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, AI.Position);
                Physics.Velocity = Vector3.Zero;
                Sprite.ReloopAnimations(Creature.CharacterMode.Attacking);
                yield return(Act.Status.Running);
            }
            Sprite.PauseAnimations(Creature.CharacterMode.Attacking);
            CurrentCharacterMode = CharacterMode.Idle;
            yield return(Act.Status.Success);
        }
Пример #4
0
        public IEnumerable <Act.Status> HitAndWait(bool loadBar, Func <float> maxProgress,
                                                   Func <float> progress, Action incrementProgress, Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null)
        {
            CurrentCharacterMode = CharacterMode.Attacking;
            Sprite.ResetAnimations(CharacterMode.Attacking);
            Sprite.PlayAnimations(CharacterMode.Attacking);

            CurrentCharacterMode = CharacterMode.Attacking;
            Timer incrementTimer = new Timer(1.0f, false);

            while (progress() < maxProgress())
            {
                if (continueHitting != null && !continueHitting())
                {
                    yield break;
                }

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4,
                                         progress() / maxProgress());
                }

                Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos());
                Physics.Velocity = Vector3.Zero;
                Sprite.ReloopAnimations(CharacterMode.Attacking);

                if (!String.IsNullOrEmpty(playSound))
                {
                    NoiseMaker.MakeNoise(playSound, AI.Position, true);
                }

                incrementTimer.Update(DwarfTime.LastTime);
                if (incrementTimer.HasTriggered)
                {
                    incrementProgress();
                }

                yield return(Act.Status.Running);
            }
            Sprite.PauseAnimations(CharacterMode.Attacking);
            CurrentCharacterMode = CharacterMode.Idle;
            yield return(Act.Status.Success);

            yield break;
        }
Пример #5
0
        /// <summary>
        /// Basic Act that causes the creature to wait for the specified time.
        /// Also draws a loading bar above the creature's head when relevant.
        /// </summary>
        public IEnumerable <Act.Status> HitAndWait(float f, bool loadBar, Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null)
        {
            var waitTimer = new Timer(f, true);

            CurrentCharacterMode = AttackMode;
            Sprite.ResetAnimations(CurrentCharacterMode);
            Sprite.PlayAnimations(CurrentCharacterMode);

            while (!waitTimer.HasTriggered)
            {
                waitTimer.Update(DwarfTime.LastTime);

                if (continueHitting != null && !continueHitting())
                {
                    yield break;
                }
                Physics.Active = false;
                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4,
                                         waitTimer.CurrentTimeSeconds / waitTimer.TargetTimeSeconds);
                }

                Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos());
                Physics.Velocity = Vector3.Zero;
                Sprite.ReloopAnimations(AttackMode);

                if (!String.IsNullOrEmpty(playSound))
                {
                    NoiseMaker.MakeNoise(playSound, AI.Position, true);
                }

                yield return(Act.Status.Running);
            }
            Sprite.PauseAnimations(AttackMode);
            CurrentCharacterMode = CharacterMode.Idle;
            Physics.Active       = true;
            yield return(Act.Status.Success);

            yield break;
        }