Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        m_timeToNextKeyLeftRight = Time.time;
        m_timeToNextKeyDown      = Time.time;
        m_timeToNextKeyRotate    = Time.time;

        //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>();
        //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>();
        m_gameBoard    = FindObjectOfType <Board>();
        m_spawner      = FindObjectOfType <Spawner>();
        m_soundManager = FindObjectOfType <SoundManager>();
        m_scoreManager = FindObjectOfType <ScoreManager>();
        m_ghost        = FindObjectOfType <Ghost>();
        m_holder       = FindObjectOfType <Holder>();


        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING! There is no board defined");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING! There is no Sound Manager defined");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING! There is no score manager defined");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING! There is no spawner defined");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        if (m_diagnosticText3)
        {
            m_diagnosticText3.text = "";
        }
        m_dropIntervalModed = m_dropInterval;
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        // find spawner and board with GameObject.FindWithTag plus GetComponent; make sure you tag your objects correctly
        //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>();
        //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>();

        // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing
        m_gameBoard    = GameObject.FindObjectOfType <Board>();
        m_spawner      = GameObject.FindObjectOfType <Spawner>();
        m_soundManager = GameObject.FindObjectOfType <SoundManager>();
        m_scoreManager = GameObject.FindObjectOfType <ScoreManager>();
        m_ghost        = GameObject.FindObjectOfType <Ghost>();
        m_holder       = GameObject.FindObjectOfType <Holder>();


        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING!  There is no game board defined!");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING!  There is no sound manager defined!");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING!  There is no score manager defined!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING!  There is no spawner defined!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);

            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        m_dropIntervalModded = Mathf.Clamp(m_dropInterval - ((float)m_scoreManager.m_level * 0.1f), 0.05f, 1f);
    }
Пример #3
0
    public int CalcOffsetBoard(Shape shape)
    {
        int w_offset = 0;

        foreach (Transform child in shape.transform)
        {
            Vector2 pos = Vectorf.Round(child.position);

            if ((int)pos.x == -1)
            {
                w_offset -= 1;
            }
            else if ((int)pos.x == -2)
            {
                w_offset -= 10;
            }
            else if ((int)pos.x == m_width)
            {
                w_offset += 1;
            }
            else if ((int)pos.x == m_width + 1)
            {
                w_offset += 10;
            }
        }
        return(w_offset);
    }
Пример #4
0
    // Start is called before the first frame update
    void Start()
    {
        Vector2 originalVector = new Vector2(4.3f, 1.3f);
        Vector2 newVector      = Vectorf.Round(originalVector);

        Debug.Log(newVector.ToString());
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        // find spawner and board with GameObject.FindWithTag plus GetComponent; make sure you tag your objects correctly
        //m_gameBoard = GameObject.FindWithTag("Board").GetComponent<Board>();
        //m_spawner = GameObject.FindWithTag("Spawner").GetComponent<Spawner>();

        // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing
        m_gameBoard = GameObject.FindObjectOfType <Board>();
        m_spawner   = GameObject.FindObjectOfType <Spawner>();


        if (m_spawner)
        {
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
            }

            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
        }


        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING!  There is no game board defined!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING!  There is no spawner defined!");
        }
    }
Пример #6
0
    // Start is called before the first frame update
    void Start()
    {
        m_TimeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_TimeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_TimeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING! There is no board definied!");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING! There is no soundManager definied!");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING! There is no scoreManager definied!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING! There is no spawner definied!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }
    }
