示例#1
0
        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();
        }
示例#2
0
        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();
        }