Example #1
0
        /// <summary>
        /// Indicates whether the Tilez has Collsion or not
        /// </summary>
        /// <param name="tTile">Tilez to be checked</param>
        public bool Collisionreturner(Tilez tTile)
        {
            switch (tTile)
            {
            case Tilez.water:
                return(true);

            case Tilez.obstacleStone:
                return(true);

            case Tilez.structureStone:
                return(true);

            case Tilez.structureWood:
                return(true);

            case Tilez.treeFoilage:
                return(true);

            case Tilez.treeTop:
                return(true);

            case Tilez.treeTrunk:
                return(true);

            default:
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// Constructor of a normal Node
        /// </summary>
        /// <param name="tTile">Tile of the Node</param>
        /// <param name="vPosition">Position of the Node</param>
        /// <param name="nParentNode">ParentNode of the Node</param>
        /// <param name="nTargetNode">TargetNode of the Node</param>
        public Node(Tilez tTile, Vector2f vPosition, Node nParentNode, Node nTargetNode)
        {
            this.tTile     = tTile;
            this.vPosition = vPosition;

            bCollision = Collisionreturner(tTile);

            this.nParent = nParentNode;

            this.nStartNode  = nParentNode;
            this.nTargetNode = nTargetNode;

            SetiGCost();
            SetiHCost(nTargetNode.vPosition);

            iFCost = iGCost + iHCost;

            if (nParentNode.nChild == null)
            {
                nParentNode.nChild = new Node(tTile, vPosition, nTargetNode, bCollision, iGCost, iHCost, iFCost);
            }

            else if (nParentNode.nChild.iFCost > iFCost)
            {
                nParentNode.nChild = new Node(tTile, vPosition, nTargetNode, bCollision, iGCost, iHCost, iFCost);
            }
        }
Example #3
0
        // Normal Node
        public Node(Tilez Tile, Vector2f Position, Node ParentNode, Node targetNode)
        {
            this.Tile     = Tile;
            this.Position = Position;

            Collision = Collisionreturner(Tile);

            this.ParentNode = ParentNode;

            this.startNode  = ParentNode;
            this.targetNode = targetNode;

            SetiGCost();
            SetiHCost(targetNode.Position);

            iFCost = iGCost + iHCost;

            if (ParentNode.ChildNode == null)
            {
                ParentNode.ChildNode = new Node(Tile, Position, targetNode, Collision, iGCost, iHCost, iFCost);
            }

            else if (ParentNode.ChildNode.iFCost > iFCost)
            {
                ParentNode.ChildNode = new Node(Tile, Position, targetNode, Collision, iGCost, iHCost, iFCost);
            }
        }
Example #4
0
        /// <summary>
        /// Constructor of a StartNode (= A Node)
        /// </summary>
        /// <param name="tTile">Tile of the Node</param>
        /// <param name="vPosition">Position of the Node</param>
        /// <param name="vTargetVector">Position of the TargetNode</param>
        public Node(Tilez tTile, Vector2f vPosition, Vector2f vTargetVector)
        {
            this.tTile     = tTile;
            this.vPosition = vPosition;

            bCollision = Collisionreturner(tTile);

            iGCost = 0;
            SetiHCost(vTargetVector);

            iFCost = iGCost + iHCost;
        }
Example #5
0
        // StartNode (= A)
        public Node(Tilez Tile, Vector2f Position, Vector2f targetVector)
        {
            this.Tile     = Tile;
            this.Position = Position;

            Collision = Collisionreturner(Tile);

            iGCost = 0;
            SetiHCost(targetVector);

            iFCost = iGCost + iHCost;
        }
Example #6
0
        /// <summary>
        /// Constrcutor of a TargetNode (=B Node)
        /// </summary>
        /// <param name="tTile">Tile of the Node</param>
        /// <param name="vPosition">Position of the Node</param>
        /// <param name="nStartNode">StartNode (= A Node)</param>
        public Node(Tilez tTile, Vector2f vPosition, Node nStartNode)
        {
            this.tTile     = tTile;
            this.vPosition = vPosition;

            bCollision = Collisionreturner(tTile);

            this.nStartNode = nStartNode;
            SetiGCost();
            iHCost = 0;

            iFCost = iGCost + iHCost;
        }
Example #7
0
        /// <summary>
        /// Constructor of a ChildNode
        /// </summary>
        /// <param name="tTile">Tile of the ParentNode</param>
        /// <param name="vPosition">Position of the ParentNode</param>
        /// <param name="nTargetNode">targetNode of the ParentNode</param>
        /// <param name="bCollision">Collision of the ParentNode</param>
        /// <param name="iGCost">iGCost of the ParentNode</param>
        /// <param name="iHCost">iHCost of the ParentNode</param>
        /// <param name="iFCost">iFCost of the ParentNode</param>
        private Node(Tilez tTile, Vector2f vPosition, Node nTargetNode, bool bCollision, uint iGCost, uint iHCost, uint iFCost)
        {
            this.tTile     = tTile;
            this.vPosition = vPosition;

            this.bCollision = bCollision;

            this.nTargetNode = nTargetNode;

            this.iGCost = iGCost;
            this.iHCost = iHCost;
            this.iFCost = iFCost;
        }
Example #8
0
        //TargetNode (= B)
        public Node(Tilez Tile, Vector2f Position, Node keyNode)
        {
            this.Tile     = Tile;
            this.Position = Position;

            Collision = Collisionreturner(Tile);

            startNode = keyNode;
            SetiGCost();
            iHCost = 0;

            iFCost = iGCost + iHCost;
        }
Example #9
0
        private Node(Tilez Tile, Vector2f Position, Node targetNode, bool Collision, uint iGCost, uint iHCost, uint iFCost)
        {
            this.Tile     = Tile;
            this.Position = Position;

            this.Collision = Collision;

            this.targetNode = targetNode;

            this.iGCost = iGCost;
            this.iHCost = iHCost;
            this.iFCost = iFCost;
        }
Example #10
0
        /// <summary>
        /// Returns collision bool in dependency of the given Tilez type
        /// </summary>
        /// <param name="eTile"></param>
        /// <returns></returns>
        public static bool CollisionReturner(Tilez eTile)
        {
            switch (eTile)
            {
            case Tilez.groundGrass:
                return(false);

            case Tilez.groundStone:
                return(false);

            case Tilez.groundWood:
                return(false);

            default:
                return(true);
            }
        }
        /// <summary>
        /// Hardcoded list of all sources on the tile sheet. Has to be manually updated with every tile on the source sheet that is added or removed.
        /// </summary>
        /// <param name="eTile"></param>
        /// <returns></returns>
        protected IntRect TileSourceDeterminat0r(Tilez eTile)
        {
            int iColumn = 0;
            int iRow    = 0;

            switch (eTile)
            {
            case Tilez.water:
                iColumn = 0;
                iRow    = 5;
                break;

            case Tilez.obstacleStone:
                iColumn = 0;
                iRow    = 4;
                break;

            case Tilez.structureStone:
                iColumn = 1;
                iRow    = 3;
                break;

            case Tilez.structureWood:
                iColumn = 0;
                iRow    = 3;
                break;

            case Tilez.treeFoilage:
                iColumn = 2;
                iRow    = 2;
                break;

            case Tilez.treeTop:
                iColumn = 1;
                iRow    = 2;
                break;

            case Tilez.treeTrunk:
                iColumn = 0;
                iRow    = 2;
                break;

            case Tilez.groundWood:
                iColumn = 2;
                iRow    = 1;
                break;

            case Tilez.groundStone:
                iColumn = 1;
                iRow    = 1;
                break;

            case Tilez.groundGrass:
                iColumn = 0;
                iRow    = 1;
                break;

            case Tilez.white:
                iColumn = 3;
                iRow    = 0;
                break;

            case Tilez.grey:
                iColumn = 2;
                iRow    = 0;
                break;

            case Tilez.darkGrey:
                iColumn = 1;
                iRow    = 0;
                break;

            default:
                iColumn = 0;
                iRow    = 0;
                break;
            }
            return(new IntRect(iColumn * tileArrayCreation.GetTileSize(), iRow * tileArrayCreation.GetTileSize(), tileArrayCreation.GetTileSize(), tileArrayCreation.GetTileSize()));
        }