Пример #7
0
    private void Start()
    {
        //Tag method faster
        m_gameBoard    = GameObject.FindWithTag("Board").GetComponent <Board>();
        m_spawner      = GameObject.FindWithTag("Spawner").GetComponent <Spawner>();
        m_soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundManager>();
        m_scoreManager = GameObject.FindWithTag("ScoreManager").GetComponent <ScoreManager>();

        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        //Alternative Method(This is slow)
        //m_gameBoard = GameObject.FindObjectOfType<Board>();
        //m_spawner = GameObject.FindObjectOfType<Spawner>();
        ////
        //also same
        //m_gameBoard = GameObject.FindObjectOfType(typeof(Board)) as Board;
        //m_spawner = GameObject.FindObjectOfType(typeof(Spawner)) as Spawner;

        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING! MISSING GAME BOARD!!!");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING! MISSING SOUND MANAGER!!!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING! MISSING SPAWNER!!!");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING! MISSING SCORE MANAGER!!!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }
        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        m_dropIntervalModded = m_dropInterval;
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        //m_gameBoard = GameObject.FindWithTag ("Board").GetComponent<Board>();
        //m_spawner = GameObject.FindWithTag ("Spawner").GetComponent<Spawner>();
        m_gameBoard    = GameObject.FindObjectOfType <Board>();
        m_spawner      = GameObject.FindObjectOfType <Spawner> ();
        m_soundManager = GameObject.FindObjectOfType <SoundManager> ();
        m_scoreManager = GameObject.FindObjectOfType <ScoreManager> ();
        m_ghost        = GameObject.FindObjectOfType <Ghost> ();
        m_holder       = GameObject.FindObjectOfType <Holder> ();

        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;


        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING! There is no game board defined!");
        }
        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING! There is no sound manager defined!");
        }
        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING! There is no score manager defined!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING! There is no spawner defined!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
                if (m_activeShape.name == m_spawner.m_allShapes[3].name + "(Clone)")
                {
                    m_activeShape.MoveRight();
                }
            }
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }
        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        m_dropIntervalModded = m_dropInterval;

        m_gridArray = m_gameBoard.GetGridArray();
    }
Пример #9
0
 public static void AssertSize(Vectorf vector, uint size)
 {
     if (vector.DimensionCount != size)
     {
         throw new ArgumentException(string.Format("Vector invalid size, should be {0} but is {1}",
                                                   size, vector.DimensionCount));
     }
 }
Пример #10
0
    // Start is called before the first frame update
    void Start()
    {
        //call helper script to make sure block be on whole number location
        Vector2 originalVector = new Vector2(4.3f, 1.3f);
        Vector2 newVector      = Vectorf.Round(originalVector);

        Debug.Log(newVector.ToString());
    }
Пример #11
0
    private void Start()
    {
        gameBoard = GameObject.FindObjectOfType <Board>();
        spawner   = GameObject.FindObjectOfType <Spawner>();

        ghost  = GameObject.FindObjectOfType <Ghost>();
        holder = GameObject.FindObjectOfType <Holder>();

        soundManager = GameObject.FindObjectOfType <SoundManager>();
        scoreManager = GameObject.FindObjectOfType <ScoreManager>();

        timeToNextKeyLeftRight = Time.time + keyRepeatRateLeftRight;
        timeToNextKeyRotate    = Time.time + keyRepeatRateRotate;
        timeToNextKeyDown      = Time.time + keyRepeatRateDown;

        if (!gameBoard)
        {
            Debug.Log("WARNING! There is no game board defined!");
        }

        if (!soundManager)
        {
            Debug.Log("WARNING! There is no sound manager defined!");
        }

        if (!scoreManager)
        {
            Debug.Log("WARNING! There is no score manager defined!");
        }


        if (!spawner)
        {
            Debug.Log("WARNING! There is no spawner defined!");
        }
        else
        {
            if (activeShape == null)
            {
                activeShape = spawner.SpawnShape();
            }

            spawner.transform.position = Vectorf.Round(spawner.transform.position);
        }

        if (gameOverPanel)
        {
            gameOverPanel.SetActive(false);
        }

        if (pausePanel)
        {
            pausePanel.SetActive(false);
        }

        dropIntervalModded = dropInterval;
    }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        m_gameBoard    = GameObject.FindWithTag("Board").GetComponent <Board>();
        m_spawner      = GameObject.FindWithTag("Spawner").GetComponent <Spawner>();
        m_soundManager = FindObjectOfType <SoundManager>();
        m_scoreManager = FindObjectOfType <ScoreManager>();
        m_ghost        = FindObjectOfType <Ghost>();
        m_holder       = FindObjectOfType <Holder>();

        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_gameBoard)
        {
            Debug.LogWarning("Warning: No game board defined");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("Warning: No SoundManager defined");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("Warning: No ScoreManager defined");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("Warning: No spawner defined");
        }
        else
        {
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
            //Make sure spawner spawns on even position to align with grid
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
        }

        //Make sure gameover and pause panels aren't showing at game start
        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }
        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        m_dropIntervalModded = m_dropInterval;
    }
