示例#1
0
        /// <summary>
        /// General left rotation
        /// </summary>
        /// <param name="node">top of rotated subtree</param>
        private void RotateLeft(IntervalNode <TKey, TValue> node)
        {
            var           pivot    = node.Right;
            NodeDirection dir      = node.ParentDirection;
            var           parent   = node.Parent;
            var           tempTree = pivot.Left;

            pivot.Left  = node;
            node.Parent = pivot;
            node.Right  = tempTree;
            if (tempTree != Sentinel)
            {
                tempTree.Parent = node;
            }

            if (dir == NodeDirection.LEFT)
            {
                parent.Right = pivot;
            }
            else if (dir == NodeDirection.RIGHT)
            {
                parent.Left = pivot;
            }
            else
            {
                Root = pivot;
            }

            pivot.Parent = parent;

            pivot.RecalculateMaxEnd();
            node.RecalculateMaxEnd();
        }
        public void AddChild(BinaryTreeNode btn, NodeDirection nd)
        {
            btn.Parent = this;

            if(nd == NodeDirection.Left)
                this.LeftChild = btn;
            else
                this.RightChild = btn;
        }
 public override void ConnectNodeToBlock(NodeDirection dir, BuildingBlock bb)
 {
     if (dir == NodeDirection.Bottom)
     {
         nextBuildingBlock = bb;
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }
示例#4
0
 public Node(float outputCooldown, int leftDownTileID, int rightDownTileID, NodeDirection direction,
             InputStrategy inputStrategy, ProcessStrategy processStrategy, OutputStrategy outputStrategy)
     : this(outputCooldown)
 {
     LeftDownTileID = leftDownTileID;
     RightDownTileID = rightDownTileID;
     Direction = direction;
     _inputStrategy = inputStrategy;
     _outputStrategy = outputStrategy;
     _processStrategy = processStrategy;
 }
示例#5
0
        public void AgragandoHijo(BinaryTreeNode btn, NodeDirection nd)
        {
            btn.Padre = this;

            if (nd == NodeDirection.Left)
            {
                this.IzqHijo = btn;
            }
            else
            {
                this.DerHijo = btn;
            }
        }
        public override Point GetNode(NodeDirection dir)
        {
            switch (dir)
            {
            case NodeDirection.Top:
                return(new Point(this.rec.Location.X + this.rec.Width / 2, this.rec.Location.Y));

            case NodeDirection.Bottom:
                return(new Point(this.rec.Location.X + this.rec.Width / 2, this.rec.Location.Y + this.rec.Height));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void AssignPatch(ref QuadTreeNode node, NodeDirection nodeDirection, int topLeftVertex, int topRightVertex, int bottomLeftVertex, int bottomRightVertex)
        {
            List <Vector3> vertices = new List <Vector3>();
            List <Vector2> uvCoor   = new List <Vector2>();

            for (int z = topLeftVertex; z <= bottomLeftVertex; z += terrainRef.Width)
            {
                for (int x = z; x < (z + (topRightVertex - topLeftVertex) + 1); x++)
                {
                    vertices.Add(terrainRef.Vertices[x]);
                    uvCoor.Add(terrainRef.uvCoordinates[x]);
                }
            }
            node.Patch = new TerrainPatch((node.Level * 10) + (int)nodeDirection, node.BoundingBox2D, vertices, uvCoor, topRightVertex - topLeftVertex);
        }
        public override void ConnectNodeToBlock(NodeDirection dir, BuildingBlock bb)
        {
            switch (dir)
            {
            case NodeDirection.Left:
                nextTrueBlock = bb;
                break;

            case NodeDirection.Right:
                nextFalseBlock = bb;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
    bool TestEnemyDirection(Node tNode, int step, NodeDirection direction)
    {
        switch (direction)
        {
        case NodeDirection.North:
            if (tNode.NorthNode != null && tNode.NorthNode.EnemyVisited == step)
            {
                return(true);
            }
            else
            {
                return(false);
            }

        case NodeDirection.East:
            if (tNode.EastNode != null && tNode.EastNode.EnemyVisited == step)
            {
                return(true);
            }
            else
            {
                return(false);
            }

        case NodeDirection.South:
            if (tNode.SouthNode != null && tNode.SouthNode.EnemyVisited == step)
            {
                return(true);
            }
            else
            {
                return(false);
            }

        case NodeDirection.West:
            if (tNode.WestNode != null && tNode.WestNode.EnemyVisited == step)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        return(false);
    }
        public override Point GetNode(NodeDirection dir)
        {
            switch (dir)
            {
            case NodeDirection.Top:
                return(points[2]);

            case NodeDirection.Bottom:
                return(points[0]);

            case NodeDirection.Left:
                return(points[1]);

            case NodeDirection.Right:
                return(points[3]);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public static Node GetConveyour(NodeDirection direction)
 {
     return new Node(600f, 10, 11, direction, new StandartInput(), new StandartProcess(), new StandartOutput());
 }
示例#12
0
 public abstract void ConnectNodeToBlock(NodeDirection dir, BuildingBlock bb);
示例#13
0
 public NodeTarget(ITreeItem node, NodeDirection direction)
 {
     this.node      = node;
     this.direction = direction;
 }
示例#14
0
 public Node GetNode(NodeDirection direction, GridDirection compass)
 {
     return(nodes.Find(ni => ni.boundDirect == direction && ni.compassDirection == compass));
 }
示例#15
0
 public abstract Point GetNode(NodeDirection dir);
 public static Node GetRockMine(NodeDirection direction)
 {
     float outputCD = new Random().Next(1000, 1500);
     return new Node(outputCD, 12, 12, direction, new NoInput(), new GenerateRock(), new StandartOutput());
 }
示例#17
0
        private void AssignPatch(ref QuadTreeNode node, NodeDirection nodeDirection, int topLeftVertex, int topRightVertex, int bottomLeftVertex, int bottomRightVertex)
        {
            List<Vector3> vertices = new List<Vector3>();
            List<Vector2> uvCoor = new List<Vector2>();

            for (int z = topLeftVertex; z <= bottomLeftVertex; z += terrainRef.Width)
            {
                for (int x = z; x < (z + (topRightVertex - topLeftVertex) + 1); x++)
                {
                    vertices.Add(terrainRef.Vertices[x]);
                    uvCoor.Add(terrainRef.uvCoordinates[x]);
                }
            }
            node.Patch = new TerrainPatch((node.Level * 10) + (int)nodeDirection, node.BoundingBox2D, vertices, uvCoor, topRightVertex - topLeftVertex);
        }
示例#18
0
 public NodeDistance(NodeDirection nodes, float distance)
 {
     this.nodes	  = nodes;
     this.distance = distance;
 }
 public static Node Tower(NodeDirection direction)
 {
     return new Node(200, 15, 15, direction, new StandartInput(), new StandartProcess(), new NoOutput());
 }
示例#20
0
        List <Vector2> OptomisePath(List <Vector2> inPath)
        {
            // If the path finding algo returns a path, optomise it so that any series of nodes in a line are compressed to a single node/destination for the enemy player.

            if (inPath == null || inPath.Count == 0)
            {
                return(new List <Vector2>());
            }
            else
            {
                List <Vector2> optomisedPath = new List <Vector2>();

                Vector2 startPosition;
                Vector2 lastNode        = new Vector2(0, 0);
                Vector2 destinationNode = new Vector2(0, 0);

                NodeDirection nodeDirection     = NodeDirection.Unset;
                NodeDirection lastNodeDirection = NodeDirection.Unset;
                // NodeDirection lineDirection;

                startPosition = inPath.First <Vector2>(); // pop off the first element to prime the loop
                lastNode      = inPath.First <Vector2>();
                optomisedPath.Add(inPath.First <Vector2>());
                inPath.Remove(inPath.First <Vector2>());

                for (int i = 0; i < inPath.Count; i++) // This is processed forwards and builds a List of vectors to be returned along the way, which is exactly what the enemy character expects.
                {
                    Vector2 Node       = inPath[i];
                    Vector2 difference = Node - lastNode;

                    if (difference.X == 16)
                    {
                        nodeDirection = NodeDirection.Right;
                    }
                    else if (difference.X == -16)
                    {
                        nodeDirection = NodeDirection.Left;
                    }
                    else if (difference.Y == 16)
                    {
                        nodeDirection = NodeDirection.Down;
                    }
                    else if (difference.Y == -16)
                    {
                        nodeDirection = NodeDirection.Up;
                    }
                    else
                    {
                        Debug.Assert(true);
                    }


                    // If we've changed direction, store the position in the optomised path.
                    if (lastNodeDirection != NodeDirection.Unset && lastNodeDirection != nodeDirection)
                    {
                        optomisedPath.Add(startPosition);
                        startPosition = Node;
                    }
                    else
                    {
                        startPosition = startPosition + difference;
                    }

                    lastNodeDirection = nodeDirection;
                    lastNode          = Node;
                }
                // Add the final position
                optomisedPath.Add(startPosition);

                return(optomisedPath);
            }
        }