public void PrepareMe(Dictionary <int, Result[]> inGameResults, Result[] afterGameResults, string reason, int distance, Mission mission, PlayerState player)
    {
        Distance         = distance;
        GameOverReason   = reason;
        Mission          = mission;
        InGameResults    = inGameResults;
        AfterGameResults = afterGameResults;

        if (Passed = Mission.Passed(InGameResults, AfterGameResults))
        {
            player.MissionDone(Mission);
        }
        CarSmasherSocial.UpdateLeaderboard(GoogleLeaderboard.LEADERB_BEST_DISTANCES_ADV, afterGameResults);
        HighScores.AddScore(Distance, HighScoreType.Adventure);

        foreach (AchievQuery aq in Mission.AfterGameReqs)
        {
            TaskToBeDone       = aq.ScoreType;
            TaskToBeDoneAmount = aq.Value;
        }

        foreach (Result r in afterGameResults)
        {
            if (r.ScoreType == SCORE_TYPE.COINS)
            {
                CoinsCollected = r.Value;
            }
            if (r.ScoreType == TaskToBeDone)
            {
                TaskDoneAmount = r.Value;
            }
        }
    }
Exemplo n.º 2
0
    private void ManageStatePlaying()
    {
        bool isGameOver = false;

        m_gameTime += Time.deltaTime;
        seconds     = Mathf.RoundToInt(m_gameTime);

        m_TimerText.text = string.Format("{0:D2}:{1:D2}", (seconds / 60), (seconds % 60));

        if (OneTankLeft() == true)
        {
            isGameOver = true;
        }
        else if (IsPlayerDead() == true)
        {
            isGameOver = true;
        }

        if (isGameOver == true)
        {
            m_GameState = GameState.GameOver;
            m_TimerText.gameObject.SetActive(false);


            m_gameTimeList.Add(seconds);

            //m_NewGameButton.gameObject.SetActive(true);
            //m_HighScoresButton.gameObject.SetActive(true);

            DisplayButtons(true);

            if (IsPlayerDead() == true)
            {
                m_MessageText.text = "TRY AGAIN";
            }
            else
            {
                m_MessageText.text = "WINNER!";

                // Save the score
                m_HighScores.AddScore(Mathf.RoundToInt(m_gameTime));
                m_HighScores.SaveScoresToFile();
            }

            int timeToBeat = FindTimeToBeat();

            m_TimeToBeatText.text = "Time To Beat: " + string.Format("{0:D2}:{1:D2}", (timeToBeat / 60), (timeToBeat % 60));
        }

        CheckForPause();
    }
    public void PrepareMe(Dictionary <int, Result[]> inGameResults, Result[] afterGameResults, string reason, int distance, Mission mission, PlayerState player)
    {
        Distance       = distance;
        GameOverReason = reason;
        Mission        = mission;
        Player         = player;
        HighScores.AddScore(distance, HighScoreType.Classic);
        int place = HighScores.GetPlaceFor(distance, HighScoreType.Classic);

        if (place == 1)
        {
            PlaySingleSound.SpawnSound(Sounds.Fanfare, Camera.main.gameObject.transform.position, 0.2f);
            if (distance > 50)
            {
                ShowNewHighScoreScreen = true;
            }
        }

        foreach (Result result in afterGameResults)
        {
            switch (result.ScoreType)
            {
            case SCORE_TYPE.FUEL_PICKED:
                FuelPickedUp = result.Value;
                break;

            case SCORE_TYPE.FUEL_PICKED_IN_ROW:
                FuelPickedUpInARow = result.Value;
                break;

            case SCORE_TYPE.FUEL_PICKED_WHEN_LOW:
                FuelPickedUpWhenLow = result.Value;
                break;

            case SCORE_TYPE.TURNS:
                Turns = result.Value;
                break;

            case SCORE_TYPE.COINS:
                CoinsPickedUp = result.Value;
                break;
            }
        }
        CarSmasherSocial.UpdateLeaderboard(CarSmasherSocial.ClassicLeaderboard.Id, afterGameResults);
        //if someone had internet issues before, at least we can update high score with his best distance and come unlockable achievements
        //we don't want this. this is sending best score for every day player is playing
        //List<int> topScores = HighScores.GetTopScores (1);
        //int bestDistance = topScores.Count > 0 ? topScores [0] : 0;
        //InGameAchievements.Add(bestDistance, new Result[]{new Result (SCORE_TYPE.DISTANCE, bestDistance)});
    }
Exemplo n.º 4
0
    public void AddHighScore()
    {
        m_InputGroup.SetActive(false);

        Score score;

        score.name  = m_input.text;
        score.value = m_scoreCount;

        m_highScores.AddScore(score);
        m_highScores.WriteScores();

        m_hasName = true;
    }
