private void OnDisable() { EventsSystem.REMOVE_StepsChangedListener(StepSound); EventsSystem.REMOVE_GameLoseListener(LoseSound); EventsSystem.REMOVE_GameWinListener(WinSound); EventsSystem.REMOVE_PlayerFailListener(FailSound); EventsSystem.REMOVE_PlayerSuccessListener(SuccessSound); }
public void HandOffTorch() { FindObjectOfType <Player>().AddToSteps(stepsValue); FindObjectOfType <LevelManager>().RemoveTorchPoint(this); stepsValue = 0; EventsSystem.PlayerSuccess(); Destroy(gameObject); }
private void Move() { if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += Vector3.left; if (!levelManager.CanMove(transform.position)) { transform.position -= Vector3.left; EventsSystem.PlayerFail(); return; } stepsRemaining--; EventsSystem.StepsChanged(stepsRemaining); numberDisplay.SetNumberDisplay(stepsRemaining); } if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) { transform.position += Vector3.right; if (!levelManager.CanMove(transform.position)) { transform.position -= Vector3.right; EventsSystem.PlayerFail(); return; } stepsRemaining--; EventsSystem.StepsChanged(stepsRemaining); numberDisplay.SetNumberDisplay(stepsRemaining); } if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { transform.position += Vector3.up; if (!levelManager.CanMove(transform.position)) { transform.position -= Vector3.up; EventsSystem.PlayerFail(); return; } stepsRemaining--; EventsSystem.StepsChanged(stepsRemaining); numberDisplay.SetNumberDisplay(stepsRemaining); } if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)) { transform.position += Vector3.down; if (!levelManager.CanMove(transform.position)) { transform.position -= Vector3.down; EventsSystem.PlayerFail(); return; } stepsRemaining--; EventsSystem.StepsChanged(stepsRemaining); numberDisplay.SetNumberDisplay(stepsRemaining); } }
private void Update() { if (stepsRemaining <= 0) { EventsSystem.GameLost(); this.enabled = false; } if (stepsRemaining > 0) { Move(); } }
private void Awake() { m_Canvas.gameObject.SetActive(true); m_UI.transform.position = m_UIStartPosition.position; m_PrincessIconStartPosition = m_PrincessIcon.position; m_PrincessGoToPosition = m_PrincessIconStartPosition; m_Instance = this; m_MoveToCrown = false; GetObjectPool = GetComponent <ObjectPool>(); GetScoreSystem = GetComponent <ScoreSystem>(); GetEventSystem = GetComponent <EventsSystem>(); m_DateChecker = GetComponent <DateChecker>(); GetEventSystem.m_PrincessCaughtEvent += PrincessCaught; }
/* * EACH LEVEL HAS A NUMBER * - FIND A WAY TO READ THE NAME OF THE SCENE? * * EACH LEVEL IS AN ARRAY OF STRINGS * LEVELS <BOOL, STRING[]> * |-WORLD |---LEVEL * * LEVELS WRAPPED - ACTIVE TOGGLE * ON INIT LOADS FROM STRING AND MOVES PLAYER * */ private void OnEnable() { InitUI(); if (TorchPoints == null) { TorchPoints = new Dictionary <Vector3, TorchPoint>(); } if (Spaces == null) { Spaces = new Dictionary <Vector3, Space>(); } EventsSystem.ADD_GameLoseListener(LoseScreen); EventsSystem.ADD_GameWinListener(WinScreen); }
public bool CanMove(Vector3 _locationToCheck) { if (TorchPoints.ContainsKey(_locationToCheck)) { TorchPoints[_locationToCheck].HandOffTorch(); } if (Spaces[_locationToCheck].currentSPACE_STATE != SPACE_STATE.BLOCKED) { if (Spaces[_locationToCheck].currentSPACE_STATE == SPACE_STATE.EXIT_SPACE) { EventsSystem.GameWon(); } // Spaces[_locationToCheck].currentSPACE_STATE = SPACE_STATE.BLOCKED; return(true); } return(false); }
private void OnDisable() { EventsSystem.REMOVE_GameLoseListener(LoseScreen); EventsSystem.REMOVE_GameWinListener(WinScreen); }
public void AddToSteps(int _stepsToAdd) { stepsRemaining += _stepsToAdd; EventsSystem.StepsChanged(stepsRemaining); numberDisplay.SetNumberDisplay(stepsRemaining); }