public CellSelector(DungeonTilemap map) : base(map) { Camera = map.Camera; _dragThreshold = PixelScene.defaultZoom * DungeonTilemap.Size / 2; }
public virtual void Reset(int from, int to, int image, Glowing glowing, ICallback listener) { Revive(); View(image, glowing); _callback = listener; Point(DungeonTilemap.TileToWorld(from)); var dest = DungeonTilemap.TileToWorld(to); var d = PointF.Diff(dest, Point()); Speed.Set(d).Normalize().Scale(SPEED); if (image == 31 || image == 108 || image == 109 || image == 110) { AngularSpeed = 0; Angle = 135 - (float)(Math.Atan2(d.X, d.Y) / 3.1415926 * 180); } else { AngularSpeed = image == 15 || image == 106 ? 1440 : 720; } var tweener = new PosTweener(this, dest, d.Length / SPEED); tweener.Listener = this; Parent.Add(tweener); }
public CheckedCell(int pos) : base(TextureCache.CreateSolid(Android.Graphics.Color.Argb(0xFF, 0x55, 0xAA, 0xFF))) { Origin.Set(0.5f); Point(DungeonTilemap.TileToWorld(pos).Offset(DungeonTilemap.Size / 2, DungeonTilemap.Size / 2)); _alpha = 0.8f; }
public Compass(int cell) { Copy(Icons.COMPASS.Get()); Origin.Set(Width / 2, Radius); _cell = cell; _cellCenter = DungeonTilemap.TileCenterToWorld(cell); Visible = false; }
public Sink(int pos) { _pos = pos; var p = DungeonTilemap.TileCenterToWorld(pos); Pos(p.X - 2, p.Y + 1, 4, 0); Pour(_factory, 0.05f); }
public Wind(int pos) { _pos = pos; var p = DungeonTilemap.TileToWorld(pos); _x = p.X; _y = p.Y; _delay = pdsharp.utils.Random.Float(5); }
public Smoke(int pos) { _pos = pos; var p = DungeonTilemap.TileCenterToWorld(pos); Pos(p.X - 4, p.Y - 2, 4, 0); Pour(Factory, 0.2f); }
public static Emitter Get(int cell) { var p = DungeonTilemap.TileToWorld(cell); var emitter = GameScene.Emitter(); emitter.Pos(p.X, p.Y, DungeonTilemap.Size, DungeonTilemap.Size); return(emitter); }
public static Emitter Center(int cell) { var p = DungeonTilemap.TileToWorld(cell); var emitter = GameScene.Emitter(); emitter.Pos(p.X + DungeonTilemap.Size / 2, p.Y + DungeonTilemap.Size / 2); return(emitter); }
public Flow(int pos) { _pos = pos; var p = DungeonTilemap.TileToWorld(pos); _y = p.Y + DungeonTilemap.Size - 1; _x = p.X; _delay = pdsharp.utils.Random.Float(Delay); }
public Torch(int pos) { _pos = pos; var p = DungeonTilemap.TileCenterToWorld(pos); Pos(p.X - 1, p.Y + 3, 2, 0); Pour(FlameParticle.Factory, 0.15f); Add(new Halo(16, 0xFFFFCC, 0.2f).Point(p.X, p.Y)); }
public override void OnComplete(Animation anim) { base.OnComplete(anim); if (anim != AttackAnimation) { return; } if (Dungeon.Visible[Ch.pos] || Dungeon.Visible[_attackPos]) { Parent.Add(new DeathRay(Center(), DungeonTilemap.TileCenterToWorld(_attackPos))); } }
protected internal override Item AffectItem(Item item) { if (item.Identified) { return(null); } item.Identify(); Badge.ValidateItemLevelAquired(item); Emitter.Parent.Add(new Identification(DungeonTilemap.TileCenterToWorld(Pos))); Journal.Remove(Journal.Feature.WELL_OF_AWARENESS); return(item); }
public virtual void Reset(Plant plant) { Revive(); Reset(plant.Image); Alpha(1f); _pos = plant.Pos; var p = DungeonTilemap.TileToWorld(plant.Pos); X = p.X; Y = p.Y; _state = State.Growing; _time = Delay; }
public override void Update() { if (!(Visible = Dungeon.Visible[_pos])) { return; } base.Update(); if (!((_delay -= Game.Elapsed) <= 0)) { return; } _delay = pdsharp.utils.Random.Float(); var p = DungeonTilemap.TileToWorld(_pos); Recycle <Sparkle>().Reset(p.X + pdsharp.utils.Random.Float(DungeonTilemap.Size), p.Y + pdsharp.utils.Random.Float(DungeonTilemap.Size)); }
private void UseTargeting() { _targeting = _lastTarget != null && _lastTarget.IsAlive && Dungeon.Visible[_lastTarget.pos]; if (!_targeting) { return; } if (Actor.All.Contains(_lastTarget)) { _lastTarget.Sprite.Parent.Add(_crossM); _crossM.Point(DungeonTilemap.TileToWorld(_lastTarget.pos)); _crossB.Visible = true; } else { _lastTarget = null; } }
public virtual void Reset(int from, int to, ICallback callback) { _callback = callback; Revive(); var pf = DungeonTilemap.TileCenterToWorld(from); var pt = DungeonTilemap.TileCenterToWorld(to); x = pf.X; y = pf.Y; Width = 0; Height = 0; var d = PointF.Diff(pt, pf); var speed = new PointF(d).Normalize().Scale(Speed); _sx = speed.X; _sy = speed.Y; _time = d.Length / Speed; }
protected internal override bool AffectHero(Hero hero) { Sample.Instance.Play(Assets.SND_DRINK); Emitter.Parent.Add(new Identification(DungeonTilemap.TileCenterToWorld(Pos))); hero.Belongings.Observe(); for (var i = 0; i < Level.Length; i++) { var terr = Dungeon.Level.map[i]; if ((Terrain.Flags[terr] & Terrain.SECRET) == 0) { continue; } Level.Set(i, Terrain.discover(terr)); GameScene.UpdateMap(i); if (Dungeon.Visible[i]) { GameScene.DiscoverTile(i, terr); } } Buff.Affect <Awareness>(hero, Awareness.Duration); Dungeon.Observe(); Dungeon.Hero.Interrupt(); GLog.Positive(TXT_PROCCED); Journal.Remove(Journal.Feature.WELL_OF_AWARENESS); 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(); }
protected internal override void Fx(int cell, ICallback callback) { cell = Ballistica.Trace[Math.Min(Ballistica.Distance, Distance()) - 1]; CurUser.Sprite.Parent.Add(new DeathRay(CurUser.Sprite.Center(), DungeonTilemap.TileCenterToWorld(cell))); callback.Call(); }
public static void At(int cell, Color color, int n) { At(DungeonTilemap.TileCenterToWorld(cell), color, n); }
public WndInfoCell(int cell) { var tile = Dungeon.Level.map[cell]; if (Level.water[cell]) { tile = Terrain.WATER; } else if (Level.pit[cell]) { tile = Terrain.CHASM; } var titlebar = new IconTitle(); if (tile == Terrain.WATER) { var water = new Image(Dungeon.Level.WaterTex()); water.Frame(0, 0, DungeonTilemap.Size, DungeonTilemap.Size); titlebar.Icon(water); } else { titlebar.Icon(DungeonTilemap.Tile(tile)); } titlebar.Label(Dungeon.Level.TileName(tile)); titlebar.SetRect(0, 0, WIDTH, 0); Add(titlebar); var info = PixelScene.CreateMultiline(6); Add(info); var desc = new StringBuilder(Dungeon.Level.TileDesc(tile)); const string newLine = "\\Negative"; foreach (var blob in Dungeon.Level.Blobs.Values) { if (blob.Cur[cell] <= 0 || blob.TileDesc() == null) { continue; } if (desc.Length() > 0) { desc.Append(newLine); } desc.Append(blob.TileDesc()); } info.Text(desc.Length() > 0 ? desc.ToString() : TxtNothing); info.MaxWidth = WIDTH; info.Measure(); info.X = titlebar.Left(); info.Y = titlebar.Bottom() + Gap; Resize(WIDTH, (int)(info.Y + info.Height)); }