Example #1
0
        protected internal override void DoRead()
        {
            var respawnPoints = Level.NEIGHBOURS8.Select(t => CurUser.pos + t).Where(p => Actor.FindChar(p) == null && (Level.passable[p] || Level.avoid[p])).ToList();

            var nImages = Nimages;

            while (nImages > 0 && respawnPoints.Count > 0)
            {
                var index = pdsharp.utils.Random.Index(respawnPoints);

                var mob = new MirrorImage();
                mob.Duplicate(CurUser);
                GameScene.Add(mob);
                WandOfBlink.Appear(mob, respawnPoints[index]);

                respawnPoints.Remove(index);
                nImages--;
            }

            if (nImages < Nimages)
            {
                SetKnown();
            }

            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #2
0
 public static void Process(int pos)
 {
     if (spawned && given && !processed && (depth == Dungeon.Depth))
     {
         if (alternative)
         {
             FetidRat rat = new FetidRat();
             rat.pos = Dungeon.Level.RandomRespawnCell();
             if (rat.pos != -1)
             {
                 GameScene.Add(rat);
                 processed = true;
             }
         }
         else
         {
             if (pdsharp.utils.Random.Int(left2kill) == 0)
             {
                 Dungeon.Level.Drop(new DriedRose(), pos).Sprite.Drop();
                 processed = true;
             }
             else
             {
                 left2kill--;
             }
         }
     }
 }
Example #3
0
        public override void Press(int cell, Character hero)
        {
            base.Press(cell, hero);

            if (enteredArena || !OutsideEntraceRoom(cell) || hero != Dungeon.Hero)
            {
                return;
            }

            enteredArena = true;

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            do
            {
                boss.pos = pdsharp.utils.Random.Int(Length);
            }while (!passable[boss.pos] || !OutsideEntraceRoom(boss.pos) || Dungeon.Visible[boss.pos]);

            GameScene.Add(boss);

            Set(arenaDoor, Terrain.LOCKED_DOOR);
            GameScene.UpdateMap(arenaDoor);
            Dungeon.Observe();
        }
Example #4
0
        public override int DefenseProc(Character enemy, int damage)
        {
            var spawnPoints = new List <int>();

            for (var i = 0; i < Level.NEIGHBOURS8.Length; i++)
            {
                var p = pos + Level.NEIGHBOURS8[i];
                if (FindChar(p) == null && (Level.passable[p] || Level.avoid[p]))
                {
                    spawnPoints.Add(p);
                }
            }

            if (spawnPoints.Count <= 0)
            {
                return(base.DefenseProc(enemy, damage));
            }

            var larva = new Larva();

            larva.pos = Random.Element(spawnPoints);

            GameScene.Add(larva);
            AddDelayed(new Pushing(larva, pos, larva.pos), -1);

            return(base.DefenseProc(enemy, damage));
        }
Example #5
0
        public override void Press(int cell, Character ch)
        {
            base.Press(cell, ch);

            if (ch != Dungeon.Hero || _enteredArena || !RoomExit.Inside(cell))
            {
                return;
            }

            _enteredArena = true;

            int pos;

            do
            {
                pos = RoomExit.Random();
            }while (pos == cell || Actor.FindChar(pos) != null);

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            boss.pos   = pos;
            GameScene.Add(boss);
            boss.Notice();

            MobPress(boss);

            Set(_arenaDoor, Terrain.LOCKED_DOOR);
            GameScene.UpdateMap(_arenaDoor);
            Dungeon.Observe();
        }
Example #6
0
        public override int DefenseProc(Character enemy, int damage)
        {
            if (HP < damage + 2)
            {
                return(damage);
            }

            var passable = Level.passable;

            int[] neighbours = { pos + 1, pos - 1, pos + Level.Width, pos - Level.Width };
            var   candidates = neighbours.Where(n => passable[n] && FindChar(n) == null).Select(n => n).ToList();

            if (candidates.Count <= 0)
            {
                return(damage);
            }

            Swarm clone = Split();

            clone.HP    = (HP - damage) / 2;
            clone.pos   = Random.Element(candidates);
            clone.State = clone.HUNTING;

            if (Dungeon.Level.map[clone.pos] == Terrain.DOOR)
            {
                Door.Enter(clone.pos);
            }

            GameScene.Add(clone, SplitDelay);
            AddDelayed(new Pushing(clone, pos, clone.pos), -1);

            HP -= clone.HP;

            return(damage);
        }
Example #7
0
        protected internal override void OnZap(int cell)
        {
            var localLevel = Level;

            for (var i = 1; i < Ballistica.Distance - 1; i++)
            {
                var c = Ballistica.Trace[i];
                if (levels.Level.flamable[c])
                {
                    GameScene.Add(Blob.Seed(c, 1, typeof(Fire)));
                }
            }

            GameScene.Add(Blob.Seed(cell, 1, typeof(Fire)));

            var ch = Actor.FindChar(cell);

            if (ch == null)
            {
                return;
            }

            ch.Damage(pdsharp.utils.Random.Int(1, 8 + localLevel * localLevel), this);
            Buff.Affect <Burning>(ch).Reignite(ch);

            ch.Sprite.Emitter().Burst(FlameParticle.Factory, 5);

            if (ch != CurUser || ch.IsAlive)
            {
                return;
            }

            Dungeon.Fail(Utils.Format(ResultDescriptions.WAND, name, Dungeon.Depth));
            GLog.Negative("You killed yourself with your own Wand of Firebolt...");
        }
Example #8
0
        public override void Press(int cell, Character hero)
        {
            base.Press(cell, hero);

            if (enteredArena || !outsideEntraceRoom(cell) || hero != Dungeon.Hero)
            {
                return;
            }

            enteredArena = true;

            var boss = Bestiary.Mob(Dungeon.Depth);

            boss.State = boss.HUNTING;
            do
            {
                boss.pos = Random.Int(Length);
            }while (!passable[boss.pos] || !outsideEntraceRoom(boss.pos) || Dungeon.Visible[boss.pos]);

            GameScene.Add(boss);

            Set(arenaDoor, Terrain.WALL);
            GameScene.UpdateMap(arenaDoor);
            Dungeon.Observe();

            CellEmitter.Get(arenaDoor).Start(Speck.Factory(Speck.ROCK), 0.07f, 10);
            Camera.Main.Shake(3, 0.7f);
            Sample.Instance.Play(Assets.SND_ROCKS);
        }
Example #9
0
        private static readonly Mob Dummy; // = new Mob();

        // 0x770088
        public static void Trigger(int pos, Character c)
        {
            if (Dungeon.BossLevel())
            {
                return;
            }

            if (c != null)
            {
                Actor.OccupyCell(c);
            }

            var nMobs = 1;

            if (Random.Int(2) == 0)
            {
                nMobs++;
                if (Random.Int(2) == 0)
                {
                    nMobs++;
                }
            }

            // It's complicated here, because these traps can be activated in chain
            var candidates = new List <int>();

            foreach (var neighbour in Level.NEIGHBOURS8)
            {
                var p = pos + neighbour;
                if (Actor.FindChar(p) == null && (Level.passable[p] || Level.avoid[p]))
                {
                    candidates.Add(p);
                }
            }

            var respawnPoints = new List <int>();

            while (nMobs > 0 && candidates.Count > 0)
            {
                var index = Random.Index(candidates);

                Dummy.pos = candidates[index];
                Actor.OccupyCell(Dummy);

                var cand = candidates[index];
                candidates.RemoveAt(index);
                respawnPoints.Add(cand);

                nMobs--;
            }

            foreach (var point in respawnPoints)
            {
                var mob = Bestiary.Mob(Dungeon.Depth);
                mob.State = mob.WANDERING;
                GameScene.Add(mob, Delay);
                WandOfBlink.Appear(mob, point);
            }
        }
Example #10
0
        public override void Activate(Character ch)
        {
            base.Activate(ch);

            if (ch != null)
            {
                GameScene.Add(Blob.Seed(Pos, 300 + 20 * Dungeon.Depth, typeof(ConfusionGas)));
            }
        }
Example #11
0
        public override void Move(int step)
        {
            if (State == FLEEING)
            {
                GameScene.Add(Blob.Seed(pos, Random.Int(5, 7), typeof(Web)));
            }

            base.Move(step);
        }
Example #12
0
        protected internal override void OnZap(int cell)
        {
            var localLevel = Level;

            var n = localLevel + 2;

            if (Actor.FindChar(cell) != null && Ballistica.Distance > 2)
            {
                cell = Ballistica.Trace[Ballistica.Distance - 2];
            }

            var passable = BArray.or(levels.Level.passable, levels.Level.avoid, null);

            foreach (var actor in Actor.All.OfType <Character>())
            {
                passable[(actor).pos] = false;
            }

            PathFinder.BuildDistanceMap(cell, passable, n);
            var dist = 0;

            if (Actor.FindChar(cell) != null)
            {
                PathFinder.Distance[cell] = int.MaxValue;
                dist = 1;
            }

            float lifespan = localLevel + 3;

sheepLabel:
            for (var i = 0; i < n; i++)
            {
                do
                {
                    for (var j = 0; j < levels.Level.Length; j++)
                    {
                        if (PathFinder.Distance[j] != dist)
                        {
                            continue;
                        }

                        var sheep = new Sheep();
                        sheep.Lifespan = lifespan;
                        sheep.pos      = j;
                        GameScene.Add(sheep);
                        Dungeon.Level.MobPress(sheep);

                        CellEmitter.Get(j).Burst(Speck.Factory(Speck.WOOL), 4);

                        PathFinder.Distance[j] = int.MaxValue;

                        goto sheepLabel;
                    }
                    dist++;
                } while (dist < n);
            }
        }
        protected internal override void Shatter(int cell)
        {
            SetKnown();

            splash(cell);
            Sample.Instance.Play(Assets.SND_SHATTER);

            GameScene.Add(Blob.Seed(cell, 1000, typeof(ParalyticGas)));
        }
Example #14
0
            protected override bool Act()
            {
                foreach (var neighbour in Level.NEIGHBOURS9)
                {
                    GameScene.Add(Blob.Seed(pos + neighbour, 2, typeof(Fire)));
                }

                return(base.Act());
            }
        protected internal override void Shatter(int cell)
        {
            SetKnown();

            splash(cell);
            Sample.Instance.Play(Assets.SND_SHATTER);

            var fire = Blob.Seed(cell, 2, typeof(Fire));

            GameScene.Add(fire);
        }
Example #16
0
        public override void Activate(Character ch)
        {
            base.Activate(ch);

            GameScene.Add(Blob.Seed(Pos, 2, typeof(Fire)));

            if (Dungeon.Visible[Pos])
            {
                CellEmitter.Get(Pos).Burst(FlameParticle.Factory, 5);
            }
        }
Example #17
0
        public override int Proc(Armor armor, Character attacker, Character defender, int damage)
        {
            var level = Math.Max(0, armor.level);

            if (Level.Adjacent(attacker.pos, defender.pos) && pdsharp.utils.Random.Int(level + 5) >= 4)
            {
                GameScene.Add(Blob.Seed(attacker.pos, 20, typeof(ToxicGas)));
            }

            return(damage);
        }
Example #18
0
            public override void Activate(Character ch)
            {
                base.Activate(ch);

                GameScene.Add(Blob.Seed(Pos, 100, typeof(ToxicGas)));

                Dungeon.Level.Drop(new Seed(), Pos).Sprite.Drop();

                if (ch != null)
                {
                    buffs.Buff.Prolong <Roots>(ch, Tick * 3);
                }
            }
Example #19
0
        private void Summon()
        {
            _nextPedestal = !_nextPedestal;

            Sprite.CenterEmitter().Start(Speck.Factory(Speck.SCREAM), 0.4f, 2);
            Sample.Instance.Play(Assets.SND_CHALLENGE);

            var passable = (bool[])Level.passable.Clone();

            foreach (var actor in All.OfType <Character>())
            {
                passable[(actor).pos] = false;
            }

            var undeadsToSummon = maxArmySize() - Undead.count;

            PathFinder.BuildDistanceMap(pos, passable, undeadsToSummon);
            PathFinder.Distance[pos] = int.MaxValue;
            var dist = 1;

undeadLabel:
            for (var i = 0; i < undeadsToSummon; i++)
            {
                do
                {
                    for (var j = 0; j < Level.Length; j++)
                    {
                        if (PathFinder.Distance[j] != dist)
                        {
                            continue;
                        }

                        var undead = new Undead();
                        undead.pos = j;
                        GameScene.Add(undead);

                        WandOfBlink.Appear(undead, j);
                        new Flare(3, 32).Color(0x000000, false).Show(undead.Sprite, 2f);

                        PathFinder.Distance[j] = int.MaxValue;

                        goto undeadLabel;
                    }

                    dist++;
                }while (dist < undeadsToSummon);
            }

            Yell("Arise, slaves!");
        }
Example #20
0
        public virtual void SpawnFists()
        {
            var fist1 = new RottingFist();
            var fist2 = new BurningFist();

            do
            {
                fist1.pos = pos + Level.NEIGHBOURS8[Random.Int(8)];
                fist2.pos = pos + Level.NEIGHBOURS8[Random.Int(8)];
            }while (!Level.passable[fist1.pos] || !Level.passable[fist2.pos] || fist1.pos == fist2.pos);

            GameScene.Add(fist1);
            GameScene.Add(fist2);
        }
Example #21
0
        public virtual Plant Plant(Plant.Seed seed, int pos)
        {
            var plant = plants[pos];

            if (plant != null)
            {
                plant.Wither();
            }

            plant = seed.Couch(pos);
            plants.Add(pos, plant);

            GameScene.Add(plant);

            return(plant);
        }
Example #22
0
        public override void Press(int cell, Character hero)
        {
            base.Press(cell, hero);

            if (_enteredArena || hero != Dungeon.Hero || cell == entrance)
            {
                return;
            }

            _enteredArena = true;

            for (var i = RoomLeft - 1; i <= RoomRight + 1; i++)
            {
                DoMagic((RoomTop - 1) * Width + i);
                DoMagic((RoomBottom + 1) * Width + i);
            }

            for (var i = RoomTop; i < RoomBottom + 1; i++)
            {
                DoMagic(i * Width + RoomLeft - 1);
                DoMagic(i * Width + RoomRight + 1);
            }

            DoMagic(entrance);
            GameScene.UpdateMap();

            Dungeon.Observe();

            var boss = new Yog();

            do
            {
                boss.pos = Random.Int(Length);
            }while (!passable[boss.pos] || Dungeon.Visible[boss.pos]);

            GameScene.Add(boss);
            boss.SpawnFists();

            _stairs  = entrance;
            entrance = -1;
        }
Example #23
0
        protected override bool Act()
        {
            if (_level.mobs.Count < _level.NMobs())
            {
                var mob = Bestiary.Mutable(Dungeon.Depth);
                mob.State = mob.WANDERING;
                mob.pos   = _level.RandomRespawnCell();
                if (Dungeon.Hero.IsAlive && mob.pos != -1)
                {
                    GameScene.Add(mob);
                    if (Statistics.AmuletObtained)
                    {
                        mob.Beckon(Dungeon.Hero.pos);
                    }
                }
            }

            Spend(Dungeon.NightMode || Statistics.AmuletObtained ? Level.TimeToRespawn / 2 : Level.TimeToRespawn);

            return(true);
        }
Example #24
0
        public static Wraith SpawnAt(int pos)
        {
            if (!levels.Level.passable[pos] || FindChar(pos) != null)
            {
                return(null);
            }

            var w = new Wraith();

            w.AdjustStats(Dungeon.Depth);
            w.pos   = pos;
            w.State = w.HUNTING;
            GameScene.Add(w, SpawnDelay);

            w.Sprite.Alpha(0);
            w.Sprite.Parent.Add(new AlphaTweener(w.Sprite, 1, 0.5f));

            w.Sprite.Emitter().Burst(ShadowParticle.Curse, 5);

            return(w);
        }
Example #25
0
        protected override void OnThrow(int cell)
        {
            var enemy = Actor.FindChar(cell);

            if (enemy == null || enemy == CurUser)
            {
                if (Level.flamable[cell])
                {
                    GameScene.Add(Blob.Seed(cell, 4, typeof(Fire)));
                }
                else
                {
                    base.OnThrow(cell);
                }
            }
            else
            {
                if (!CurUser.Shoot(enemy, this))
                {
                    Dungeon.Level.Drop(this, cell).Sprite.Drop();
                }
            }
        }
Example #26
0
        protected internal override void OnZap(int cell)
        {
            for (var i = 1; i < Ballistica.Distance - 1; i++)
            {
                var p  = Ballistica.Trace[i];
                var c1 = Dungeon.Level.map[p];

                if (c1 == Terrain.EMPTY || c1 == Terrain.EMBERS || c1 == Terrain.EMPTY_DECO)
                {
                    levels.Level.Set(p, Terrain.GRASS);
                }
            }

            var c = Dungeon.Level.map[cell];

            if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO || c == Terrain.GRASS || c == Terrain.HIGH_GRASS)
            {
                GameScene.Add(Blob.Seed(cell, (Level + 2) * 20, typeof(Regrowth)));
            }
            else
            {
                GLog.Information("nothing happened");
            }
        }
