Ejemplo n.º 1
0
    private void checkAndHandleInputs()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }
        else
        {
            float vert   = Input.GetAxis("Vertical");
            float mouseX = Input.GetAxis("Mouse X");
            float mouseY = Input.GetAxis("Mouse Y");

            switch (_state)
            {
            case GameStates.Preload:
                break;

            case GameStates.Setup:
                break;

            case GameStates.MainMenu:
                break;

            case GameStates.Playing:
                playingWASD((vert > 0), (vert < 0));
                playingMouse(mouseX, mouseY);
                if (IN_EDITOR)
                {
                    if (Input.GetKeyDown(KeyCode.Alpha1))
                    {
                        _player.AddScore(Color.red);
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha2))
                    {
                        _player.AddScore(new Color(1f, 1f, 0f));
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha3))
                    {
                        _player.AddScore(Color.blue);
                    }
                }
                break;

            case GameStates.GameOver:
                break;

            default:
                break;
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (this.gameObject.activeSelf)
        {
            if (collision.GetComponent <PlayerController>() && !isPlayerBullet)
            {
                player.GetDamage(bulletDamage, Vector2.zero, 100);
                Destroy(this.gameObject);
            }

            if (collision.GetComponent <EnemyBehaviour>() && isPlayerBullet && !isAimPlayerBullet)
            {
                var enemy = collision.GetComponent <EnemyBehaviour>();
                enemy.GetDamage(bulletDamage, enemy.transform.position, 100);
                Destroy(this.gameObject);
                if (enemy.HP <= 0)
                {
                    player.AddScore(enemy.IsBoss);
                }
                player.CheckLevelUI();
            }
        }
    }