Exemplo n.º 1
0
        public override void Die(object cause)
        {
            curAction = null;

            DewVial.AutoDrink(this);
            if (IsAlive)
            {
                new Flare(8, 32).Color(0xFFFF66, true).Show(Sprite, 2f);
                return;
            }

            FixTime();
            base.Die(cause);

            var ankh = Belongings.GetItem <Ankh>();

            if (ankh == null)
            {
                ReallyDie(cause);
            }
            else
            {
                Dungeon.DeleteGame(Dungeon.Hero.heroClass, false);
                GameScene.Show(new WndResurrect(ankh, cause));
            }
        }
Exemplo n.º 2
0
        private bool ActDescend(HeroAction.Descend action)
        {
            var stairs = action.Dst;

            if (pos == stairs && pos == Dungeon.Level.exit)
            {
                curAction = null;

                var hunger = Buff <Hunger>();
                if (hunger != null && !hunger.IsStarving)
                {
                    hunger.Satisfy(-Hunger.Starving / 10);
                }

                InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
                Game.SwitchScene(typeof(InterlevelScene));

                return(false);
            }

            if (GetCloser(stairs))
            {
                return(true);
            }

            Ready();
            return(false);
        }
Exemplo n.º 3
0
        private void Ready()
        {
            Sprite.Idle();
            curAction = null;
            ready     = true;

            GameScene.Ready();
        }
Exemplo n.º 4
0
        public virtual void Interrupt()
        {
            if (curAction != null && curAction.Dst != pos)
            {
                lastAction = curAction;
            }

            curAction = null;
        }
Exemplo n.º 5
0
        private bool ActPickUp(HeroAction.PickUp action)
        {
            var dst = action.Dst;

            if (pos == dst)
            {
                var heap = Dungeon.Level.heaps[pos];
                if (heap != null)
                {
                    var item = heap.PickUp();
                    if (item.DoPickUp(this))
                    {
                        if (!(item is Dewdrop))
                        {
                            if ((item is ScrollOfUpgrade && ((ScrollOfUpgrade)item).IsKnown) ||
                                (item is PotionOfStrength && ((PotionOfStrength)item).IsKnown))
                            {
                                GLog.Positive(TxtYouNowHave, item.Name);
                            }
                            else
                            {
                                GLog.Information(TxtYouNowHave, item.Name);
                            }
                        }

                        if (!heap.IsEmpty)
                        {
                            GLog.Information(TxtSomethingElse);
                        }

                        curAction = null;
                    }
                    else
                    {
                        Dungeon.Level.Drop(item, pos).Sprite.Drop();
                        Ready();
                    }
                }
                else
                {
                    Ready();
                }

                return(false);
            }

            if (GetCloser(dst))
            {
                return(true);
            }

            Ready();

            return(false);
        }
Exemplo n.º 6
0
        public override void OnAttackComplete()
        {
            AttackIndicator.Target(_enemy);

            Attack(_enemy);
            curAction = null;

            Invisibility.Dispel();

            base.OnAttackComplete();
        }
Exemplo n.º 7
0
        private bool ActAscend(HeroAction.Ascend action)
        {
            var stairs = action.Dst;

            if (pos == stairs && pos == Dungeon.Level.entrance)
            {
                if (Dungeon.Depth == 1)
                {
                    if (Belongings.GetItem <Amulet>() == null)
                    {
                        GameScene.Show(new WndMessage(TxtLeave));
                        Ready();
                    }
                    else
                    {
                        Dungeon.Win(ResultDescriptions.WIN);
                        Dungeon.DeleteGame(Dungeon.Hero.heroClass, true);
                        Game.SwitchScene(typeof(SurfaceScene));
                    }
                }
                else
                {
                    curAction = null;

                    var hunger = Buff <Hunger>();
                    if (hunger != null && !hunger.IsStarving)
                    {
                        hunger.Satisfy(-Hunger.Starving / 10);
                    }

                    InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
                    Game.SwitchScene(typeof(InterlevelScene));
                }

                return(false);
            }

            if (GetCloser(stairs))
            {
                return(true);
            }

            Ready();
            return(false);
        }