Example #27
0
        public override int Proc(Armor armor, Character attacker, Character defender, int damage)
        {
            var level = Math.Max(0, armor.level);

            if (pdsharp.utils.Random.Int(level / 2 + 6) < 5)
            {
                return(damage);
            }

            var respawnPoints = new List <int>();

            for (var i = 0; i < Level.NEIGHBOURS8.Length; i++)
            {
                var p = defender.pos + Level.NEIGHBOURS8[i];
                if (Actor.FindChar(p) == null && (Level.passable[p] || Level.avoid[p]))
                {
                    respawnPoints.Add(p);
                }
            }

            if (respawnPoints.Count <= 0)
            {
                return(damage);
            }

            var mob = new MirrorImage();

            mob.Duplicate((Hero)defender);
            GameScene.Add(mob);
            WandOfBlink.Appear(mob, pdsharp.utils.Random.Element(respawnPoints));

            defender.Damage(pdsharp.utils.Random.IntRange(1, defender.HT / 6), this); //attacker
            CheckOwner(defender);

            return(damage);
        }
Example #28
0
 public void AddCard(CardInfo?info)
 {
     // Add card to scene and hand
     this.onHand.Add(game.Add(new Card(info.Value)));
 }
Example #29
0
        protected override bool Act()
        {
            GameScene.Add(Blob.Seed(pos, 30, typeof(ToxicGas)));

            return(base.Act());
        }
