Exemplo n.º 1
0
    IEnumerator GoLose()
    {
        yield return(new WaitForSeconds(2));

        hs.AddScore(points, this.name);
        gm.GoMenu();
        lose = false;
    }
 public void NextLevel()
 {
     TotalStatistics.LevelsScore[TotalStatistics.CurrentLevel] = Statistic.Score + Statistic.TimeScore;
     TotalStatistics.CurrentLevel++;
     TotalStatistics.TotalScore = Statistic.TotalScore;
     if (TotalStatistics.CurrentLevel == 10)//если прошли все уровни то записываем рекорд
     {
         Highscore hs = new Highscore();
         hs.AddScore(TotalStatistics.Nickname, TotalStatistics.TotalScore);
     }
     SceneManager.LoadScene(2);
 }
Exemplo n.º 3
0
    /// <summary>
    /// Fixeds the update.
    /// </summary>
    void FixedUpdate()
    {
        if ((locatedScrap) || (timer > 0f))
        {
            timer += Time.fixedDeltaTime;
            if (timer > animationSpeed)
            {
                timer = 0f;
            }

            if (locatedScrap)
            {
                line.SetPosition(1, locatedScrap.transform.position);
                line.SetPosition(0, transform.position);

                Highscore.AddScore(scrap.TakeScrap(transferSpeed * Time.fixedDeltaTime, timer == 0f));
            }

            material.mainTextureOffset = new Vector2(-1f + (2f * timer / animationSpeed), 0f);
        }
    }
Exemplo n.º 4
0
    private void Update()
    {
        if (player.dead && !setup)
        {
            // deactivate playercamera and stop the map.
            cam.SetActive(false);
            map.stop = true;

            // activate endscreen.
            endScreenPanel.SetActive(true);
            hudPanel.SetActive(false);

            // set state to correct gamestate.
            if (player.state == 0)
            {
                stateText.text = "Game Over";
            }
            else if (player.state == 1)
            {
                stateText.text = "Congratulations";
            }

            // display points
            pointText.text = player.points.ToString();


            // if score is on highscore..
            highscoreIndex = highscoreScript.AddScore(player.points);

            if (highscoreIndex == -1)
            {
                inputField.interactable   = false;
                submitButton.interactable = false;
                retryButton.interactable  = true;
                exitButton.interactable   = true;
            }
            else
            {
                inputField.interactable   = true;
                submitButton.interactable = true;
                retryButton.interactable  = false;
                exitButton.interactable   = false;
            }

            setup = true;
        }
        if (Input.GetButtonDown("Cancel") && !player.dead && !startPanel.activeSelf && !optionsPanel.activeSelf && !endScreenPanel.activeSelf)
        {
            if (pausePanel.activeSelf)
            {
                Resume();
            }
            else
            {
                pausePanel.SetActive(true);
                hudPanel.SetActive(false);
                player.stop = true;
                map.stop    = true;
                cam.SetActive(false);
                pointDisplayPause.text = pointDisplay.text;
            }
        }
        if (startPanel.activeSelf)
        {
            time          -= Time.deltaTime;
            countdown.text = ((int)time).ToString();
            if ((int)time <= 0)
            {
                startPanel.SetActive(false);
                map.stop    = false;
                player.stop = false;
            }
        }

        pointDisplay.text = player.points.ToString();
    }
Exemplo n.º 5
0
    public void TryOption(int optionID)
    {
        switch (options)
        {
        case ShipShopOptions.Ships:
            if (optionID == 0)
            {
                // Enough scrap? Buy Pigeon
                if (Highscore.TryRemoveScore(optionSettings [(int)options].options [0].cost))
                {
                    Instantiate(pigeonPrefab);
                    int audioID = Random.Range(0, optionSettings [(int)options].options [0].voiceOver.Length);
                    audioManager.Play(optionSettings [(int)options].options [0].voiceOver [audioID]);
                }
            }
            else
            {
                // Enough scrap? Buy UFO
                if (Highscore.TryRemoveScore(optionSettings [(int)options].options [1].cost))
                {
                    Instantiate(uFOPrefab);
                    int audioID = Random.Range(0, optionSettings [(int)options].options [1].voiceOver.Length);
                    audioManager.Play(optionSettings [(int)options].options [1].voiceOver [audioID]);
                }
            }
            break;

        case ShipShopOptions.Drones:
            if (optionID == 0)
            {
                // Enough scrap and still upgradable? Buy Drone
                if (currentSelection.UpgradeAvailable() && (Highscore.TryRemoveScore(optionSettings [(int)options].options [0].cost)))
                {
                    currentSelection.BuyUpgrade();
                    int audioID = Random.Range(0, optionSettings [(int)options].options [0].voiceOver.Length);
                    audioManager.Play(optionSettings [(int)options].options [0].voiceOver [audioID]);
                }
            }             // No second option needed
            break;

        case ShipShopOptions.Boost:
            if (optionID == 0)
            {
                // Enough scrap and still upgradable? Buy Boost
                if (currentSelection.UpgradeAvailable() && (Highscore.TryRemoveScore(optionSettings [(int)options].options [0].cost)))
                {
                    currentSelection.BuyUpgrade();
                    int audioID = Random.Range(0, optionSettings [(int)options].options [0].voiceOver.Length);
                    audioManager.Play(optionSettings [(int)options].options [0].voiceOver [audioID]);
                }
            }
            else
            {
                // Destroy ship and regain scrap
                Highscore.AddScore(optionSettings [(int)options].options [1].cost);
                currentSelection.DestroyShip();
                int audioID = Random.Range(0, optionSettings [(int)options].options [1].voiceOver.Length);
                audioManager.Play(optionSettings [(int)options].options [1].voiceOver [audioID]);
            }
            break;

        case ShipShopOptions.Waypoint:
            if (optionID == 0)
            {
                // Enough scrap and still upgradable? Buy Waypoint
                if (currentSelection.UpgradeAvailable() && (Highscore.TryRemoveScore(optionSettings [(int)options].options [0].cost)))
                {
                    currentSelection.BuyUpgrade();
                    int audioID = Random.Range(0, optionSettings [(int)options].options [0].voiceOver.Length);
                    audioManager.Play(optionSettings [(int)options].options [0].voiceOver [audioID]);
                }
            }
            else
            {
                // Destroy ship and regain scrap
                Highscore.AddScore(optionSettings [(int)options].options [1].cost);
                currentSelection.DestroyShip();
                int audioID = Random.Range(0, optionSettings [(int)options].options [1].voiceOver.Length);
                audioManager.Play(optionSettings [(int)options].options [1].voiceOver [audioID]);
            }
            break;
        }
    }