Пример #13
0
    // Use this for initialization
    void Start()
    {
        m_gameBoard    = GameObject.FindObjectOfType <Board>();
        m_spawner      = GameObject.FindObjectOfType <Spawner>();
        m_soundManager = GameObject.FindObjectOfType <SoundManager> ();
        m_scoreManager = GameObject.FindObjectOfType <ScoreManager> ();
        m_highScores   = GameObject.FindObjectOfType <HighScores>();
        m_holder       = GameObject.FindObjectOfType <Holder> ();
        m_input        = GameObject.FindObjectOfType <InputField>();

        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING!  There is no game board defined!");
        }

        if (!m_soundManager)
        {
            Debug.LogWarning("WARNING!  There is no sound manager defined!");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING!  There is no score manager defined!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING!  There is no spawner defined!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
                m_settleTime  = 1;
            }
        }

        if (!m_gameOver)
        {
            m_gameOverPanel.transform.localScale = new Vector3(0, 0, 0);
        }


        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }
    }
Пример #14
0
    void Start()
    {
        _gameBoard    = GameObject.FindObjectOfType <Board>();
        _spawner      = GameObject.FindObjectOfType <Spawner>();
        _soundManager = GameObject.FindObjectOfType <SoundManager>();
        _scoreManager = GameObject.FindObjectOfType <ScoreManager>();
        _ghost        = GameObject.FindObjectOfType <Ghost>();
        _holder       = GameObject.FindObjectOfType <Holder>();


        _timeToNextKeyDown      = Time.time + keyRepeatRateDown;
        _timeToNextKeyLeftRight = Time.time + keyRepeatRateLeftRight;

        if (!_gameBoard)
        {
            Debug.LogWarning("WARNING!  There is no game board defined!");
        }

        if (!_soundManager)
        {
            Debug.LogWarning("WARNING!  There is no sound manager defined!");
        }

        if (!_scoreManager)
        {
            Debug.LogWarning("WARNING!  There is no score manager defined!");
        }

        if (!_spawner)
        {
            Debug.LogWarning("WARNING!  There is no spawner defined!");
        }
        else
        {
            _spawner.transform.position = Vectorf.Round(_spawner.transform.position);

            if (!_activeShape)
            {
                _activeShape = _spawner.SpawnShape();
            }
        }

        if (gameOverPanel)
        {
            gameOverPanel.SetActive(false);
        }

        if (pausePanel)
        {
            pausePanel.SetActive(false);
        }

        _dropIntervalModded = Mathf.Clamp(dropInterval - ((float)_scoreManager.level * 0.1f), 0.05f, 1f);
    }
Пример #15
0
    /*
     *  store the block into the layout_grid array as a child class
     */
    public void StoreBlock(Blocks block)
    {
        if (block == null)
        {
            return;
        }

        foreach (Transform child in block.transform)
        {
            Vector2 position = Vectorf.Round(child.position);
            layout_grid[(int)position.x, (int)position.y] = child;
        }
    }
Пример #16
0
    public void StoreShapeInGrid(Shape shape)
    {
        if (shape == null)
        {
            return;
        }

        foreach (Transform child in shape.transform)
        {
            Vector2 pos = Vectorf.Round(child.position);
            _grid[(int)pos.x, (int)pos.y] = child;
        }
    }
Пример #17
0
    public bool IsValidPosBoard(Shape shape)
    {
        foreach (Transform child in shape.transform)
        {
            Vector2 pos = Vectorf.Round(child.position);

            if (!IsWithinBoard((int)pos.x, (int)pos.y))
            {
                return(false);
            }
        }
        return(true);
    }
