示例#1
0
    void OnEnable()
    {
        // Drop time reduces when the game level goes up
        dropTime = 1 - GameSystem.gsInstance.gameLevel * 0.1f;

        // Assign TetrominoSystem Component
        tetroSystem = GameObject.FindObjectOfType <TetrominoSystem>();

        // Assign attached blocks to blocks list
        blocks = new TetrominoBlockController[4];
        for (int i = 0; i < blocks.Length; i++)
        {
            TetrominoBlockController newBlock = transform.GetChild(0).GetChild(i).GetComponent <TetrominoBlockController>();
            blocks[i] = newBlock;
        }

        // Assign TetrominoController to current tetromino variable
        curTetroController = gameObject.GetComponent <TetrominoController>();
        curBlocks          = gameObject;

        // Assign touch controller event
        TouchController.swipeEvent    += SwipeHandler;
        TouchController.swipeEndEvent += SwipeEndHandler;
        TouchController.tapEvent      += TapHandler;
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        gsInstance = this;

        // Assign system components
        _gridSystem  = GameObject.FindObjectOfType <GridSystem>();
        _spawnContrl = GameObject.FindObjectOfType <SpawnController>();
        _scoreContrl = GameObject.FindObjectOfType <ScoreController>();
        soundContrl  = GameObject.FindObjectOfType <SoundController>();
        _tetroSystem = GameObject.FindObjectOfType <TetrominoSystem>();

        // Assign value from score controller
        gameLevel = _scoreContrl.curLevel;

        // Set first level threshold
        _nextLevelThreshold = 1000;
    }
    // Start is called before the first frame update
    void Start()
    {
        // Initialize instance
        instance = this;

        // Middle: Spawn I, O in the middle columns
        // Left-Middle: Spawn J, L, T, Z, S in the left-middle columns
        _spawnMiddle     = new Vector2Int(4, 21);
        _spawnLeftMiddle = new Vector2Int(3, 21);

        // Assign Tetromino System Component
        tetroSystem = GameObject.FindObjectOfType <TetrominoSystem>();

        // Initial bag shuffule
        _bagIdxList = ShuffleIndex();

        // Spawn Intial Tetromino
        SpawnTetromino();
    }
 void Start()
 {
     grid        = GameObject.FindObjectOfType <GridSystem>();
     tetroSystem = GameObject.FindObjectOfType <TetrominoSystem>();
 }