private void Jump() { _timeToJump = JumpDelay; for (var i = 0; i < 4; i++) { int trapPos; do { trapPos = pdsharp.utils.Random.Int(Level.Length); }while (!Level.fieldOfView[trapPos] || !Level.passable[trapPos]); if (Dungeon.Level.map[trapPos] != Terrain.INACTIVE_TRAP) { continue; } Level.Set(trapPos, Terrain.POISON_TRAP); GameScene.UpdateMap(trapPos); ScrollOfMagicMapping.Discover(trapPos); } int newPos; do { newPos = pdsharp.utils.Random.Int(Level.Length); }while (!Level.fieldOfView[newPos] || !Level.passable[newPos] || Level.Adjacent(newPos, Enemy.pos) || FindChar(newPos) != null); Sprite.Move(pos, newPos); Move(newPos); if (Dungeon.Visible[newPos]) { CellEmitter.Get(newPos).Burst(Speck.Factory(Speck.WOOL), 6); Sample.Instance.Play(Assets.SND_PUFF); } Spend(1 / Speed()); }
public virtual bool Search(bool intentional) { var smthFound = false; var positive = 0; var negative = 0; foreach (var bonus in Buffs <RingOfDetection.Detection>().Select(buff => buff.Level)) { if (bonus > positive) { positive = bonus; } else if (bonus < 0) { negative += bonus; } } var distance = 1 + positive + negative; var level = intentional ? (2 * Awareness - Awareness * Awareness) : Awareness; if (distance <= 0) { level /= 2 - distance; distance = 1; } var cx = pos % Level.Width; var cy = pos / Level.Width; var ax = cx - distance; if (ax < 0) { ax = 0; } var bx = cx + distance; if (bx >= Level.Width) { bx = Level.Width - 1; } var ay = cy - distance; if (ay < 0) { ay = 0; } var by = cy + distance; if (by >= Level.Height) { by = Level.Height - 1; } for (var y = ay; y <= by; y++) { for (int x = ax, p = ax + y * Level.Width; x <= bx; x++, p++) { if (!Dungeon.Visible[p]) { continue; } if (intentional) { Sprite.Parent.AddToBack(new CheckedCell(p)); } if (!Level.secret[p] || (!intentional && !(Random.Float() < level))) { continue; } var oldValue = Dungeon.Level.map[p]; GameScene.DiscoverTile(p, oldValue); Level.Set(p, Terrain.discover(oldValue)); GameScene.UpdateMap(p); ScrollOfMagicMapping.Discover(p); smthFound = true; } } if (intentional) { Sprite.ShowStatus(CharSprite.Default, TxtSearch); Sprite.DoOperate(pos); if (smthFound) { SpendAndNext(Random.Float() < level ? TimeToSearch : TimeToSearch * 2); } else { SpendAndNext(TimeToSearch); } } if (!smthFound) { return(false); } GLog.Warning(TxtNoticedSmth); Sample.Instance.Play(Assets.SND_SECRET); Interrupt(); return(true); }