Exemplo n.º 1
0
        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile
        {
            DebugLogger.Trace("QPath::FindPath");
            if (world == null || unit == null || startTile == null || endTile == null)
            {
                DebugLogger.Log(LogLevel.Error, "null values passed to FindPath", "QPath");
                return(null);
            }

            // Call on our actual path solver


            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();

            DebugLogger.Trace("QPath::FindPath");
            return(resolver.GetList());
        }
        //public static IEnumerable FindPath(IQPathWorld world, IQPathUnit unit, IQPathTile startTile, IQPathTile endTile)


        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile
        {
            Util.WriteDebugLog(string.Format("QPath::FindPath() run"), GameManager.LogLevel_Error, GameManager.instance.debug, GameManager.instance.LogLevel);

            if (world == null || unit == null | startTile == null || endTile == null)
            {
                Util.WriteDebugLog(string.Format("Null value passed to QPath::FindPath()"), GameManager.LogLevel_Error, GameManager.instance.debug, GameManager.instance.LogLevel);
                Debug.LogError("QPath::FindPath() ERROR");
                return(null);
            }

            // Call on our actual path solver
            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();

            //TODO fix this
            return(resolver.GetList());
        }
Exemplo n.º 3
0
        public QPath_AStar(IQPathUnit unit, T startTile, T endTile, CostEstimateDelegate costEstimateFunc)
        {
            this.unit      = unit;
            this.startTile = startTile;
            this.endTile   = endTile;

            this.costEstimateFunc = costEstimateFunc;
        }
Exemplo n.º 4
0
 public float AggregateTileCostToEnter(float costSoFar, IQPathTile sourcetile, IQPathUnit theUnit)
 {
     // TODO: We are ignoring source tile for now, will change soon
     // return ((Unit)theUnit).TotalTurnsToEnterHex(this, costSoFar);
     //return BaseMovementCost();
     return(((Unit)theUnit).TotalTurnsToEnterHex((Hex)sourcetile, costSoFar));
     //throw new System.NotImplementedException();
 }
Exemplo n.º 5
0
 public QPath_AStar(
     IQPathWorld world,
     IQPathUnit unit,
     T starttile,
     T endtile,
     CostEstimateDelegate CostEstimateFunc)
 {
     this.world            = world;
     this.unit             = unit;
     this.starttile        = starttile;
     this.endtile          = endtile;
     this.CostEstimateFunc = CostEstimateFunc;
 }
Exemplo n.º 6
0
        public QPath_AStar(IQPathWorld world,
                           IQPathUnit unit,
                           T startTile,
                           T endTile,
                           CostEstimateDelegate costEstimateFunc)
        {
            this.world     = world;
            this.unit      = unit;
            this.startTile = startTile;
            this.endTile   = endTile;
            this.costEstimateDelegateFunc = costEstimateFunc;

            // Do we need to explicitly create a graph?
        }
