Example #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Item"))
     {
         WhackItem item = other.GetComponentInParent <WhackItem>();
         if (item)
         {
             Debug.Log("whack");
             other.transform.root.gameObject.SetActive(false);
             item.FreeSpace();
         }
     }
 }
    private void SpawnItem(WhackItem item, Transform transformToOccupy)
    {
        int materialIndex = UnityEngine.Random.Range(0, 2);
        int meshIndex     = UnityEngine.Random.Range(0, 2);

        WhackItem spawnedItem = Instantiate(item, transformToOccupy.position, Quaternion.identity);

        spawnedItem.Init(this, transformToOccupy, avaliableMaterials[materialIndex], avaliableMeshes[meshIndex]);

        int outcome = (materialIndex == 0 && meshIndex == 0) ? 0 : 1;

        perceprton.SendData(materialIndex, meshIndex, outcome, transformToOccupy.position);

        Destroy(spawnedItem.gameObject, lifeTime);
        if (freeTransforms.Contains(transformToOccupy))
        {
            freeTransforms.Remove(transformToOccupy);
        }
    }