Ejemplo n.º 1
0
    private bool CheckArroundIs_AlreadyExistUnit(ref SSectorIndex pSectorIndex)
    {
        _setCheckSector.Clear();

        if (eCheckOption == ESectorArroundCheckOption.FourWay)
        {
            for (int i = pSectorIndex.iX - 1; i < 3; i++)
            {
                SSectorIndex sCurrentCheckSector = new SSectorIndex(i, pSectorIndex.iY);
                if (pSectorIndex.CheckIsEqual(ref sCurrentCheckSector) == false &&
                    _mapUseSector.ContainsValue(new SSectorIndex(i, pSectorIndex.iY)))
                {
                    return(false);
                }
            }

            for (int i = pSectorIndex.iY - 1; i < 3; i++)
            {
                SSectorIndex sCurrentCheckSector = new SSectorIndex(pSectorIndex.iX, i);
                if (pSectorIndex.CheckIsEqual(ref sCurrentCheckSector) == false &&
                    _mapUseSector.ContainsValue(new SSectorIndex(pSectorIndex.iX, i)))
                {
                    return(false);
                }
            }
        }
        else if (eCheckOption == ESectorArroundCheckOption.EightWay)
        {
            for (int i = pSectorIndex.iX - 1; i < 3; i++)
            {
                for (int j = pSectorIndex.iY - 1; j < 3; j++)
                {
                    SSectorIndex sCurrentCheckSector = new SSectorIndex(i, j);
                    if (pSectorIndex.CheckIsEqual(ref sCurrentCheckSector) == false &&
                        _mapUseSector.ContainsValue(new SSectorIndex(i, j)))
                    {
                        return(false);
                    }
                }
            }
        }

        return(true);
    }