Exemplo n.º 1
0
        void MoveEmptySpace(Vector2 newCoordinates)
        {
            var tail = snake.GetTail();
            var previousCoordinate = tail.coordinates;

            tail.transform.SetAsFirstSibling();
            tail.coordinates        = newCoordinates;
            tail.transform.position = snake.boardCoordinates.GetPositionForCoordinates(newCoordinates);

            snake.EmitOccupationEvent(GameEvents.coordinateOccupied, newCoordinates, tail.gameObject);
            snake.EmitOccupationEvent(GameEvents.coordinateDisoccupied, previousCoordinate);
        }
Exemplo n.º 2
0
        public SnakeChild CreateChildAt(Vector2 coordinates)
        {
            var child = GameObject.Instantiate <SnakeChild>(snake.snakeData.childPrefab, transform);

            child.transform.localScale = snake.blockSize;
            child.transform.position   = snake.boardCoordinates.GetPositionForCoordinates(coordinates);
            child.coordinates          = coordinates;

            snake.EmitOccupationEvent(
                GameEvents.coordinateOccupied,
                coordinates,
                child.gameObject
                );

            return(child);
        }