Esempio n. 1
0
    private void Update()
    {
        keepPos();
        healthBar.UpdateBar(currentHealth, maxHealth);
        shieldBar.UpdateBar(currentShield, maxShield);
        energyBar.UpdateBar(currentEnergy, maxEnergy);
        if (currentHealth <= 0)
        {
            explosion.transform.position = transform.position;
            explosion.SetActive(true);
            Destroy(player);
            PlayerPrefs.SetInt("BB8-HighScore", SumScore.HighScore);
            //SumScore.SaveHighScore();
            SumScore.Reset();
            //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            //SceneManager.LoadScene("menu");
            deathMenu.SetActive(true);
        }

        if (currentEnergy < maxEnergy)
        {
            currentEnergy += 10 * Time.deltaTime;
        }

        if (currentShield <= 0)
        {
            escudo[0].SetActive(false);
            escudo[1].SetActive(false);
        }
        else
        {
            escudo[0].SetActive(true);
            escudo[1].SetActive(true);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0) && SceneManager.GetActiveScene().buildIndex == 0)
        {
            loading.SetActive(true);
            StartCoroutine(LoadLevel(1));
        }

        if (player.GetComponent <playerTarget>().currentHealth <= 0 && SumScore.Score >= 5)
        {
            playerBar.SetActive(false);
            bossBar.SetActive(false);
            continueAgain.SetActive(true);
            SumScore.Subtract(5);
            StartCoroutine(LoadLevel(SceneManager.GetActiveScene().buildIndex));
        }
        else if (player.GetComponent <playerTarget>().currentHealth <= 0 && SumScore.Score < 5)
        {
            playerBar.SetActive(false);
            bossBar.SetActive(false);
            gameOver.SetActive(true);
            SumScore.Reset();
            StartCoroutine(LoadLevel(0));
        }

        if (stageTrigger == null)
        {
            playerBar.SetActive(false);
            bossBar.SetActive(false);
            stageClear.SetActive(true);
            //StartCoroutine(LoadLevel(1));
            LoadNextLevel();
        }
    }
 public void RandomSceneSelectionForStartScreen()
 {
     SumScore.Reset();
     SoundManager.PlayUISound(fx_click, 100);
     noSceneRepeat();
     Sc_TimerBar.time = 10;
     SceneManager.LoadScene(randomSceneRange);
 }
Esempio n. 4
0
    // Start is called before the first frame update
    public void Start()
    {
        InitGame();
        HideGame();
        StartGame();
        SumScore.Reset();

        wrongCnt = 0;
    }
Esempio n. 5
0
 // Update is called once per frame
 void Update()
 {
     healthBar.UpdateBar(currentHealth, maxHealth);
     shieldBar.UpdateBar(currentShield, maxShield);
     if (currentHealth <= 0)
     {
         SumScore.SaveHighScore();
         SumScore.Reset();
         //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         //Exit();
         deathMenu.SetActive(true);
         Time.timeScale = 0;
     }
 }
Esempio n. 6
0
    void Start()
    {
        SumScore.Reset(); // Ensure score is 0 when object loads
        if (initialScore != 0)
        {
            SumScore.Add(initialScore);  // Set initial score
        }
        if (storeHighScore)
        {
            if (PlayerPrefs.HasKey("sumHS"))
            {
                // Set high score value and tell manager
                SumScore.HighScore = PlayerPrefs.GetInt("sumHS");
                UpdatedHS();
            }
            else
            {
                SumScore.HighScore = 0;
            }
        }

        Updated(); // Set initial score in UI
    }
Esempio n. 7
0
 /// <summary>Resets score to zero</summary>
 /// <remarks>Can call from button in inspector</remarks>
 public void ResetPoints()
 {
     SumScore.Reset();
 }
Esempio n. 8
0
    void OnCollisionEnter(Collision collision)
    {
        audience = new GameObject[] { audience1, audience2, audience3, audience4, audience5, audience6, audience7, audience8 };      //, audience9, audience10}
        score    = 0;
        ContactPoint contact = collision.contacts[0];
        Vector3      pos     = contact.point;

        point_x = pos.x;
        point_y = pos.y;
        //TODO assign Points x,y and Origin x,y
        float dist = Mathf.Sqrt(((point_y - origin_y) * (point_y - origin_y)) + ((point_x - origin_x) * (point_x - origin_x)));

        if (dist <= outer_b_r)
        {
            if (dist <= inner_b_r)
            {
                score = 50;
            }
            else
            {
                score = 25;
            }
        }
        else
        {
            float angle = (Mathf.Atan2((point_y - origin_y), (point_x - origin_x)) * 180) / Mathf.PI;
            if ((point_y < origin_y))
            {
                angle += 360;
            }
            angle += 9;
            int index   = ((int)(angle / 18)) % 20;
            int section = val_scores[index];
            Debug.Log("ANGLE IS -------- : " + angle);

            if (dist <= inner_single_r)
            {
                score = section;
            }
            else if (dist <= triple_r)
            {
                score = 3 * section;
            }
            else if (dist <= outer_single_r)
            {
                score = section;
            }
            else if (dist <= double_r)
            {
                score = 2 * section;
            }
            else
            {
                score = 0;
            }
        }
        if (dist <= t_radius)
        {
            collision.collider.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            collision.collider.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
            collision.collider.GetComponent <Rigidbody>().isKinematic     = true;
            this.gameObject.GetComponent <AudioSource> ().Play();
        }
        //scoreboard.GetComponent<SumScore>().Add(score);
        SumScore.IncrementDartCount();
        if (SumScore.Score - score > 0)
        {
            SumScore.Subtract(score);
            if (score != 0)
            {
                foreach (GameObject aud in audience)
                {
                    aud.GetComponent <Animation> ().Play("applause");
                }
            }
        }
        else if (SumScore.Score - score == 0)
        {
            SumScore.Subtract(score);
            SumScore.SaveHighScore(SumScore.DartScore);
            SumScore.Reset();
            SumScore.Add(101);
            foreach (GameObject aud in audience)
            {
                aud.GetComponent <Animation> ().Play("celebration");
            }
        }
        else
        {
            SumScore.Subtract(0);
            Debug.Log("Last dart score must be equal to remaining score");
        }
    }