Exemplo n.º 5
0
    private void ShowHighScores()
    {
        if (!HighScores.scoreTable.Contains(new HighScores.scoreKeeper(p_name, score)))
        {
            HighScores.AddScore(p_name, score);
        }

        highScoresTables[0].text = HighScores.scoreTable[0].name + HighScores.scoreTable[0].score;
        highScoresTables[1].text = HighScores.scoreTable[1].name + HighScores.scoreTable[1].score;
        highScoresTables[2].text = HighScores.scoreTable[2].name + HighScores.scoreTable[2].score;
        highScoresTables[3].text = HighScores.scoreTable[3].name + HighScores.scoreTable[3].score;

        HighScores.SaveHighScores();

        HighScoreDisplay.SetActive(true);
    }
Exemplo n.º 6
0
    private void Update()
    {
        switch (m_GameState)
        {
        case GameState.Start:
            Cursor.lockState = CursorLockMode.None;

            break;

        case GameState.Playing:
            Cursor.lockState = CursorLockMode.Locked;
            m_gameTimer     -= Time.deltaTime;
            if (m_gameTimer <= 0)
            {
                m_GameState = GameState.Lose;
            }
            else if (RC.m_hasWon == true)   //ADD DIFFERENT CODE FOR WINNING
            {
                m_HighScores.AddScore(Mathf.RoundToInt(m_gameTimer));
                m_HighScores.SaveScoresToFile();
                RC.m_hasWon = false;
                m_GameState = GameState.Win;
            }
            break;

        case GameState.Win:
            Cursor.lockState = CursorLockMode.None;
            m_gameTimer      = 300f;
            break;

        case GameState.Lose:
            Cursor.lockState = CursorLockMode.None;
            m_gameTimer      = 300f;
            break;
        }
    }
Exemplo n.º 7
0
    void Update()
    {
        switch (m_GameState)
        {
        case GameState.Start:
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_TimerText.gameObject.SetActive(true);
                m_MessageText.text = "";
                m_GameState        = GameState.Playing;

                for (int i = 0; i < m_Tanks.Length; i++)
                {
                    m_Tanks[i].SetActive(true);
                }
            }
            break;

        case GameState.Playing:
            bool isGameOver = false;

            m_gameTime += Time.deltaTime;
            int seconds = Mathf.RoundToInt(m_gameTime);
            m_TimerText.text = string.Format("{0:D2}:{1:D2}", (seconds / 60), (seconds % 60));

            if (OneTankLeft() == true)
            {
                isGameOver = true;
            }
            else if (IsPlayerDead() == true)
            {
                isGameOver = true;
            }

            if (isGameOver == true)
            {
                m_GameState = GameState.GameOver;
                m_TimerText.gameObject.SetActive(false);

                if (IsPlayerDead() == true)
                {
                    m_MessageText.text = "TRY AGAIN";
                }
                else
                {
                    m_MessageText.text = "WINNER!";

                    //save the score
                    m_HighScores.AddScore(Mathf.RoundToInt(m_gameTime));
                    m_HighScores.SaveScoresToFile();
                }
            }
            break;

        case GameState.GameOver:
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_gameTime         = 0;
                m_GameState        = GameState.Playing;
                m_MessageText.text = "";
                m_TimerText.gameObject.SetActive(true);

                for (int i = 0; i < m_Tanks.Length; i++)
                {
                    m_Tanks[i].SetActive(true);
                }
            }
            break;
        }

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
    }
