void MoveAway() { connectionEffect.ConnectionIsFinished -= MoveAway; vectToTargetMultiplier = moveAwaySpeed; GridController gridController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GridController>(); float xPos = gridController.OccupatedNodesRowsRadius + moveAwayDistance; float yPos = gridController.OccupatedNodesRowsRadius + moveAwayDistance; if (Random.Range(0, 0.99f) > 0.5f) { xPos *= -1; } if (Random.Range(0, 0.99f) > 0.5f) { yPos *= -1; } FinishedMoving += DestroySelf; StartCoroutine(MoveToTarget(new Vector2(transform.position.x + xPos, transform.position.y + yPos))); StartCoroutine(RotateToTarget(new Vector2(transform.position.x + xPos, transform.position.y + yPos))); if (FinishedConnection != null) { FinishedConnection(); } }
void DestroySelf() { FinishedMoving -= DestroySelf; Destroy(gameObject); }