private void OnStartClicked() { InputManager.OnDownPressed = null; InputManager.OnUpPressed = null; InputManager.OnInteractPressed = null; MediaPlayer.Stop(); MediaPlayer.Play(ContentChest.GameMusic); #if DEBUG RequestScreenChange?.Invoke(new GameScreen(ContentChest.Maps.Count)); #else RequestScreenChange?.Invoke(new GameScreen()); #endif }
public FinishScreen() { var timer = new Timer { Interval = 4000 }; timer.Elapsed += (e, b) => { RequestScreenChange?.Invoke(new MainMenuScreen()); timer.Stop(); ; }; timer.Start(); }
public GameScreen(int level = 1) { if (!LevelExists(level)) { RequestScreenChange?.Invoke(new GameScreen(level - 1)); return; } _world = new World(level) { RequestNotification = s => RequestNotification?.Invoke(s), RequestTransitionReset = ResetTransition, RequestScreenChange = (screen) => RequestScreenChange?.Invoke(screen) }; Transition.OnTransitionOutEnded = _world.Progress; UIManager = _world.UIManager; }
private void OnContentLoaded() { if (_started) { return; } _started = true; ContentChest.SplashSound.Play(); var timer = new Timer { Interval = 2000 }; timer.Elapsed += (e, b) => { timer.Stop(); RequestScreenChange?.Invoke(new MainMenuScreen()); }; timer.Start(); }
private void ResetWorld() { RequestScreenChange?.Invoke(new GameScreen(_currentLevel)); }
private void UseItem() { if (Player.TargetTile != Player.Tile) { return; } var facing = Player.GetFacingTile(); if (facing == null) { return; } if (facing.WorldObject != null && facing.WorldObject.CanUse) { ContentChest.Sounds[facing.WorldObject.UseSound].Play(); BeginProgress(); return; } var slot = UIManager.GetSelectedSlot(); if (slot.Item == null) { return; } var successful = false; if (!slot.Item.Usable && slot.Item.RepairID != 0) { if (facing.WorldObject != null && facing.WorldObject.Repairable) { successful = facing.WorldObject.Repair(slot.Item.ItemName); if (successful) { ContentChest.InsertSound.Play(); } if (facing.WorldObject.Repaired && facing.WorldObject.EndsLevelOnRepair) { var timer = new Timer { Interval = 2000 }; ContentChest.WindMillSound.Play(); timer.Elapsed += (e, b) => { timer.Stop(); if (GameScreen.LevelExists(_currentLevel + 1)) { RequestScreenChange?.Invoke(new GameScreen(_currentLevel + 1)); } else { RequestScreenChange?.Invoke(new FinishScreen()); } }; timer.Start(); } } } else { var protoType = ContentChest.ProtoTypes[slot.Item.FileName]; successful = protoType.CreateInstance(facing); if (successful) { ContentChest.Sounds[protoType.PlaceSound].Play(); PowerUpNeighbours(facing); AddWorldObject(facing.WorldObject); } } if (!successful) { return; } slot.Remove(1); }