Пример #18
0
    public void StoreShapeInGrid(Tetrimino tetrimino)
    {
        if (tetrimino == null)
        {
            return;
        }

        foreach (Transform child in tetrimino.transform)
        {
            Vector2 position = Vectorf.Round(child.position);
            m_grid[(int)position.x, (int)position.y] = child;
        }
    }
Пример #19
0
    public bool IsValidPosOccupied(Shape shape)
    {
        foreach (Transform child in shape.transform)
        {
            Vector2 pos = Vectorf.Round(child.position);

            if (IsOccupied((int)pos.x, (int)pos.y, shape))
            {
                return(false);
            }
        }
        return(true);
    }
Пример #20
0
    void Start()
    {
        m_board         = FindObjectOfType <Board>();
        m_spawner       = FindObjectOfType <Spawner>();
        m_soundManager  = FindObjectOfType <SoundManager>();
        m_scoreManager  = FindObjectOfType <ScoreManager>();
        m_ghost         = FindObjectOfType <Ghost>();
        m_holder        = FindObjectOfType <Holder>();
        m_addPlayer     = FindObjectOfType <AddPlayer>();
        m_getPlayerInfo = FindObjectOfType <GetPlayerInfos>();
        m_updatePlayer  = FindObjectOfType <UpdatePlayer>();

        m_timeToNextKey          = Time.time;
        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_spawner || !m_board || !m_soundManager || !m_scoreManager)
        {
            Debug.LogWarning("Warning! m_board or m_spawner or m_soundManager or m_scoreManager aren't defined.");
        }
        else
        {
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
            }

            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }


        m_dropIntervalModded          = m_dropInterval;
        m_soundManager.m_fxEnabled    = SaveManager.Instance.IsFxOn();
        m_soundManager.m_musicEnabled = SaveManager.Instance.IsMusicOn();

        m_soundManager.m_fxIconToggle.ToggleIcon(m_soundManager.m_fxEnabled);
        m_soundManager.m_musicIconToggle.ToggleIcon(m_soundManager.m_musicEnabled);

        m_soundManager.UpdateMusic();
    }
Пример #21
0
  void Start() {
    m_gameBoard = FindObjectOfType<Board>();
    m_spawner = FindObjectOfType<Spawner>();
    m_timeToNextKey = Time.time;

    if(m_spawner) {
      m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);

      if(m_activeShape == null) {
        m_activeShape = m_spawner.SpawnShape();
      }
    } else {
      Debug.LogWarning("Warning! No spawner defined");
    }
  }
Пример #22
0
    private void Start()
    {
        gameOverPanel.SetActive(false);
        pausePanel.SetActive(false);

        GetReferences();
        MakeAssertions();

        spawner.transform.position = Vectorf.Round(spawner.transform.position);
        if (activeShape == null)
        {
            activeShape = spawner.SpawnShape();
        }

        dropIntervalMod = dropInterval;
    }
Пример #23
0
    public bool IsValidPosition(Tetrimino tetrimino)
    {
        foreach (Transform child in tetrimino.transform)
        {
            Vector2 position = Vectorf.Round(child.position);
            if (!IsOnBoard((int)position.x, (int)position.y))
            {
                return(false);
            }

            if (IsOccupied((int)position.x, (int)position.y, tetrimino))
            {
                return(false);
            }
        }
        return(true);
    }
Пример #24
0
        /// <summary>
        /// The n-th column of vector.
        /// </summary>
        /// <param name="index">Column index.</param>
        /// <returns>Vector.</returns>
        public Vectorf Column(uint index)
        {
            if (index >= elements.GetLength(1))
            {
                throw new ArgumentException("The dense matrix has only " + elements.GetLength(1)
                                            + " columns.");
            }

            // We construct vector.
            Vectorf vector = new Vectorf((uint)elements.GetLength(0));

            for (int i = 0; i < elements.GetLength(0); i++)
            {
                vector[(uint)i] = elements[i, index];
            }

            return(vector);
        }
