private GameObject SpawnWithTail(GameObject headPrototype, GameObject tailPrototype, int tailsCount, bool isNeedToUpdateUI = false) { GameObject head = Instantiate(headPrototype); head.transform.position = LevelManager.RandomFieldPosition; ISnake headController = head.GetComponent <ISnake>(); for (int i = 0; i < tailsCount; i++) { GameObject tail = Instantiate(tailPrototype); headController.AddTail(tail); if (isNeedToUpdateUI) { ReferenceContainer.UiManager.UpdateLengthText(headController.TailsLength + 1); } } return(head); }