public Queue<Executable> DecideActions() { DungeonCharacter dchar = achar.dchar; Dictionary<int, float> rangesLeft = new Dictionary<int, float>(); Dictionary<int, int> parents = new Dictionary<int, int>(); Queue<Executable> execQueue = new Queue<Executable>(); List<Tile> tileRange = dchar.GetPassTileRange(dchar.character.moveRange + 1, rangesLeft, parents, dchar.TraversibleTile); if (GameState.mState.charsInPlay.Count > 0) { float[] charDists = new float[GameState.mState.charsInPlay.Count]; int[] charTiles = new int[GameState.mState.charsInPlay.Count]; for (int i = 0; i < GameState.mState.charsInPlay.Count; i++) { List<Tile> validNghs = GameState.mState.charsInPlay[i].entity.tile.GetNeighbors().FindAll(t => (t.entities.Count == 0) && (tileRange.Contains(t))); if (validNghs.Count > 0) { Tile bestTile = validNghs[0]; foreach (Tile n in validNghs) { if (rangesLeft[n.key].CompareTo(rangesLeft[bestTile.key]) > 0) { bestTile = n; } } charTiles[i] = bestTile.key; charDists[i] = rangesLeft[bestTile.key]; } else { charTiles[i] = -1; charDists[i] = -1; } } DungeonCharacter gbestChar = null; Tile gbestTile = null; int gbestDist = 0; for (int j = 0; j < GameState.mState.charsInPlay.Count; j++) { if (charDists[j] > 0 && charDists[j] > gbestDist) { gbestChar = GameState.mState.charsInPlay[j]; gbestTile = Tile.KeyToTile(charTiles[j]); } } if (gbestChar != null) { List<Tile> path = dchar.GetPath(gbestTile, rangesLeft, parents); MoveExec move = new MoveExec(dchar, dchar.entity.tile, gbestTile, path); execQueue.Enqueue(move); AttackExec attk = new AttackExec(dchar, gbestChar); execQueue.Enqueue(attk); } } return execQueue; }
public Executable UpdateConfig() { Tile t = config.UpdateConfig(); if (t != null) { atexe = new AttackExec(dchar, t.GetBottomChar()); return atexe; } return null; }