public override void Update() { if (_menu.Activated) { switch (_menu.SelectedItem) { case 0: SoundController.PlaySound(SoundController.Back); Objects.Destroy(_menu); Objects.Destroy(this); break; case 1: if (GameCntrl.WindowManager.IsFullScreen) { _menu.Items[1] = Strings.FullscreenOff; GameCntrl.WindowManager.SetFullScreen(false); } else { _menu.Items[1] = Strings.FullscreenOn; GameCntrl.WindowManager.SetFullScreen(true); } _menu.Activated = false; break; case 2: GameCntrl.MyGame.Exit(); break; } } }
public override void Update() { if (Objects.Count <Arena>() > 0) { Borderless = true; } if (Input.KeyboardCheckPress(Controls.KeyA) || Input.KeyboardCheckPress(Controls.KeyB)) { if (_dialogueLines[LineId].Length != _typedText.ToString().Length) { _typedText = new StringBuilder(_dialogueLines[LineId]); } else { if (!Locked) { LineId += 1; _typedText.Clear(); if (LineId >= _dialogueLines.Length) { LineId = _dialogueLines.Length - 1; Controls.Enabled = true; Objects.Destroy(this); Input.KeyboardClear(); } } } } if (_dialogueLines[LineId].Length != _typedText.ToString().Length) { _typeAlarm.Update(); if (!_typeAlarm.Active) { _typeAlarm.Set(_typeSpeed); } if (_typeAlarm.Triggered) { if (!Voiceless) { SoundController.PlaySound(SoundController.Voice); } _typedText.Append(_dialogueLines[LineId].ElementAt(_typedText.Length)); if (_dialogueLines[LineId].Length - 1 > _typedText.Length) { char nextCh = _dialogueLines[LineId].ElementAt(_typedText.Length); if (nextCh == ' ') { _typedText.Append(' '); } if (nextCh == Environment.NewLine.ElementAt(0)) { _typedText.Append(Environment.NewLine); } } } } }
public override void Update() { if (!Activated) { if (Input.KeyboardCheckPress(Controls.KeyUp)) { SelectedItem -= 1; SoundController.PlaySound(SoundController.Blip); } if (Input.KeyboardCheckPress(Controls.KeyDown)) { SelectedItem += 1; SoundController.PlaySound(SoundController.Blip); } } // Wrapping cursor. if (SelectedItem < 0) { SelectedItem += Items.Length; } if (SelectedItem >= Items.Length) { SelectedItem -= Items.Length; } // Wrapping cursor. if (Input.KeyboardCheckPress(Controls.KeyA)) { Activated = true; } }
void ItemActivate() { // New game. if (SelectedItem == 0) { SoundController.CurrentSong.Stop(); SoundController.PlaySound(SoundController.NewGame); _controlsBlock = true; _newGameAlarm = _newGameTime; _newGameAnimation = true; } // New game. // Load game. if (SelectedItem == 1) { if (File.Exists(Environment.CurrentDirectory + '/' + GameplayController.SaveDir + "/save.map")) { GameplayController.LoadGame(); Objects.Destroy(this); } } // Load game. // Open editor. if (SelectedItem == 2) { new MapEditor(); Objects.Destroy(this); } // Open editor. // Load map. if (SelectedItem == 3) { System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Title = "Save map file"; dialog.Filter = "Map File|*.map"; dialog.ShowDialog(); if (dialog.FileName != "") { MapEditor.LoadMap(dialog.FileName, false); Inventory inv = new Inventory(); Objects.Destroy(this); } } // Load map. // Exit. if (SelectedItem == 4) { GameCntrl.MyGame.Exit(); } // Exit. }
void UseFood(InventoryItem item, int health) { string[] lines; string[] names = { "" }; if (RestoreHealth(health)) { SoundController.PlaySound(SoundController.Heal); lines = new string[] { Strings.EatingFood.Replace("{0}", item.Name1.ToLower()) }; } else { lines = new string[] { Strings.EatingDeny.Replace("{0}", item.Name1.ToLower()) }; item.Amount += 1; } PassDialogue(new Dialogue(names, lines)); }
public override void Update() { if (_currentSelectionMenu != null) { if (_currentSelectionMenu.Activated) { if (_currentSelectionMenu.SelectedItem >= _currentInventory.Count) { // Back button. Objects.Destroy(_currentSelectionMenu); _currentSelectionMenu = null; _currentInventory = null; SoundController.PlaySound(SoundController.Back); // Back button. } else { // Item. InventoryItem item = _currentInventory.ElementAt(_currentSelectionMenu.SelectedItem).Value; bool invoke = true; if (item.Spendable) { item.Amount -= 1; if (_currentInventory == Items) { if (item.Amount <= 0) { _currentInventory.Remove(item.Token); } } else { if (Objects.ObjExists <Battle.Arena>()) { if (item.Amount < 0) { item.Amount = 0; invoke = false; _currentSelectionMenu.Activated = false; } } else { Objects.Destroy(_currentSelectionMenu); new Dialogue(new string[] { "" }, new string[] { Strings.CantUsePotionsNow }); invoke = false; _currentSelectionMenu = null; _currentInventory = null; } } } if (invoke) { Objects.Destroy(_currentSelectionMenu); _currentSelectionMenu = null; _currentInventory = null; _itemActions[item.Token].Invoke(item); } // Item. } } } }
public override void Update() { if (!_controlsBlock) { if (Input.KeyboardCheckPress(Controls.KeyUp)) { SelectedItem -= 1; SoundController.PlaySound(SoundController.Blip); } if (Input.KeyboardCheckPress(Controls.KeyDown)) { SelectedItem += 1; SoundController.PlaySound(SoundController.Blip); } // Wrapping cursor. if (SelectedItem < 0) { SelectedItem += Items.Length; } if (SelectedItem >= Items.Length) { SelectedItem -= Items.Length; } // Wrapping cursor. if (Input.KeyboardCheckPress(Controls.KeyA)) { ItemActivate(); } } if (_newGameAnimation) { _newGameAlarm -= 1; if (_newGameAlarm == 0) { switch (_newGameAnimationStage) { case 0: GameConsole.BaseBackgroundColor = _bufferFg; GameConsole.BaseForegroundColor = _bufferFg; break; case 1: GameConsole.BaseBackgroundColor = _bufferFg; GameConsole.BaseForegroundColor = _bufferBg; break; case 2: GameConsole.BaseBackgroundColor = _bufferBg; GameConsole.BaseForegroundColor = _bufferFg; break; } _newGameAnimationStage += 1; _newGameAlarm = _newGameTime; } // Shitcoding my way to victory. if (_newGameAnimationStage > 40 && !SoundController.NewGame.IsPlaying) { StartNewGame(); } } }