Example #30
0
        public override void Enter()
        {
            models = new Models(Program.Instance.content, Program.Instance.Device);

            var interfaceManager = Program.Instance.InterfaceManager;

            interfaceManager.Add(new WorldSceneControl(interfaceManager, Program.Instance.content)
            {
                Scene = GameScene = new GameScene(Program.Instance),
                Size = ((Control)interfaceManager.Root).Size
            });
            GameScene.Camera = new LookatCamera(Program.Instance);

            HUD = new Client.Interface.HUD(interfaceManager)
            {
                Position = new Vector3(0, 0, 10)
            };
            interfaceManager.Add(HUD);

            Console.WriteLine("Client inited");

            Program.Instance.KeyDown += new System.Windows.Forms.KeyEventHandler(OnKeyDown);
            Program.Instance.KeyUp += new System.Windows.Forms.KeyEventHandler(OnKeyUp);

            Server.Log.Output += new Action<string>((s) => Console.WriteLine(s));

            var m = Program.Instance.Map;

            worldwidth = m.Width;
            worldheight = m.Height;

            motionSimulation = new Common.Motion.Simulation(0, 0, m.Width, m.Height,
                (x, y) => { return Common.Math.GetHeight(m.Heightmap, m.Width, m.Height, new SlimDX.Vector3(x, y, 0)); });

            foreach (Common.Entities.Prop prop in m.PropEntities)
            {
                GameScene.Add(new WorldEntity()
                {
                    Model = models.GetModel(m.PropClasses[prop.Class].Model),
                    Translation = prop.Position,
                    Rotation = Quaternion.RotationAxis(Vector3.UnitZ, prop.Rotation),
                    Scale = new Vector3(prop.Scale, prop.Scale, prop.Scale),
                    Name = prop.Name,
                });
                motionSimulation.CreateStatic(prop.Position, prop.Rotation, prop.Scale, m.PropClasses[prop.Class].CollisionRadius);
            }

            SlimDX.Direct3D9.Mesh ground_mesh = Ground.CreateMesh(Program.Instance.Device, m);
            ground_mesh.ComputeNormals();
            GameScene.View.content.Register("groundmesh", ground_mesh);

            terrainTexture = Program.Instance.content.Get<Texture>("ground.jpg");
            //terrainTexture = Program.Instance.content.Get<Texture>("robber1.png");

            GameScene.Add(new WorldEntity()
            {
                Model = new Model()
                {
                    XMesh = ground_mesh,
                    Texture = terrainTexture,
                    IsBillboard = false,
                    Effect = Program.Instance.content.Get<SlimDX.Direct3D9.Effect>("ground.fx")
                }
            });

            GameState.InitTextures();
        }
Example #31
0
            public override int DefenseProc(Character enemy, int damage)
            {
                GameScene.Add(Blob.Seed(pos, 20, typeof(ParalyticGas)));

                return(base.DefenseProc(enemy, damage));
            }