Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        point.text = playerModel.GetPoint().ToString();
        life.text = playerModel.getLife().ToString();
        Debug.Log(gameModel.getEnemyCount());
        if (gameModel.getStarted())
        {
            Debug.Log("started");
            if (gameModel.getEnemyCount() == 0)
            {
                SceneManager.LoadScene("win");
                playerModel.SetLevel(playerModel.GetLevel()+1);
                playerModel.SaveData();     
                Debug.Log("I WIN I WIN");
                gameModel.SetStarted(false);
            }
            else if (playerPresenter.isAlive())
            {
                bool arrived = playerPresenter.movePlayer();
                if (arrived && !gameModel.getShooted())
                {
                    enemyPresenter.createEnemy(playerModel.GetSign(), playerPresenter.getPlayer(), gameModel.getEnemyCount());
                    gameModel.SetIsShooting(true);
                }

                if (gameModel.IsShooting() && Input.GetKeyDown(KeyCode.Space))
                {
                    playerPresenter.shoot();
                    StartCoroutine(enemyPresenter.shoot());
                    gameModel.setShooted(true);
                    gameModel.SetIsShooting(false);
                }
                Debug.Log("Enemy Presenter"+enemyPresenter.isEnemyDead().ToString());
                Debug.Log("Enemy Model"+gameModel.getEnemyMoving().ToString());
                if (!enemyPresenter.isEnemyDead() && gameModel.getEnemyMoving())
                {
                    gameModel.setEnemyArrived(enemyPresenter.moveEnemy());
                    if (gameModel.getEnemyArrived())
                    {
                        playerPresenter.checkMovement();
                        gameModel.setEnemyMoving(false);
                        gameModel.setShooted(false);
                    }

                }

				
                if (gameModel.getShooted() && enemyPresenter.isEnemyDead())
                {
                    
                    gameModel.setEnemyCount(gameModel.getEnemyCount() -1 );
                    gameModel.setShooted(false);
                    playerPresenter.checkMovement();
                }

                if (enemyPresenter.getStillPlaying() && !gameModel.getChanging())
                {
                    gameModel.setChanging(true);
                    enemyPresenter.checkMovment();
                    gameModel.setEnemyMoving(true);
                }
            }
            else
            {
                gameModel.SetStarted(false);
                SceneManager.LoadScene("lose");
                Debug.Log("YOU ARE F*****G DEAD");
            }

        }
    }