protected override void Start() { base.Start(); gameMode = GameMode.NOGAME; //Listen when will shot be fired ShotSignal.AddListener((float shotPower) => ShotBall(shotPower)); //Change shot power at bar to inform player ShotPower.AddListener((float shotPower) => ChangeBallPowerBar(shotPower)); LoadScoreBoard(); }
private void Update() { //If game is not in the play, //there is not need for collecting input if (isGamePlaying) { //Debug.Log("Update"); //Save time if space bar is pressed //And return to do not change camera angle if (Input.GetKey(KeyCode.Space)) { //Debug.Log("KeyDown"); m_shotTime += Time.deltaTime; ShotPower.Dispatch(m_shotTime); return; } else if (Input.GetKeyUp(KeyCode.Space)) { //Debug.Log("KeyMove"); m_shotTime += Time.deltaTime; ShotSignal.Dispatch(m_shotTime); m_shotTime = 0; return; } } if (Input.GetMouseButtonDown(0)) { //Debug.Log("MouseDown :"+ Input.mousePosition.x+" "+ Input.mousePosition.y); //Get move values and send them to listener at camera hanle m_moveHorizontal = Input.mousePosition.x; m_moveVertical = Input.mousePosition.y; return; } if (Input.GetMouseButton(0)) { //Debug.Log("MouseHeld :" + Input.mousePosition.x + " " + Input.mousePosition.y); //Debug.Log("MouseMoveHeld :" + (Input.mousePosition.x - m_moveHorizontal) + " " + (Input.mousePosition.y - m_moveVertical)); //Get move values and send them to listener at camera hanle m_moveHorizontal = Input.mousePosition.x - m_moveHorizontal; m_moveVertical = Input.mousePosition.y - m_moveVertical; MoveSignal.Dispatch(m_moveHorizontal, m_moveVertical); m_moveHorizontal = Input.mousePosition.x; m_moveVertical = Input.mousePosition.y; } }