Exemplo n.º 1
0
    public InputManager()
    {
        _controls = new PlayerInput();

        #region Game
        _controls.Game.Movement.started   += ctx => ShipMove.Invoke(true);
        _controls.Game.Movement.canceled  += ctx => ShipMove.Invoke(false);
        _controls.Game.Rotation.performed += ctx => ShipRotate.Invoke(ctx.ReadValue <float>());
        _controls.Game.Rotation.canceled  += ctx => ShipRotate.Invoke(0);
        _controls.Game.Fire.started       += ctx => ShipFire.Invoke(true);
        _controls.Game.Fire.canceled      += ctx => ShipFire.Invoke(false);
        _controls.Game.Pause.started      += ctx => GamePause.Invoke();
        _controls.Game.Restart.started    += ctx => GameRestart.Invoke();
        #endregion

        #region Pause
        _controls.Pause.Exit.started   += ctx => PauseExit.Invoke();
        _controls.Pause.Resume.started += ctx => PauseResume.Invoke();
        #endregion

        #region Game Over
        _controls.GameOver.Restart.started += ctx => GameOverRestart.Invoke();
        _controls.GameOver.Exit.started    += ctx => GameOverExit.Invoke();
        #endregion

        GameManager.Instance.OnGameStateChanged += SwitchInputType;
    }
Exemplo n.º 2
0
 void ShowMenu(int a)
 {
     Menu.SetActive(false);
     PausedMenu.SetActive(false);
     if (a == 0)
     {
         Menu.SetActive(true);
     }
     else if (a == 1)
     {
         PausedMenu.SetActive(true);
     }
     else if (a == 2)
     {
         GameRestart.SetActive(true);
         lifeLeft = PlayerPrefs.GetInt("lifeLeft", 3);
         if (lifeLeft == 0)
         {
             GameRestart.transform.Find("checkpoint").gameObject.SetActive(false);
         }
         for (int i = (lifeLeft + 1); i <= 3; i++)
         {
             GameRestart.transform.Find("LifeHolder").Find("" + i).Find("Image").gameObject.SetActive(true);
         }
     }
 }
Exemplo n.º 3
0
    void Start()
    {
        gameRestart = GetComponent <GameRestart>();
        pointCount  = GetComponent <PointCount>();

        actualTime     = initialTime;
        timeCount.text = actualTime.ToString();
        InvokeRepeating("DecreaseTime", 1f, 1f);
    }
Exemplo n.º 4
0
 public static void RestartGame()
 {
     GameRestart?.Invoke();
     GameStartOrRestart?.Invoke();
     CurrentGameState = GameState.Playing;
     if (Instance.debug)
     {
         Debug.Log("Restart Game");
     }
 }
Exemplo n.º 5
0
    IEnumerator PowerUpSpawnRoutine()
    {
        gameRestart = GameObject.Find("GameRestart").GetComponent <GameRestart>();

        while (gameRestart.gameOver == false)
        {
            yield return(new WaitForSeconds(10.0f));

            int randomPowerup = Random.Range(-1, 2);
            Instantiate(powerups[randomPowerup], new Vector3(Random.Range(-1.913f, 1.77f), Random.Range(0.177f, 0.826f), 0), Quaternion.identity);
        }
    }
Exemplo n.º 6
0
    private IEnumerator EnemySpawnRoutine()
    {
        gameRestart = GameObject.Find("GameRestart").GetComponent <GameRestart>();
        Player player = GetComponent <Player>();

        while (gameRestart.gameOver == false)
        {
            yield return(new WaitForSeconds(5.0f));

            Instantiate(enemyShipPrefab, new Vector3(Random.Range(-1.787f, 1.614f), 0.5488f), Quaternion.identity);
        }
    }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        gameRestart = GameObject.Find("GameRestart").GetComponent <GameRestart>();

        while (gameRestart.gameOver == true)
        {
            return;
        }

        transform.Translate(Vector3.down * _speed * Time.deltaTime);
        if (transform.position.y < boundaryYnegative)
        {
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 8
0
        protected void UpdateEndOfGame(GameTime gameTime)
        {
            if ((GameRestart.enterButton(currentMouseState) && Mouse.GetState().LeftButton == ButtonState.Pressed) || (previousKeyboardState.IsKeyUp(Keys.Enter) && currentKeyboardState.IsKeyDown(Keys.Enter)))
            {
                Reset();
                _state = GameState.GamePlay;
            }

            /*if (GameExit.isInsideCircle(currentMouseState) && Mouse.GetState().LeftButton == ButtonState.Pressed)
             * {
             *  Exit();
             * }*/
            if (currentKeyboardState.IsKeyDown(Keys.Escape) && previousKeyboardState.IsKeyUp(Keys.Escape))
            {
                Exit();
            }
        }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        gameRestart = GameObject.Find("GameRestart").GetComponent <GameRestart>();

        while (gameRestart.gameOver == true)
        {
            return;
        }

        x = Random.Range(-1.787f, 1.614f);

        transform.Translate(Vector3.down * speed * Time.deltaTime);

        float boundaryYnegative = -1.108565f;

        if (transform.position.y < boundaryYnegative)
        {
            transform.position = new Vector3(x, 0.725f, 0);
        }
    }
Exemplo n.º 10
0
    // Start is called before the first frame update
    void Start()
    {
        _gameRestart = GameObject.Find("GameRestart").GetComponent <GameRestart>();

        _gameRestart.gameOver = true;
        eliminations          = 0;

        //current pos = new position
        transform.position = new Vector3(0, -0.799f, 0);

        TripleShotCooldown = Time.time + 4;

        lives = 3;

        shieldCount = 0;

        shieldActive       = false;
        PowerupStatus.text = "Triple Shot Status: Not Ready";
        LiveCounter.text   = "Lives: " + lives;
        _startNewGame.SetActive(false);
        ShieldHealth.text = "";
    }
Exemplo n.º 11
0
 private void Awake()
 {
     instance = this;
 }