Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        player          = GameObject.Find("Player");
        respawnPoint.x *= GameManager.tileWidth + GameManager.tileWidth / 2;
        respawnPoint.y *= -GameManager.tileHeight + GameManager.tileHeight / 2;
        currentWaypoint = respawnPoint;
        Spawn();
        pathIndex = -1;
        path      = null;

        state     = STATE.PATH;
        pathState = PATH_STATE.NOT_FOLLOW;

        spotter            = this.GetComponent <Spotter>();
        spotter.inRange    = spotRange;
        spotter.leashRange = outOfSpotRange;
        spotter.target     = player;

        attack                 = this.GetComponent <SimpleAutoAttack>();
        attack.cooldown        = attackCoolDown;
        attack.range           = attackRange;
        attack.speedMultiplier = attackSpeedMultiplier;
        attack.power           = attackPower;
        attack.layerMask       = 1 << player.layer;
        // these last two variables were added to make
        // the component slightly more modular
        attack.alwaysAttack  = false;
        attack.nameOfTargets = new string[] { player.name };

        astar      = this.GetComponent <AStarPathing>();
        astar.grid = GameManager.level;
        astar.validSqrCosts.Add(GameManager.ITEM, 1);
        astar.validSqrCosts.Add(GameManager.COIN, 1);
        astar.CalculatePathForWaypoints(waypoints);
    }
    public void recalculatePath(ref AStarPathing pathing, Vector2 pos)
    {
        pathing = new AStarPathing(grid.getTileLocation(pos), grid.getTileLocation(positionScaled), grid);

        pathing.path.Clear();
        pathing.findPath();

        pathing.path.Insert(0, grid.getTileLocation(pos));
        pathing.path.RemoveAt(pathing.path.Count - 1);
    }
Beispiel #3
0
 static void Main(string[] args)
 {
     Console.Write("test");
     //CachedMap map = new CachedMap("E:\\Games\\d3advanced\\demonbuddy\\demonbuddy_180_leveling\\eu1_apollo_tr_agbact222\\atGuard");
     CachedMap map = new CachedMap("E:\\Games\\d3advanced\\demonbuddy\\demonbuddy_180_leveling\\eu1_apollo_tr_agbact222\\atQueen");
     AStarPathing pathing = new AStarPathing(map);
     MapWindow.Instance(new MapDrawer(map), false).Visible = true;
     MapWindow.Instance().GetDrawer().SetPathing(pathing);
     MapWindow.Instance().Redraw();
     //Console.ReadKey();
 }
Beispiel #4
0
 public FindPathAction(ECSInstance ecsInstance, Vector2 start, Vector2 finish, GameMap map)
 {
     f_EcsInstance = ecsInstance;
     f_Pathing     = new AStarPathing(start, finish, map);
 }
Beispiel #5
0
 public void SetPathing(AStarPathing pathing)
 {
     this.pathing = pathing;
 }