Example #1
0
	public static bool IsBuildingHover(this IObstacleInfo buildingInfo, IMapData mapData)
	{
		if(Application.loadedLevelName != ClientStringConstants.BUILDING_SCENE_LEVEL_NAME)
		{
			return false;
		}
		else
		{
			TilePosition buildingPosition = buildingInfo.GetBuildingFirstBuildingPosition();
			return mapData.GetBuildingObjectFromBuildingObstacleMap(buildingPosition.Row, buildingPosition.Column) == null;
		}
	}
    public bool GeneratePosition(int removableObjectNo, IMapData mapData)
    {
        RemovableObjectLogicObject logicObject = this.GetRemovableObject(removableObjectNo);

        List <TilePosition> validPosition = new List <TilePosition>();

        for (int r = 0; r < ClientSystemConstants.BUILDING_TILE_MAP_SIZE.height; r++)
        {
            for (int c = 0; c < ClientSystemConstants.BUILDING_TILE_MAP_SIZE.width; c++)
            {
                bool         isValid  = true;
                TilePosition position = new TilePosition(c, r);
                foreach (TilePosition offset in logicObject.LogicData.BuildingObstacleList)
                {
                    TilePosition p = position + offset;
                    if (!p.IsValidBuildingTilePosition() || mapData.GetBuildingObjectFromBuildingObstacleMap(p.Row, p.Column) != null)
                    {
                        isValid = false;
                        break;
                    }
                    if (LogicController.Instance.IsNewPlayer &&
                        ClientSystemConstants.INITIAL_REMOVABLE_OBJECT_INVALID_RECT.Contains(
                            new Vector2(position.Column, position.Row)))
                    {
                        isValid = false;
                        break;
                    }
                }
                if (isValid)
                {
                    validPosition.Add(position);
                }
            }
        }

        if (validPosition.Count == 0)
        {
            this.m_ObjectDict.Remove(removableObjectNo);
            return(false);
        }
        else
        {
            TilePosition position = validPosition[CommonHelper.GetRandomNumber(0, validPosition.Count)];
            logicObject.GeneratePosition(position);
            return(true);
        }
    }