Ejemplo n.º 1
0
        private async void Tree_Selected(object sender, RoutedEventArgs e)
        {
            var treeview = sender as TreeView;
            selectedNodeItem = treeview.SelectedItem as NodeItem;
            var node = treeview.SelectedItem as NodeItem;
            if (node == null)
            {
                return;
            }
            if (node.IsDir)
            {
                //    if (node.Name == @"/")
                //    {
                //     await   AddTreeChildren(node, true);
                //    }
                //    else
                //    {
                 FillChildren(node);
                
            }
            flag = true;

            tb_currentPath.Text = (node.ParentPath + "/" + node.Name).Replace("//", "/");
            
        }
Ejemplo n.º 2
0
    public void UpdateUI()
    {
        int offsetX = facingRight ? 1 : -1;

        if (nodeItem == null)
        {
            SetUIPos(new Vector2(UIOffset.x * offsetX, UIOffset.y));
        }
        else
        {
            //如果单位面前的节点有单位,UI移动到源点
            if (!BattleManager.instance.map.isNodeAvailable((nodeItem.pos + new Vector2Int(offsetX, 0))))
            {
                return;
            }
            NodeItem item = BattleManager.instance.map.GetNodeItem(nodeItem.pos + new Vector2Int(offsetX, 0));
            if (item.nodeObject != null && item.nodeObject.nodeObjectType == NodeObjectType.unit)
            {
                SetUIPos(new Vector2(0, 0));
            }
            else
            {
                SetUIPos(new Vector2(UIOffset.x * offsetX, UIOffset.y));
            }
        }
    }
Ejemplo n.º 3
0
        private int Bubble(int idx)
        {
            // Bubble the new root through the heap
            int currentIdx = idx;
            int leftIdx    = currentIdx * 2;
            int rightIdx   = leftIdx + 1;
            NodeItem <TKey, TValue> act   = m_heap[currentIdx];
            NodeItem <TKey, TValue> left  = m_heap[leftIdx];
            NodeItem <TKey, TValue> right = m_heap[rightIdx];

            int swapIdx = currentIdx;

            if (leftIdx <= MaxIndex && Comparer.Compare(act.Key, left.Key) <= 0)
            {
                swapIdx = leftIdx;
            }
            if (rightIdx <= MaxIndex && Comparer.Compare(act.Key, right.Key) <= 0)
            {
                swapIdx = rightIdx;
            }

            if (currentIdx == swapIdx)
            {
                return(currentIdx);
            }

            Swap(ref m_heap[currentIdx], ref m_heap[swapIdx]);
            return(swapIdx);
        }
Ejemplo n.º 4
0
    // 取得周围的节点
    public List <NodeItem> getNeibourhood(NodeItem node)
    {
        List <NodeItem> list = new List <NodeItem> ();

        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                // 如果是自己,则跳过
                if (i == 0 && j == 0)
                {
                    continue;
                }

                //只检测上下左右
                if (Mathf.Abs(i) == Mathf.Abs(j))
                {
                    continue;
                }
                int x = node.x + i;
                int y = node.y + j;
                // 判断是否越界,如果没有,加到列表中
                if (x < w && x >= 0 && y < h && y >= 0)
                {
                    list.Add(grid [x, y]);
                }
            }
        }
        return(list);
    }
Ejemplo n.º 5
0
        private static void FillTables(NodeItem treeRoot, DatabaseSchema schema)
        {
            var tableRoot = new NodeItem(NodeType.Tables)
            {
                Schema = treeRoot.Name, Name = "Tables"
            };

            //tableRoot.Tag = schema;
            //tableRoot.ToolTipText = RightClickToScript;
            treeRoot.Items.Add(tableRoot);

            foreach (var table in schema.Tables.OrderBy(x => x.SchemaOwner).ThenBy(x => x.Name))
            {
                var name = table.Name;
                if (!string.IsNullOrEmpty(table.SchemaOwner))
                {
                    name = table.SchemaOwner + "." + name;
                }
                var tableNode = new NodeItem(NodeType.Table)
                {
                    Name = name, Schema = treeRoot.Name
                };
                //tableNode.Tag = table;
                //tableNode.ToolTipText = RightClickToScript;
                tableRoot.Items.Add(tableNode);
                foreach (var column in table.Columns)
                {
                    FillColumn(tableNode, column);
                }
                //FillConstraints(table, tableNode);
                //FillTriggers(table, tableNode);
                //FillIndexes(table, tableNode);
            }
        }
