Exemplo n.º 1
0
        public void UpdateGrid(Mino _mino)
        {
            // 一度対象のオブジェクトのgridデータを削除
            for (int y = 0; y < Defines.GridHeightMax; y++)
            {
                for (int x = 0; x < Defines.GridWidthMax; x++)
                {
                    if (grid[y, x] != null)
                    {
                        if (grid[y, x].parent == _mino.movementController.m_tfPivot)
                        {
                            grid[y, x] = null;
                        }
                    }
                }
            }

            // 対象のオブジェクトのグリッドを位置から
            foreach (Transform child in _mino.movementController.m_tfPivot)
            {
                if (child.gameObject.tag.Equals("Block"))
                {
                    Vector2 v = Defines.roundVec2(child.position - m_tfPivot.position);
                    grid[(int)v.y, (int)v.x] = child;
                }
            }
        }
Exemplo n.º 2
0
 public void GhostFix(Mino _mino)
 {
     _mino.movementController.Ghost();
     for (int i = 0; i < Defines.GridHeightMax; i++)
     {
         _mino.movementController.GhostMove(true);
         if (!IsValidGridPosition(_mino, "BlockGhost"))
         {
             _mino.movementController.GhostMove(false);
             break;
         }
     }
 }
Exemplo n.º 3
0
 public void RotateClockWise(bool _bIsCw, Mino _mino)
 {
     _mino.movementController.RotateClockWise(_bIsCw);
     if (IsValidGridPosition(_mino))
     {
         UpdateGrid(_mino);
     }
     else
     {
         _mino.movementController.RotateClockWise(!_bIsCw);
     }
     GhostFix(_mino);
 }
Exemplo n.º 4
0
 public bool IsAlive(Mino _mino)
 {
     foreach (Transform child in _mino.transform.GetComponentsInChildren <Transform>())
     {
         if (child.gameObject.tag.Equals("Block"))
         {
             Vector2 v = Defines.roundVec2(child.position - m_tfPivot.position);
             if (v.y < 20)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        public void Fall()
        {
            if (GridManager.Instance != null && !GridManager.Instance.Fall(currentMino))
            {
                Debug.Log("FallFix");

                if (!GridManager.Instance.IsAlive(currentMino))
                {
                    Debug.LogError("GameOver");
                }

                currentMino.movementController.enabled = false;
                currentMino.enabled = false;
                currentMino         = null;

                GridManager.Instance.PlaceMinos();
            }
        }
Exemplo n.º 6
0
        public void MoveHorizontal(Mino _mino, bool _bIsLeft)
        {
            float deltaMovement = _bIsLeft ? -1.0f : 1.0f;

            // Modify position
            _mino.transform.position += new Vector3(deltaMovement, 0, 0);

            // Check if it's valid
            if (IsValidGridPosition(_mino)) // It's valid. Update grid.
            {
                UpdateGrid(_mino);
            }
            else // It's not valid. revert movement operation.
            {
                _mino.transform.position += new Vector3(-deltaMovement, 0, 0);
            }
            GhostFix(_mino);
        }
Exemplo n.º 7
0
        public void Spawn()
        {
            Debug.Log("Spawn");

            // Spawn Group at current Position
            GameObject temp = m_queStandbyMino.Dequeue();

            if (currentMino != null)
            {
                currentMino.movementController.DeleteGhost();
            }
            currentMino                  = temp.GetComponent <Mino>();
            temp.transform.parent        = m_goBlockHolder.transform;
            temp.transform.localScale    = Vector3.one;
            temp.transform.localPosition = Vector3.zero;


            if (GridManager.Instance != null && !GridManager.Instance.Fall(currentMino, 0))
            {
                // GameOver
                Debug.Log("GameOver");
            }
            else
            {
                Debug.Log("大丈夫だった");
            }

            GridManager.Instance.GhostFix(currentMino);


            int iLoopIndex = 0;

            foreach (GameObject obj in m_queStandbyMino)
            {
                float fPitchSclae = 0.5f;
                obj.transform.localScale    = Vector3.one * fPitchSclae;
                obj.transform.localPosition = new Vector3(
                    0.0f,
                    iLoopIndex * -4.0f * fPitchSclae,
                    0.0f);

                iLoopIndex += 1;
            }
        }
Exemplo n.º 8
0
        public bool IsValidGridPosition(Mino _mino, string _targetTag = "Block")
        {
            foreach (Transform child in _mino.transform.GetComponentsInChildren <Transform>())
            {
                if (child.gameObject.tag.Equals(_targetTag))
                {
                    Vector2 v = Defines.roundVec2(child.position - m_tfPivot.position);
                    v += new Vector2(0.0f, 0.0f);
                    //Debug.Log(v);
                    if (!InsideBorder(v))
                    {
                        return(false);
                    }

                    if (grid[(int)v.y, (int)v.x] != null &&
                        grid[(int)v.y, (int)v.x].GetComponentInParent <Mino>() != _mino)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 9
0
        public bool Fall(Mino _mino, int _iPitch = 1)
        {
            bool bRet = false;

            debug_grid.text  = "●○" + "\n";
            debug_grid.text += "●○";


            _mino.transform.position += (Vector3.down * _iPitch);
            if (IsValidGridPosition(_mino))
            {
                // アップデート
                GhostFix(_mino);
                UpdateGrid(_mino);
                bRet = true;
            }
            else
            {
                Debug.Log("revert");
                _mino.movementController.DeleteGhost();
                _mino.transform.position += (Vector3.up * _iPitch);
            }
            return(bRet);
        }