private void Start() { initialMoveAfter = MoveAfter; snake = new List <SnakePart>(); deathBlocks = new List <GameObject>(); var head = new SnakePart { Part = Instantiate(SnakePartPrefab, transform), Head = true }; lastPart = head; snake.Add(head); squareSide = SnakePartPrefab.transform.localScale.x; head.Part.GetComponent <BoxCollider>().enabled = true; subscribe(); }
private void growSnake() { MoveAfter -= IncreaseSpeedBy; var squareSide = SnakePartPrefab.transform.localScale.x; var newBody = new SnakePart { Part = Instantiate(SnakePartPrefab, lastPart.Part.transform.position, Quaternion.identity, transform), FollowPart = lastPart, ActiveAfter = 1, }; lastPart = newBody; snake.Add(newBody); spawnDeathBlock(); MinigameManager.Events.EventScored(); }