/// <summary> /// Surface detection logic /// </summary> private void DetectionLogic() { if (!canRun) { return; } Debug.DrawRay(_childBall.position, -_childBall.transform.up * detectionDist, Color.red); if (Physics.Raycast(_childBall.position, -_childBall.transform.up, out RaycastHit hit, detectionDist, interactionLayers)) { //Debug.Log("GameObject " + hit.collider.gameObject.name); GameObject collidedObject = hit.collider.gameObject; if (collidedObject.TryGetComponent <IInteractable>(out IInteractable Iobj)) { if (!_splashBuffer) { _splashBuffer = true; GameObject splashMark = Instantiate(splashPrefab, hit.point + (Vector3.up * 0.01f), splashPrefab.transform.rotation, collidedObject.transform); } Iobj.Interaction(); } else if (collidedObject.CompareTag("GameOverObj")) { GameManager.Instance.GameOverEventCall(); } }
public void GetCollision(Object[] obj) { foreach (Object Iobj in obj) { Iobj.CollidingObjects.Clear(); for (int x = 0; x < Objects.Count; x++) { if (Iobj.NAME != Objects[x].NAME && Iobj.CheckIfColliding(Objects[x])) { Iobj.CollidingObjects.Add(Objects[x]); } } } }
static void Main() { ArrayList objArrayList = new ArrayList(); clsCircle objCircle = new clsCircle(); clsLine objLine = new clsLine(); clsRectangle objRect = new clsRectangle(); clsSquare objSquare = new clsSquare(); objArrayList.Add(objCircle); objArrayList.Add(objLine); objArrayList.Add(objRect); objArrayList.Add(objSquare); foreach (IUserInterface Iobj in objArrayList) { Iobj.Draw(); } Console.ReadLine(); }