IsGamePaused() public static method

public static IsGamePaused ( ) : bool
return bool
Example #1
0
 // Update is called once per frame
 void Update()
 {
     if (!isDragging || GameHandler.IsGamePaused())
     {
         return;
     }
     mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     goTo          = new Vector3(mousePosition.x, mousePosition.y, 0);//new Vector3(Mathf.Floor(mousePosition.x) + .5f, Mathf.Floor(mousePosition.y) + .5f, 0);
     distance      = Vector2.Distance(hoverSprite.transform.position, goTo);
     goToNormal    = (goTo - hoverSprite.transform.position).normalized;
     if (distance < Vector2.Distance(hoverSprite.transform.position, hoverSprite.transform.position + goToNormal * speed * Time.deltaTime))
     {
         hoverSprite.transform.position = goTo;
     }
     else
     {
         hoverSprite.transform.Translate(goToNormal * speed * Time.deltaTime);
     }
     if (Input.GetMouseButtonDown(0))
     {
         if (!ButtonAtPosition())
         {
             if (cost <= PlayerStats.Money)
             {
                 if (!TurrentAtPosition(hoverSprite.transform.position))
                 {
                     if (!RouteAtPosition())
                     {
                         Instantiate(dragging, hoverSprite.transform.position, transform.rotation, GamePlayWindow.GetTransform());
                         PlayerStats.changeMoneyAmount(-cost);
                         SoundManager.PlaySound(SoundManager.Sound.TowerPlace);
                         SoundManager.PlaySound(SoundManager.Sound.TowerPurchase);
                         Destroy(hoverSprite);
                         dragging   = null;
                         isDragging = false;
                     }
                     else
                     {
                         UnityEngine.Debug.Log("Route There");
                         SoundManager.PlaySound(SoundManager.Sound.Error);
                     }
                 }
                 else
                 {
                     UnityEngine.Debug.Log("Turrent There");
                     SoundManager.PlaySound(SoundManager.Sound.Error);
                 }
             }
             else
             {
                 UnityEngine.Debug.Log("No Gold");
                 SoundManager.PlaySound(SoundManager.Sound.Error);
             }
         }
     }
 }
Example #2
0
 public void SetHover(GameObject turrent)
 {
     if (GameHandler.IsGamePaused())
     {
         return;
     }
     if (!isDragging)
     {
         hoverSprite = new GameObject("TurrentHover");
         hoverSprite.AddComponent <SpriteRenderer>().sprite = turrent.GetComponent <SpriteRenderer>().sprite;
         if (turrent.GetComponent <BoxCollider2D>() != null)
         {
             hoverSprite.AddComponent <BoxCollider2D>().size      = turrent.GetComponent <BoxCollider2D>().size;
             hoverSprite.GetComponent <BoxCollider2D>().offset    = turrent.GetComponent <BoxCollider2D>().offset;
             hoverSprite.GetComponent <BoxCollider2D>().isTrigger = true;
         }
         else if (turrent.GetComponent <CircleCollider2D>() != null)
         {
             hoverSprite.AddComponent <CircleCollider2D>().radius    = turrent.GetComponent <CircleCollider2D>().radius;
             hoverSprite.GetComponent <CircleCollider2D>().isTrigger = true;
         }
         range   = turrent.GetComponent <TowerStats>().range;
         cost    = turrent.GetComponent <TowerStats>().cost;
         hoverRb = hoverSprite.AddComponent <Rigidbody2D>();
         hoverRb.gravityScale = 0f;
         if (range > 0)
         {
             rangeObject = new GameObject("Range");
             rangeObject.AddComponent <SpriteRenderer>().sprite = GameAssets.i.rangeSprite;
             rangeObject.GetComponent <SpriteRenderer>().color -= new Color(0, 0, 0, 0.5f);
             rangeObject.transform.SetParent(hoverSprite.transform);
             rangeObject.transform.position   += new Vector3(0, 0, .5f);
             rangeObject.transform.localScale *= range * 2f;
         }
         dragging   = turrent;
         isDragging = true;
     }
     else if (dragging == turrent)
     {
         Destroy(hoverSprite);
         dragging   = null;
         isDragging = false;
     }
 }
Example #3
0
 // Update is called once per frame
 void Update()
 {
     if (beesAmbiance != null)
     {
         if (!GameHandler.IsGamePaused())
         {
             if (beesAmbiance.isPlaying)
             {
                 if (!anyInRange())
                 {
                     beesAmbiance.Pause();
                 }
             }
             else if (anyInRange())
             {
                 beesAmbiance.UnPause();
             }
         }
     }
     if (stats.fireCountdown == stats.fireRate)
     {
         foreach (AlienHealth alienHealth in GameObject.FindObjectsOfType <AlienHealth>())
         {
             if (Vector2.Distance(alienHealth.gameObject.transform.position, transform.parent.position) <= radius)
             {
                 alienHealth.reduceHealth(stats.damage);
             }
         }
         stats.fireCountdown = 0f;
     }
     else
     {
         stats.fireCountdown = Mathf.Clamp(stats.fireCountdown + Time.deltaTime, 0f, stats.fireRate);
     }
     if (radius != stats.range)
     {
         area  += speed * Time.deltaTime;
         radius = Mathf.Clamp(Mathf.Sqrt(area / Mathf.PI), 0f, stats.range);
     }
     angle += turnSpeed * Time.deltaTime / radius;
     transform.position = offset + new Vector3(radius * Mathf.Cos(angle), radius * Mathf.Sin(angle), 0);
     transform.rotation = Quaternion.Euler(0, 0, (angle * Mathf.Rad2Deg));
 }
Example #4
0
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //	* New Method: Get Delta Time
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 private float GetDeltaTime()
 {
     return((GameHandler.IsGamePaused() && m_bUpdateWhenPaused) ? DynamicUpdateManager.GetDeltaTime() : Time.deltaTime);
 }