Ejemplo n.º 1
0
        public void LoadNodesRes(GameObject obj)
        {
            if (resNode != null)
            {
                GameObject.DestroyImmediate(resNode);
                _nodeGameObjects.Clear();
            }

            resNode      = obj;
            resNode.name = "map_node_res";
            resNode.transform.localPosition = new Vector3(0, drawGizmosHeight, 0);
            SceneMoveNodeResAsset comp = resNode.GetComponent <SceneMoveNodeResAsset>();

            _nodeGameObjects = comp.nodeGameObjecs;
        }
Ejemplo n.º 2
0
        public void ShowAllNodes(bool show, bool force = false)
        {
            if (show == showGrids && !force)
            {
                return;
            }
            showGrids = show;
            NGUITools.SetActive(resNode, show, false);
            if (!show)
            {
                return;
            }
            foreach (var item in gridNodeList)
            {
                if (_nodeGameObjects.ContainsKey(item.index))
                {
                    Logger.Error("has key = " + item.index);
                    continue;
                }

                GameObject obj = new GameObject(item.index.ToString());
                Vector2    pos = GetGridCenter(item.index);
                obj.transform.parent        = resNode.transform;
                obj.transform.localPosition = new Vector3(pos.x, 0, pos.y);
                obj.layer = LayerMask.NameToLayer("TileNode");
                BoxCollider box = obj.AddMissingComponent <BoxCollider>();
                box.size = Vector3.one;

                Object temp = GetNodeType(item.nodeType);
                if (temp != null)
                {
                    GameObject child = GameObject.Instantiate(temp, resNode.transform) as GameObject;
                    child.transform.parent        = obj.transform;
                    child.transform.localPosition = Vector3.zero;
                }

                _nodeGameObjects.Add(item.index, obj);
            }

            SceneMoveNodeResAsset comp = resNode.GetComponent <SceneMoveNodeResAsset>();

            comp.nodeGameObjecs = _nodeGameObjects;
        }