private void OnLevelSelected() { _level = PrefabRepository.Instance.GetLevelPrefab(@"Content\Levels\" + _levelName + ".eql"); GameWorldManager.Instance.SetState(_level._savedState); GameWorldManager.Instance.LoadLastState(); LoadLevel(); Platform.Instance.PhysicsWorld.Gravity = Vector2.UnitY * Platform.Instance.PhysicsWorld.Gravity.Length(); _debugViewState = false; _actionToggleDebugView = false; _debugView = new DebugViewXNA(Platform.Instance.PhysicsWorld); _debugView.LoadContent(Platform.Instance.Device, Platform.Instance.Content); //_debugView.RemoveFlags( DebugViewFlags.Joint ); //_debugView.AppendFlags( DebugViewFlags.PerformanceGraph ); _debugView.TextColor = Color.Black; _view = Matrix.Identity; //Song song = _contentManager.Load<Song>( "music/Beluga_-_Lost_In_Outer_Space" ); //Platform.Instance.SoundManager.PlayMusic( song ); FrameUpdateManager.Instance.Register(HintManager.Instance); FrameUpdateManager.Instance.Register(SceneManager.Instance); _levelLoaded = true; }
private void CreateLevel() { _currentLevel = Instantiate(_level, _startPosition, Quaternion.identity); foreach (var gun in _currentLevel.Guns) { gun.OnFiring += GiveItem; } }
public override void OnUpdate(GameTime gameTime) { if (!_levelLoaded) { return; } base.OnUpdate(gameTime); _pausePhysics = true; if (Keyboard.GetState().IsKeyDown(Keys.LeftControl) && Keyboard.GetState().IsKeyDown(Keys.S) && !_saveAction) { _saveAction = true; GameWorldManager.Instance.SaveState(); _level = PrefabRepository.Instance.GetLevelPrefab(@"Content\Levels\" + _levelName + ".eql"); _level.SetState(GameWorldManager.Instance.GetState()); _level.SerializeLevel(); HintManager.Instance.SpawnHint("Saved " + _levelName, new Vector2(200, 200), 5000, 13); } else if (Keyboard.GetState().IsKeyUp(Keys.S) || Keyboard.GetState().IsKeyUp(Keys.LeftControl)) { _saveAction = false; } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.D)) { if (!_actionToggleDebugView) { _debugViewState = !_debugViewState; _actionToggleDebugView = true; } } if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.D)) { _actionToggleDebugView = false; } if (_inputAggregator.HasEvent(UISButton.G, true)) { _debugViewGrid = !_debugViewGrid; } // debug view segments _debugViewGridstep = UnitsConverter.ToSimUnits(1f); if (_inputAggregator.HasEvent(UISButton.LeftControl) || _inputAggregator.HasEvent(UISButton.RightControl)) { _debugViewGridstep *= 2f; } else if (_inputAggregator.HasEvent(UISButton.LeftShift) || _inputAggregator.HasEvent(UISButton.RightShift)) { _debugViewGridstep *= 0.1f; } }
public void LoadLevel() { string _levelName = "level2"; _level = PrefabRepository.Instance.GetLevelPrefab(@"Content\Levels\" + _levelName + ".eql"); GameWorldManager.Instance.SetState(_level._savedState); GameWorldManager.Instance.LoadLastState(); LoadStatics(); LoadSemiStatics(); LoadDynamics(); LoadTriggers(); }
private void OnWaveOver(bool state) { _previousLevel = _currentLevel; foreach (var gun in _currentLevel.Guns) { gun.OnFiring -= GiveItem; gun.IsActive = false; } _startPosition.z = _startPosition.z + 16f; CreateLevel(); if (state) { _mainCamera.transform.DOMove( new Vector3(_mainCamera.transform.position.x, _mainCamera.transform.position.y, _mainCamera.transform.position.z + 16f), 2f).OnComplete(GoToNextLevelWin); } else { _mainCamera.transform.DOMove( new Vector3(_mainCamera.transform.position.x, _mainCamera.transform.position.y, _mainCamera.transform.position.z + 16f), 2f).OnComplete(GoToNextLevelLoose); } }