Exemple #1
0
        // genera las casillas del tipo que le indique puzzle (matriz logica de tipos)
        private void GenerateCasillas(TankPuzzle puzzle)
        {
            if (puzzle == null)
            {
                throw new ArgumentNullException(nameof(puzzle));
            }

            var rows    = casillas.GetLength(0);
            var columns = casillas.GetLength(1);

            bool tankInitialized = false;

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < columns; c++)
                {
                    Casilla casilla = casillas[r, c];
                    if (casilla == null)
                    {
                        casilla = Instantiate(casillaPrefab, new Vector3(-((casillas.GetLength(1) / 2.0f) * POSITION_FACTOR_C - (POSITION_FACTOR_C / 2.0f)) + c * POSITION_FACTOR_C, 0,
                                                                         (casillas.GetLength(0) / 2.0f) * POSITION_FACTOR_R - (POSITION_FACTOR_R / 2.0f) - r * POSITION_FACTOR_R),
                                              Quaternion.identity);

                        casillas[r, c] = casilla;
                    }

                    casilla.position = new Position((uint)r, (uint)c);
                    casilla.Initialize(this, (uint)puzzle.GetType(r, c));

                    if (!tankInitialized && puzzle.GetType(r, c) == 0)
                    {
                        GameManager.instance.setTankPosition(casilla.transform.position);
                        puzzle.InitialTankPosition = casilla.position;
                        puzzle.TankPosition        = puzzle.InitialTankPosition;
                        tankInitialized            = true;
                    }
                }
            }
        }
Exemple #2
0
        // genera las casillas del tipo que le indique puzzle (matriz logica de tipos de estancia)
        private void GenerateCasillas(CluedoPuzzle puzzle)
        {
            var rows    = casillas.GetLength(0);
            var columns = casillas.GetLength(1);

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < columns; c++)
                {
                    Casilla casilla = casillas[r, c];
                    if (casilla == null)
                    {
                        casilla = Instantiate(casillaPrefab, new Vector3(-((casillas.GetLength(1) / 2.0f) * POSITION_FACTOR_C - (POSITION_FACTOR_C / 2.0f)) + c * POSITION_FACTOR_C, 0,
                                                                         (casillas.GetLength(0) / 2.0f) * POSITION_FACTOR_R - (POSITION_FACTOR_R / 2.0f) - r * POSITION_FACTOR_R),
                                              Quaternion.identity);

                        casillas[r, c] = casilla;
                    }

                    casilla.position = new Position(r, c);
                    casilla.Initialize(this, puzzle.GetType(r, c));
                }
            }

            // para cada ficha del gm le establecemos la posicion fisica que corresponda
            for (int i = 0; i < gm.characters.Count; i++)
            {
                Vector3 position = casillas[gm.characters[i].ficha_.position.GetRow(), gm.characters[i].ficha_.position.GetColumn()].transform.position;
                gm.characters[i].ficha_.setPosition(position);
                if (i < gm.numPlayers)
                {
                    casillas[gm.characters[i].ficha_.position.GetRow(), gm.characters[i].ficha_.position.GetColumn()].tienePlayer = true;
                }
                else
                {
                    casillas[gm.characters[i].ficha_.position.GetRow(), gm.characters[i].ficha_.position.GetColumn()].tieneSuspect = true;
                }
            }
        }