// handle camera action based on the cue ball event private void OnCueBallEvent(object sender, IGameEvent gameEvent) { CueBallActionEvent cueBallActionEvent = (CueBallActionEvent)gameEvent; switch (cueBallActionEvent.State) { case CueBallActionEvent.States.Stationary: case CueBallActionEvent.States.Default: { float yPos = transform.position.y; // move the camera closer to the cue ball transform.position = _cueBall.transform.position - transform.forward * _distFromCueBall; transform.position = new Vector3(transform.position.x, yPos, transform.position.z); // keep looking at the cue ball transform.LookAt(_cueBall); // reset the pos to rot vector _posToRot = Vector3.one; } break; case CueBallActionEvent.States.Striked: { _posToRot = _cueBall.transform.position; } break; } }
private void OnCueBallStriked(object sender, IGameEvent gameEvent) { CueBallActionEvent actionEvent = (CueBallActionEvent)gameEvent; if (_isPlaying && actionEvent.State == CueBallActionEvent.States.Striked) { HasStrikedBall = true; } }
private void OnCueBallEvent(object sender, IGameEvent gameEvent) { CueBallActionEvent actionEvent = (CueBallActionEvent)gameEvent; switch (actionEvent.State) { case CueBallActionEvent.States.Stationary: { // change the curr state to default now _currState = CueBallActionEvent.States.Default; } break; } }
/// <summary> /// handle cue controller based on the cue ball events /// </summary> /// <param name="sender"></param> /// <param name="gameEvent"></param> private void OnCueBallEvent(object sender, IGameEvent gameEvent) { CueBallActionEvent cueBallActionEvent = (CueBallActionEvent)gameEvent; // start moving the cue stick towards the ball switch (cueBallActionEvent.State) { case CueBallActionEvent.States.Stationary: case CueBallActionEvent.States.Default: { // making sure everything is clean _forceGathered = 0f; // on ready for next shot position the cue controller closer to cue ball transform.position = _cueBall.transform.position - transform.forward * _defaultDistFromCueBall; transform.LookAt(_cueBall); _posToRot = Vector3.one; } break; case CueBallActionEvent.States.Striked: { _cueReleasedToStrike = false; // make the cue ball go back in the play state if (GameManager.Instance.CurrGameState == GameManager.GameState.Play) { // move the cue backward after striking so that cue ball doesnt touch the cue StartCoroutine(MoveCueAfterStrike(transform.position, _cueBall.transform.position - transform.forward * _defaultDistFromCueBall * 1.5f, 1.0f)); } transform.LookAt(_cueBall); _posToRot = _cueBall.transform.position; } break; } }