public RoadNodeTable(RoadNodeTable copy) { CurrentX = copy.CurrentX; CurrentY = copy.CurrentY; StartX = copy.StartX; RolMaxHeight = copy.RolMaxHeight; Nodes = copy.Nodes.ToList(); NodeDic = new Dictionary <Vector2, RoadNode>(copy.NodeDic); LineCount = copy.LineCount.ToList(); First = copy.First; }
private void GetNext() { Gdata.RecordSpot.Add(1); var road = new RoadNodeTable(ShowData(Gdata.RecordSpot, false), 6); var bigEyeRoad = new RoadNodeTable(road, EnumTrendType.BigEyeRoad, 6); NextBlackBigEye.spriteName = bigEyeRoad.Nodes[bigEyeRoad.Nodes.Count - 1].IsRed ? "smallYQRed" : "smallYQBlack"; NextRedBigEye.spriteName = !bigEyeRoad.Nodes[bigEyeRoad.Nodes.Count - 1].IsRed ? "smallYQRed" : "smallYQBlack"; var smallRoad = new RoadNodeTable(road, EnumTrendType.SmallRoad, 6); NextBlackSmall.spriteName = smallRoad.Nodes[smallRoad.Nodes.Count - 1].IsRed ? "smallYSRed" : "smallYSBlack"; NextRedSmall.spriteName = !smallRoad.Nodes[smallRoad.Nodes.Count - 1].IsRed ? "smallYSRed" : "smallYSBlack"; var roachRoad = new RoadNodeTable(road, EnumTrendType.RoachRoad, 6); NextBlackRoach.spriteName = roachRoad.Nodes[roachRoad.Nodes.Count - 1].IsRed ? "smallSRed" : "smallSBalck"; NextRedRoach.spriteName = !roachRoad.Nodes[roachRoad.Nodes.Count - 1].IsRed ? "smallSRed" : "smallSBalck"; Gdata.RecordSpot.RemoveAt(Gdata.RecordSpot.Count - 1); }
/// <summary> /// 三小路 /// </summary> /// <param name="bigRoad"></param> /// <param name="type"></param> /// <param name="maxHeight"></param> /// <returns></returns> public RoadNodeTable(RoadNodeTable bigRoad, EnumTrendType type, int maxHeight) { CurrentX = 1; CurrentY = 1; StartX = 1; Nodes = new List <RoadNode>(); NodeDic = new Dictionary <Vector2, RoadNode>(); LineCount = new List <int>(); RolMaxHeight = maxHeight; LineCount.Add(0); First = true; Nstep = (int)type + 1; var bigRoadList = bigRoad.Nodes; //遍历大路单 foreach (var it in bigRoadList) { AddSingleItem(it, bigRoad); } }
/// <summary> /// 添加单独数据(三小路) /// </summary> /// <param name="it"></param> /// <param name="bigRoad"></param> /// <returns></returns> public bool AddSingleItem(RoadNode it, RoadNodeTable bigRoad) { bool returnState = false; //满足此两项条件 方可产生节点 if (it.X > Nstep || (it.X == Nstep && it.Y > 1)) { //看整齐 if (it.Y == 1) { returnState = InsertNode(bigRoad.GetRolCount(it.X - 2) == bigRoad.GetRolCount(it.X + 1 - Nstep)); } else { //看有无 int nTempX = it.X + 1 - Nstep; returnState = bigRoad.CheckHasNode(nTempX, it.Y) ? InsertNode(true) : InsertNode(!bigRoad.CheckHasNode(nTempX, it.Y - 1)); } } return(returnState); }
public void GetOtherRoad(int[] data) { var road = new RoadNodeTable(data, 6); while (BigRoadParenTransform.transform.childCount > 0) { DestroyImmediate(BigRoadParenTransform.transform.GetChild(0).gameObject); } while (BigEyeRoadParenTransform.transform.childCount > 0) { DestroyImmediate(BigEyeRoadParenTransform.transform.GetChild(0).gameObject); } while (SmallRoadParenTransform.transform.childCount > 0) { DestroyImmediate(SmallRoadParenTransform.transform.GetChild(0).gameObject); } while (RoachRoadParentTransform.transform.childCount > 0) { DestroyImmediate(RoachRoadParentTransform.transform.GetChild(0).gameObject); } for (int i = 0; i < road.Nodes.Count; i++) { var item = YxWindowUtils.CreateItem(BigRoadSpriteItem, BigRoadParenTransform); item.spriteName = road.Nodes[i].IsRed ? "bigRed" : "bigBlack"; item.transform.localPosition = new Vector3((road.Nodes[i].X - 1) * 18.3f, (road.Nodes[i].Y - 1) * -17.9f, 0); } var bigRoadLine = road.LineCount.Count; // Debug.LogError("-------------------------bigRoadLine count"+ bigRoadLine); while (bigRoadLine > 32) { BigRoadScrollBar.value = 1; BigRoadGrid.transform.GetChild(bigRoadLine).gameObject.SetActive(true); bigRoadLine -= 1; } if (road.LineCount.Count <= 32) { for (int i = 32; i < 42; i++) { if (BigRoadGrid.transform.GetChild(i).gameObject.activeSelf) { BigRoadGrid.transform.GetChild(i).gameObject.SetActive(false); } } } BigRoadGrid.repositionNow = true; if (!_isFirst) { StartCoroutine(FlashSprite(BigRoadParenTransform)); } var bigEyeRoad = new RoadNodeTable(road, EnumTrendType.BigEyeRoad, 6); for (int i = 0; i < bigEyeRoad.Nodes.Count; i++) { var item = YxWindowUtils.CreateItem(BigEyeRoadSpriteItem, BigEyeRoadParenTransform); item.spriteName = bigEyeRoad.Nodes[i].IsRed ? "smallYQRed" : "smallYQBlack"; item.transform.localPosition = new Vector3((bigEyeRoad.Nodes[i].X - 1) * 9.1f, (bigEyeRoad.Nodes[i].Y - 1) * -9.2f, 0); } var bigEyeRoadLine = bigEyeRoad.LineCount.Count; // Debug.LogError("-------------------------bigEyeRoadLine count" + bigEyeRoadLine); while (bigEyeRoadLine > 32) { BigEyeRoadScrollBar.value = 1; var bigEyeLine = (int)Math.Ceiling(bigEyeRoadLine * 1.0f / 2); BigEyeRoadGrid.transform.GetChild(bigEyeLine).gameObject.SetActive(true); bigEyeRoadLine -= 1; } if (bigEyeRoad.LineCount.Count <= 32) { for (int i = 16; i < 26; i++) { if (BigEyeRoadGrid.transform.GetChild(i).gameObject.activeSelf) { BigEyeRoadGrid.transform.GetChild(i).gameObject.SetActive(false); } } } BigEyeRoadGrid.repositionNow = true; if (!_isFirst) { StartCoroutine(FlashSprite(BigEyeRoadParenTransform)); } var smallRoad = new RoadNodeTable(road, EnumTrendType.SmallRoad, 6); for (int i = 0; i < smallRoad.Nodes.Count; i++) { var item = YxWindowUtils.CreateItem(SmallRoadSpriteItem, SmallRoadParenTransform); item.spriteName = smallRoad.Nodes[i].IsRed ? "smallYSRed" : "smallYSBlack"; item.transform.localPosition = new Vector3((smallRoad.Nodes[i].X - 1) * 9.1f, (smallRoad.Nodes[i].Y - 1) * -9.2f, 0); } var smallRoadLine = smallRoad.LineCount.Count; // Debug.LogError("-------------------------smallRoadLine count" + smallRoadLine); while (smallRoadLine > 32) { SmallRoadScrollBar.value = 1; var smallLine = (int)Math.Ceiling(smallRoadLine * 1.0f / 2); SmallRoadGrid.transform.GetChild(smallLine).gameObject.SetActive(true); smallRoadLine -= 1; } if (smallRoad.LineCount.Count <= 32) { for (int i = 16; i < 26; i++) { if (SmallRoadGrid.transform.GetChild(i).gameObject.activeSelf) { SmallRoadGrid.transform.GetChild(i).gameObject.SetActive(false); } } } SmallRoadGrid.repositionNow = true; if (!_isFirst) { StartCoroutine(FlashSprite(SmallRoadParenTransform)); } var roachRoad = new RoadNodeTable(road, EnumTrendType.RoachRoad, 6); for (int i = 0; i < roachRoad.Nodes.Count; i++) { var item = YxWindowUtils.CreateItem(RoachRoadSpriteItem, RoachRoadParentTransform); item.spriteName = roachRoad.Nodes[i].IsRed ? "smallSRed" : "smallSBalck"; item.transform.localPosition = new Vector3((roachRoad.Nodes[i].X - 1) * 9.1f, (roachRoad.Nodes[i].Y - 1) * -9.2f, 0); } var roachRoadLine = roachRoad.LineCount.Count; // Debug.LogError("-------------------------roachRoadLine count" + roachRoadLine); while (roachRoadLine > 32) { RoachRoadScrollBar.value = 1; var roachLine = (int)Math.Ceiling(roachRoadLine * 1.0f / 2); RoachRoadGrid.transform.GetChild(roachLine).gameObject.SetActive(true); roachRoadLine -= 1; } if (roachRoad.LineCount.Count <= 32) { for (int i = 16; i < 26; i++) { if (RoachRoadGrid.transform.GetChild(i).gameObject.activeSelf) { RoachRoadGrid.transform.GetChild(i).gameObject.SetActive(false); } } } RoachRoadGrid.repositionNow = true; if (!_isFirst) { StartCoroutine(FlashSprite(RoachRoadParentTransform)); } }