Ejemplo n.º 1
0
        private void GenerateRandomBlock()
        {
            MapModel   mapModel = MapModel.Inst;
            GComponent mapBlock = mapModel.GetCurrentBlockCom();

            AddChildAt(mapBlock, 1);    //要在TopFrame下面

            //根据数据初始化不同的地图块
            foreach (var child in mapBlock.GetChildren())
            {
                MapNodeCom childNode = child as MapNodeCom;
                if (childNode == null)
                {
                    continue;
                }
                string      strIndex = childNode.name.Replace("node", "");
                MapNodeBase nodeData = mapModel.GetCurrentLayerMapNodeData(strIndex);
                if (nodeData == null)
                {
                    Debug.LogError("no node data:" + strIndex);
                    continue;
                }
                childNode.SetNodeData(nodeData);
                childNode.onClick.Add(OnNodeClick);

                _dicNodeCom.Add(strIndex, childNode);
            }
        }
Ejemplo n.º 2
0
        //更新可进入的节点
        private void UpdateCanEnterNode()
        {
            MapNodeBase lastEnterNode = MapModel.Inst.enterNode;
            List <int>  lstCanEnterIndex;

            if (lastEnterNode == null)   //如果还没有进入过节点
            {
                lstCanEnterIndex = new List <int>()
                {
                    1
                }
            }
            ;
            else
            {
                lstCanEnterIndex = GetNextCanEnterIndexList(lastEnterNode.nodeIndex);
            }

            SetAllNodeNotEnter();
            foreach (int canEnterIndex in lstCanEnterIndex)
            {
                MapNodeCom nodeCom = GetNodeCom(canEnterIndex);
                if (nodeCom == null)
                {
                    Debug.LogError("can't find note:" + canEnterIndex);
                    continue;
                }
                nodeCom.SetCanEnter(true);
            }
        }
Ejemplo n.º 3
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            node1 = (MapNodeCom)this.GetChild("node1");
            node2 = (MapNodeCom)this.GetChild("node2");
            node3 = (MapNodeCom)this.GetChild("node3");
            node4 = (MapNodeCom)this.GetChild("node4");
            node5 = (MapNodeCom)this.GetChild("node5");
            node7 = (MapNodeCom)this.GetChild("node7");
            node8 = (MapNodeCom)this.GetChild("node8");
        }
Ejemplo n.º 4
0
        //设置所有节点为不可进入状态
        private void SetAllNodeNotEnter()
        {
            GComponent mapBlock = MapModel.Inst.GetCurrentBlockCom();

            foreach (var child in mapBlock.GetChildren())
            {
                MapNodeCom childNode = child as MapNodeCom;
                if (childNode != null)
                {
                    childNode.SetCanEnter(false);
                }
            }
        }
Ejemplo n.º 5
0
        private void OnNodeClick(EventContext context)
        {
            MapNodeCom nodeCom = context.sender as MapNodeCom;

            MapModel.Inst.SetEnterNode(nodeCom.nodeData);
            switch (nodeCom.nodeData.nodeType)
            {
            case MapNodeType.NORMAL_ENEMY:
                SceneManager.LoadScene(SceneName.BATTLE);
                break;

            default:
                Debug.LogError("unhandle node type:" + nodeCom.nodeData.nodeType);
                break;
            }
        }