Exemple #1
0
 private void AddRandomTetrominos()
 {
     for (int i = 0; i < tetrominos.Count; i++)
     {
         NextTetrominos.Insert(NextTetrominos.Count - i + rnd.Next(i + 1),
                               new Tetromino(tetrominos[i]));
     }
 }
Exemple #2
0
 void Hold()
 {
     if (HoldTetromino != null)
     {
         NextTetrominos.Insert(0, HoldTetromino);
     }
     HoldTetromino          = CurrentTetromino;
     HoldTetromino.Rotation = 0;
     PickTetromino();
 }
Exemple #3
0
        private void PickTetromino()
        {
            CurrentTetromino = NextTetrominos[0];

            CurrentTetromino.PositionX = NumHiddenRows + CurrentTetromino.NumRows / 2;
            CurrentTetromino.PositionY = Board.NumColumns / 2 - 1;

            NextTetrominos.RemoveAt(0);
            if (NextTetrominos.Count < tetrominos.Count)
            {
                AddRandomTetrominos();
            }
            if (!Board.DoesTetrominoFit(CurrentTetromino))
            {
                State            = GameState.GameOver;
                CurrentTetromino = null;
            }
        }
Exemple #4
0
    // Use this for initialization
    void Awake()
    {
        blocks           = new int [20, 10];
        tetromino        = tetrominoObj.GetComponent <TetrominoController> ();
        queue            = queueObj.GetComponent <NextTetrominos> ();
        hold             = holdObj.GetComponent <HoldTetromino> ();
        networkBlocks    = "";
        justSpanwed      = true;
        gameRunning      = false;
        dropDelay        = 1f;
        dropDelayCounter = dropDelay;
        ResetCurrentPos();
        x      = new int[4];
        y      = new int[4];
        startX = -1.88f;
        startY = 4.005f;
        InitializeBlocksObj();
        UpdateBlocksState();
        randomedTetrominos = new int[4];
        RandomTetrominos();
        holdUsed = false;
        pushUsed = false;
        time     = 120f;
        score    = 0;

        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://tetris-a8118.firebaseio.com/");

        // Get the root reference location of the database.
        reference = FirebaseDatabase.DefaultInstance.RootReference;
        reference.ValueChanged += (object sender, ValueChangedEventArgs args) => {
            if (args.DatabaseError != null)
            {
                Debug.LogError(args.DatabaseError.Message);
                return;
            }
            if (args.Snapshot.Child(myEnemy).HasChild("score"))
            {
                escore = args.Snapshot.Child(myEnemy).Child("score").Value.ToString();
            }
        };
    }