generateFragments() приватный Метод

Turns Gameobject into multiple fragments
private generateFragments ( ) : void
Результат void
Пример #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Destroy(col);
        if (!isInvis && health >= 0)
        {
            Debug.Log("Here");
            isInvis = true;
            hearts[health].GetComponent <Animator>().SetBool("Start", true);
            time = Time.time + invisTime;
        }
        if (health < 0)
        {
            ex.generateFragments();
            ex.explode();
            GameObject.Find("Thrust").transform.position = new Vector2(2000, 2000);
            alive = false;
            setGameOver();

            // gameObject.GetComponent<PlayerController>().speed = 0;
            //Game Over
            // Debug.Log("here");
            // GameObject.Find("Game Over").SetActive(true);
        }

        // if(!invis)
        // hearts[health].SetActive(false);
        // gameObject.AddComponent<PolygonCollider2D>();
        // gameObject.GetComponent<PolygonCollider2D>(). = true;
    }
Пример #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     ex.generateFragments();
     if (collision.gameObject.tag != "Player")
     {
         Debug.Log("Hit");
         if (transform.localScale.x > 2)
         {
             //Add way for larger asteroids to break into a couple
         }
         ex.explode();
         Debug.Log(pointValue);
         score.GetComponent <Score>().addScore(pointValue);
         //GameObject.Destroy(gameObject);
     }
     else
     {
         ex.explode();
     }
 }
Пример #3
0
 private void OnMouseDown()
 {
     if (!_isFreezed)
     {
         clicksToDestroy--;
         HitEvent?.Invoke();
         if (clicksToDestroy <= 0)
         {
             gameProxy.AddScore(score);
             DieEvent?.Invoke();
             explodable.generateFragments();
             foreach (var fragment in explodable.fragments)
             {
                 fragment.AddComponent <ObjectCleaner>();
             }
             gameProxy.AddTime(timeAddedOnDestroy);
             gameProxy.ExplosionForce.doExplosion(transform.position);
             explodable.explode();
         }
     }
 }