Exemplo n.º 7
0
        public static T[] FindPath <T>(IQPathUnit unit, T startTile, T endTile, CostEstimateDelegate costEstimateFunc) where T : IQPathTile
        {
            if (unit == null || startTile == null || endTile == null)
            {
                Debug.LogError("null values passed to QPath::FindPath");
                return(null);
            }

            QPath_AStar <T> resolver = new QPath_AStar <T>(unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();

            return(resolver.GetList());
        }
Exemplo n.º 8
0
 public QPath_AStar(
     IQPathWorld world,
     IQPathUnit unit,
     T startTile,
     T endTile,
     CostEstimateDelegate costEstimateFunc
     )
 {
     // Setup
     this.world            = world;
     this.unit             = unit;
     this.startTile        = startTile;
     this.endTile          = endTile;
     this.costEstimateFunc = costEstimateFunc;
 }
Exemplo n.º 9
0
 public QPath_AStar(
     IQPathWorld theWorld,
     IQPathUnit theUnit,
     T startTile,
     T endTile,
     CostEstimateDelegate costEstimateFunc
     )
 {
     // Do Setup
     this.theWorld         = theWorld;
     this.theUnit          = theUnit;
     this.startTile        = startTile;
     this.endTile          = endTile;
     this.costEstimateFunc = costEstimateFunc;
 }
Exemplo n.º 10
0
        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile
        {
            if (world == null || unit == null || startTile == null || endTile == null)
            {
                return(null);
            }

            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();
            return(resolver.GetList());
        }
Exemplo n.º 11
0
        public static T[] FindPath <T>(
            IQPathWorld theWorld,
            IQPathUnit theUnit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile
        {
            // Debug.Log("QPath started!");
            if (theWorld == null || theUnit == null || startTile == null || endTile == null)
            {
                Debug.LogError("Null in pathfinding QPath:IQPathTile:FindPath");
                return(null);
            }

            QPath_AStar <T> resolver = new QPath_AStar <T>(theWorld, theUnit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();
            return(resolver.GetList());
        }
Exemplo n.º 12
0
        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile
        {
            if (world == null || unit == null || startTile == null || endTile == null)
            {
                Debug.LogError("Null values passed to QPath::FindPath");
                return(null);
            }

            // Call on path solver (could have different types)
            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();

            return(resolver.GetList());
        }
Exemplo n.º 13
0
        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile
            ) where T : IQPathTile
        {
            //Debug.Log("QPath::FindPath");
            if (world == null || unit == null || startTile == null || endTile == null)
            {
                //Debug.LogError("null values passed to QPath::FindPath");
                return(null);
            }

            // Call on our actual path solver


            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile);

            resolver.DoWork();
            return(resolver.GetList());
        }
Exemplo n.º 14
0
        public static T[] FindPath <T>(
            IQPathWorld world,
            IQPathUnit unit,
            T starttile,
            T endtile,
            CostEstimateDelegate CostEstimateFunc

            ) where T : IQPathTile
        {
            //Debug.Log("Running Status");

            if (world == null || unit == null || starttile == null || endtile == null)
            {
                Debug.LogError("null values passes");
            }

            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, starttile, endtile, CostEstimateFunc);

            resolver.DoWork();

            return(resolver.GetList());
        }
Exemplo n.º 15
0
        public static T[] FindPath <T>( //<T> define FindPath as generic - specify object type inside angle braces (that implements IQPathTile)
            IQPathWorld world,
            IQPathUnit unit,
            T startTile,
            T endTile,
            CostEstimateDelegate costEstimateFunc
            ) where T : IQPathTile //requires (guarentees) that whatever class T is, it implements IQPathTile
        {
            //error checking
            Debug.Log("QPath::FindPath");
            if (world == null || unit == null || startTile == null || endTile == null)
            {
                Debug.LogError("null values passed to QPath::FindPath");
                return(null);
            }

            // Call on the path solver (A* in this case)

            QPath_AStar <T> resolver = new QPath_AStar <T>(world, unit, startTile, endTile, costEstimateFunc);

            resolver.DoWork();

            return(resolver.GetList());
        }
Exemplo n.º 16
0
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit)
 {
     // TODO: We are ignoring source tile right now, this will have to change when
     // we have rivers.
     return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar));
 }
Exemplo n.º 17
0
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathTile[] twins, IQPathUnit theUnit)
 {
     return ((_Enemy)theUnit).TileToTileCost(this, twins);
 }
Exemplo n.º 18
0
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit unit)
 {
     return(((Unit)(unit)).AggregateTurnsToEnterHex(this, costSoFar));
 }
Exemplo n.º 19
0
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit)
 {
     //TODO: We are ignoring source tile atm, this will need to change with rivers
     return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar));
 }
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit)
 {
     //throw new System.NotImplementedException();
     //todo we are ignoring source tile right now, this will have to change when we have rivers
     return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar));
 }
Exemplo n.º 21
0
 public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit)
 {
     return(((Unit)theUnit).AggregateTurnsToEnterTile(this, costSoFar));
 }
Exemplo n.º 22
0
    public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit unit)
    {
        Fighter f = (Fighter)unit;

        return((f).AggregateTurnsToEnterTile(this, costSoFar) + MoveCost(f.Unit));
    }