コード例 #1
0
    public void DrawGhost(tetris_Shape originalShape, tetris_Board gameBoard)
    {
        if (!m_ghostShape)
        {
            m_ghostShape = Instantiate(originalShape, originalShape.transform.position, originalShape.transform.rotation) as tetris_Shape;
            m_ghostShape.gameObject.name = "GhostShape";

            SpriteRenderer[] allRenders = m_ghostShape.GetComponentsInChildren <SpriteRenderer>();

            foreach (SpriteRenderer r in allRenders)
            {
                r.color = m_color;
            }
        }
        else
        {
            m_ghostShape.transform.position   = originalShape.transform.position;
            m_ghostShape.transform.rotation   = originalShape.transform.rotation;
            m_ghostShape.transform.localScale = Vector3.one;
        }

        m_hitBottom = false;

        while (!m_hitBottom)
        {
            m_ghostShape.MoveDown();
            if (!gameBoard.IsValidPosition(m_ghostShape))
            {
                m_ghostShape.MoveUp();
                m_hitBottom = true;
            }
        }
    }
コード例 #2
0
    private void MoveDown()
    {
        m_timeToDrop        = Time.time + m_dropIntervalModded;
        m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown;

        m_activeShape.MoveDown();
        PlaySound(m_soundManager.m_moveSound, 0.01f);

        if (!m_gameBoard.IsValidPosition(m_activeShape))
        {
            if (m_gameBoard.IsOverLimit(m_activeShape))
            {
                GameOver();
            }
            else
            {
                LandShape();
            }
        }
    }