Exemplo n.º 8
0
    private void Update()
    {
        switch (m_GameState)
        {
        case GameState.Start:
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_BombCountNum.gameObject.SetActive(true);
                m_BombCountText.gameObject.SetActive(true);
                m_ScoreNum.gameObject.SetActive(true);
                m_ScoreText.gameObject.SetActive(true);
                m_TimerNum.gameObject.SetActive(true);
                m_TimerText.gameObject.SetActive(true);
                m_lowHealthEdge.gameObject.SetActive(true);
                m_MessageText.text = "";
                m_GameState        = GameState.Playing;
                for (int i = 0; i < m_Tanks.Count; i++)
                {
                    m_Tanks[i].SetActive(true);
                }
                TankSpawner spTank = Object.FindObjectOfType <TankSpawner>();
                spTank.spawnTank();
            }
            break;

        case GameState.Playing:
            //if(m_Tanks.Contains(m_PlayerTank) == false)
            //{
            //}
            bool isGameOver = false;
            m_gameTime += Time.deltaTime;
            int seconds = Mathf.RoundToInt(m_gameTime);
            m_TimerNum.text = string.Format("{0:D2}:{1:D2}", (seconds / 60), (seconds % 60));
            m_Score         = Mathf.RoundToInt(0 + (m_gameTime * (m_Tanks.Count - 1)));
            m_ScoreNum.text = m_Score.ToString();
            if (IsPlayerDead() == true)
            {
                isGameOver = true;
            }
            if (isGameOver == true)
            {
                m_GameState = GameState.GameOver;
                m_BombCountNum.gameObject.SetActive(false);
                m_BombCountText.gameObject.SetActive(false);
                m_ScoreNum.gameObject.SetActive(false);
                m_ScoreText.gameObject.SetActive(false);
                m_TimerNum.gameObject.SetActive(false);
                m_TimerText.gameObject.SetActive(false);
                m_FinalScore.gameObject.SetActive(true);
                m_lowHealthEdge.gameObject.SetActive(false);
                m_NewGameButton.gameObject.SetActive(true);
                m_HighScoresButton.gameObject.SetActive(true);
                if (ScoreTabToggle == true)
                {
                    m_HighScorePanel.gameObject.SetActive(false);
                    ScoreTabToggle = false;
                }
                m_Score            = Mathf.RoundToInt(0 + (m_gameTime * (m_Tanks.Count - 1)));
                m_MessageText.text = "Your final score is:";
                m_FinalScore.text  = m_Score.ToString();
                //save the score
                m_HighScores.AddScore(m_Score);
                m_HighScores.SaveScoresToFile();
            }
            else
            {
                TankShooting countBomb = Object.FindObjectOfType <TankShooting>();
                m_BombCountNum.text = countBomb.m_bombCount.ToString();
            }
            break;

        case GameState.GameOver:
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_gameTime         = 0;
                m_GameState        = GameState.Playing;
                m_MessageText.text = "";
                m_BombCountNum.gameObject.SetActive(true);
                m_BombCountText.gameObject.SetActive(true);
                m_ScoreNum.gameObject.SetActive(true);
                m_ScoreText.gameObject.SetActive(true);
                m_TimerNum.gameObject.SetActive(true);
                m_TimerText.gameObject.SetActive(true);
                m_FinalScore.gameObject.SetActive(false);
                m_NewGameButton.gameObject.SetActive(false);
                m_HighScoresButton.gameObject.SetActive(false);
                foreach (GameObject tank in m_Tanks)
                {
                    tank.SetActive(false);
                }
                foreach (Bomb bomb in FindObjectsOfType <Bomb>())
                {
                    bomb.Kill();
                }
                m_Tanks.RemoveRange(0, m_Tanks.Count);
                m_Tanks.Add(m_PlayerTank);
                m_Tanks[0].SetActive(true);
                m_PlayerTank.transform.position = new Vector3(0, 0, 0);
                m_PlayerTank.transform.rotation = new Quaternion(0, 0, 0, 0);
                TankSpawner spTank = Object.FindObjectOfType <TankSpawner>();
                spTank.spawnTank();
            }
            break;
        }
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
        if ((Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.Tab)) && ScoreTabToggle == true)
        {
            m_HighScorePanel.gameObject.SetActive(false);
        }
    }
Exemplo n.º 9
0
    void Update()
    {
        m_canfly = UpgradeBox.m_canFly;
        switch (m_GameState)
        {
        case GameState.Start:
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_timerText.gameObject.SetActive(true);
                m_messageText.text = "";

                m_GameState = GameState.Play;
                for (int i = 0; i < m_tanks.Length; i++)
                {
                    m_tanks[i].SetActive(true);
                }
            }
            break;

        case GameState.Play:
            bool isGameOver = false;

            m_GameTime += Time.deltaTime;
            int seconds = Mathf.RoundToInt(m_GameTime);

            m_timerText.text = string.Format("{0:D2}:{1:D2}", (seconds / 60), (seconds % 60));

            if (OneTankLeft() == true)
            {
                isGameOver = true;
            }
            else if (IsPlayerDead() == true && m_canfly == false)
            {
                isGameOver = true;
            }

            if (isGameOver == true)
            {
                m_GameState = GameState.GameOver;
                m_timerText.gameObject.SetActive(false);

                if (IsPlayerDead() == true)
                {
                    m_messageText.text = "Try Again";
                    SceneManager.LoadScene(0);
                }
                else
                {
                    m_messageText.text = "WINNER!";

                    m_HighScores.AddScore(Mathf.RoundToInt(m_GameTime));
                    m_HighScores.SaveScoresToFile();
                }
            }
            break;

        case (GameState.GameOver):
            if (Input.GetKeyUp(KeyCode.Return) == true)
            {
                m_GameTime  = 0;
                m_GameState = GameState.Play;

                m_messageText.text = "";
                m_timerText.gameObject.SetActive(true);

                for (int i = 0; i < m_tanks.Length; i++)
                {
                    m_tanks[i].SetActive(true);
                }
            }
            break;
        }
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }
    }