private void StateTransition() { _player.invincible = true; if (_justTransitioned) { //TODO add enemy, puzzle and tile resetting on grid change UpdateScreenBorders(); LoadGridEntities(); _justTransitioned = false; } if (!UpdateCamera()) { _player.invincible = false; //delete old objects _oldEntities.Clear(); // TODO update miniminimap //TODO reset broom _player.dontMove = false; //TODO update minimap _state = PlayStateState.S_NORMAL; } }
private void StateNormal() { if (GlobalState.SetDialogueMode) { _state = PlayStateState.S_DIALOGUE; _childState = new DialogueState(); _player.BeIdle(); return; } CheckForTransition(); if (KeyInput.JustPressedRebindableKey(KeyFunctions.Pause)) { _childState = new PauseState(); _state = PlayStateState.S_PAUSED; _updateEntities = false; _player.dontMove = true; _player.skipBroom = true; SoundManager.PlaySoundEffect("pause_sound"); } if (!_player.broom.exists) { if (KeyInput.JustPressedRebindableKey(KeyFunctions.NextPage)) { SwitchBroom(true); } else if (KeyInput.JustPressedRebindableKey(KeyFunctions.PreviousPage)) { SwitchBroom(false); } if (KeyInput.JustPressedKey(Keys.D4) && InventoryManager.HasTransformer && BroomType.Transformer != InventoryManager.EquippedBroom) { SetBroom(BroomType.Transformer); } else if (KeyInput.JustPressedKey(Keys.D1) && InventoryManager.HasBroom && BroomType.Normal != InventoryManager.EquippedBroom) { SetBroom(BroomType.Normal); } else if (GlobalState.CanChangeBroom) { if (KeyInput.JustPressedKey(Keys.D3) && InventoryManager.HasWiden && BroomType.Wide != InventoryManager.EquippedBroom) { SetBroom(BroomType.Wide); } else if (KeyInput.JustPressedKey(Keys.D2) && InventoryManager.HasLenghten && BroomType.Long != InventoryManager.EquippedBroom) { SetBroom(BroomType.Long); } } } //TODO check if player is unalive }
private void CheckForTransition() { _state = PlayStateState.S_TRANSITION; if (_player.Position.X < _gridBorders.X) { GlobalState.CURRENT_GRID_X--; _player.Position.X = _gridBorders.X - _player.width; } else if (_player.Position.Y < _gridBorders.Y) { GlobalState.CURRENT_GRID_Y--; _player.Position.Y = _gridBorders.Y - _player.height; } else if (_player.Position.Y > _gridBorders.Bottom - _player.height) { GlobalState.CURRENT_GRID_Y++; _player.Position.Y = _gridBorders.Y + _gridBorders.Height; } else if (_player.Position.X > _gridBorders.Right - _player.width) { GlobalState.CURRENT_GRID_X++; _player.Position.X = _gridBorders.Right; } else { _state = PlayStateState.S_NORMAL; } //debugText.text += " ub: " + upperBorder.toString() + "leb: " + leftBorder.toString() + "\n camx: " + FlxG.camera.bounds.x.toString() + "camy: " + FlxG.camera.bounds.y.toString() + //"\n x: " + player.x.toFixed(2) + " y: " + player.y.toFixed(2); if (_state == PlayStateState.S_TRANSITION) { _player.grid_entrance = _player.Position; _justTransitioned = true; _player.dontMove = true; //TODO maybe put this in Player.cs to get the transition bug _player.velocity = Vector2.Zero; } }
public override void Update() { switch (_state) { case PlayStateState.S_NORMAL: StateNormal(); break; case PlayStateState.S_TRANSITION: //Registry.sound_data.current_song.volume = FlxG.volume * Registry.volume_scale; StateTransition(); DoCollisions(); UpdateEntities(); return; case PlayStateState.S_PAUSED: if (_childState is PauseState pauseState) { pauseState.Update(); if (pauseState.Exited) { _state = PlayStateState.S_NORMAL; _childState = null; _player.dontMove = false; _player.skipBroom = false; _player.broom.UpdateBroomType(); _updateEntities = true; return; } } break; case PlayStateState.S_PLAYER_DIED: break; case PlayStateState.S_JUST_ENTERED_MAP: break; case PlayStateState.S_DIRECT_CONTROLS: break; case PlayStateState.S_CUTSCENE: break; case PlayStateState.S_DIALOGUE: if (_childState is DialogueState dialogueState) { _player.dontMove = true; _player.skipBroom = true; dialogueState.Update(); if (GlobalState.Dialogue == "") { _state = PlayStateState.S_NORMAL; _childState = null; _player.dontMove = false; _player.skipBroom = false; } } break; default: break; } if (_updateEntities) { if (!_justTransitioned) { DoCollisions(); } UpdateEntities(); } if (InventoryManager.EquippedBroomChanged) { InventoryManager.EquippedBroomChanged = false; UpdateBroomIcon(); } if (GlobalState.RefreshLabels) { SetKeyLabel(); } #if DEBUG DebugKeyInput(); #endif Refreshes(); }