예제 #1
0
        private bool CheckCanMove(int targetRow, int targetCol, MapDataType targetData)
        {
            SceneModule _sceneModule = (SceneModule)GameManager.GameManagerObj.GetComponent <GameManager>().GetModuleByName("SceneModule");
            int         _dataRow     = _sceneModule.getMapDataRow();
            int         _dataCol     = _sceneModule.getMapDataCol();
            bool        _ret         = false;

            if (m_skillId == SkillId.NONE)
            {
                return(_ret);
            }
            if (targetData == MapDataType.NONE || targetData == MapDataType.JUMATUI)
            {
                return(_ret);
            }
            if (targetRow < 0 || targetRow >= _dataRow || targetCol < 0 || targetCol >= _dataCol)
            {
                return(_ret);
            }
            switch (m_skillId)
            {
            case SkillId.JU:
                if (targetRow == m_playerPos.m_row)
                {
                    if (_sceneModule.Data[targetRow][targetCol] == MapDataType.NEWMODE)
                    {
                        return(_ret);
                    }
                    if (targetCol > m_playerPos.m_col)
                    {
                        for (int _i = m_playerPos.m_col + 1; _i <= targetCol; _i++)
                        {
                            if (_sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.GAOTAI ||
                                _sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.NONE ||
                                _sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.JUMATUI ||
                                _sceneModule.m_npcList[m_playerPos.m_row][_i] != null)
                            {
                                return(_ret);
                            }
                            else
                            {
                                if (_sceneModule.m_enemyList[m_playerPos.m_row][_i] != null && _i != targetCol)
                                {
                                    return(_ret);
                                }
                            }
                        }
                        _ret = true;
                        return(_ret);
                    }
                    else if (targetCol < m_playerPos.m_col)
                    {
                        for (int _i = m_playerPos.m_col - 1; _i >= targetCol; _i--)
                        {
                            if (_sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.GAOTAI ||
                                _sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.NONE ||
                                _sceneModule.Data[m_playerPos.m_row][_i] == MapDataType.JUMATUI ||
                                _sceneModule.m_npcList[m_playerPos.m_row][_i] != null)
                            {
                                return(_ret);;
                            }
                            else
                            {
                                if (_sceneModule.m_npcList[m_playerPos.m_row][_i] != null && _i != targetCol)
                                {
                                    return(_ret);
                                }
                            }
                        }
                        _ret = true;
                        return(_ret);
                    }
                }
                else if (targetCol == m_playerPos.m_col)
                {
                    if (_sceneModule.Data[targetRow][targetCol] == MapDataType.NEWMODE)
                    {
                        return(_ret);
                    }
                    if (targetRow > m_playerPos.m_row)
                    {
                        for (int _i = m_playerPos.m_row + 1; _i <= targetRow; _i++)
                        {
                            if (_sceneModule.Data[_i][targetCol] == MapDataType.GAOTAI ||
                                _sceneModule.Data[_i][targetCol] == MapDataType.NONE ||
                                _sceneModule.Data[_i][targetCol] == MapDataType.JUMATUI ||
                                _sceneModule.m_npcList[_i][targetCol] != null)
                            {
                                return(_ret);
                            }
                            else
                            {
                                if (_sceneModule.m_enemyList[_i][targetCol] != null && _i != targetRow)
                                {
                                    return(_ret);
                                }
                            }
                        }
                        _ret = true;
                        return(_ret);
                    }
                    else if (targetRow < m_playerPos.m_row)
                    {
                        for (int _i = m_playerPos.m_row - 1; _i >= targetRow; _i--)
                        {
                            if (_sceneModule.Data[_i][targetCol] == MapDataType.GAOTAI ||
                                _sceneModule.Data[_i][targetCol] == MapDataType.NONE ||
                                _sceneModule.Data[_i][targetCol] == MapDataType.JUMATUI ||
                                _sceneModule.m_npcList[_i][targetCol] != null)
                            {
                                return(_ret);;
                            }
                            else
                            {
                                if (_sceneModule.m_enemyList[_i][targetCol] != null && _i != targetRow)
                                {
                                    return(_ret);
                                }
                            }
                        }
                        _ret = true;
                        return(_ret);
                    }
                }
                break;

            case SkillId.MA:
                if (targetRow == m_playerPos.m_row + 2)
                {
                    if (targetCol == m_playerPos.m_col + 1 || targetCol == m_playerPos.m_col - 1)
                    {
                        if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                            (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                             (_sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col] != MapDataType.GAOTAI &&
                              _sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col] != MapDataType.JUMATUI)))
                        {
                            if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row + 1, m_playerPos.m_col))
                            {
                                _ret = true;
                            }
                        }
                    }
                }
                else if (targetRow == m_playerPos.m_row - 2)
                {
                    if (targetCol == m_playerPos.m_col + 1 || targetCol == m_playerPos.m_col - 1)
                    {
                        if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                            (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                             (_sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col] != MapDataType.GAOTAI &&
                              _sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col] != MapDataType.JUMATUI)))
                        {
                            if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row - 1, m_playerPos.m_col))
                            {
                                _ret = true;
                            }
                        }
                    }
                }

                else if (targetCol == m_playerPos.m_col + 2)
                {
                    if (targetRow == m_playerPos.m_row + 1 || targetRow == m_playerPos.m_row - 1)
                    {
                        if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                            (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                             (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col + 1] != MapDataType.GAOTAI &&
                              _sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col + 1] != MapDataType.JUMATUI)))
                        {
                            if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row, m_playerPos.m_col + 1))
                            {
                                _ret = true;
                            }
                        }
                    }
                }
                else if (targetCol == m_playerPos.m_col - 2)
                {
                    if (targetRow == m_playerPos.m_row + 1 || targetRow == m_playerPos.m_row - 1)
                    {
                        if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                            (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                             (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col - 1] != MapDataType.GAOTAI &&
                              _sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col - 1] != MapDataType.JUMATUI)))
                        {
                            if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row, m_playerPos.m_col - 1))
                            {
                                _ret = true;
                            }
                        }
                    }
                }
                break;

            case SkillId.PAO:
                break;

            case SkillId.XIANG:
                if (targetRow == m_playerPos.m_row + 2 && targetCol == m_playerPos.m_col + 2)
                {
                    if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                        (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                         (_sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col + 1] != MapDataType.GAOTAI &&
                          _sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col + 1] != MapDataType.JUMATUI)))
                    {
                        if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row + 1, m_playerPos.m_col + 1))
                        {
                            _ret = true;
                        }
                    }
                }
                else if (targetRow == m_playerPos.m_row + 2 && targetCol == m_playerPos.m_col - 2)
                {
                    if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                        (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                         (_sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col - 1] != MapDataType.GAOTAI &&
                          _sceneModule.Data[m_playerPos.m_row + 1][m_playerPos.m_col - 1] != MapDataType.JUMATUI)))
                    {
                        if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row + 1, m_playerPos.m_col - 1))
                        {
                            _ret = true;
                        }
                    }
                }
                else if (targetRow == m_playerPos.m_row - 2 && targetCol == m_playerPos.m_col + 2)
                {
                    if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                        (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                         (_sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col + 1] != MapDataType.GAOTAI &&
                          _sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col + 1] != MapDataType.JUMATUI)))
                    {
                        if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row - 1, m_playerPos.m_col + 1))
                        {
                            _ret = true;
                        }
                    }
                }
                else if (targetRow == m_playerPos.m_row - 2 && targetCol == m_playerPos.m_col - 2)
                {
                    if (_sceneModule.Data[targetRow][targetCol] != MapDataType.NEWMODE &&
                        (_sceneModule.Data[m_playerPos.m_row][m_playerPos.m_col] == MapDataType.GAOTAI ||
                         (_sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col - 1] != MapDataType.GAOTAI &&
                          _sceneModule.Data[m_playerPos.m_row - 1][m_playerPos.m_col - 1] != MapDataType.JUMATUI)))
                    {
                        if (_sceneModule.m_npcList[targetRow][targetCol] == null && !PosExitChess(m_playerPos.m_row - 1, m_playerPos.m_col - 1))
                        {
                            _ret = true;
                        }
                    }
                }
                break;

            case SkillId.SHI:
                break;

            case SkillId.BING:
                break;
            }
            return(_ret);
        }