Ejemplo n.º 6
0
        private async Task AddTreeChildren(NodeItem node,bool isRoot)
        {
           
            
            if (!node.IsDir) { return; }
            if (isRoot)
            {
                var rootnode=  itemlist.FirstOrDefault(x=>x.Name=="/");
                if (rootnode != null)
                {
                    rootnode.Children.Clear();
                }
                var rootresult = await getFile(rootnode.Name);
                foreach (var file in rootresult.Files)
                {
                    var newnode = new NodeItem { Name = file.Name, ParentPath = rootnode.Name, IsDir = file.Dir ,ImagePath=file.Icon };
                    rootnode.Children.Add(newnode);
                }
            }
            else
            {
                node.Children.Clear();
                var result = await getFile(node.ParentPath +"/"+ node.Name);
                if (result == null)
                {
                    return;
                }
                foreach (var file in result.Files)
                {
                    node.Children.Add(new NodeItem {Parent=node, Name = file.Name, ParentPath = (node.ParentPath+"/" + node.Name).Replace("//","/") , IsDir = file.Dir , ImagePath =file.Icon});
                }
            }

            
        }
Ejemplo n.º 7
0
    void MoveToNode(NodeItem _node)
    {
        //改变单位朝向
        BattleManager.currentActionUnit.FaceTarget(_node.transform.position);

        BattleManager.instance.map.LinkNodeWithUnit(BattleManager.currentActionUnit, _node);
    }
Ejemplo n.º 8
0
        private Expression BuildExpressionInternal(IList <NodeItem> nodeItems)
        {
            var min = nodeItems.Max(n => n.Kind);

            NodeItem lowest = nodeItems.FirstOrDefault(n => n.Kind == min);

            if (lowest.Kind == NodeKind.SubExpression)
            {
                nodeItems = lowest.NodeItems;
                min       = nodeItems.Max(n => n.Kind);
                lowest    = nodeItems.SingleOrDefault(n => n.Kind == min);
            }

            var index            = nodeItems.IndexOf(lowest);
            var previousSiblings = nodeItems.Take(index).ToList();
            var nextSiblings     = nodeItems.Skip(index + 1).ToList();

            var result = BuildExpressionFrom(lowest, previousSiblings, nextSiblings);

            if (_forcedOutputType != null && _forcedOutputType != result.Type)
            {
                result = Expression.Convert(result, _forcedOutputType);
            }

            return(result);
        }
Ejemplo n.º 9
0
    //释放魔法
    public void CastMagic(NodeItem _nodeitem = null)
    {
        int magicLevel = currentMagic.GetMagicLevel(BattleManager.currentHero);
        int mana       = currentMagic.GetManaCost(BattleManager.currentHero);

        //扣除魔法值
        BattleManager.currentHero.mana -= mana;

        //界面暂停

        int effect = Mathf.Min(currentMagic.effects.Length - 1, magicLevel);

        currentMagic.effects[effect].originPlayer = BattleManager.currentSide;
        //释放魔法
        if (_nodeitem == null)
        {
            //无目标直接释放
            currentMagic.effects[effect].Invoke();
        }
        else
        {
            if (currentMagic.targetType[Mathf.Min(currentMagic.targetType.Length - 1, magicLevel)] == MagicTargetType.Node)
            {
                currentMagic.effects[effect].targetNode = _nodeitem;
            }
            else
            {
                currentMagic.effects[effect].targetUnit = _nodeitem.nodeObject.GetComponent <Unit>();
            }
            currentMagic.effects[effect].Invoke();
        }

        StartCoroutine(CastingMagic());
    }
Ejemplo n.º 10
0
    //得到周边节点
    public List <NodeItem> GetNearNode(NodeItem node)
    {
        List <NodeItem> NearList = new List <NodeItem>();

        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                if (i == 0 && j == 0)                 //跳过自身
                {
                    continue;
                }
                else
                {
                    int x = node.x + i;
                    int y = node.y + j;
                    if (x > centerX - width && x < centerX + width && y > centerY - height && y < centerY + height) //不超过边界则放到集合中
                    {
                        NearList.Add(Grid[Mathf.Abs(x) - Width * m - 2, Mathf.Abs(y) - Height * n - 1]);
                    }
                }
            }
        }
        return(NearList);
    }
Ejemplo n.º 11
0
    //得到周边节点
    public List <NodeItem> GetNearNode(NodeItem node)
    {
        List <NodeItem> NearList = new List <NodeItem>();

        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                if (i == 0 && j == 0)                 //跳过自身
                {
                    continue;
                }
                else
                {
                    int x = node.x + i;
                    int y = node.y + j;
                    if (x > 1 && x < w && y > 1 && y < h) //不超过边界则放到集合中
                    {
                        NearList.Add(Grid[x, y]);
                    }
                }
            }
        }
        return(NearList);
    }
