public override int Proc(Armor armor, Character attacker, Character defender, int damage) { if (Dungeon.BossLevel()) { return(damage); } var nTries = (armor.level < 0 ? 1 : armor.level + 1) * 5; for (var i = 0; i < nTries; i++) { var pos = pdsharp.utils.Random.Int(Level.Length); if (!Dungeon.Visible[pos] || !Level.passable[pos] || Actor.FindChar(pos) != null) { continue; } WandOfBlink.Appear(defender, pos); Dungeon.Level.Press(pos, defender); Dungeon.Observe(); break; } return(damage); }
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); }
public void OnSelect(int?target) { if (target == null) { return; } if (!Level.fieldOfView[target.Value] || !(Level.passable[target.Value] || Level.avoid[target.Value]) || Actor.FindChar(target.Value) != null) { GLog.Warning(TXT_FOV); return; } CurUser.HP -= (CurUser.HP / 3); foreach (var mob in Dungeon.Level.mobs.Where(mob => Level.fieldOfView[mob.pos])) { Buff.Prolong <Blindness>(mob, 2); mob.State = mob.WANDERING; mob.Sprite.Emitter().Burst(Speck.Factory(Speck.LIGHT), 4); } WandOfBlink.Appear(CurUser, target.Value); CellEmitter.Get(target.Value).Burst(Speck.Factory(Speck.WOOL), 10); Sample.Instance.Play(Assets.SND_PUFF); Dungeon.Level.Press(target.Value, CurUser); Dungeon.Observe(); CurUser.SpendAndNext(Actor.Tick); }
public static void TeleportHero(Hero hero) { var count = 10; int pos; do { pos = Dungeon.Level.RandomRespawnCell(); if (count-- <= 0) { break; } } while (pos == -1); if (pos == -1) { GLog.Warning(TxtNoTeleport); } else { WandOfBlink.Appear(hero, pos); Dungeon.Level.Press(pos, hero); Dungeon.Observe(); GLog.Information(TxtTeleported); } }
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); } }
public override void Execute(Hero hero, string action) { if (action == AcSet || action == AcReturn) { if (Dungeon.BossLevel()) { hero.Spend(TimeToUse); GLog.Warning(TxtPreventing); return; } for (var i = 0; i < Level.NEIGHBOURS8.Length; i++) { if (Actor.FindChar(hero.pos + Level.NEIGHBOURS8[i]) == null) { continue; } GLog.Warning(TxtCreatures); return; } } switch (action) { case AcSet: _returnDepth = Dungeon.Depth; _returnPos = hero.pos; hero.Spend(TimeToUse); hero.Busy(); hero.Sprite.DoOperate(hero.pos); Sample.Instance.Play(Assets.SND_BEACON); GLog.Information(TxtReturn); break; case AcReturn: if (_returnDepth == Dungeon.Depth) { Reset(); WandOfBlink.Appear(hero, _returnPos); Dungeon.Level.Press(_returnPos, hero); Dungeon.Observe(); } else { InterlevelScene.mode = InterlevelScene.Mode.RETURN; InterlevelScene.returnDepth = _returnDepth; InterlevelScene.returnPos = _returnPos; Reset(); Game.SwitchScene <InterlevelScene>(); } break; default: base.Execute(hero, action); break; } }
private void Blink(int target) { var cell = Ballistica.Cast(pos, target, true, true); if (FindChar(cell) != null && Ballistica.Distance > 1) { cell = Ballistica.Trace[Ballistica.Distance - 2]; } WandOfBlink.Appear(this, cell); _delay = BlinkDelay; }
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!"); }
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); }
public override void Create() { Music.Instance.Play(Assets.TUNE, true); Music.Instance.Volume(1f); PixelDungeon.LastClass(Dungeon.Hero.heroClass.Ordinal()); base.Create(); Camera.Main.ZoomTo(defaultZoom + PixelDungeon.Zoom()); Scene = this; _terrain = new Group(); Add(_terrain); _water = new SkinnedBlock(levels.Level.Width * DungeonTilemap.Size, Level.Height * DungeonTilemap.Size, Dungeon.Level.WaterTex()); _terrain.Add(_water); _ripples = new Group(); _terrain.Add(_ripples); _tiles = new DungeonTilemap(); _terrain.Add(_tiles); Dungeon.Level.AddVisuals(this); _plants = new Group(); Add(_plants); foreach (var plant in Dungeon.Level.plants.Values) { AddPlantSprite(plant); } _heaps = new Group(); Add(_heaps); foreach (var heap in Dungeon.Level.heaps.Values) { AddHeapSprite(heap); } _emitters = new Group(); _effects = new Group(); _emoicons = new Group(); _mobs = new Group(); Add(_mobs); foreach (var mob in Dungeon.Level.mobs) { AddMobSprite(mob); if (Statistics.AmuletObtained) { mob.Beckon(Dungeon.Hero.pos); } } Add(_emitters); Add(_effects); _gases = new Group(); Add(_gases); foreach (var blob in Dungeon.Level.Blobs.Values) { blob.Emitter = null; AddBlobSprite(blob); } _fog = new FogOfWar(Level.Width, Level.Height); _fog.UpdateVisibility(Dungeon.Visible, Dungeon.Level.visited, Dungeon.Level.mapped); Add(_fog); Brightness(PixelDungeon.Brightness()); _spells = new Group(); Add(_spells); _statuses = new Group(); Add(_statuses); Add(_emoicons); _hero = new HeroSprite(); _hero.Place(Dungeon.Hero.pos); _hero.UpdateArmor(); _mobs.Add(_hero); Add(new HealthIndicator()); Add(_cellSelector = new CellSelector(_tiles)); var sb = new StatusPane(); sb.Camera = uiCamera; sb.SetSize(uiCamera.CameraWidth, 0); Add(sb); _toolbar = new Toolbar(); _toolbar.Camera = uiCamera; _toolbar.SetRect(0, uiCamera.CameraHeight - _toolbar.Height, uiCamera.CameraWidth, _toolbar.Height); Add(_toolbar); var attack = new AttackIndicator(); attack.Camera = uiCamera; attack.SetPos(uiCamera.CameraWidth - attack.Width, _toolbar.Top() - attack.Height); Add(attack); _log = new GameLog(); _log.Camera = uiCamera; _log.SetRect(0, _toolbar.Top(), attack.Left(), 0); Add(_log); if (Dungeon.Depth < Statistics.DeepestFloor) { GLog.Information(TxtWelcomeBack, Dungeon.Depth); } else { GLog.Information(TxtWelcome, Dungeon.Depth); Sample.Instance.Play(Assets.SND_DESCEND); } switch (Dungeon.Level.feeling) { case Level.Feeling.CHASM: GLog.Warning(TxtChasm); break; case Level.Feeling.WATER: GLog.Warning(TxtWater); break; case Level.Feeling.GRASS: GLog.Warning(TxtGrass); break; } if (Dungeon.Level is RegularLevel && ((RegularLevel)Dungeon.Level).SecretDoors > pdsharp.utils.Random.IntRange(3, 4)) { GLog.Warning(TxtSecrets); } if (Dungeon.NightMode && !Dungeon.BossLevel()) { GLog.Warning(TxtNightMode); } _busy = new BusyIndicator(); _busy.Camera = uiCamera; _busy.X = 1; _busy.Y = sb.Bottom() + 1; Add(_busy); switch (InterlevelScene.mode) { case InterlevelScene.Mode.RESURRECT: WandOfBlink.Appear(Dungeon.Hero, Dungeon.Level.entrance); new Flare(8, 32).Color(0xFFFF66, true).Show(_hero, 2f); break; case InterlevelScene.Mode.RETURN: WandOfBlink.Appear(Dungeon.Hero, Dungeon.Hero.pos); break; case InterlevelScene.Mode.FALL: Chasm.HeroLand(); break; case InterlevelScene.Mode.DESCEND: switch (Dungeon.Depth) { case 1: WndStory.ShowChapter(WndStory.ID_SEWERS); break; case 6: WndStory.ShowChapter(WndStory.ID_PRISON); break; case 11: WndStory.ShowChapter(WndStory.ID_CAVES); break; case 16: WndStory.ShowChapter(WndStory.ID_METROPOLIS); break; case 22: WndStory.ShowChapter(WndStory.ID_HALLS); break; } if (Dungeon.Hero.IsAlive && Dungeon.Depth != 22) { Badge.ValidateNoKilling(); } break; } Camera.Main.Target = _hero; //var m = new string[Level.Width]; //var b = new StringBuilder(); //for (var i = 0; i < Level.passable.Length; i++) //{ // var cx = i % Level.Width; // var cy = i / Level.Width; // if (i == Dungeon.Hero.pos) // { // m[cx] += "H"; // continue; // } // if (Level.passable[i]) // m[cx] += "."; // else // m[cx] += "#"; //} //foreach (var s in m) // b.AppendLine(s); //Debug.WriteLine(b); //for (var i = 0; i < Dungeon.Level.mapped.Length; i++) // Dungeon.Level.mapped[i] = true; FadeIn(); }