Exemplo n.º 1
0
    /// <summary>
    /// 初始化已经存在的建筑位置
    /// </summary>
    public void InitBuildingExist()
    {
        listBuildingExist.Clear();
        GameDataBean      gameData      = GameDataHandler.Instance.manager.GetGameData();
        List <InnResBean> listFurniture = gameData.GetInnBuildData().GetFurnitureList(buildLayer);

        if (listFurniture != null)
        {
            foreach (InnResBean itemBuilding in listFurniture)
            {
                foreach (Vector3Bean itemPosition in itemBuilding.listPosition)
                {
                    listBuildingExist.Add(TypeConversionUtil.Vector3BeanToVector3(itemPosition));
                }
            }
        }
        listBuildingExistForWall.Clear();
        List <InnResBean> listWall = gameData.GetInnBuildData().GetWallList(buildLayer);

        if (listWall != null)
        {
            foreach (InnResBean itemBuilding in listWall)
            {
                //因为保存的tile是从0,0坐标开始的。而实际判断是以1,0开始所以需要+1
                listBuildingExistForWall.Add(itemBuilding.GetStartPosition() + new Vector3(1, 0, 0));
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 找到所有桌子
    /// </summary>
    /// <returns></returns>
    public List <BuildBedCpt> InitBedList(InnBuildBean innBuildData)
    {
        if (bedContainer == null)
        {
            return(listBedCpt);
        }
        BuildBedCpt[] tableArray = bedContainer.GetComponentsInChildren <BuildBedCpt>();
        listBedCpt = TypeConversionUtil.ArrayToList(tableArray);
        //设置每张床的美观值
        try
        {
            List <InnResBean> listFurnitureData = innBuildData.GetFurnitureList(2);
            List <InnResBean> listFloorData     = innBuildData.GetFloorList(2);
            List <InnResBean> listWallData      = innBuildData.GetWallList(2);

            Dictionary <Vector3, InnResBean> mapFurnitureData = new Dictionary <Vector3, InnResBean>();
            Dictionary <Vector3, InnResBean> mapFloorData     = new Dictionary <Vector3, InnResBean>();
            Dictionary <Vector3, InnResBean> mapWallData      = new Dictionary <Vector3, InnResBean>();

            foreach (InnResBean innResData in listFurnitureData)
            {
                mapFurnitureData.Add(TypeConversionUtil.Vector3BeanToVector3(innResData.startPosition), innResData);
            }
            foreach (InnResBean innResData in listFloorData)
            {
                mapFloorData.Add(TypeConversionUtil.Vector3BeanToVector3(innResData.startPosition), innResData);
            }
            foreach (InnResBean innResData in listWallData)
            {
                mapWallData.Add(TypeConversionUtil.Vector3BeanToVector3(innResData.startPosition), innResData);
            }

            if (listBedCpt != null)
            {
                for (int i = 0; i < listBedCpt.Count; i++)
                {
                    BuildBedCpt buildBedCpt        = listBedCpt[i];
                    float       totalAddAesthetics = 0;
                    float       totalSubAesthetics = 0;
                    GetAroundAesthetics(mapFurnitureData, buildBedCpt.transform.position, 3, out float addFurnitureAesthetics, out float subFurnitureAesthetics);
                    totalAddAesthetics += addFurnitureAesthetics;
                    totalSubAesthetics += subFurnitureAesthetics;
                    GetAroundAesthetics(mapFloorData, buildBedCpt.transform.position - new Vector3(0.5f, 0.5f), 3, out float addFloorAesthetics, out float subFloorAesthetics);
                    totalAddAesthetics += addFloorAesthetics;
                    totalSubAesthetics += subFloorAesthetics;
                    GetAroundAesthetics(mapWallData, buildBedCpt.transform.position - new Vector3(0.5f, 0.5f), 3, out float addWallAesthetics, out float subWallAesthetics);
                    totalAddAesthetics += addWallAesthetics;
                    totalSubAesthetics += subWallAesthetics;
                    buildBedCpt.SetAddAesthetics((float)decimal.Round(decimal.Parse(totalAddAesthetics + ""), 1), (float)decimal.Round(decimal.Parse(totalSubAesthetics + ""), 1));
                }
            }
        }
        catch
        {
        }
        return(listBedCpt);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 修建建筑
    /// </summary>
    /// <param name="furnitureData"></param>
    /// <returns></returns>
    public GameObject BuildFurniture(InnResBean furnitureData, BuildBedBean buildBedData)
    {
        if (furnitureData == null)
        {
            return(null);
        }
        GameObject buildItemObj = InnBuildHandler.Instance.manager.GetFurnitureObjById(furnitureData, buildContainer.transform, buildBedData);

        buildItemObj.transform.position = TypeConversionUtil.Vector3BeanToVector3(furnitureData.startPosition);
        BaseBuildItemCpt buildItemCpt = buildItemObj.GetComponent <BaseBuildItemCpt>();

        buildItemCpt.SetDirection(furnitureData.direction);
        return(buildItemObj);
    }
Exemplo n.º 4
0
 public Vector3 GetVector3()
 {
     return(TypeConversionUtil.Vector3BeanToVector3(this));
 }
Exemplo n.º 5
0
 public Vector3 GetStartPosition()
 {
     return(TypeConversionUtil.Vector3BeanToVector3(startPosition));
 }