コード例 #1
0
    // Use this for initialization
    void Start()
    {
        BuildingRect a = new BuildingRect(1, 1, 1, 1);
        BuildingRect b = new BuildingRect(1, 1, 1, 1);

        Debug.Log("a==b:" + a.Equals(b));
    }
コード例 #2
0
ファイル: MapManager.cs プロジェクト: FollowCD/MapGenerator
    int GetShortestDisToActivedAreas(BuildingRect buildingInfo)
    {
        if (buildingInfo == null)
        {
            Debug.LogError("参数错误,建筑信息为空");
            return(0);
        }
        else if (!PosValid(new Vector2Int(buildingInfo.x, buildingInfo.y)))
        {
            Debug.LogError(string.Format("给定建筑坐标已经超出地图范围,建筑位置:({0}{1}),地图大小:{2}x{3}"
                                         , buildingInfo.x, buildingInfo.y, mapConfigData.MapWidth, mapConfigData.MapHeight));
            return(0);
        }
        else
        {
            var coordList = GetBuilingCoords(buildingInfo);

            int minDis = mapConfigData.MapWidth * mapConfigData.MapHeight;
            for (int i = 0; i < coordList.Count; i++)
            {
                var shortestDes = FindShortestPath(coordList[i]);
                var dis         = GetDistance(shortestDes, coordList[i]);

                if (minDis > dis)
                {
                    minDis           = dis;
                    testbuilingCoord = coordList[i];
                    testactiveCoord  = shortestDes;
                }
            }

            return(minDis);
        }
    }
コード例 #3
0
 /// <summary>
 /// 点亮建筑,做管理标记
 /// </summary>
 /// <param name="pos"></param>
 public void LightBuilding(BuildingRect pos)
 {
     if (_BuildingInDark.ContainsKey(pos))
     {
         _UnInvestigatedBuilding.Add(pos, _BuildingInDark[pos]);
         _BuildingInDark.Remove(pos);
     }
 }
コード例 #4
0
 /// <summary>
 /// 建筑收复,做管理标记
 /// </summary>
 /// <param name="pos"></param>
 public void RecoverBuilding(BuildingRect pos)
 {
     if (_DiscoverBuilding.ContainsKey(pos))
     {
         _RecoverBuilding.Add(pos, _DiscoverBuilding[pos]);
     }
     else if (_UnInvestigatedBuilding.ContainsKey(pos))
     {
         _RecoverBuilding.Add(pos, _UnInvestigatedBuilding[pos]);
     }
 }
コード例 #5
0
 public bool IsEquals(BuildingRect temp)
 {
     if (temp == null)
     {
         return(false);
     }
     else
     {
         return(x == temp.x && y == temp.y && h == temp.h && w == temp.w);
     }
 }
コード例 #6
0
ファイル: MapManager.cs プロジェクト: FollowCD/MapGenerator
    List <Vector2Int> GetBuilingCoords(BuildingRect builing)
    {
        var list = new List <Vector2Int>();

        for (int i = 0; i < builing.w; i++)
        {
            for (int j = 0; j < builing.h; j++)
            {
                var item = new Vector2Int(builing.x + i, builing.y + j);
                list.Add(item);
            }
        }

        return(list);
    }
コード例 #7
0
    void OnGenerateClick()
    {
        BuildingRect rect     = new BuildingRect(1, 1);
        BuildingRect rect1    = new BuildingRect(1, 1);
        var          building = GameData.Instance.BuildingMgr.RequestBuilding(BuildingType.kFarmLit, rect);

        GameData.Instance.BuildingMgr.RequestBuilding(BuildingType.kFarmLit, rect1);
        if (building != null)
        {
            var go = Instantiate(BuildingTemplate);
            go.transform.SetParent(BuildingTemplate.transform.parent);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.SetActive(true);
            var b = go.GetComponent <Building>();
            if (b != null)
            {
                b.Data = building;
            }
        }
    }
コード例 #8
0
        public BuildingBasic RequestBuilding(int type, BuildingRect pos)
        {
            if (_UnInvestigatedBuilding.ContainsKey(pos))
            {
                return(_UnInvestigatedBuilding[pos]);
            }
            else if (_DiscoverBuilding.ContainsKey(pos))
            {
                return(_DiscoverBuilding[pos]);
            }
            else if (_RecoverBuilding.ContainsKey(pos))
            {
                return(_RecoverBuilding[pos]);
            }
            else if (_BuildingInDark.ContainsKey(pos))
            {
                return(_BuildingInDark[pos]);
            }
            else
            {
                BuildingBasic building = CreateBuilding(type);
                if (building != null)
                {
                    var temp = ConfigManager.Instance.GetBuildTemplateByType(type);
                    if (temp != null)
                    {
                        building.UpdateFoodNum(Convert.ToInt16(Utils.PickRandom(temp.Foods)));
                        building.UpdateSurvivorsNum(Convert.ToInt16(Utils.PickRandom(temp.Survivor)));
                        building.UpdateEquipNum(Convert.ToInt16(Utils.PickRandom(temp.Equip)));
                        building.PushOptions(temp.Options);
                        building.Name         = temp.Name;
                        building.Investigated = false;
                    }

                    _BuildingInDark.Add(pos, building);
                }
                return(building);
            }
        }
コード例 #9
0
ファイル: MapManager.cs プロジェクト: FollowCD/MapGenerator
 /// <summary>
 /// 获取目标建筑物距离激活区域的最短距离
 /// </summary>
 /// <param name="buildInfo"> 建筑信息 </param>
 /// <returns></returns>
 public int GetDistanceToActivedArea(BuildingRect buildInfo)
 {
     return(GetShortestDisToActivedAreas(buildInfo));
 }
コード例 #10
0
 public bool HasZombies(BuildingRect org)
 {
     return(true);
 }