Exemplo n.º 1
0
 protected virtual void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <Arrow> ())
     {
         Dirt dirt = this.gameObject.AddComponent <Dirt> ();
         dirt.Initialize(collision.gameObject.transform.position);
         arrowCollisionSound = (AudioClip)Resources.Load("Audio/shieldBlock");
         AudioSource.PlayClipAtPoint(arrowCollisionSound, this.gameObject.transform.position);
     }
 }
Exemplo n.º 2
0
    private void InitDirt()
    {
        GameObject container = new GameObject();

        container.name                    = originalDirt.name + "_container";
        container.transform.parent        = transform;
        container.transform.localPosition = Vector3.zero;
        container.transform.localScale    = Vector3.one;
        container.transform.localRotation = Quaternion.identity;

        for (int j = 0; j < 6; j++)
        {
            for (int i = 0; i < diversity; i++)
            {
                GameObject go = Instantiate(originalDirt.gameObject);
                go.transform.parent        = container.transform;
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale    = Vector3.one;
                go.transform.localRotation = Quaternion.identity;

                Dirt dirt = go.GetComponent <Dirt>();

                switch (j)
                {
                case 0: dirt.Initialize(false, false, false, false, 0.3f); break;

                case 1: dirt.Initialize(false, true, false, false, 0.3f); break;

                case 2: dirt.Initialize(false, false, true, true, 0.3f); break;

                case 3: dirt.Initialize(false, true, true, false, 0.3f); break;

                case 4: dirt.Initialize(false, true, true, true, 0.3f); break;

                case 5: dirt.Initialize(true, true, true, true, 0.3f); break;

                default: break;
                }

                dirtMeshes[j * diversity + i] = dirt.meshFilter.sharedMesh;
                if (j == 5)
                {
                    break;
                }
            }
        }

        container.SetActive(false);
    }