Ejemplo n.º 1
0
    //检查当前家具移动目标位置是否合法
    public bool CheckTargetOffset(Vector2Int characterCoordinate, Vector2Int paraOffset)
    {
        bool res = true;

        // 1.先移除
        for (int i = 0; i < occupyTiles.GetLength(0); i++)
        {
            MainWorldController.DeregisterFurnitureOnSingleTile(this, occupyTiles[i]);
        }

        // 检查主角是否可以移动
        if (!MainWorldController.CheckTilePassable(characterCoordinate + paraOffset))
        {
            res = false;
        }

        // 2.检查当前家具是否能够移动
        for (int i = 0; i < occupyTiles.GetLength(0); i++)
        {
            if (!MainWorldController.CheckTileDisposable(occupyTiles[i] + paraOffset))
            {
                res = false;
            }
        }

        // 3.恢复初始移除
        for (int i = 0; i < occupyTiles.GetLength(0); i++)
        {
            MainWorldController.RegisterFurnitureOnSingleTile(this, occupyTiles[i]);
        }

        return(res);
    }