void CreateLayer(StageLayer stageLayer) { float fullWidth = Screen.width - LayerNameWidth; float nodeFullWidth = fullWidth / stageLayer.Nodes.Count; Vector2 nodeSize = NodeModel.GetComponent <RectTransform>().sizeDelta; float nodeXLeft = LayerNameWidth + (nodeFullWidth - nodeSize.x) / 2; float posY = stageLayer.Layer * _layerHeight + LayerGap; posY += (_layerHeight - nodeSize.y) / 2.0f; foreach (BaseStageNode stageNode in stageLayer.Nodes) { float posX = nodeXLeft + nodeFullWidth * stageNode.Index; CreateNode(stageNode, posX, posY); } GameObject layerNameObj = Instantiate(LayerNameModel); layerNameObj.GetComponent <Text>().text = stageLayer.Name; layerNameObj.transform.SetParent(StageLayerTrans); layerNameObj.transform.localPosition = new Vector3(50, posY, 0); }
void CreateLayer(StageLayer stageLayer) { //CatDebug.LogFunc(GetHashCode().ToString()); float allNodeWidth = _stageScrollContent.GetComponent <RectTransform>().sizeDelta.x - LayerNameWidth; float singleNodeWidth = allNodeWidth / stageLayer.Nodes.Count; Vector2 modelNodeSize = _stageNodeModel.GetComponent <RectTransform>().sizeDelta; float nodeXLeft = LayerNameWidth + (singleNodeWidth - modelNodeSize.x) / 2; float posY = stageLayer.Layer * _layerHeight + BottomGap; posY += (_layerHeight - modelNodeSize.y) / 2.0f; foreach (BaseStageNode stageNode in stageLayer.Nodes) { float posX = nodeXLeft + singleNodeWidth * stageNode.Index; CreateNode(stageNode, posX, posY); } GameObject layerNameObj = Instantiate(_layerNameModel); layerNameObj.GetComponent <Text>().text = stageLayer.Name; layerNameObj.transform.SetParent(_stageLayerRootTrans); layerNameObj.transform.localPosition = new Vector3(50, posY, 0); }
void CreateStageConfig() { StageNodeStart nodeStart1 = new StageNodeStart(1, 0, "P1", "", "Assets/Res/Icon/cards/ico_head_aoyou"); nodeStart1.NextNodes.Add(10); nodeStart1.NextNodes.Add(11); StageNodeStart nodeStart2 = new StageNodeStart(2, 1, "P2", "", "Assets/Res/Icon/cards/ico_head_aoyou"); nodeStart2.NextNodes.Add(10); nodeStart2.NextNodes.Add(11); StageNodeFight nodeFight1 = new StageNodeFight(10, 0, "Fight", "", "Assets/Res/Icon/cards/ico_head_anduxie"); nodeFight1.SetData(100, 1, 1); nodeFight1.NextNodes.Add(20); nodeFight1.NextNodes.Add(21); StageNodeFight nodeFight2 = new StageNodeFight(20, 1, "Fight", "", "Assets/Res/Icon/cards/ico_head_anduxie"); nodeFight2.SetData(100, 1, 1); nodeFight2.NextNodes.Add(40); StageNodeSafe nodeSafe = new StageNodeSafe(40, 0, "House", "", "Assets/Res/Icon/Item/ico_common_mianzhan"); nodeSafe.NextNodes.Add(30); StageNodeFight nodeFightBoss = new StageNodeFight(30, 0, "FighBoss", "", "Assets/Res/Icon/cards/ico_head_baoshi"); nodeFightBoss.SetData(200, 1, 1); StageNodeReward nodeReward1 = new StageNodeReward(11, 1, "Reward", "", "Assets/Res/Icon/cards/ico_head_guidiao"); Dictionary <int, int> cRewards = new Dictionary <int, int>(); cRewards.Add(10000, 10); cRewards.Add(10001, 20); nodeReward1.AddData("Job", "2", cRewards); nodeReward1.AddData(string.Empty, "", cRewards); nodeReward1.NextNodes.Add(20); nodeReward1.NextNodes.Add(21); StageNodeReward nodeReward2 = new StageNodeReward(21, 0, "Reward", "", "Assets/Res/Icon/cards/ico_head_guidiao"); Dictionary <int, int> cRewards2 = new Dictionary <int, int>(); cRewards2.Add(10000, 11); cRewards2.Add(10001, 21); nodeReward2.AddData("Job", "2", cRewards2); nodeReward2.AddData(string.Empty, "", cRewards2); nodeReward2.NextNodes.Add(40); StageLayer layer0 = new StageLayer(0, "Start", ""); layer0.Nodes.Add(nodeStart1); layer0.Nodes.Add(nodeStart2); StageLayer layer1 = new StageLayer(1, "L1", ""); layer1.Nodes.Add(nodeFight1); layer1.Nodes.Add(nodeReward1); StageLayer layer2 = new StageLayer(2, "L2", ""); layer2.Nodes.Add(nodeFight2); layer2.Nodes.Add(nodeReward2); StageLayer layer3 = new StageLayer(3, "L3", ""); layer3.Nodes.Add(nodeSafe); StageLayer layer4 = new StageLayer(4, "Boss", ""); layer4.Nodes.Add(nodeFightBoss); stageConfig = new StageConfig(0, "Stage First", ""); stageConfig.Layers.Add(layer0); stageConfig.Layers.Add(layer1); stageConfig.Layers.Add(layer2); stageConfig.Layers.Add(layer3); stageConfig.Layers.Add(layer4); stageConfig.ItemIds.Add(20000); stageConfig.Sort(); }