Exemplo n.º 8
0
        public override void OnOperateComplete()
        {
            var unlock = curAction as HeroAction.Unlock;

            if (unlock != null)
            {
                if (_theKey != null)
                {
                    _theKey.Detach(Belongings.Backpack);
                    _theKey = null;
                }

                var doorCell = unlock.Dst;
                var door     = Dungeon.Level.map[doorCell];

                Level.Set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
                GameScene.UpdateMap(doorCell);
            }
            else
            {
                var chest = curAction as HeroAction.OpenChest;
                if (chest != null)
                {
                    if (_theKey != null)
                    {
                        _theKey.Detach(Belongings.Backpack);
                        _theKey = null;
                    }

                    var heap = Dungeon.Level.heaps[chest.Dst];
                    if (heap.HeapType == Heap.Type.Skeleton)
                    {
                        Sample.Instance.Play(Assets.SND_BONES);
                    }
                    heap.Open(this);
                }
            }
            curAction = null;

            base.OnOperateComplete();
        }
Exemplo n.º 9
0
        public virtual bool Handle(int cell)
        {
            if (cell == -1)
            {
                return(false);
            }

            Character ch;
            Heap      heap;

            if (Dungeon.Level.map[cell] == Terrain.ALCHEMY && cell != pos)
            {
                curAction = new HeroAction.Cook(cell);
            }
            else
            if (Level.fieldOfView[cell] && (ch = FindChar(cell)) is Mob)
            {
                if (ch is NPC)
                {
                    curAction = new HeroAction.Interact((NPC)ch);
                }
                else
                {
                    curAction = new HeroAction.Attack(ch);
                }
            }
            else
            if ((heap = Dungeon.Level.heaps[cell]) != null)
            {
                switch (heap.HeapType)
                {
                case Heap.Type.Heap:
                    curAction = new HeroAction.PickUp(cell);
                    break;

                case Heap.Type.ForSale:
                    if (heap.Size() == 1 && heap.Peek().Price() > 0)
                    {
                        curAction = new HeroAction.Buy(cell);
                    }
                    else
                    {
                        curAction = new HeroAction.PickUp(cell);
                    }
                    break;

                default:
                    curAction = new HeroAction.OpenChest(cell);
                    break;
                }
            }
            else if (Dungeon.Level.map[cell] == Terrain.LOCKED_DOOR ||
                     Dungeon.Level.map[cell] == Terrain.LOCKED_EXIT)
            {
                curAction = new HeroAction.Unlock(cell);
            }
            else if (cell == Dungeon.Level.exit)
            {
                curAction = new HeroAction.Descend(cell);
            }
            else if (cell == Dungeon.Level.entrance)
            {
                curAction = new HeroAction.Ascend(cell);
            }
            else
            {
                curAction  = new HeroAction.Move(cell);
                lastAction = null;
            }

            return(Act());
        }
Exemplo n.º 10
0
 public virtual void Resume()
 {
     curAction  = lastAction;
     lastAction = null;
     Act();
 }
Exemplo n.º 11
0
        protected override bool Act()
        {
            base.Act();

            if (Paralysed)
            {
                curAction = null;

                SpendAndNext(Tick);
                return(false);
            }

            CheckVisibleMobs();
            AttackIndicator.UpdateState();

            if (curAction == null)
            {
                if (RestoreHealth)
                {
                    if (IsStarving || HP >= HT)
                    {
                        RestoreHealth = false;
                    }
                    else
                    {
                        Spend(TimeToRest);
                        Next();
                        return(false);
                    }
                }

                Ready();
                return(false);
            }
            RestoreHealth = false;

            ready = false;

            if (curAction is HeroAction.Move)
            {
                return(ActMove((HeroAction.Move)curAction));
            }

            if (curAction is HeroAction.Interact)
            {
                return(ActInteract((HeroAction.Interact)curAction));
            }

            if (curAction is HeroAction.Buy)
            {
                return(ActBuy((HeroAction.Buy)curAction));
            }

            if (curAction is HeroAction.PickUp)
            {
                return(ActPickUp((HeroAction.PickUp)curAction));
            }

            if (curAction is HeroAction.OpenChest)
            {
                return(ActOpenChest((HeroAction.OpenChest)curAction));
            }

            if (curAction is HeroAction.Unlock)
            {
                return(ActUnlock((HeroAction.Unlock)curAction));
            }

            if (curAction is HeroAction.Descend)
            {
                return(ActDescend((HeroAction.Descend)curAction));
            }

            if (curAction is HeroAction.Ascend)
            {
                return(ActAscend((HeroAction.Ascend)curAction));
            }

            if (curAction is HeroAction.Attack)
            {
                return(ActAttack((HeroAction.Attack)curAction));
            }

            if (curAction is HeroAction.Cook)
            {
                return(ActCook((HeroAction.Cook)curAction));
            }

            return(false);
        }