private void InitMap() { Dictionary <int, LTInstanceNode> dataDic = LTInstanceMapModel.Instance.NodeDataHashDic; if (dataDic == null) { return; } List <LTInstanceNode> dataList = new List <LTInstanceNode>(); int HeightCount = 4; int WidthCount = 5; int yMax = LTInstanceMapModel.Instance.CurNode.y + HeightCount; int xMax = LTInstanceMapModel.Instance.CurNode.x + WidthCount; for (int y = LTInstanceMapModel.Instance.CurNode.y - HeightCount; y <= yMax; y++) { int hash_1 = y * 100; for (int x = LTInstanceMapModel.Instance.CurNode.x - WidthCount; x < xMax; x++) { int hash = hash_1 + x; LTInstanceNode cell; if (dataDic.TryGetValue(hash, out cell)) { if (!cell.CanPass) { continue; } dataList.Add(cell); } } } if (dataList == null || dataList.Count < 0) { return; } for (var i = 0; i < dataList.Count; ++i) { var node = dataList[i]; LTInstanceRowCtrl row = null; if (rowCtrlDic.TryGetValue(node.y, out row)) { LTInstanceNodeTemp cell = null; if (row.itemObjDic.TryGetValue(node.x, out cell)) { cell.UpdateData(node); } else { row.CreateNodeFromCache(node); } } else { CreateRow(node); } } }
private void CreateRow(LTInstanceNode node) { GameObject row = GameObject.Instantiate(RowObj); row.CustomSetActive(true); row.transform.SetParent(RowObjContainer.transform); row.transform.localPosition = new Vector3(node.y * LTInstanceConfig.SMALL_MAP_SCALE_X, -node.y * LTInstanceConfig.SMALL_MAP_SCALE_Y); row.transform.localScale = Vector3.one; row.name = node.y.ToString(); LTInstanceRowCtrl ctrl = row.GetMonoILRComponent <LTInstanceRowCtrl>(); ctrl.CreateNodeFromCache(node); rowCtrlDic.Add(node.y, ctrl); }
private void InitMap() { Dictionary <int, LTInstanceNode> dataDic = LTInstanceMapModel.Instance.NodeDataHashDic; if (dataDic == null) { return; } List <LTInstanceNode> dataList = new List <LTInstanceNode>(); foreach (var it in dataDic) { dataList.Add(it.Value); } if (dataList == null || dataList.Count < 0) { return; } for (var i = 0; i < dataList.Count; ++i) { var node = dataList[i]; if (!node.CanPass) { continue; } LTInstanceRowCtrl row = null; if (rowCtrlDic.TryGetValue(node.y, out row)) { LTInstanceNodeTemp cell = null; if (row.itemObjDic.TryGetValue(node.x, out cell)) { cell.UpdateData(node); } else { row.CreateNodeFromCache(node); } } else { CreateRow(node); } } }
private void CreateRowFromCache(LTInstanceNode node) { GameObject row = null; LTInstanceRowCtrl ctrl = null; row = GameObject.Instantiate(RowObj); ctrl = row.GetMonoILRComponent <LTInstanceRowCtrl>(); row.CustomSetActive(true); row.transform.SetParent(RowObjContainer.transform); row.transform.localPosition = new Vector3(node.y * LTInstanceConfig.MAP_X, -node.y * LTInstanceConfig.MAP_Y, -node.y * LTInstanceConfig.MAP_YZ); row.transform.localScale = Vector3.one; row.name = node.y.ToString(); mRows.Add(row); //------ ctrl.MapCtrl = this; ctrl.Num = node.y; ctrl.CreateNodeFromCache(node); rowCtrlDic.Add(node.y, ctrl); }