Exemplo n.º 1
0
    private void GameOver()
    {
        state = GameManager.State.GameOver;
        SoundMenager.Singlton.PlaySound(SoundGame.Gameover);

        SaveDataGame();

        if (continueGame)
        {
            ScenManager.Singlton.GameOverPause();
            continueGame = false;
        }
        else
        {
            ScenManager.Singlton.GameOver();
        }
    }
Exemplo n.º 2
0
    private void HandleStateChange(GameManager.State state)
    {
        switch (state)
        {
        case GameManager.State.Play:
            HandlePlayState();
            break;

        case GameManager.State.Pause:
            HandlePauseState();
            break;

        case GameManager.State.Count:
            break;

        default:
            throw new ArgumentOutOfRangeException("state", state, null);
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        GameManager.State gameState = GameManager.gameState;

        if (gameState != prevState && gameState == GameManager.State.ACTIVE)
        {
            AddUserActivity();
        }

        if (gameState == GameManager.State.IDLE)
        {
            AddUptime(Time.deltaTime, false);
        }
        else
        {
            AddUptime(Time.deltaTime, true);
        }

        prevState = gameState;
    }
Exemplo n.º 4
0
    private void GameManager_OnStateChanged(GameManager.State newState)
    {
        if (newState == GameManager.State.GameOver)
        {
            instructionsText.gameObject.SetActive(true);
            instructionsText.text = @"GAME OVER
    'R' - Play / Restart";
        }
        else if (newState == GameManager.State.Menu)
        {
            instructionsText.gameObject.SetActive(true);
            instructionsText.text = @"Arrow Up - Rotate
    Arrow Left - Move Left
    Arrow Right - Move Right
    Arrow Down - Move Down

    'R' - Play / Restart";
        }
        else if (newState == GameManager.State.Play)
        {
            instructionsText.gameObject.SetActive(false);
        }
    }
    protected override void OnGameManagerStateChange(GameManager.State newState)
    {
        gameObject.SetActive(newState != GameManager.State.Menu);
        menuPP.SetActive(newState == GameManager.State.Menu);

        gamePanel.SetActive(newState == GameManager.State.Game);
        gamePP.SetActive(newState == GameManager.State.Game);

        Cursor.visible = newState != GameManager.State.Game;

        if (newState == GameManager.State.Launch)
        {
            gamePanel.SetActive(false);
            winnerImage.color = GameManager.Instance.Winner.Color;
        }

        if (newState == GameManager.State.GameOver)
        {
            gamePanel.SetActive(false);
            gameOverPanel.SetActive(true);
            gameOverPP.SetActive(true);
        }
    }
Exemplo n.º 6
0
    //add 1 to win/draw/lose prefs value
    public void AddResult(GameManager.State state)
    {
        switch (state)
        {
        case GameManager.State.PlayerWin:

            PlayerPrefsManager.SetWins(PlayerPrefsManager.GetWins() + 1);
            break;

        case GameManager.State.AIWin:

            PlayerPrefsManager.SetLoses(PlayerPrefsManager.GetLoses() + 1);
            break;

        case GameManager.State.Draw:

            PlayerPrefsManager.SetDraws(PlayerPrefsManager.GetDraws() + 1);
            break;

        default:
            break;
        }
    }
Exemplo n.º 7
0
    // Shooting off ammo
    public void EndShooting()
    {
        shootingCountAmmo--;

        //  Debug.Log(shootingCountAmmo);
        if (shootingCountAmmo == 0)
        {
            this.state = GameManager.State.Idle;
            Addline();

            SetPositionBrickKill(new Vector3(GetRendomPositionXBrick(), positionStartBrick.y, 0));
            SetPositionBall(new Vector3(GetRendomPositionXBrick(false), Ball.position.y, 0));

            if (killBrick)
            {
                BrickKill.gameObject.SetActive(true);
                countAmmo += 1;

                killBrick = false;
            }
            сountBоll = countAmmo;
            UpdateCountBall();
        }
    }
Exemplo n.º 8
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (!isTouchable)
     {
         return;
     }
     if (collision.gameObject.tag == "Player")
     {
         var player = FindObjectOfType <PlayerBehaviour>();
         GameManager.State playerState = player.GetState();
         if (playerState == currentState)
         {
             RecieveDamage();
         }
         else
         {
             dealDamage(player);
         }
     }
     else
     {
         Debug.Log("Collision occured");
     }
 }
Exemplo n.º 9
0
 public void SetDimension(GameManager.State dimension)
 {
     dimension_ = dimension;
 }
Exemplo n.º 10
0
    private void UpdateTargeting()
    {
        Vector3 a       = beginTargetPos;
        Vector3 vector  = this.mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -this.mainCamera.transform.position.z));
        Vector3 vector2 = vector - this.beginTargetPos;

        float num = Vector3.Distance(a, vector);

        if (Input.GetMouseButton(0))
        {
            if (num > 1f && a.y > vector.y)
            {
                float num2 = Mathf.Atan2(a.y - vector.y, a.x - vector.x) * 57.29578f;

                num2 *= -1;
                num2 += 90;

                if (num2 < -80f)
                {
                    num2 = -80f;
                }
                else if (num2 > 80f)
                {
                    num2 = 80f;
                }

                Vector3 normal = Ball.position;

                directionTarget.y = normal.y + Mathf.Cos(num2 / 57.29578f);
                directionTarget.x = normal.x + Mathf.Sin(num2 / 57.29578f);

                Arrow.localRotation = Quaternion.Euler(0f, 0f, -num2);

                if (Arrow.gameObject.activeSelf == false)
                {
                    Arrow.gameObject.SetActive(true);
                }
            }

            TouchLine.localScale = new Vector3(vector2.magnitude, 0.04f, 1f);
            TouchLine.rotation   = Quaternion.Euler(0f, 0f, Mathf.Atan2(vector2.y, vector2.x) * 57.29578f);
            TouchLine.position   = a + vector2.normalized * vector2.magnitude / 2f;
        }


        if (Input.GetMouseButtonUp(0) && num > 1f)
        {
            this.state = GameManager.State.Shooting;
            TouchLine.gameObject.SetActive(false);
            Arrow.gameObject.SetActive(false);

            this.state        = GameManager.State.Shooting;
            shootingCountAmmo = 0;
            StartCoroutine(Shooting((directionTarget - Arrow.position).normalized));
        }
        else if (Input.GetMouseButtonUp(0))
        {
            state = GameManager.State.Idle;
            TouchLine.gameObject.SetActive(false);
            Arrow.gameObject.SetActive(false);
        }
    }
Exemplo n.º 11
0
 public void СontinueGame()
 {
     state = GameManager.State.Idle;
     ScenManager.Singlton.Window.gameObject.SetActive(false);
     RemoveLines();
 }
Exemplo n.º 12
0
 void ChangeState(GameManager.State state)
 {
     SetSprite(state);
     currentState = state;
 }
 protected abstract void OnGameManagerStateChange(GameManager.State newState);
Exemplo n.º 14
0
 protected override void OnGameManagerStateChange(GameManager.State newState)
 {
     gameObject.SetActive(newState == GameManager.State.Menu);
 }
Exemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     Time.timeScale = paused ? 0 : 1;
     GameManager.State gameState = paused ? GameManager.State.Paused : GameManager.State.Running;
     GameManager.instance.SetState(gameState);
 }
 protected override void OnGameManagerStateChange(GameManager.State newState)
 {
     targetGroup.DoUpdate();
 }