Пример #25
0
    /*
     * check if each block inside the layout is inside the width boundary
     */
    public bool isValidPosition(Blocks block)
    {
        //loop to check if block is in boundary and if it overlaps
        foreach (Transform child in block.transform)
        {
            Vector2 position = Vectorf.Round(child.position);

            if (!isInLayout((int)position.x, (int)position.y))
            {
                return(false);
            }

            if (isOverlay((int)position.x, (int)position.y, block))
            {
                return(false);
            }
        }
        return(true);
    }
Пример #26
0
    void Start()
    {
        InitializeObjects();
        InitializeVariables();
        ErrorHandling();

        if (!m_spawner)
        {
            Debug.LogWarning("GAMECONTROLLER START: There is no spawner defined!");
        }
        else
        {
            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
        }
    }
Пример #27
0
    // Use this for initialization
    void Start()
    {
        // Locate the spawner and boards gameobjects
        this.gameBoard    = GameObject.FindWithTag("Board").GetComponent <Board>();
        this.spawner      = GameObject.FindWithTag("Spawner").GetComponent <Spawner>();
        this.soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundManager>();

        this.timeToNextKeyLeftRight = Time.time;
        this.timeToNextKeyRotate    = Time.time;
        this.timeToNextKeyDown      = Time.time;
        this.timeToDrop             = Time.time + this.dropInterval;

        if (!this.gameBoard)
        {
            Debug.LogWarning("WARNING! There is no game board defined!");
        }

        if (!this.soundManager)
        {
            Debug.LogWarning("WARNING! There is no sound manager defined!");
        }

        if (!this.spawner)
        {
            Debug.LogWarning("WARNING! There is no spawner defined!");
        }
        else
        {
            // Spawn a new shape if we currently don't have one
            if (this.activeShape == null)
            {
                this.activeShape = this.spawner.SpawnShape();
            }

            this.spawner.transform.position = Vectorf.Round(this.spawner.transform.position);
        }

        if (this.gameOverPanel)
        {
            this.gameOverPanel.SetActive(false);
        }
    }
Пример #28
0
    // Use this for initialization
    void Start()
    {
        // find spawner and board with generic version of GameObject.FindObjectOfType, slower but less typing
        m_gameBoard    = GameObject.FindObjectOfType <Board>();
        m_spawner      = GameObject.FindObjectOfType <Spawner>();
        m_scoreManager = GameObject.FindObjectOfType <ScoreManager>();

        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_gameBoard)
        {
            Debug.LogWarning("WARNING!  There is no game board defined!");
        }

        if (!m_scoreManager)
        {
            Debug.LogWarning("WARNING!  There is no score manager defined!");
        }

        if (!m_spawner)
        {
            Debug.LogWarning("WARNING!  There is no spawner defined!");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);

            if (!m_activeShape)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        m_dropIntervalModded = Mathf.Clamp(m_dropInterval - ((float)m_scoreManager.m_level * 0.1f), 0.05f, 1f);
    }
Пример #29
0
    // Use this for initialization
    void Start()
    {
        m_gameBoard    = FindObjectOfType <Board>();
        m_spawner      = FindObjectOfType <Spawner>();
        m_scoreManager = FindObjectOfType <ScoreManager>();

        if (!m_gameBoard)
        {
            Debug.Log("There is no game board");
        }

        if (!m_scoreManager)
        {
            Debug.Log("There is no scoreManager");
        }

        if (!m_spawner)
        {
            Debug.Log("There is no spawner");
        }
        else
        {
            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
            }
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }

        m_dropIntervalModded = m_dropInterval;
    }
Пример #30
0
    // method that takes shape as an argument
    // loops through all the shape squares that's within board
    public bool IsValidPosition(Shape shape)
    {
        // for each loop: loop through each individual square of the shape
        foreach (Transform child in shape.transform)
        {
            Vector2 pos = Vectorf.Round(child.position);                                // if any of those squares fails the condition, then the shape is in invalid position
            if (!IsWithinBoard((int)pos.x, (int)pos.y))
            {
                // then return false

                return(false);
            }
            // Each child square will have 2 checks,
            // verify that each square is both on the board.
            // and not on a square that's been taken
            if (IsOccupied((int)pos.x, (int)pos.y, shape))
            {
                return(false);
            }
        }
        return(true);
    }