private void Zoom(float value) { pdsharp.noosa.Camera.Main.ZoomTo(value); PixelDungeon.Zoom((int)(value - PixelScene.defaultZoom)); UpdateEnabled(); }
protected override void CreateChildren() { base.CreateChildren(); _image = PixelDungeon.Challenges() > 0 ? Icons.CHALLENGE_ON.Get() : Icons.CHALLENGE_OFF.Get(); Add(_image); }
private void SoundClick(Button obj) { var checkBox = obj as CheckBox; PixelDungeon.SoundFx(checkBox != null && checkBox.Checked()); Sample.Instance.Play(Assets.SND_CLICK); }
private void StartAction(Button obj) { Dungeon.Hero = null; PixelDungeon.Challenges(Dungeon.Challenges); InterlevelScene.mode = InterlevelScene.Mode.DESCEND; InterlevelScene.noStory = true; Game.SwitchScene <InterlevelScene>(); }
protected override void OnClick() { if (Game.Scene is TitleScene) { Game.Instance.Finish(); } else { PixelDungeon.SwitchNoFade <TitleScene>(); } }
private void StartNewGame() { Dungeon.Hero = null; InterlevelScene.mode = InterlevelScene.Mode.DESCEND; if (PixelDungeon.Intro()) { PixelDungeon.Intro(false); Game.SwitchScene(typeof(IntroScene)); } else { Game.SwitchScene(typeof(InterlevelScene)); } }
public override void OnBackPressed() { if (_editable) { var value = 0; for (var i = 0; i < _boxes.Count; i++) { if (_boxes[i].Checked()) { value |= Challenges.MASKS[i]; } } PixelDungeon.Challenges(value); } base.OnBackPressed(); }
public static Blob Seed(int cell, int amount, Type type) { try { var gas = Dungeon.Level.Blobs[type]; if (gas == null) { gas = (Blob)Activator.CreateInstance(type); Dungeon.Level.Blobs.Add(type, gas); } gas.Seed(cell, amount); return(gas); } catch (Exception e) { PixelDungeon.ReportException(e); return(null); } }
protected override void OnTouchUp(Touch t) { if (!_pinching || (t != Touch && t != _another)) { return; } _pinching = false; var zoom = (float)Math.Round(Camera.Zoom); Camera.ZoomTo(zoom); PixelDungeon.Zoom((int)(zoom - PixelScene.defaultZoom)); _dragging = true; if (t == Touch) { Touch = _another; } _another = null; _lastPos.Set(Touch.Current); }
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 override void OnBackPressed() { PixelDungeon.SwitchNoFade <TitleScene>(); }
public WndSettings(bool inGame) { CheckBox btnImmersive = null; if (inGame) { var w = BtnHeight; _btnZoomOut = new RedButton(TxtZoomOut); _btnZoomOut.ClickAction = button => Zoom(pdsharp.noosa.Camera.Main.Zoom - 1); Add(_btnZoomOut.SetRect(0, 0, w, BtnHeight)); _btnZoomIn = new RedButton(TxtZoomIn); _btnZoomIn.ClickAction = button => Zoom(pdsharp.noosa.Camera.Main.Zoom + 1); Add(_btnZoomIn.SetRect(WIDTH - w, 0, w, BtnHeight)); var btnZoomDefault = new RedButton(TxtZoomDefault); btnZoomDefault.ClickAction = button => Zoom(PixelScene.defaultZoom); btnZoomDefault.SetRect(_btnZoomOut.Right(), 0, WIDTH - _btnZoomIn.Width - _btnZoomOut.Width, BtnHeight); Add(btnZoomDefault); } else { var btnScaleUp = new CheckBox(TxtScaleUp); btnScaleUp.ClickAction = ScaleUpClick; btnScaleUp.SetRect(0, 0, WIDTH, BtnHeight); btnScaleUp.SetChecked(PixelDungeon.ScaleUp()); Add(btnScaleUp); btnImmersive = new CheckBox(TxtImmersive); btnImmersive.ClickAction = ImmersiveClick; btnImmersive.SetRect(0, btnScaleUp.Bottom() + Gap, WIDTH, BtnHeight); btnImmersive.SetChecked(PixelDungeon.Immersed()); btnImmersive.Enable(Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat); Add(btnImmersive); } var btnMusic = new CheckBox(TxtMusic); btnMusic.ClickAction = button => { var checkBox = button as CheckBox; PixelDungeon.Music(checkBox != null && checkBox.Checked()); }; btnMusic.SetRect(0, (btnImmersive != null ? btnImmersive.Bottom() : BtnHeight) + Gap, WIDTH, BtnHeight); btnMusic.SetChecked(PixelDungeon.Music()); Add(btnMusic); var btnSound = new CheckBox(TxtSound); btnSound.ClickAction = SoundClick; btnSound.SetRect(0, btnMusic.Bottom() + Gap, WIDTH, BtnHeight); btnSound.SetChecked(PixelDungeon.SoundFx()); Add(btnSound); if (!inGame) { var btnOrientation = new RedButton(OrientationText()); btnOrientation.ClickAction = OrientationClick; btnOrientation.SetRect(0, btnSound.Bottom() + Gap, WIDTH, BtnHeight); Add(btnOrientation); Resize(WIDTH, (int)btnOrientation.Bottom()); } else { var btnBrightness = new CheckBox(TxtBrightness); btnBrightness.ClickAction = button => { var checkBox = button as CheckBox; PixelDungeon.Brightness(checkBox != null && checkBox.Checked()); }; btnBrightness.SetRect(0, btnSound.Bottom() + Gap, WIDTH, BtnHeight); btnBrightness.SetChecked(PixelDungeon.Brightness()); Add(btnBrightness); Resize(WIDTH, (int)btnBrightness.Bottom()); } }
public string OrientationText() { return(PixelDungeon.Landscape() ? TxtSwitchPort : TxtSwitchLand); }
public override void Create() { base.Create(); Badge.LoadGlobal(); uiCamera.Visible = false; var w = Camera.Main.CameraWidth; var h = Camera.Main.CameraHeight; var left = (w - WIDTH) / 2; var top = (h - HEIGHT) / 2; var bottom = h - top; var archs = new Archs(); archs.SetSize(w, h); Add(archs); var title = BannerSprites.Get(BannerSprites.Type.SelectYourHero); title.X = Align((w - title.Width) / 2); title.Y = top; Add(title); btnNewGame = new GameButton(TXT_NEW); btnNewGame.ClickAction = NewGameClick; Add(btnNewGame); btnLoad = new GameButton(TXT_LOAD); btnLoad.ClickAction = LoadClick; Add(btnLoad); var classes = new[] { HeroClass.Warrior, HeroClass.Mage, HeroClass.Rogue, HeroClass.Huntress }; const float shieldW = WIDTH / 2; var shieldH = Math.Min((bottom - BUTTON_HEIGHT - title.Y - title.Height) / 2, shieldW * 1.2f); top = (bottom - BUTTON_HEIGHT + title.Y + title.Height - shieldH * 2) / 2; for (var i = 0; i < classes.Length; i++) { var shield = new ClassShield(classes[i], this); shield.SetRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH); Add(shield); if (Shields.ContainsKey(classes[i])) { Shields[classes[i]] = shield; } else { Shields.Add(classes[i], shield); } } unlock = new Group(); Add(unlock); var challenge = new ChallengeButton(); challenge.SetPos(w / 2 - challenge.Width / 2, top + shieldH - challenge.Height / 2); Add(challenge); if (!(huntressUnlocked = Badge.IsUnlocked(Badge.BOSS_SLAIN_3))) { var text = CreateMultiline(TXT_UNLOCK, 9); text.MaxWidth = (int)WIDTH; text.Measure(); float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.Height) / 2; foreach (var line in new LineSplitter(text.Font, text.Scale, text.Text()).Split()) { line.Measure(); line.Hardlight(0xFFFF00); line.X = Align(left + WIDTH / 2 - line.Width / 2); line.Y = Align(pos); unlock.Add(line); pos += line.Height; } } var btnExit = new ExitButton(); btnExit.SetPos(Camera.Main.CameraWidth - btnExit.Width, 0); Add(btnExit); curClass = null; UpdateClass(HeroClass.Values()[PixelDungeon.LastClass()]); FadeIn(); }
private void ImmersiveClick(Button button) { var checkBox = button as CheckBox; PixelDungeon.Immerse(checkBox != null && checkBox.Checked()); }
private void ScaleUpClick(Button obj) { var checkBox = obj as CheckBox; PixelDungeon.ScaleUp(checkBox != null && checkBox.Checked()); }
private void OrientationClick(Button obj) { PixelDungeon.Landscape(!PixelDungeon.Landscape()); }
public override void Create() { base.Create(); Music.Instance.Play(Assets.THEME, true); //Music.Instance.Volume(1f); uiCamera.Visible = false; var w = Camera.Main.CameraWidth; var h = Camera.Main.CameraHeight; const float height = 180; var archs = new Archs(); archs.SetSize(w, h); Add(archs); var title = BannerSprites.Get(BannerSprites.Type.PixelDungeon); Add(title); title.X = (w - title.Width) / 2; title.Y = (h - height) / 2; PlaceTorch(title.X + 20, title.Y + 20); PlaceTorch(title.X + title.Width - 20, title.Y + 20); var btnBadges = new DashboardItem(TxtBadges, 3); btnBadges.ClickAction = (button) => PixelDungeon.SwitchNoFade <BadgesScene>(); btnBadges.SetPos(w / 2 - btnBadges.Width, (h + height) / 2 - DashboardItem.Size); Add(btnBadges); var btnAbout = new DashboardItem(TxtAbout, 1); btnAbout.ClickAction = (button) => PixelDungeon.SwitchNoFade <AboutScene>(); btnAbout.SetPos(w / 2, (h + height) / 2 - DashboardItem.Size); Add(btnAbout); var btnPlay = new DashboardItem(TxtPlay, 0); btnPlay.ClickAction = (button) => PixelDungeon.SwitchNoFade <StartScene>(); btnPlay.SetPos(w / 2 - btnPlay.Width, btnAbout.Top() - DashboardItem.Size); Add(btnPlay); var btnHighscores = new DashboardItem(TxtHighscores, 2); btnHighscores.ClickAction = (button) => PixelDungeon.SwitchNoFade <RankingsScene>(); btnHighscores.SetPos(w / 2, btnPlay.Top()); Add(btnHighscores); var version = new BitmapText("v " + Game.version, font1x); version.Measure(); version.Hardlight(0x888888); version.X = w - version.Width; version.Y = h - version.Height; Add(version); var btnPrefs = new PrefsButton(); btnPrefs.SetPos(0, 0); Add(btnPrefs); var btnExit = new ExitButton(); btnExit.SetPos(w - btnExit.Width, 0); Add(btnExit); FadeIn(); }
public override void Create() { base.Create(); GameScene.Scene = null; defaultZoom = (int)Math.Ceiling(Game.density * 2.5); while ((Game.Width / defaultZoom < MIN_WIDTH || Game.Height / defaultZoom < MIN_HEIGHT) && defaultZoom > 1) { defaultZoom--; } landscapeAvailable = Game.Height / defaultZoom >= MIN_WIDTH && Game.Width / defaultZoom >= MIN_HEIGHT; if (PixelDungeon.ScaleUp()) { while ((Game.Width / (defaultZoom + 1) >= MIN_WIDTH && Game.Height / (defaultZoom + 1) >= MIN_HEIGHT)) { defaultZoom++; } } minZoom = 1; maxZoom = defaultZoom * 2; Camera.Reset(new PixelCamera(defaultZoom)); float uiZoom = defaultZoom; uiCamera = Camera.CreateFullscreen(uiZoom); Camera.Add(uiCamera); if (font1x == null) { // 3x5 (6) font1x = Font.ColorMarked(BitmapCache.Get(Assets.FONTS1X), Android.Graphics.Color.Argb(0x00, 0x00, 0x00, 0x00), Font.LatinFull); font1x.BaseLine = 6; font1x.tracking = -1; // 5x8 (10) font15x = Font.ColorMarked(BitmapCache.Get(Assets.FONTS15X), 12, Android.Graphics.Color.Argb(0x00, 0x00, 0x00, 0x00), Font.LatinFull); font15x.BaseLine = 9; font15x.tracking = -1; // 6x10 (12) font2x = Font.ColorMarked(BitmapCache.Get(Assets.FONTS2X), 14, Android.Graphics.Color.Argb(0x00, 0x00, 0x00, 0x00), Font.LatinFull); font2x.BaseLine = 11; font2x.tracking = -1; // 7x12 (15) font25x = Font.ColorMarked(BitmapCache.Get(Assets.FONTS25X), 17, Android.Graphics.Color.Argb(0x00, 0x00, 0x00, 0x00), Font.LatinFull); font25x.BaseLine = 13; font25x.tracking = -1; // 9x15 (18) font3x = Font.ColorMarked(BitmapCache.Get(Assets.FONTS3X), 22, Android.Graphics.Color.Argb(0x00, 0x00, 0x00, 0x00), Font.LatinFull); font3x.BaseLine = 17; font3x.tracking = -2; } Sample.Instance.Load(Assets.SND_CLICK, Assets.SND_BADGE, Assets.SND_GOLD); }