Esempio n. 1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.layer == blockLayerIndex)
     {
         Vector3 normal = collision.contacts[0].normal;
         if (canCollide || normal == collision.gameObject.transform.up /*&& !enteredCollision*/)
         {
             collidedNow = true;
             //enteredCollision = true;
             if (mode == (int)Mode.normal)
             {
                 SetEnergy();
             }
             BlockCollision(collision);
         }
         else
         {
             if (GameConst.instance.isGameOn)
             {
                 GameConst.instance.isGameOn = false;
                 this.speed = Vector3.zero;
                 uIScript.StartCoroutine(uIScript.AdvertiseReward());
                 if (isVibrationOn)
                 {
                     VibrationPop.vibrateforDuration(2);
                 }
             }
         }
     }
     else if (collision.gameObject.layer == coinLayerIndex)
     {
         int gold = PlayerPrefs.GetInt("Gold", 0);
         gold += 3;
         PlayerPrefs.SetInt("Gold", gold);
         collision.gameObject.SetActive(false);
         this.transform.position = new Vector3(this.transform.position.x, height, this.transform.position.z);
         if (isVibrationOn)
         {
             VibrationPop.vibrateforDuration(1);
         }
     }
     else if (collision.gameObject.layer == edgeLayerIndex)
     {
         if (GameConst.instance.isGameOn)
         {
             GameConst.instance.isGameOn = false;
             this.speed = Vector3.zero;
             uIScript.StartCoroutine(uIScript.AdvertiseReward());
             if (isVibrationOn)
             {
                 VibrationPop.vibrateforDuration(2);
             }
         }
     }
 }
    public IEnumerator CountDown()
    {
        int timer = 3;

        uIScript.countDown.gameObject.SetActive(true);
        while (timer >= 1)
        {
            uIScript.countDown.text = timer.ToString();
            yield return(new WaitForSecondsRealtime(1f));;
            timer--;
            yield return(null);
        }
        uIScript.countDown.gameObject.SetActive(false);
        if (!isStarted)
        {
            isStarted = true;
            isGameOn  = true;
            gunScript.StartGun();
            Time.timeScale = 1f;
            uIScript.startGame();
            StopCoroutine(CountDown());
            yield break;
        }
        else
        {
            Time.timeScale = 1f;
            isGameOn       = true;
            GameObject.FindWithTag("Explode").GetComponent <ExplosionParticleScript>().StopExplosion();
            gunScript.StartGun();
            StopCoroutine(uIScript.AdvertiseReward());
            StopCoroutine(CountDown());
            if (uIScript.secondChance.gameObject.activeInHierarchy)
            {
                uIScript.secondChance.gameObject.SetActive(false);
            }
        }
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.layer == LayerMask.NameToLayer("player"))
     {
         if (Player.instance.mode == (int)Player.Mode.normal)
         {
             //collision.gameObject.SetActive(false);
             if (GameConst.instance.isGameOn)
             {
                 GameConst.instance.isGameOn = false;
                 Player.instance.speed       = Vector3.zero;
                 uIScript.StartCoroutine(uIScript.AdvertiseReward());
                 Player.instance.BulletImpactOutput(5f, .75f);
             }
             this.gameObject.SetActive(false);
         }
         else if (Player.instance.mode == (int)Player.Mode.bulletProof)
         {
             this.gameObject.SetActive(false);
             Player.instance.BulletImpactOutput(3f, 1.5f);
             Player.instance.bulletHits += 1;
         }
     }
 }