public void PlaceHeroNextToTile(GameContextSwitchKind context, Hero hero, HeroPlacementResult res, Tile baseTile) { Tile heroStartTile = null; if (baseTile != null) { var emptyOnes = GetEmptyNeighborhoodTiles(baseTile); if (emptyOnes.Any()) { heroStartTile = emptyOnes.First(); } else { heroStartTile = GetClosestEmpty(baseTile, false); } } if (heroStartTile == null) { heroStartTile = GetHeroStartTile(); } //heroStartTile.DungeonNodeIndex = heroStartTile.DungeonNodeIndex; res.Tile = heroStartTile; PlaceHeroAtTile(context, hero, heroStartTile); }
public void PlaceHeroAtTile(GameContextSwitchKind context, Hero hero, Tile tile) { ClearOldHeroPosition(context); if (SetTile(hero, tile.point, false)) { hero.DungeonNodeIndex = tile.DungeonNodeIndex; } }
public void ClearOldHeroPosition(GameContextSwitchKind context) { var heros = GetTiles <Hero>(); var heroInNode = heros.SingleOrDefault(); //if (heroInNode == null && context == GameContextSwitchKind.DungeonSwitched) // Logger.LogError("SwitchTo heros.Count = " + heros.Count); if (heroInNode != null) { SetEmptyTile(heroInNode.point);//Hero is going to be placed in the node, remove it from the old one (CurrentNode) } }