コード例 #1
0
        private static void UpdateGridAndExistingCreeps(this GameLevel level, Vector2D gridPosition)
        {
            var index = level.GetIndexForMapData(gridPosition);

            level.MapData[index] = LevelTileType.Placeable;
            level.GetPathFinding().SetReachableAndUpdate(index);
            foreach (var creep in EntitiesRunner.Current.GetEntitiesOfType <Creep>())
            {
                level.IsTherePossibleExitPath(creep);
            }
            level.UpdatePathsIfPossible();
        }
コード例 #2
0
        private static bool IsPossibleAddTower(this GameLevel level, Vector2D gridPosition)
        {
            var index = level.GetIndexForMapData(gridPosition);

            if (level.UpdateExistingCreeps(gridPosition + Vector2D.Half) &&
                level.UpdatePathsIfPossible())
            {
                return(true);
            }
            level.MapData[index] = LevelTileType.Placeable;
            level.GetPathFinding().SetReachableAndUpdate(index);
            return(false);
        }
コード例 #3
0
 public static void RemoveTowers(this GameLevel level)
 {
     foreach (var tower in EntitiesRunner.Current.GetEntitiesOfType <Tower>())
     {
         var towerMapPos = level.GetMapCoordinates(tower.Position.GetVector2D());
         var index       = level.GetIndexForMapData(towerMapPos);
         if (index >= level.MapData.Length)
         {
             return;
         }
         level.MapData[index] = LevelTileType.Placeable;
         level.GetPathFinding().SetReachableAndUpdate(index);
         tower.Dispose();
     }
 }
コード例 #4
0
        private static void SetUnreacheableTile(this GameLevel level, Vector2D position,
                                                TowerType type)
        {
            var pathfinding = level.GetPathFinding();
            var index       = (int)(position.X + position.Y * level.Size.Width);

            level.MapData[index] = LevelTileType.Blocked;
            pathfinding.SetUnreachableAndUpdate(index);
            var towerProperties = ContentLoader.Load <TowerPropertiesXml>(Xml.TowerProperties.ToString());
            var buff            = new BuffEffect(Player.Current.Avatar.GetType().Name + "RangeMultiplier");
            var range           = towerProperties.Get(type).Range;

            range *= buff.Multiplier > 0.0f ? buff.Multiplier : 1.0f;
            pathfinding.UpdateWeightInAdjacentNodes(position, (int)range, 100);
        }
コード例 #5
0
        public static void SellTower(this GameLevel level, Vector2D position)
        {
            var list = EntitiesRunner.Current.GetEntitiesOfType <Tower>();

            foreach (var tower in list)
            {
                var towerTile = tower.Position - Vector2D.Half;
                if (towerTile != position)
                {
                    continue;
                }
                PlaySound(GameSounds.TowerSell);
                level.EarnGold((int)(tower.GetStatValue("Cost") / 2));
                level.GetPathFinding().UpdateWeightInAdjacentNodes(position,
                                                                   (int)(tower.GetStatValue("Range")), -100);
                tower.Dispose();
                level.UpdateGridAndExistingCreeps(position);
                return;
            }
        }