public void SetWord() { int min_length = Mathf.Clamp(Mathf.FloorToInt(GameController.instance.block_multiplier / 8f) - 1, 3, slots.Length - 1); int max_length = Mathf.Clamp(Mathf.FloorToInt(GameController.instance.block_multiplier / 8f) + 2, 3, slots.Length - 1); int level = (int)GameController.instance.level; word = WordHandler.instance.RandomWord(Random.Range(min_length, max_length)); offset = Random.Range(0, slots.Length - word.Length); for (int i = 0; i < word.Length; i++) { if (word[i] == Tile.question_mark || word[i] == Tile._) { Chasm chasm = Instantiate(GameController.instance.ChasmPrefab, slots[i + offset].position, transform.rotation).GetComponent <Chasm>(); chasm.full_word = this; chasm.this_index = i; chasm.transform.parent = slots[i + offset].parent; slots[i + offset].gameObject.SetActive(false); items[i + offset] = chasm.transform; } else { Transform letter_holder = Instantiate(WordHandler.instance.LetterPrefab, slots[i + offset].position, transform.rotation).transform; mr = letter_holder.GetComponent <MeshRenderer>(); mr.material.SetTexture("_MainTex", WordHandler.instance.lettertile_textures[(int)word[i]]); letter_holder.parent = slots[i + offset].parent; slots[i + offset].gameObject.SetActive(false); items[i + offset] = letter_holder; } } }
private bool GetCloser(int target) { if (Rooted) { return(false); } var step = -1; if (Level.Adjacent(pos, target)) { if (FindChar(target) == null) { if (Level.pit[target] && !Flying && !Chasm.JumpConfirmed) { Chasm.HeroJump(this); Interrupt(); return(false); } if (Level.passable[target] || Level.avoid[target]) { step = target; } } } else { const int len = Level.Length; var p = Level.passable; var v = Dungeon.Level.visited; var m = Dungeon.Level.mapped; var passable = new bool[len]; for (var i = 0; i < len; i++) { passable[i] = p[i] && (v[i] || m[i]); } step = Dungeon.FindPath(this, pos, target, passable, Level.fieldOfView); } if (step == -1) { return(false); } var oldPos = pos; Move(step); Sprite.Move(oldPos, pos); Spend(1 / Speed()); return(true); }
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(); }
public virtual void MobPress(Mob mob) { int cell = mob.pos; if (pit[cell] && !mob.Flying) { Chasm.MobFall(mob); return; } bool trap = true; switch (map[cell]) { case Terrain.TOXIC_TRAP: ToxicTrap.Trigger(cell, mob); break; case Terrain.FIRE_TRAP: FireTrap.Trigger(cell, mob); break; case Terrain.PARALYTIC_TRAP: ParalyticTrap.Trigger(cell, mob); break; case Terrain.POISON_TRAP: PoisonTrap.Trigger(cell, mob); break; case Terrain.ALARM_TRAP: AlarmTrap.Trigger(cell, mob); break; case Terrain.LIGHTNING_TRAP: LightningTrap.Trigger(cell, mob); break; case Terrain.GRIPPING_TRAP: GrippingTrap.Trigger(cell, mob); break; case Terrain.SUMMONING_TRAP: SummoningTrap.Trigger(cell, mob); break; case Terrain.DOOR: Door.Enter(cell); goto default; default: trap = false; break; } if (trap) { if (Dungeon.Visible[cell]) { Sample.Instance.Play(Assets.SND_TRAP); } Set(cell, Terrain.INACTIVE_TRAP); GameScene.UpdateMap(cell); } var plant = plants[cell]; if (plant != null) { plant.Activate(mob); } }
public virtual void Press(int cell, actors.Character ch) { if (pit[cell] && ch == Dungeon.Hero) { Chasm.HeroFall(cell); return; } var trap = false; switch (map[cell]) { case Terrain.SECRET_TOXIC_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.TOXIC_TRAP; case Terrain.TOXIC_TRAP: trap = true; ToxicTrap.Trigger(cell, ch); break; case Terrain.SECRET_FIRE_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.FIRE_TRAP; case Terrain.FIRE_TRAP: trap = true; FireTrap.Trigger(cell, ch); break; case Terrain.SECRET_PARALYTIC_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.PARALYTIC_TRAP; case Terrain.PARALYTIC_TRAP: trap = true; ParalyticTrap.Trigger(cell, ch); break; case Terrain.SECRET_POISON_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.POISON_TRAP; case Terrain.POISON_TRAP: trap = true; PoisonTrap.Trigger(cell, ch); break; case Terrain.SECRET_ALARM_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.ALARM_TRAP; case Terrain.ALARM_TRAP: trap = true; AlarmTrap.Trigger(cell, ch); break; case Terrain.SECRET_LIGHTNING_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.LIGHTNING_TRAP; case Terrain.LIGHTNING_TRAP: trap = true; LightningTrap.Trigger(cell, ch); break; case Terrain.SECRET_GRIPPING_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.GRIPPING_TRAP; case Terrain.GRIPPING_TRAP: trap = true; GrippingTrap.Trigger(cell, ch); break; case Terrain.SECRET_SUMMONING_TRAP: GLog.Information(TXT_HIDDEN_PLATE_CLICKS); goto case Terrain.SUMMONING_TRAP; case Terrain.SUMMONING_TRAP: trap = true; SummoningTrap.Trigger(cell, ch); break; case Terrain.HIGH_GRASS: HighGrass.Trample(this, cell, ch); break; case Terrain.WELL: WellWater.AffectCell(cell); break; case Terrain.ALCHEMY: if (ch == null) { Alchemy.Transmute(cell); } break; case Terrain.DOOR: Door.Enter(cell); break; } if (trap) { Sample.Instance.Play(Assets.SND_TRAP); if (ch == Dungeon.Hero) { Dungeon.Hero.Interrupt(); } Set(cell, Terrain.INACTIVE_TRAP); GameScene.UpdateMap(cell); } var plant = plants[cell]; if (plant != null) { plant.Activate(ch); } }