Esempio n. 1
0
        public IEnumerable <Status> WaitForResources()
        {
            if (Item.ResourcesReservedFor == Agent)
            {
                yield return(Act.Status.Success);

                yield break;
            }

            WanderAct wander = new WanderAct(Agent, 60.0f, 5.0f, 1.0f);

            wander.Initialize();
            var enumerator = wander.Enumerator;

            while (!Item.HasResources)
            {
                enumerator.MoveNext();
                if (Item.ResourcesReservedFor == null || Item.ResourcesReservedFor.IsDead)
                {
                    Agent.SetMessage("Waiting for resources failed.");
                    yield return(Act.Status.Fail);

                    yield break;
                }
                yield return(Act.Status.Running);
            }

            yield return(Act.Status.Success);
        }
Esempio n. 2
0
        public IEnumerable <Act.Status> SummonSkeletons()
        {
            while (true)
            {
                Skeletons.RemoveAll(skeleton => skeleton.IsDead);
                Creature.CurrentCharacterMode  = CharacterMode.Idle;
                Creature.OverrideCharacterMode = false;

                SummonTimer.Update(DwarfTime.LastTime);
                if (SummonTimer.HasTriggered && Skeletons.Count < MaxSkeletons)
                {
                    Creature.CurrentCharacterMode  = Creature.Stats.CurrentClass.AttackMode;
                    Creature.OverrideCharacterMode = true;
                    Creature.Sprite.ReloopAnimations(Creature.Stats.CurrentClass.AttackMode);
                    SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_ic_necromancer_summon, Position, true);
                    SummonTimer.Reset(SummonTimer.TargetTimeSeconds);
                    for (int i = Skeletons.Count; i < MaxSkeletons; i += 2)
                    {
                        SummonSkeleton();
                    }
                    yield return(Act.Status.Success);
                }
                else if (SummonTimer.HasTriggered)
                {
                    yield return(Act.Status.Success);
                }

                GatherSkeletonsTimer.Update(DwarfTime.LastTime);
                if (GatherSkeletonsTimer.HasTriggered)
                {
                    var wander = new WanderAct(this, GatherSkeletonsTimer.TargetTimeSeconds, 1.0f, 1.0f);

                    foreach (var status in wander.Run())
                    {
                        GatherSkeletons();
                        yield return(Act.Status.Running);
                    }
                }

                AttackTimer.Update(DwarfTime.LastTime);
                if (AttackTimer.HasTriggered)
                {
                    OrderSkeletonsToAttack();
                }

                yield return(Act.Status.Running);
            }
        }