private void OnMouseDown() { if (destructed) { return; } Vector3 _position = transform.position; Collider[] collidersHit = Physics.OverlapSphere(_position, radius); if (collidersHit.Length > 0) { foreach (Collider collider in collidersHit) { ClickForPoints c = collider.GetComponent <ClickForPoints>(); if (c != null) { c.ImpactFloor(); } } } if (radiusIndicator != null && radiusIndicatorGO != null) { radiusIndicator.color = Color.yellow; radiusIndicatorGO.SetActive(true); } if (fx != null) { Instantiate(fx, (_position == null) ? transform.position : (Vector3)_position, Quaternion.identity, null); } Destruct(); //Destroy(gameObject); }
public override GameObject Spawn() { GameObject g = base.Spawn(); ClickForPoints o = g.GetComponent <ClickForPoints>(); if (o != null) { o.boolEvent.AddListener(Destroyed); o.impact.AddListener(ShakeCamera); // Vary Model int i = Random.Range(0, Mathf.Min(numModelsSpawn, models.Length)); if (models[i] != null) { o.type = (FallingObjectType)i; GameObject m = Instantiate(models[i], o.transform.position, Quaternion.identity, o.displayRoot); o.displayRoot.transform.forward = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); } //o.boolEvent.AddListener((bool b) => { if (displayCase.isActiveAndEnabled) { displayCase.DisplayThing(i); } }); o.intEvent.AddListener(scoreTracker.ProcessScoreChange); //spawnEvent.Invoke(o); //spawnEvent.Invoke(g); } return(o.gameObject); }