public void CheckSurrounding() { Direction missedHole = Direction.None; foreach (Direction hole in _holeLocations) { Point targetPoint = DirectionExtensions.GetDirectionPoint(hole); GameObject side = GridLevelManager.Instance.GetCircleData(targetPoint.X + GetPoint().X, targetPoint.Y + GetPoint().Y); if (side != null) { CircleData sideData = side.GetComponent <CircleData>(); if (sideData != null) { if (sideData.MatchConnectingHole(hole)) { if (sideData.LightOn()) { sideData.SetNextCircleData(this); TurnLightOn(); if (missedHole != Direction.None) { targetPoint = DirectionExtensions.GetDirectionPoint(missedHole); side = GridLevelManager.Instance.GetCircleData(targetPoint.X + GetPoint().X, targetPoint.Y + GetPoint().Y); sideData = side.GetComponent <CircleData>(); sideData.CheckSurrounding(); } } else if (LightOn()) { sideData.CheckSurrounding(); } else { missedHole = hole; } } } } } if (GridLevelManager.Instance.CheckWinTile(GetPoint())) { if (_lightUp) { foreach (Direction hole in _holeLocations) { if (GridLevelManager.Instance.DirectionFacingGoal(hole, GetPoint().X, GetPoint().Y)) { GridLevelManager.Instance.ExecuteWin(); } } } } }
public void OnEndDrag(PointerEventData eventData) { DraggedObject = null; if (transform.parent == _startParent) { transform.position = _startPosition; } else { transform.localPosition = Vector3.zero; GridLevelManager.Instance.SetCircleData(gameObject, _circleData.GetPoint()); _lockRotation = true; } _circleData.CheckSurrounding(); _collider.size = _startCollider; }