private void OnTriggerEnter2D(Collider2D collision) { if (!readCollision) { return; } ShapeMatch shape = collision.GetComponent <ShapeMatch>(); if (shape != null) { if (rightShapeRoutine != null) { StopCoroutine(rightShapeRoutine); } anim.SetTrigger("Print"); if (shape.CheckShape(ShapeController.GetCurrentShape())) { rightShapeRoutine = RightShapeCoroutine(); StartCoroutine(rightShapeRoutine); OnShapeGuessed?.Invoke(); return; } OnShapeWrong?.Invoke(); } }
public void SpawnShape(ShapeScriptable _shapeToSpawn) { //Calculate Random Position float randomXValue = UnityEngine.Random.Range((bgBounds.center.x - bgBounds.extents.x) + 1f, (bgBounds.center.x + bgBounds.extents.x) - 1f); Vector3 spawnVector = new Vector3(randomXValue, transform.position.y, transform.position.z); //Calculate Random Rotation float randomRoation = UnityEngine.Random.Range(-60f, 60f); Quaternion spawnRotation = Quaternion.Euler(0, 0, randomRoation); ShapeMatch newShape = PoolManager.instance.GetPooledObject(ObjectTypes.Shape, gameObject).GetComponent <ShapeMatch>(); if (newShape != null) { newShape.transform.SetPositionAndRotation(spawnVector, spawnRotation); newShape.Setup(_shapeToSpawn, cam); spawnedShapes.Add(newShape); } }
private void HandleShapeDestroyed(ShapeMatch _shapeDestroied) { spawnedShapes.Remove(_shapeDestroied); }