public override void Initialize() { GridCount = new Vector2(32, 32); CreepEnd = new Vector2(GridCount.X - 1, 15); LevelGrid = new byte[(int)GridCount.X, (int)GridCount.Y]; Background = CurrGame.SpriteBatch; GridSize.X = CurrGame.CreepFieldWidth / GridCount.X; GridSize.Y = CurrGame.CreepFieldHeight / GridCount.Y; ResetLevel(); WallTex = CurrGame.Content.Load <Texture2D>("Tower\\Textures\\Wall"); Origin = Vector2.Zero; Size = new Vector2(GridSize.X, GridSize.Y); Scale = new Vector2(Size.X / WallTex.Width, Size.Y / WallTex.Height); LoadLevel(); EndPositions = WaveManager.GenerateRandomList(32); PathFinder = new PathFinder(LevelGrid) { Diagonals = false, HeuristicEstimate = 100, SearchLimit = 99999 }; base.Initialize(); }
public override void LoadContent() { CurrGame = (PathDefenceGame)ScreenManager.Game; LevelManager = new LevelManager(CurrGame, this, levelName); LevelManager.Initialize(); WaveManager = new WaveManager(CurrGame, this, levelName); WaveManager.Initialize(); Background = new BackgroundGamePlayScreen(CurrGame, levelName); Background.Initialize(); TowerManager = new TowerManager(CurrGame, this); TowerManager.Initialize(); MoneyManager = new MoneyManager(CurrGame, this); MoneyManager.Initialize(); LiveManager = new LiveManager(CurrGame, this); LiveManager.Initialize(); PointsManager = new PointsManager(); PointsManager.Initialize(); GuiManager = new GuiManager(CurrGame, this); GuiManager.Initialize(); CreepDeleteList.AddRange(CreepList); AddCreepList.Clear(); CreepTimer.Start(); gameState = EGameState.Running; CurrGame.IsMouseVisible = true; base.LoadContent(); }
public Queue <Vector2> FindPath(Vector2 start) { var tmpList = new Queue <Vector2>(); CreepEnd = new Vector2(GridCount.X - 1, EndPositions.Dequeue()); if (EndPositions.Count == 0) { EndPositions = WaveManager.GenerateRandomList(32); } List <PathFinderNode> pathList = PathFinder.FindPath(start, CreepEnd); if (pathList != null) { for (int i = pathList.Count - 1; i >= 0; i--) { PathFinderNode node = pathList[i]; tmpList.Enqueue(new Vector2(node.X, node.Y)); } } return(tmpList); }