comprime este codigo al maximo para que pueda ser usado louego en chatgpt como memoria…
- User
comprime este codigo al maximo para que pueda ser usado louego en chatgpt como memoria de la IA: "using System; using System.Collections.Generic; using UnityEngine; using System.Linq; using DG.Tweening; using Random = System.Random;
public class GemsManager : MonoBehaviour { public Sprite[] sprites; public GameObject gemPrefab; public GameObject targetPosition; public GameObject particleSystemGems;
private static readonly char[] G = {'R', 'G', 'B', 'Y', 'P'}; private const int N = 6; private static readonly Random Random1 = new(DateTime.Now.Millisecond); private static List<List<char>> _board; int[,] board = new int[N, N]; HashSet<Position> positions = new HashSet<Position>(); class Position { public int col; public int row; public float x; public float y; } // Start is called before the first frame update private void Start() { _board = GenerateBoard(); FillBoard(); ShowBoard(board); // Debug.Log of the board //Debug Log formatted of the _board and in order to see the board var mensaje = string.Join("\n", _board.Select(row => string.Join(" ", row))); Debug.Log(mensaje); GenerateScreenBoard(); var gems = FindHorizontalLine(board); gems.AddRange(FindVerticalLines(board)); //delay 1 segundo if (gems.Count > 0) { gems = gems.OrderBy(x => x.Item1).ThenBy(x => x.Item2).ToList(); ShowGems(gems); RemoveGems(board, gems); ShowBoard(board); } } private void FillBoard() { for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) board[i, j] = Array.IndexOf(G, _board[i][j]); } private void RemoveGems(int[,] board, List<(int, int)> gems) { foreach (var (x, y) in gems) { board[x, y] = -1; GameObject gem = GameObject.Find($"Piece_{x}_{y}"); ParticleSystem particleSystem1 = Instantiate(particleSystemGems).GetComponent<ParticleSystem>(); // Posicionar el sistema de partículas en la posición de la gema, menos la z Transform transform1; (transform1 = particleSystem1.transform).SetParent(gem.transform); transform1.localPosition = new Vector3(1, 1, -1); // Activar el sistema de partículas // Mover la gema a la posición del objetivo delay 1 segundo gem.transform.DOMove(targetPosition.transform.position, 3f).SetDelay(2f) .OnStart(() => particleSystem1.Play()).OnComplete(() => Destroy(gem)); } // Hacer que las gemas caigan hacia abajo var listaPrimerBlanco = new List<(int, int)>(); var listaGemas = new List<(int, int)>(); for (int col = 0; col < N; col++) { // extraer las gemas no vacías en la columna actual var nonEmptyGems = new List<int>(); for (int row = 0; row < board.GetLength(0); row++) { if (board[row, col] != -1) { nonEmptyGems.Add(board[row, col]); } } var primerFlag = false; for (int row = board.GetLength(0) - 1; row >= 0; row--) { if (board[row, col] != -1) { if (primerFlag) { listaGemas.Add((row, col)); } } else { primerFlag = true; } } if (nonEmptyGems.Count == 6) continue; // agregar valores nulos al principio de la lista nonEmptyGems para que tenga N elementos nonEmptyGems.InsertRange(0, Enumerable.Repeat(-1, board.GetLength(0) - nonEmptyGems.Count)); // reemplazar las gemas en la columna actual con la lista nonEmptyGems actualizada // Assign the values from the nonEmptyGems list to the board array, column by column. var flag = false; for (int row = board.GetLength(0) - 1; row >= 0; row--) { if (!flag && board[row, col] == -1) { flag = true; listaPrimerBlanco.Add((row, col)); } board[row, col] = nonEmptyGems[row]; } } // Animar las gemas que caen AnimarGemasCaen(listaGemas, listaPrimerBlanco); // Generar nuevas gemas aleatorias para llenar los espacios vacíos for (int col = 0; col < board.GetLength(1); col++) { var emptySpaces = new List<int>(); for (int i = 0; i < board.GetLength(0); i++) { if (board[i, col] == -1) emptySpaces.Add(i); } foreach (var i in emptySpaces) { board[i, col] = Random1.Next(0, G.Length); var newPiece = CreateIconsAtPosition(i, col); var position = newPiece.transform.position; var positionY = position.y - 6f; newPiece.transform.DOMoveY(positionY, 1f).SetEase(Ease.Flash) .SetDelay(4f - i/2f); } } }" - Assistant