private void BreakObject(Destruct instance, Vector3 rayDirection, Vector3 hitPoint)
    {
        GameObject fractured   = instance.fracturedPrefab;
        GameObject smokeEffect = instance.smokeParticle;
        AudioClip  breakSound  = instance.shatter;
        Vector3    pos         = instance.transform.position;
        Quaternion rot         = instance.transform.rotation;

        Destroy(instance.gameObject);
        if (smokeEffect)
        {
            Vector3 heightFix = new Vector3(pos.x, pos.y + 1f, pos.z);
            smoke = (GameObject)Instantiate(smokeEffect, heightFix, rot);
        }
        AudioSource.PlayClipAtPoint(breakSound, pos);
        GameObject go = (GameObject)Instantiate(fractured, pos, rot);

        go.name = "FracturedClone";
        foreach (Rigidbody rb in go.GetComponentsInChildren <Rigidbody>())
        {
            rb.AddForceAtPosition(rayDirection * impactForce, hitPoint, ForceMode.Impulse);
        }
        StartCoroutine(removeDebris(go, removeDebrisDelay));
        if (smoke)
        {
            Destroy(smoke, 2f);
        }
    }
Exemplo n.º 2
0
 public static void Main()
 {
     for (int i = 0; i < 1000000; i++)
     {
         Destruct.Create(i);
         System.Threading.Tasks.Task.Delay(200000);
     }
     Console.Read();
 }
Exemplo n.º 3
0
    public static void Main()
    {
        Destruct ob = new Destruct(0);

        for (int i = 1; i < 100; i++)
        {
            // Destruct o = new Destruct();
            Destruct o = new Destruct(i);
        }
        Console.WriteLine("Done");
    }
Exemplo n.º 4
0
    public static void Main()
    {
        int      count;
        Destruct ob = new Destruct(0);

        /* Теперь сгенерируем большое число объектов.
         * В какой-то момент начнется сбор мусора.
         * Замечание: возможно, для активизации этого
         * процесса вам придется увеличить количество
         * генерируемых объектов. */
        for (count = 1; count < 10; count++)
        {
            ob.generator(count);
        }
        Console.WriteLine("Готово!");
    }
    static void Main()
    {
        int      count;
        Destruct ob = new Destruct(0);

        /* Now, generate a large number of objects. At
         * some point, garbage collection will occur.
         * Note: You might need to increase the number
         * of objects generated in order to force
         * garbage collection. */
        for (count = 1; count < 300; count++)
        {
            ob.Generator(count);
        }
        Console.WriteLine("Done");
    }
    void Update()
    {
        Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            if (Input.GetMouseButton(0) && !inCycle)
            {
                StartCoroutine(delay(gunShotFrequency));
                AudioSource.PlayClipAtPoint(shotSound[Random.Range(0, shotSound.Length)], transform.position);
                if (hit.transform.GetComponent <Destruct> ())
                {
                    Destruct d = hit.transform.GetComponent <Destruct> ();
                    BreakObject(d, ray.direction, hit.point);
                }
            }
        }
    }
Exemplo n.º 7
0
    static void Main()
    {
        int      count;
        Destruct ob = new Destruct(0);

        /* А теперь создать большое число объектов.
         * В какой-то момент произойдет "сборка мусора".
         * Примечание: для того чтобы активизировать
         * "сборку мусора", возможно, придется увеличить
         * число создаваемых объектов. */
        for (count = 1; count < 100000; count++)
        {
            ob.Generator(count);
        }
        Console.WriteLine("Готово!");
        Console.WriteLine("Готово!");
        Console.WriteLine("Готово!");
        Console.WriteLine("Готово!");
        Console.WriteLine("Готово!");
        Console.WriteLine("Готово!");
    }
Exemplo n.º 8
0
 // Метод создает объект, который немедленно // разрушается.
 public void generator(int i)
 {
     Destruct о = new Destruct(i);
 }
Exemplo n.º 9
0
 // Generates an object that is immediately destroyed.
 public void Generator(int i)
 {
     Destruct o = new Destruct(i);
 }
Exemplo n.º 10
0
 // Създава обект и незабавно го унищожава.
 public static void Generator(int i)
 {
     Destruct о = new Destruct(i);
 }
Exemplo n.º 11
0
 public static void Create(int i)
 {
     Destruct o = new Destruct(i);
 }