Пример #1
0
 public void InitFloor()
 {
     if (Node == null)
     {
         Debug.LogError("MapBuilding.InitFloor Node == null");
         return;
     }
     if (Node.ChildNodes == null)
     {
         Node.RefreshChildrenNodes();
     }
     if (Node.ChildNodes != null)
     {
         foreach (var item in Node.ChildNodes)
         {
             if (item == null)
             {
                 continue;
             }
             //Topologies.Find(Topo => Topo.Name == item.NodeName);
             MapFloor floor = FloorList.Find(Floor => Floor.FloorName == item.NodeName);
             if (floor != null)
             {
                 floor.FloorNode = item;
                 floor.InitRoom();
             }
             else
             {
                 Debug.LogError("InitFloor floor == null : " + item.NodeName);
             }
         }
     }
 }
Пример #2
0
    private void DeserializeFloors(object rawData)
    {
        var data = (JArray)rawData;

        floors.Clear();
        int floorNumber = 0;

        foreach (var floor in data)
        {
            var floorOutput = new MapFloor(floorNumber);
            int cursor      = 0;
            for (int x = 0; x < (int)(long)floor["width"]; x++)
            {
                for (int y = 0; y < (int)(long)floor["height"]; y++)
                {
                    floorOutput.layout[x, y].character = ((string)floor["layout"])[cursor].ToString();
                    floorOutput.seen[x, y]             = ((string)floor["layout"])[cursor].ToString() == "1";
                    cursor++;
                }
            }
            floorNumber++;
            floorOutput.startingX = (int)(long)floor["startingX"];
            floorOutput.startingY = (int)(long)floor["startingY"];
            floorOutput.endingX   = (int)(long)floor["endingX"];
            floorOutput.endingY   = (int)(long)floor["endingY"];
            floors.Add(floorOutput);
        }
    }
Пример #3
0
    /// <summary>
    /// 添加按钮信息
    /// </summary>
    /// <param name="switchButton"></param>
    /// <param name="floorInfo"></param>
    private void AddSwitchInfo(Transform switchButton, MapFloor floorInfo)
    {
        switchButton.gameObject.SetActive(true);
        MapSwitchItem item = switchButton.GetComponent <MapSwitchItem>();

        ItemList.Add(item);
        item.SetItem(floorInfo, this);
    }
Пример #4
0
 private void BuildFloors()
 {
     for (int i = 0; i < 5; i++)
     {
         floors.Add(new MapFloor(i));
     }
     currentFloor = floors[0];
 }
Пример #5
0
    //Create passage between the current cell and the neighbor
    public void CreatePassage(Cell cell, Cell otherCell, MapDirection dir)
    {
        //Instantiate the passage in the cell's position, facing the other cell
        MapFloor passage = Instantiate(passagePrefab) as MapFloor;

        passage.Initialise(cell, otherCell, dir);
        //Instantiate another passage in the other cell's position, facing the current cell
        passage = Instantiate(passagePrefab) as MapFloor;
        passage.Initialise(otherCell, cell, dir.GetOpposite());
    }
Пример #6
0
 /// <summary>
 /// 选中当前楼层
 /// </summary>
 /// <param name="currentFloor"></param>
 private void SelectCurrentFloor(MapFloor currentFloor)
 {
     foreach (var item in ItemList)
     {
         if (item.CurrentFloor == currentFloor)
         {
             item.Selcet();
         }
     }
 }
Пример #7
0
 /// <summary>
 /// 选中楼层
 /// </summary>
 /// <param name="Floor"></param>
 public void SelectFloor(DepNode Floor)
 {
     gameObject.SetActive(true);
     foreach (var item in FloorList)
     {
         if (item.FloorNode == null)
         {
             continue;
         }
         if (item.FloorNode.NodeID == Floor.NodeID)
         {
             CurrentFloor = item;
             item.ShowFloor();
             if (MapLoadManage.Instance)
             {
                 MapLoadManage.Instance.ShowMapPageSwitch(item, FloorList);
             }
         }
     }
 }
Пример #8
0
 public void ShowMapSwitch(MapFloor currentFloor, List <MapFloor> FloorList)
 {
     if (ItemSelectNode == currentFloor.FloorNode)
     {
         return;
     }
     CurrentLayoutHeight = LayoutGroup.preferredHeight;
     Debug.Log("LayoutHeight:" + CurrentLayoutHeight);
     if (FloorList == null || FloorList.Count == 1)
     {
         Hide();
         return;
     }
     else
     {
         Window.SetActive(true);
         ItemList.Clear();
         InitItem(FloorList);
         SelectCurrentFloor(currentFloor);
     }
 }
Пример #9
0
    public void Load(string filename)
    {
        //todo: load
        var data = File.ReadAllText(filename);
        var json = JsonConvert.DeserializeObject <Dictionary <string, object> >(data);

        posX = (int)(long)json["posX"];
        posY = (int)(long)json["posY"];
        currentFloorNumber = (int)(long)json["currentFloorNumber"];
        numFloors          = (int)(long)json["numFloors"];
        DeserializeFloors(json["floors"]);
        currentFloor = floors[currentFloorNumber];
        DeserializeMonsters(json["monsters"]);
        DeserializePlayer(json["player"]);
        loaded = true;
        UserInterface.instance.SetUpCardPositions();
        //tint each map floor
        foreach (var floor in floors)
        {
            floor.TintMap();
        }
    }
Пример #10
0
 /// <summary>
 /// 设置父物体信息
 /// </summary>
 /// <param name="mapFloor"></param>
 public void SetParentInfo(MapFloor mapFloor)
 {
     Floor = mapFloor;
 }
Пример #11
0
 /// <summary>
 /// 设置项目
 /// </summary>
 /// <param name="floor"></param>
 /// <param name="manager"></param>
 public void SetItem(MapFloor floor, MapSwitch manager)
 {
     CurrentFloor        = floor;
     SwitchManager       = manager;
     FloorIndexText.text = floor.FloorNum.ToString();
 }
Пример #12
0
 /// <summary>
 /// 取消选中
 /// </summary>
 public void DisSelect()
 {
     gameObject.SetActive(false);
     CurrentFloor.HideFloor();
     CurrentFloor = null;
 }
Пример #13
0
 public void SetFloor(MapFloor floor, int x, int y)
 {
     floorLevel[x, y] = floor;
 }
Пример #14
0
 public void FillFloor(MapFloor floor)
 {
     for (int x = 0; x < w; x++)
     {
         for (int y = 0; y < h; y++)
         {
             SetFloor(floor, x, y);
         }
     }
 }
Пример #15
0
 /// <summary>
 /// 显示楼层切页
 /// </summary>
 public void ShowMapPageSwitch(MapFloor currentFloor, List <MapFloor> FloorList)
 {
     SwitchManager.ShowMapSwitch(currentFloor, FloorList);
 }