public MainPage() { InitializeComponent(); SoundPlayer.FillDictionary(App.Current.Resources.MergedDictionaries[0]); SoundPlayer.BackgroundMusic.FillBgDictionary(App.Current.Resources.MergedDictionaries[1]); TextHandler.FillDictionary(App.Current.Resources.MergedDictionaries[2]); this.GotFocus += MainPageGotFocus; this.LostFocus += MainPageLostFocus; _keyHandler = new KeyHandler(this); _menuEngine = new MenuEngine(this.gameSurface); _menuEngine.Updated += MenuEngineUpdated; _levelEngine = new LevelEngine(new Canvas()); _levelEngine.Renewed += LevelEngineRenewed; _hudEngine = new HudEngine(new Canvas()); _scoreEngine = new ScoreEngine(new Canvas(), 10); Level.Player = Player = new Player(); _renderNotifier = new RenderNotifier(this); _renderNotifier.AddObservedChild(this.gameSurface); _renderNotifier.RenderComplete += RenderNotifierRenderComplete; _mainLoop = new CompositionTargetGameLoop(); _mainLoop.Update += MainLoopUpdate; }
private void Awake() { Time.timeScale = 1; level = GameData.levels[SceneManager.GetActiveScene().name]; current = this; Unit.init = false; }
void OnUserInput(string input) { if (input == "menu") { game_state = Screen.MainMenu; ShowMainMenu(); } else { if (level_engine != null && level_engine.completed_cnt == 6) { level_engine.st.Stop(); game_state = Screen.Win; ShowWinScreen(); level_engine = null; } else if (game_state == Screen.MainMenu) { game_state = Screen.LevelInstruction; level_engine = new LevelEngine(int.Parse(input)); ShowLevelInstructions(); } else if (game_state == Screen.Level) { if (input == "scramble") { level_engine.ShowLevelData(1); } else { level_engine.ShowLevelData(0); } } else if (game_state == Screen.LevelInstruction) { game_state = Screen.Level; level_engine.ShowLevelData(0); } else if (game_state == Screen.Pass) { level_engine.ShowLevelData(0); game_state = Screen.Level; } else { game_state = Screen.MainMenu; ShowMainMenu(); } } }
public LevelHolder(LevelEngine levelEngine, HudEngine hudEngine, ScoreEngine scoreEngine) : base(_menu) { if (levelEngine == null) { throw new ArgumentNullException("No LevelEngine defined!"); } _levelEngine = levelEngine; _levelEngine.Started += LevelEngineStarted; _levelEngine.BeforeNextLevel += LevelEngineBeforeNextLevel; _levelEngine.Finished += LevelEngineFinished; if (hudEngine == null) { throw new ArgumentNullException("No HudEngine defined!"); } _hudEngine = hudEngine; _hudEngine.TimesUp += TimesUp; if (scoreEngine == null) { throw new ArgumentNullException("No ScoreEngine defined!"); } _scoreEngine = scoreEngine; ConnectPlayer(); _levelSurface = _menu.FindName("levelSurface") as Canvas; if (_levelSurface == null) { throw new NotImplementedException("levelSurface canvas not implemented"); } _levelSurface.Children.Add(_levelEngine.Container); _hudSurface = _menu.FindName("hudSurface") as Canvas; if (_hudSurface == null) { throw new NotImplementedException("hudSurface canvas not implemented"); } _hudSurface.Children.Add(_hudEngine.Container); this.Shown += LevelHolderShown; }
public override bool ProcessCollision(LevelEngine level, System.Drawing.RectangleF intersect) { switch (this.Edges) { case XEdgeType.None: break; case XEdgeType.Bounce: { var sb = this.GetScreenBounds(); if (level.Hero.DirectionX > 0) { level.Hero.Bounds.X = sb.Left - level.Hero.Bounds.Width - (level.Hero.Bounds.Right - sb.Left); } else if (level.Hero.DirectionX < 0) { level.Hero.Bounds.X = sb.Right + sb.Right - level.Hero.Bounds.Left; } else if (level.Hero.DirectionY > 0) { level.Hero.Bounds.Y = sb.Top - level.Hero.Bounds.Height - (level.Hero.Bounds.Bottom - sb.Top); } else if (level.Hero.DirectionY < 0) { level.Hero.Bounds.Y = sb.Bottom + sb.Bottom - level.Hero.Bounds.Top; } // change hero's direction level.Hero.Direction = level.Hero.Direction.Reverse(); this.EnqueueEvent(level.Hero.Id + ":bounce"); }; break; case XEdgeType.Stick: { var sb = this.GetScreenBounds(); if (level.Hero.DirectionX > 0) { level.Hero.Bounds.X = sb.Left - level.Hero.Bounds.Width; } else if (level.Hero.DirectionX < 0) { level.Hero.Bounds.X = sb.Right; } else if (level.Hero.DirectionY > 0) { level.Hero.Bounds.Y = sb.Top - level.Hero.Bounds.Height; } else if (level.Hero.DirectionY < 0) { level.Hero.Bounds.Y = sb.Bottom; } level.Hero.Direction = Direction.VectorStop; this.EnqueueEvent(level.Hero.Id + ":stick"); }; break; case XEdgeType.Teleport: break; } return(true); }
public virtual bool ProcessCollision(LevelEngine level, System.Drawing.RectangleF intersect) { return(false); }