Пример #1
0
    public void UpdateStats(TetroMinoColor type, int number)
    {
        Debug.Log("New Entry Stat");
//        int x = 28;
        if (number > 1)
        {
            var    previousHeadSpriteRenderer = statsMatrix[number - 2, (int)type].GetComponent <SpriteRenderer>();
            string previousSpriteName         = "Minos_" + ((int)type * 15 + 4);
            previousHeadSpriteRenderer.sprite = GameResources.instance.GetSpriteByName(previousSpriteName); //changes the sprite combining the color and the type;
        }

        var newHead = MinoPool.instance.GetPooledMinoObject();

        newHead.GetComponent <Mino>().enabled = false;
        newHead.SetActive(true);
        newHead.transform.parent = this.transform;
        var newHeadSpriteRenderer = newHead.GetComponent <SpriteRenderer>();

        statsMatrix[number - 1, (int)type] = newHead.transform;
        newHead.transform.parent           = place;
        newHead.transform.localPosition    = new Vector2(1 + (int)type, number - 1);

        string headSpriteName = "Minos_" + ((int)type * 15 + 3);

        newHeadSpriteRenderer.sprite       = GameResources.instance.GetSpriteByName(headSpriteName); //changes the sprite combining the color and the type
        newHeadSpriteRenderer.sortingOrder = 1;
    }
Пример #2
0
    /*
     * private void ProcessDeletedRows(int rows)
     * {
     *  Debug.Log("Fazer qualquer coisa aqui");
     *  SpawnNewTetrominoIntoGrid();
     *
     * }
     */
    private TetroMinoColor GetRandomTetroMinoType()
    {
        //Debug.Log(Game_References.instance);
        Array          values = Enum.GetValues(typeof(TetroMinoColor));
        TetroMinoColor random = (TetroMinoColor)values.GetValue(UnityEngine.Random.Range(0, 7));

        return(random);
    }
Пример #3
0
    private void SetTetroMinoMatrix(TetroMinoColor type) // sets the array acordingly to the color
    {
        switch (type)
        {
        case TetroMinoColor.Gray:

            tetrominoMatrix = new int[GRAY_SINGLE.GetLength(0), GRAY_SINGLE.GetLength(1)];
            tetrominoMatrix = (int[, ])GRAY_SINGLE.Clone();

            break;

        case TetroMinoColor.Blue:
            tetrominoMatrix = new int[BLUE_SQUARE.GetLength(0), BLUE_SQUARE.GetLength(1)];
            tetrominoMatrix = (int[, ])BLUE_SQUARE.Clone();
            break;

        case TetroMinoColor.Cyan:

            tetrominoMatrix = new int[CYAN_S.GetLength(0), CYAN_S.GetLength(1)];
            tetrominoMatrix = (int[, ])CYAN_S.Clone();
            break;

        case TetroMinoColor.Red:
            tetrominoMatrix = new int[RED_I.GetLength(0), RED_I.GetLength(1)];
            tetrominoMatrix = (int[, ])RED_I.Clone();
            break;

        case TetroMinoColor.Magenta:

            tetrominoMatrix = new int[MAGENTA_L.GetLength(0), MAGENTA_L.GetLength(1)];
            tetrominoMatrix = (int[, ])MAGENTA_L.Clone();
            break;

        case TetroMinoColor.Yellow:

            tetrominoMatrix = new int[YELLOW_J.GetLength(0), YELLOW_J.GetLength(1)];
            tetrominoMatrix = (int[, ])YELLOW_J.Clone();
            break;

        case TetroMinoColor.Green:
            tetrominoMatrix = new int[GREEN_T.GetLength(0), GREEN_T.GetLength(1)];
            tetrominoMatrix = (int[, ])GREEN_T.Clone();
            break;

        case TetroMinoColor.Orange:

            tetrominoMatrix = new int[ORANGE_S.GetLength(0), ORANGE_S.GetLength(1)];
            tetrominoMatrix = (int[, ])ORANGE_S.Clone();
            break;
        }
    }
Пример #4
0
 /// <summary>
 /// inits a tetromino with a specific color
 /// </summary>
 /// <param name="type"></param>
 public void Initialize(PlayerGrid playerGrid, TetroMinoColor type)
 {
     disabling = false;
     minos.Clear();
     gameObject.SetActive(true);
     isInitialized    = true;
     this._playerGrid = playerGrid;
     this.type        = type;
     SetTetroMinoMatrix(type);
     if (tetrominoMatrix != null)
     {
         DrawTetroMino();
     }
 }
Пример #5
0
    private void InsertSingleTetrominoAtPos(Vector2 pos, TetroMinoColor tetroMinoType)
    {
        var       tetrominoObject = TetrominoPool.instance.GetPooledTetroMinoObject();
        Tetromino tetromino       = tetrominoObject.GetComponent <Tetromino>();

        tetromino.Initialize(this, tetroMinoType);
        tetromino.transform.SetParent(this.gameObject.transform);
        tetromino.transform.localPosition = pos;
        tetrominoObject.name = "Block";
        tetrominosList.Add(tetromino);
        //tetrominoObject.GetComponent<TetrominoMovement>();
        //needs to check playerGrid
        UpdateTetrominoInGrid(tetromino);
        var sfxclip = sfx.Find(clip => clip.name.Contains("spawn"));

        Sound2DManager.instance.PlaySfx(sfxclip);
    }
Пример #6
0
    public void Initialize(int row, int col, TetroMinoColor tetroMinoType, int[,] tetrominoMatrix)
    {
        if (!transform.parent)
        {
            throw new MinoParentNotFoundException("You need to Set the Parent Before Initializing the Mino");
        }

        tetroMinoParent      = transform.parent.GetComponent <Tetromino>();
        this.tetroMinoMatrix = tetrominoMatrix;
        this.tetroMinoType   = tetroMinoType;
        transform.GetChild(0).gameObject.SetActive(false);


        if (row < 0 || col < 0 || row >= tetroMinoMatrix.GetLength(0) || col >= tetroMinoMatrix.GetLength(1))
        {
            throw new IndexOutOfRangeException();
        }


        this.row = row;
        this.col = col;
        DrawMino();


        if (!isInitialized)
        {
            isInitialized = true;
        }
        isBeingRemoved     = false;
        myAnimator         = GetComponent <Animator>();
        myAnimator.enabled = false;

        if (tetroMinoType == TetroMinoColor.Gray)
        {
            myAnimator.enabled = true;
            transform.GetChild(0).gameObject.SetActive(true);
        }
    }
Пример #7
0
 public void ChangeTetrominoToNewType(TetroMinoColor type)
 {
     ResetTetroMino();
     tetrominoMatrix = null;
     Initialize(_playerGrid, type);
 }
Пример #8
0
 private void ProcessNextTetromino() //next Tetromino will appear for each pfPlayer every time a Tetromino is Placed
 {
     nextTetroMinoType = GetRandomTetroMinoType();
     nextTetrominoPreviw.ChangeTetrominoToNewType(nextTetroMinoType);
 }
Пример #9
0
 public void IncrementTetroMinosSpawned(TetroMinoColor type)
 {
     totalTetrominosSpawned++;
     tetroMinosSpawned[type]++;
     roundStats.UpdateStats(type, tetroMinosSpawned[type]);
 }