private IEnumerator WaitForProvider()
        {
            while (Provider == null)
            {
                yield return(WaitFor.EndOfFrame);
            }

            scroll = Provider.GetComponent <ScrollOfTeleportation>();
            UpdateChargesCount();
            GenerateEntries();
        }
Example #2
0
        public override void Activate(Character ch)
        {
            base.Activate(ch);

            var hero = ch as Hero;

            if (hero != null)
            {
                ScrollOfTeleportation.TeleportHero(hero);
                hero.curAction = null;
            }
            else
            if (ch is Mob)
            {
                // Why do I try to choose a new position 10 times?
                // I don't remember...
                var count = 10;
                int newPos;
                do
                {
                    newPos = Dungeon.Level.RandomRespawnCell();

                    if (count-- <= 0)
                    {
                        break;
                    }
                } while (newPos == -1);

                if (newPos != -1)
                {
                    ch.pos = newPos;
                    ch.Sprite.Place(ch.pos);
                    ch.Sprite.Visible = Dungeon.Visible[Pos];
                }
            }

            if (Dungeon.Visible[Pos])
            {
                CellEmitter.Get(Pos).Start(Speck.Factory(Speck.LIGHT), 0.2f, 3);
            }
        }
        protected internal override void OnZap(int cell)
        {
            var ch = Actor.FindChar(cell);

            if (ch == CurUser)
            {
                SetKnown();
                ScrollOfTeleportation.TeleportHero(CurUser);
            }
            else
            if (ch != null)
            {
                var count = 10;
                int pos;
                do
                {
                    pos = Dungeon.Level.RandomRespawnCell();
                    if (count-- <= 0)
                    {
                        break;
                    }
                } while (pos == -1);

                if (pos == -1)
                {
                    GLog.Warning(ScrollOfTeleportation.TxtNoTeleport);
                }
                else
                {
                    ch.pos = pos;
                    ch.Sprite.Place(ch.pos);
                    ch.Sprite.Visible = Dungeon.Visible[pos];
                    GLog.Information(CurUser.Name + " teleported " + ch.Name + " to somewhere");
                }
            }
            else
            {
                GLog.Information("nothing happened");
            }
        }