Exemplo n.º 1
0
    public override float distanceBetweenParams(AStarParameters param, AStarParameters param2)
    {
        AStarEnemyParameters enemyParam  = (AStarEnemyParameters)param;
        AStarEnemyParameters enemyParam2 = (AStarEnemyParameters)param2;
//		float diag = Mathf.Min(Mathf.Abs(enemyParam.x-enemyParam2.x),Mathf.Abs(enemyParam.y-enemyParam2.y));
        float straight = Mathf.Abs(enemyParam.x - enemyParam2.x) + Mathf.Abs(enemyParam.y - enemyParam2.y);
//		return diag*1.4f + (straight - 2*diag) * 1.0f;
        Tile      t    = mapGenerator.tiles[enemyParam.x, enemyParam.y];
        Vector2   from = enemyParam.getPos();
        Vector2   to   = enemyParam2.getPos();
        Direction dir  = Tile.directionBetweenTiles(from, to);

        if (t.provokesOpportunity(dir, unit))           //.shouldTakeAttOppLeaving(unit))  {
        //	Debug.Log("Take Attack Of Opportunity: " + enemyParam.x + ", " + enemyParam.y + "   " + straight);
        {
            straight += 3;
        }
        int pass = t.passabilityInDirection(dir);

        if (pass > 1)
        {
            straight += 1 + (pass - 1) / 5;
        }
        if (t.hasAlly(unit))
        {
            straight++;
        }
        return(straight);
    }
Exemplo n.º 2
0
 public AStarNode remove(AStarParameters parameters)
 {
     for (int n = 0; n < tree.Count; n++)
     {
         if (((AStarNode)tree[n]).parameters.Equals(parameters))
         {
             return(remove(n));
         }
     }
     return(null);
 }
Exemplo n.º 3
0
    public override float heuristicForParameters(AStarParameters parameters)
    {
        float min = -1251.0f;

        foreach (AStarEnemyNode node in goalNodes)
        {
            float current = distanceBetweenParams(node.parameters, parameters);
            if (current == 0.0f)
            {
                return(0.0f);
            }
            if (min < 0.0f || current < min)
            {
                min = current;
            }
        }
        return(min >= 0.0f?min:0.0f);
    }
Exemplo n.º 4
0
    public override bool Equals(System.Object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        AStarParameters p = obj as AStarParameters;

        if ((System.Object)p == null)
        {
            return(false);
        }
        if (p == this)
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 5
0
 public AStarEnemyNode(AStarParameters parameters, float heuristic) : base(parameters, heuristic)
 {
 }
Exemplo n.º 6
0
 public AStarNode(AStarParameters parameters, float heuristic) : this(parameters)  {
     this.h = heuristic;
     //	return this;
 }
Exemplo n.º 7
0
    public AStarNode(AStarParameters parameters)
    {
//		this(parameters,0.0f);
        this.parameters = parameters;
    }
Exemplo n.º 8
0
 public virtual AStarNode createNodeWithParameters(AStarParameters parameters)
 {
     return(new AStarNode(parameters, heuristicForParameters(parameters)));
 }
Exemplo n.º 9
0
 public virtual float heuristicForParameters(AStarParameters parameters)
 {
     return(0.0f);
 }
Exemplo n.º 10
0
 public virtual float distanceBetweenParams(AStarParameters param, AStarParameters param2)
 {
     return(0.0f);
 }