Ejemplo n.º 12
0
    void Awake()
    {
        w    = Mathf.RoundToInt(transform.localScale.x * 28);
        h    = Mathf.RoundToInt(transform.localScale.y * 31);
        Grid = new NodeItem[w, h];                           //创建对应的节点二维数组


        Path = new GameObject("PathRange");

        for (int x = 2; x < w; x++)
        {
            for (int y = 2; y < h; y++)
            {
                Vector3    pos      = new Vector3(x, y, 0);
                bool       isWall   = false;
                Collider2D collider = Physics2D.OverlapCircle(pos, NodeRadius, WallLayer);
                if (collider != null)
                {
                    isWall = true;
                }

                Grid[x, y] = new NodeItem(isWall, x, y, pos);      //构建节点
            }
        }
    }
Ejemplo n.º 13
0
        private static void CountExistInPset(IfcProduct ifcProduct, NodeItem classNode)
        {
            var ifcPropertySets = ifcProduct.IsDefinedBy
                                  .Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
                                  .Select(r => ((IIfcPropertySet)r.RelatingPropertyDefinition));

            foreach (var ifcPropertySet in ifcPropertySets)
            {
                if (classNode.Children.Any(ps => ps.Name == ifcPropertySet.Name))
                {
                    NodeItem            propSetNode   = classNode.Children.Where(ps => ps.Name == ifcPropertySet.Name).FirstOrDefault();
                    List <IIfcProperty> ifcProperties = new List <IIfcProperty>();
                    // Remove duplication
                    foreach (var ifcProperty in ifcPropertySet.HasProperties)
                    {
                        if (!ifcProperties.Any(p => p.Name == ifcProperty.Name))
                        {
                            ifcProperties.Add(ifcProperty);
                        }
                    }
                    foreach (var ifcProperty in ifcProperties)
                    {
                        if (propSetNode.Children.Any(p => p.Name == ifcProperty.Name))
                        {
                            NodeItem propNode = propSetNode.Children.Where(p => p.Name == ifcProperty.Name).FirstOrDefault();
                            propNode.ExistCount++;
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
 //初始化地图
 //1. random all with wall or floor
 private void initMap()
 {
     gridNodes = new NodeItem[w, h];
     for (int i = 0; i < w; i++)
     {
         for (int j = 0; j < h; j++)
         {
             if (i == 0 || j == 0 || i == w - 1 || j == h - 1)
             {
                 gridNodes[i, j] = new NodeItem(true
                                                , new Vector3(i * 0.5f, j * 0.5f, -0.25f), i, j);
             }
             else
             {
                 gridNodes[i, j] = new NodeItem(Random.Range(0.0f, 1.0f) < 0.3f ? true : false
                                                , new Vector3(i * 0.5f, j * 0.5f, -0.25f), i, j);
             }
             NodeItem item = gridNodes [i, j];
             if (item.isWall)
             {
                 Edge[] edges = new Edge[4];
                 edges [0] = new Edge(new float[] { item.pos.x - nodeRaidus, item.pos.y - nodeRaidus }
                                      , new float[] { item.pos.x + nodeRaidus, item.pos.y - nodeRaidus });
                 edges [1] = new Edge(new float[] { item.pos.x + nodeRaidus, item.pos.y - nodeRaidus }
                                      , new float[] { item.pos.x + nodeRaidus, item.pos.y + nodeRaidus });
                 edges [2] = new Edge(new float[] { item.pos.x + nodeRaidus, item.pos.y + nodeRaidus }
                                      , new float[] { item.pos.x - nodeRaidus, item.pos.y + nodeRaidus });
                 edges [3] = new Edge(new float[] { item.x - nodeRaidus, item.pos.y + nodeRaidus }
                                      , new float[] { item.pos.x - nodeRaidus, item.pos.y - nodeRaidus });
                 gridNodes[i, j].edges = edges;
             }
         }
     }
 }
Ejemplo n.º 15
0
    //创建玩家单位
    public void CreateHeroUnits(Hero _hero, int _side)
    {
        if (_hero.heroType != null)
        {
            heroUnits[_side] = Instantiate(heroUnitPrefab, heroUnitPos[_side], Quaternion.identity);
            heroUnits[_side].GetComponent <Animator>().runtimeAnimatorController = _hero.heroType.animControl;

            //在右边则翻转英雄
            if (_side == 1)
            {
                heroUnits[_side].GetComponent <SpriteRenderer>().flipX = true;
            }
        }

        int x = (_side == 0) ? 0 : map.size.x - 1;

        for (int i = 0; i < _hero.pocketUnitNum; i++)
        {
            int playerUnitPosIndex = playerUnitPos[_hero.pocketUnitNum - 1][i];
            int unitPosIndex       = unitPos[playerUnitPosIndex];
            //创建单位
            Unit unit = CreateUnit(_hero.pocketUnits[i].type, new Vector2Int(x, unitPosIndex),
                                   _hero.pocketUnits[i].num, _side);

            //设置单位士气和运气
            unit.morale = _hero.morale;
            unit.luck   = _hero.luck;

            //链接单位和节点
            NodeItem nodeItem = map.GetNodeItem(new Vector2Int(x, unitPosIndex));
            map.LinkNodeWithUnit(unit, nodeItem);

            AddUnitToActionList(ref unitActionOrder, unit);
        }
    }
Ejemplo n.º 16
0
    void Awake()
    {
        //init grid
        w         = Mathf.RoundToInt(transform.localScale.x * 2);
        h         = Mathf.RoundToInt(transform.localScale.y * 2);
        gridNodes = new NodeItem[w, h];

        wallRange = new GameObject("WallRange");
        pathRange = new GameObject("PathRange");

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                Vector3 pos = new Vector3(i * 0.5f, j * 0.5f, -0.25f);
                // 通过节点中心发射圆形射线,检测当前位置是否可以通过
                bool isWall = Physics.CheckSphere(pos, nodeRaidus, layerMask);

                gridNodes [i, j] = new NodeItem(isWall, pos, i, j);
                // 如果是墙体,则画出不可行走的区域
                if (isWall)
                {
                    GameObject obj = GameObject.Instantiate(nodeWall, pos, Quaternion.identity) as GameObject;
                    obj.transform.SetParent(wallRange.transform);
                }
            }
        }
        initMap();
        randomTheWall();
    }
Ejemplo n.º 17
0
        private void createMainMenu()
        {
            List <MenuItem> showDataTimeMenuItems       = new List <MenuItem>();
            List <MenuItem> VersionAndCapitalsMenuItems = new List <MenuItem>();

            MenuItem showTime = new LeafItem("Show Time", new TestMenuActions.ShowTime());
            MenuItem showDate = new LeafItem("Show Date", new TestMenuActions.ShowDate());


            MenuItem countCapitals = new LeafItem("Count Capitals", new TestMenuActions.CountCapitals());
            MenuItem showVersion   = new LeafItem("Show Version", new TestMenuActions.ShowVersion());


            showDataTimeMenuItems.Add(showTime);
            showDataTimeMenuItems.Add(showDate);

            VersionAndCapitalsMenuItems.Add(countCapitals);
            VersionAndCapitalsMenuItems.Add(showVersion);

            MenuItem showDateOrTime     = new NodeItem("Show Date/Time", showDataTimeMenuItems);
            MenuItem VersionAndCapitals = new NodeItem("Version and capitals", VersionAndCapitalsMenuItems);

            m_MainMenu.AddMenuItem(showDateOrTime);
            m_MainMenu.AddMenuItem(VersionAndCapitals);
        }
Ejemplo n.º 18
0
    //获取范围内敌人,且可到达
    public List <Unit> GetEnemiesWithinRange(Unit _unit, int _range)
    {
        List <Unit> list     = new List <Unit>();
        int         speed    = _unit.GetComponent <Unit>().type.speed;
        NodeItem    nodeItem = _unit.GetComponent <Unit>().nodeItem;

        bool            walkable       = _unit.isWalker ? true : false;
        List <NodeItem> reachableNodes = BattleManager.instance.map.
                                         GetNodeItemsWithinRange(nodeItem, speed, walkable);
        List <NodeItem> attackableNodes = BattleManager.instance.map.
                                          GetNodeItemsWithinRange(nodeItem, speed + 1, walkable);

        foreach (var item in attackableNodes)
        {
            //是单位而且是敌对,且可到达
            if (item.nodeObject != null &&
                item.nodeObject.nodeObjectType == NodeObjectType.unit &&
                !BattleManager.instance.isSamePlayer(item.nodeObject.GetComponent <Unit>(), _unit) &&
                isReachableUnit(item.nodeObject.GetComponent <Unit>(), reachableNodes))
            {
                list.Add(item.nodeObject.GetComponent <Unit>());
            }
        }

        return(list);
    }
Ejemplo n.º 19
0
    void Awake()
    {
        // 初始化格子
        w    = Mathf.RoundToInt(transform.localScale.x / NodeWidth);
        h    = Mathf.RoundToInt(transform.localScale.y / NodeWidth);
        grid = new NodeItem[w, h];

        WallRange = new GameObject("WallRange");
        PathRange = new GameObject("PathRange");

        // 将墙的信息写入格子中
        for (int x = 0; x < w; x++)
        {
            for (int y = 0; y < h; y++)
            {
                Vector3 pos = new Vector3(x * NodeWidth, y * NodeWidth, -0.25f);
                // 通过节点中心发射圆形射线,检测当前位置是否可以行走,节点中心不跟墙体碰撞就可以走
                bool isWall = Physics.CheckSphere(pos, NodeWidth / 2, WhatLayer);                 //射线检测
                // 构建一个节点
                grid[x, y] = new NodeItem(isWall, pos, x, y);
                // 如果是墙体,则画出不可行走的区域
                if (isWall)
                {
                    GameObject obj = GameObject.Instantiate(NodeWall, pos, Quaternion.identity) as GameObject;
                    obj.transform.SetParent(WallRange.transform);
                }
            }
        }
    }
 public virtual void Init(Effect _parent)
 {
     originPlayer = _parent.originPlayer;
     originUnit   = _parent.originUnit;
     targetUnit   = _parent.targetUnit;
     targetNode   = _parent.targetNode;
 }
Ejemplo n.º 21
0
        /**
         * initiate navigation map
         */
        public void initNavigationMap()
        {
            StopFinding();
            for (int i = 0; i < WallMarks.transform.childCount; i++)
            {
                Destroy(WallMarks.transform.GetChild(i).gameObject);
            }
            for (int i = 0; i < PathMarks.transform.childCount; i++)
            {
                PathMarks.transform.GetChild(i).gameObject.SetActive(false);
            }
            w   = Mathf.RoundToInt(tilemapEnd.x - tilemapStart.x + 1);
            h   = Mathf.RoundToInt(tilemapEnd.y - tilemapStart.y + 1);
            map = new NodeItem[w, h];

            // write unwalkable node
            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    Vector2 pos = new Vector2(tilemapStart.x + x, tilemapStart.y + y);
                    // check walkable or not
                    bool isWall = Physics2D.OverlapCircle(pos + new Vector2(0.5f, 0.5f), Radius, wallLayer);
                    // new a node
                    map[x, y] = new NodeItem(isWall, pos, x, y);
                    // mark unwalkable node
                    if (isWall && showWallMark && WallMark)
                    {
                        GameObject obj = GameObject.Instantiate(WallMark, new Vector3(pos.x + 0.5f, pos.y + 0.5f, 0), Quaternion.identity) as GameObject;
                        obj.transform.SetParent(WallMarks.transform);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassInfo"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="item">The item.</param>
        public ClassInfo(NodeItem parent, CodeClass2 item)
            : base(null, item as CodeElement2)
        {
            this.Parent = parent;
            this.item = item;
            this.IsClass = true;

            this.Access = ObjectFactory.Convert(this.item.Access);

            this.IsAbstract = this.item.IsAbstract;

            this.IsShared = this.item.IsShared;
            this.IsGeneric = this.item.IsGeneric;
            this.Namespace = item.Namespace.FullName;
            this.DocComment = this.item.DocComment;

            IsPublic = this.IsPublic_Impl(this.item.Access);
            IsPrivate = this.IsPrivate_Impl(this.item.Access);
            IsProtected = this.IsProtected_Impl(this.item.Access);
            IsFamilyOrProtected = this.IsFamilyOrProtected_Impl(this.item.Access);

            this.IsStatic = false;
            this.IsStruct = false;

            //this.item.Children
            //this.item.DerivedTypes
            //this.item.InfoLocation
            //this.item.InheritanceKind
            //this.item.Kind = vsCMElement.
            //this.item.Parent
            //this.item.PartialClasses
            //this.item.Parts
        }
Ejemplo n.º 23
0
    //链接单位和节点
    public void LinkNodeWithUnit(Unit _unit, NodeItem _nodeItem)
    {
        //单位占据的所有节点
        List <NodeItem> nodes = new List <NodeItem>();

        nodes.Add(_nodeItem);

        //如果是双格单位,同时修改前方节点
        if (_unit.type.isTwoHexsUnit)
        {
            Vector2Int pos = _nodeItem.pos;
            pos.x += _unit.sideFacing;
            nodes.Add(GetNodeItem(pos));
        }

        //如果已经和节点链接,取消链接
        if (_unit.GetComponent <Unit>().nodeItem != null)
        {
            UnlinkNodeWithUnit(_unit);
        }

        _unit.nodeItem = _nodeItem;

        foreach (var item in nodes)
        {
            item.nodeObject = _unit;

            GetNode(item.pos).walkable = false;
        }
    }
Ejemplo n.º 24
0
    int getDistanceNodes(NodeItem a, NodeItem b)    //曼哈顿距离获取两个节点之间的距离
    {
        int cntX = Mathf.Abs(a.x - b.x);
        int cntY = Mathf.Abs(a.y - b.y);

        return(cntX + cntY);
    }
Ejemplo n.º 25
0
        /**
         * initiate navigation map
         */
        public void initNavigationMap()
        {
            StopFinding();

            Tilemap tm = GetComponent <Tilemap>();

            tilemapEnd = new Vector2(tm.size.x, tm.size.y);

            w   = Mathf.RoundToInt(tilemapEnd.x - tilemapStart.x + 1);
            h   = Mathf.RoundToInt(tilemapEnd.y - tilemapStart.y + 1);
            map = new NodeItem[w, h];

            // write unwalkable node
            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    Vector2 pos = new Vector2(tilemapStart.x + x, tilemapStart.y + y);
                    // check walkable or not
                    bool isWall = Physics2D.OverlapCircle(pos + new Vector2(0.5f, 0.5f), Radius, wallLayer);
                    // new a node
                    map[x, y] = new NodeItem(isWall, pos, x, y);
                }
            }
        }
Ejemplo n.º 26
0
    public List <NodeItem> GetTwoHexUnitReachableNodeItemsWithinRange(NodeItem _node1, NodeItem _node2, int _range, bool _walkable)
    {
        List <NodeItem> list = new List <NodeItem>();

        //获取可移动范围
        foreach (var item in GetTwoHexUnitReachableNodesWithinRange(GetNode(_node1.pos), GetNode(_node2.pos), _range, _walkable))
        {
            list.Add(GetNodeItem(item.pos));
        }

        //去除其中前方点不存在,或不可通行的节点

        /*for (int i = list.Count - 1; i > 0; i--)
         * {
         *      Vector2Int pos = list[i].pos;
         *      pos.x += BattleManager.currentActionUnit.facing;
         *      if (!isNodeAvailable(pos) || !GetNode(pos).walkable)
         *              list.RemoveAt(i);
         * }*/

        list.Remove(_node1);
        list.Remove(_node2);

        return(list);
    }
Ejemplo n.º 27
0
    private void CollectAroundEdge(int range, Vector3 pos)
    {
        NodeItem posNode = getNodeItem(pos);

        if (posNode.x <= 0 || posNode.y >= 0)
        {
            return;
        }

        List <NodeItem> visibleRange = new List <NodeItem> ();

        int startX;
        int startY;
        int endX;
        int endY;

        startX = -range + posNode.x < 0 ? 0 : -range + posNode.x;
        startY = -range + posNode.y < 0 ? 0 : -range + posNode.y;
        endX   = range + posNode.x > w ? w : range + posNode.x;
        endY   = range + posNode.y > h ? h : range + posNode.y;

        for (int i = startX; i <= endX; i += 1)
        {
            for (int j = startY; j <= endY; j += 1)
            {
                visibleRange.Add(gridNodes[posNode.x + i, posNode.y + j]);
            }
        }
    }
Ejemplo n.º 28
0
        public void PinConnected(NodeItem fromConnect, string property)
        {
            Type t    = DotaAction.GetType();
            var  prop = t.GetProperty(property);

            if (prop == null)
            {
                throw new ArgumentException("Property must be a valid KV property");
            }
            if (fromConnect.Node is VariableNode)
            {
                if (prop.PropertyType == typeof(NumberValue))
                {
                    var vn = fromConnect.Node as VariableNode;
                    var nv = new NumberValue("%" + vn.Variable.Name);

                    prop.SetMethod.Invoke(DotaAction, new object[] { nv });
                }
            }
            if (fromConnect is TargetNodeItem)
            {
                if (prop.PropertyType == typeof(TargetKey))
                {
                    var target = (fromConnect as TargetNodeItem).Target;

                    prop.SetMethod.Invoke(DotaAction, new object[] { target });
                }
            }
        }
Ejemplo n.º 29
0
    //清除嵌入墙体的边
    private void ClearInsideEdge()
    {
        for (int i = 1; i < w - 1; i++)
        {
            for (int j = 1; j < h - 1; j++)
            {
                NodeItem node = gridNodes [i, j];
                if (node.isWall)
                {
                    if (gridNodes[i, j - 1].isWall)
                    {
                        gridNodes[i, j].edges[0].isInAir = false;
                    }

                    if (gridNodes[i + 1, j].isWall)
                    {
                        gridNodes[i, j].edges[1].isInAir = false;
                    }

                    if (gridNodes[i, j + 1].isWall)
                    {
                        gridNodes[i, j].edges[2].isInAir = false;
                    }

                    if (gridNodes[i - 1, j].isWall)
                    {
                        gridNodes[i, j].edges[3].isInAir = false;
                    }
                }
            }
        }
    }
Ejemplo n.º 30
0
    public void InitNavigationMap()
    {
        //마크 삭제
        DestroyMarks();
        //타일 사이즈 가져오기
        GetTileMapEndSize();

        Width  = Mathf.RoundToInt(TilemapEnd.x - TilemapStart.x + 1); //가로
        Height = Mathf.RoundToInt(TilemapEnd.y - TilemapStart.y + 1); //세로
        Map    = new NodeItem[Width, Height];

        // Wall 노드 생성
        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                Vector2 pos = new Vector2(TilemapStart.x + x, TilemapStart.y + y);
                // 영역의 Layer가 WallLayer인지 아닌지 검사
                bool isWall = Physics2D.OverlapCircle(pos + new Vector2(0.5f, 0.5f), _radius, _wallLayer);
                // 맵 생성
                Map[x, y] = new NodeItem(isWall, pos, x, y);
                // Wall 노드 생성
                if (isWall && _ShowWallMark && _wallMarkPrefab)
                {
                    GameObject obj = GameObject.Instantiate(_wallMarkPrefab, new Vector3(
                                                                pos.x + 0.5f, pos.y + 0.5f, 0), Quaternion.identity) as GameObject;
                    obj.transform.SetParent(_wallMarks.transform);
                }
            }
        }
    }
Ejemplo n.º 31
0
 public Order(OrderType _type, Unit _origin, NodeItem _targetNode, Unit _target)
 {
     type       = _type;
     origin     = _origin;
     targetNode = _targetNode;
     target     = _target;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EnumInfo"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="item">The item.</param>
        public EnumInfo(NodeItem parent, CodeEnum item)
            : base(null, item as CodeElement2)
        {
            this._enum = item as CodeEnum;
            this.IsEnum = true;
            this.Namespace = item.Namespace.FullName;
            this.DocComment = this._enum.DocComment;

            IsPublic = this.IsPublic_Impl(this._enum.Access);
            IsPrivate = this.IsPrivate_Impl(this._enum.Access);
            IsProtected = this.IsProtected_Impl(this._enum.Access);
            IsFamilyOrProtected = this.IsFamilyOrProtected_Impl(this._enum.Access);

            this.IsStruct = true;
            this.IsStatic = true;

            GetFields();
        }
        public static NodeItem CreateNodeItem(EnvDTE.ProjectItem s)
        {
            NodeItem fld = null;

            var t = s.FileNames[1] as string;

            if (t != null)
            {
                System.IO.FileInfo f = new System.IO.FileInfo(t);

                if (f.Exists && f.Extension.Length > 0)
                    fld = new NodeItem(s);
                else
                    fld = new NodeItemFolder(s);

            }

            return fld;
        }
Ejemplo n.º 34
0
 /// <summary>
 /// return the list of derived interface.
 /// </summary>
 /// <returns></returns>
 public IEnumerable<InterfaceInfo> ImplementedInterfaces()
 {
     foreach (EnvDTE.CodeElement item in this.item.Bases)
     {
         if (item.Kind == EnvDTE.vsCMElement.vsCMElementInterface)
         {
             NodeItem parent = new NodeItem(this.item.ProjectItem);
             EnvDTE80.CodeInterface2 i = item as EnvDTE80.CodeInterface2;
             InterfaceInfo _result = ObjectFactory.Instance.CreateInterface(parent, i);
             yield return _result;
         }
     }
 }
Ejemplo n.º 35
0
        /// <summary>
        /// return the base class
        /// </summary>
        /// <returns></returns>
        public override ClassInfo GetBase()
        {
            foreach (EnvDTE.CodeElement item in this.item.Bases)
            {
                if (item.Kind == EnvDTE.vsCMElement.vsCMElementClass)
                {
                    NodeItem parent = new NodeItem(this.item.ProjectItem);
                    EnvDTE80.CodeClass2 i = item as EnvDTE80.CodeClass2;
                    ClassInfo _result = ObjectFactory.Instance.CreateClass(parent, i);
                    return _result;
                }
            }

            return null;
        }
Ejemplo n.º 36
0
        public NodeItem populateItemWinXP(Dictionary<String, String> ID)
        {
            String datesString = ID["AgentTime"];
            String[] dates = datesString.Split(',');
            String[] agents = ID["AgentName"].Split(',');
            int heartbeat_Index = -1;
            DateTime latestDate = new DateTime(0);

            //Search for the most recent heartbeat... Sometimes there are two, ignore the second
            //Console.WriteLine(ID["Name"]);
            //Console.WriteLine("Checking agents");

            for (int i = 0; i < agents.Length; i++)
            {
                if (agents[i] == "{Heartbeat Discovery}")
                {
                    if (latestDate.CompareTo(Convert.ToDateTime(dates[i])) < 0)
                    {
                        latestDate = Convert.ToDateTime(dates[i]);
                        heartbeat_Index = i;
                    }

                }

            }
            // Console.WriteLine("Finished checking Agents");

            //Heartbeat was not found. Replace the heartbeat value with a replacement
            //Console.WriteLine("Checking HeartBeats");
            if (heartbeat_Index == -1)
            {
                DateTime replacement = new DateTime();
                heartbeat_Index = 0;
                dates[heartbeat_Index] = replacement.ToString();
            }
            //Console.WriteLine("Done Checking HeartBeats = " + dates[heartbeat_Index]);
            NodeItem item = new NodeItem
            {
                Node = ID["NetbiosName"],
                Active = ID["Active"],
                Last_Login = ID["LastLogonUserName"],
                Site = ID["SiteName"],
                Owner = ID["employeeID"],
                HeartBeat = dates[heartbeat_Index],
                dateString = dates,
                DateCreated = ID["CreationDate"],
                Agents = agents,
                OS = ID["OperatingSystemNameandVersion"],
                MachineUse = "Unknown"
            };

            //Console.WriteLine("Finished populating item");
            return item;
        }
 /// <summary>
 /// 
 /// </summary>
 public virtual EnumInfo CreateEnum(NodeItem parent, CodeEnum item)
 {
     return new EnumInfo(parent, item);
 }
 /// <summary>
 /// 
 /// </summary>
 public virtual InterfaceInfo CreateInterface(NodeItem parent, CodeInterface2 item)
 {
     return new InterfaceInfo(parent, item);
 }
        /// <summary>
        /// 
        /// </summary>
        public static bool HasVbFile(NodeItem item)
        {
            if (item.KindItem == KindItem.File)
                return (Path.GetExtension(item.Filename) == ".vb");

            return false;
        }
 /// <summary>
 /// 
 /// </summary>
 public virtual ClassInfo CreateClass(NodeItem parent, CodeClass2 item)
 {
     return new ClassInfo(parent, item);
 }
Ejemplo n.º 41
0
        void InitMatrix()
        {
            // counting the number of source nodes and creating field of them
            field = new NodeItem[ fieldSource.GetLength(0), fieldSource.GetLength(1) ];

            // counting nodes
            int nodeItemCount = 0;
            for (int x = 0; x < fieldSource.GetLength(0); x++) {
                for (int y = 0; y < fieldSource.GetLength(1); y++) {
                    if (fieldSource[x, y] == 1) {
                        NodeItem item = new NodeItem() { x = x, y = y };
                        field[x,y] = item;
                        nodeItemCount++;
                    }
                }
            }

            dancingLinks.InitHeaders(nodeItemCount + figureSet.FigureCount);

            // assigning a node to every column header just to make it distinct
            ExactCover.Node header = dancingLinks.rootHeader.right;
            for (int x = 0; x < field.GetLength(0); x++) {
                for (int y = 0; y < field.GetLength(1); y++) {
                    if (field[x, y] != null) {
                        header.nodedata = field[x, y];
                        header = header.right;
                    }
                }
            }

            // assigning a node containing figure id to header columns
            figureNodes = new NodeFigure[ figureSet.FigureCount ];
            for (int i = 0; i < figureSet.FigureCount; i++) {
                var newNode = new NodeFigure() { figureId = i };
                header.nodedata = newNode;
                // all figure headers are optional
                ((ExactCover.ColumnHeader) header).optional = true;
                header = header.right;
                figureNodes[i] = newNode;
            }
        }
Ejemplo n.º 42
0
 private void ViewEZMacNetwork_Load(object sender, EventArgs e)
 {
     this.Center = CenterType.HenriettaDongle;
     this.pbTopLeft.BackgroundImage = null;
     this.pbTopLeft.Image = null;
     this.pbTopRight.BackgroundImage = null;
     this.pbTopRight.Image = null;
     this.pbBottomLeft.BackgroundImage = null;
     this.pbBottomLeft.Image = null;
     this.pbBottomRight.BackgroundImage = null;
     this.pbBottomRight.Image = null;
     this.pbArrowTopLeft.Visible = false;
     this.pbArrowTopRight.Visible = false;
     this.pbArrowBottomLeft.Visible = false;
     this.pbArrowBottomRight.Visible = false;
     this.pbArrowTopLeft.Image = null;
     this.pbArrowTopRight.Image = null;
     this.pbArrowBottomLeft.Image = null;
     this.pbArrowBottomRight.Image = null;
     for (int i = 0; i < 4; i++)
     {
         PictureBox box;
         PictureBox box2;
         TextBox box3;
         TextBox box4;
         ViewSmallBattery battery;
         ViewThermometer thermometer;
         ViewHumidity humidity;
         this.attachControls(i, out box, out box2, out box3, out battery, out box4, out thermometer, out humidity);
         NodeItem item = new NodeItem(this._myResources, box) {
             AssociatedArrow = box2,
             AssociatedIDTextBox = box3,
             AssociatedTimeTextBox = box4,
             AssociatedBattery = battery,
             AssociatedThermometer = thermometer,
             AssociatedHumidity = humidity
         };
         this._nodes.Add(item);
     }
     this.setStatus(0, Status.Initial);
 }