Пример #1
0
    public GameObject Build(string type, Vector3 pPos, Vector3 pRot)
    {
        switch (type)
        {
        case "Meteorite":
            obj = MeteoriteFactory.instance.Create(type);
            MeteoriteController a = obj.AddComponent <MeteoriteController>();
            a.SetSpeed(Random.Range(0.1f, 0.5f));
            obj.transform.position    = pPos;
            obj.transform.eulerAngles = pRot;
            return(obj);

        default:
            return(null);
        }
    }
Пример #2
0
 // Use this for initialization
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Meteorite"))
     {
         MeteoriteController mc = collision.gameObject.GetComponent <MeteoriteController>();
         mc.BlowUp();
         ContactPoint2D contactPoint   = collision.contacts[0];
         Vector2        explosionPoint = contactPoint.point;
         Instantiate(explosion, explosionPoint, Quaternion.identity);
         if (particleExplosion != null)
         {
             Instantiate(particleExplosion, explosionPoint, Quaternion.identity);
         }
         MeteoriteController meteorite = collision.gameObject.GetComponent <MeteoriteController>();
         Destroy(gameObject);
     }
     if (collision.gameObject.CompareTag("Wall"))
     {
         Destroy(gameObject);
     }
 }
Пример #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Meteorite"))
        {
            if (!godMode)
            {
                MeteoriteController meteorite = collision.gameObject.GetComponent <MeteoriteController>();
                meteorite.BlowUp();
                GameController gameController = GameObject.Find("GameManager").GetComponent <GameController>();

                if (gameController != null)
                {
                    gameController.StartMenuTimer();
                }

                BlowUp(collision);
                PlayExplosion();
                isDestroyed = true;
            }
        }
    }