public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; Content.RootDirectory = "Content"; MapHandler.GetInstance().SetDebug(false); m_TreeList = new List<TreeEntity>(); //m_TreeList.Add(new TreeEntity(new Vector2(2 * 64, 4 * 64/4 ))); //m_TreeList.Add(new TreeEntity(new Vector2(9 * 64 + 32, 7 * 64 / 4))); //m_TreeList.Add(new TreeEntity(new Vector2(0 * 64, 0 * 64 / 4))); //m_TreeList.Add(new TreeEntity(new Vector2(1 * 64, 10 * 64 / 4))); m_LumberMills = new List<LumberMill>(); //m_LumberMills.Add(new LumberMill(new Vector2(8 * 64, 8 * 64/4))); m_mouseSource = new Rectangle(0, 0, 19, 19); m_TestLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64)); m_WaterLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64)); GenerateRandomMap(); //for (int i = 4; i < 6; i++) //{ // for (int j = 0; j < 22; j++) // m_TestLayer.SetTileToSolid(i, j, m_bSetTilesToSolid); //} //m_TestLayer.SetTileToSolid(5, 21, false); //m_TestLayer.SetTileToSolid(4, 0, false); MapHandler.GetInstance().SetActiveLayer(m_TestLayer); SetTilesToSolid(); m_TestTile = new MapTile(new Vector2(0, 0), 0, new Vector2(64,64)); m_GoblinList = new List<GoblinLumberjack>(); m_Goblin = new GoblinLumberjack(ENTITY_COLOR.RED, new Vector2(5 * 64, 12 * 64/4), DIRECTION.DOWN); m_GoblinList.Add((GoblinLumberjack)m_Goblin); m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE, MapHandler.GetInstance().GetTilePosition(new Vector2(0,0)), DIRECTION.DOWN)); m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE, MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN)); m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE, MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN)); m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE, MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN)); GameEntity tempGobling; m_goblinSquad = new CompositeSquad(m_Goblin); tempGobling = m_GoblinList[1]; m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling)); tempGobling = m_GoblinList[2]; m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling)); tempGobling = m_GoblinList[3]; m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling)); tempGobling = m_GoblinList[4]; m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling)); m_FormationList = new List<Formation>(); m_FormationList.Add(FormationFactory.GetInstance().GetBoxFormation()); m_FormationList.Add(FormationFactory.GetInstance().GetDiamondFormation()); m_FormationList.Add(FormationFactory.GetInstance().GetFightingVFormation()); m_FormationList.Add(FormationFactory.GetInstance().GetLineFormation()); m_FormationList.Add(FormationFactory.GetInstance().GetShieldFormation()); //((GoblinLumberjack)m_Goblin).SetTargetLumberMill(m_LumberMills[0]); m_goblinSquad.SetFormation(m_FormationList[m_currFormationIndex]); m_Goblin.SetEntitySpeed(new Vector2(1, 1)); m_mapList = new List<List<int>>(); m_mapList.Add(new List<int>() { }); //List<Vector2> adjacents = MapHandler.GetInstance().GetAdjacentsToTile(new Vector2(5, 5)); //for (int i = 0; i < adjacents.Count; i++) //{ // Console.WriteLine(adjacents[i]); //} //AStarPathFinder finder = new AStarPathFinder(); //PathNode m_path = finder.FindPath(new Vector2(0, 0), new Vector2(3, 2)); //AStarNode node = null; //if(m_path != null) //node = (AStarNode) m_path; //int counter = 0; //while (node != null) //{ // Console.WriteLine("" + counter + ": " + node.GetNodePosition()); // counter++; // node = (AStarNode)node.GetNextNode(); //} }
public Game1() { graphics = new GraphicsDeviceManager(this); #region These aren't the droids you are looking for. graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; Content.RootDirectory = "Content"; m_TreeList = new List<TreeEntity>(); m_TreeList.Add(new TreeEntity(new Vector2(2 * 64, 4 * 24))); m_TreeList.Add(new TreeEntity(new Vector2(9 * 64 + 32, 7 * 24))); m_TreeList.Add(new TreeEntity(new Vector2(0 * 64, 0 * 24))); m_TreeList.Add(new TreeEntity(new Vector2(1 * 64, 10 * 24))); m_LumberMills = new List<LumberMill>(); m_LumberMills.Add(new LumberMill(new Vector2(8 * 64, 8 * 24))); m_mouseSource = new Rectangle(0, 0, 19, 19); m_TestLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64)); m_TestTile = new MapTile(new Vector2(0, 0), 0, new Vector2(64,64)); #endregion m_Gobling = new GoblinLumberjack(ENTITY_COLOR.RED, new Vector2(64 * 8, 0), DIRECTION.DOWN); #region These aren't the droids you are looking for. ((GoblinLumberjack)m_Gobling).SetTargetLumberMill(m_LumberMills[0]); m_Gobling.SetEntitySpeed(new Vector2(1, 1)); m_mapList = new List<List<int>>(); m_mapList.Add(new List<int>() { }); #endregion }
public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; Content.RootDirectory = "Content"; m_TreeList = new List<TreeEntity>(); m_TreeList.Add(new TreeEntity(new Vector2(2 * 64, 4 * 64/4 ))); m_TreeList.Add(new TreeEntity(new Vector2(9 * 64 + 32, 7 * 64 / 4))); m_TreeList.Add(new TreeEntity(new Vector2(0 * 64, 0 * 64 / 4))); m_TreeList.Add(new TreeEntity(new Vector2(1 * 64, 10 * 64 / 4))); m_LumberMills = new List<LumberMill>(); m_LumberMills.Add(new LumberMill(new Vector2(8 * 64, 8 * 64/4))); m_mouseSource = new Rectangle(0, 0, 19, 19); m_TestLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64)); m_WaterLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64)); GenerateRandomMap(); //for (int i = 4; i < 6; i++) //{ // for (int j = 0; j < 22; j++) // m_TestLayer.SetTileToSolid(i, j, m_bSetTilesToSolid); //} //m_TestLayer.SetTileToSolid(5, 21, false); //m_TestLayer.SetTileToSolid(4, 0, false); MapHandler.GetInstance().SetActiveLayer(m_TestLayer); SetTilesToSolid(); m_TestTile = new MapTile(new Vector2(0, 0), 0, new Vector2(64,64)); m_Gobling = new GoblinLumberjack(ENTITY_COLOR.RED, new Vector2(64 * 8, 0), DIRECTION.DOWN); ((GoblinLumberjack)m_Gobling).SetTargetLumberMill(m_LumberMills[0]); m_Gobling.SetEntitySpeed(new Vector2(1, 1)); m_mapList = new List<List<int>>(); m_mapList.Add(new List<int>() { }); //List<Vector2> adjacents = MapHandler.GetInstance().GetAdjacentsToTile(new Vector2(5, 5)); //for (int i = 0; i < adjacents.Count; i++) //{ // Console.WriteLine(adjacents[i]); //} //AStarPathFinder finder = new AStarPathFinder(); //PathNode m_path = finder.FindPath(new Vector2(0, 0), new Vector2(3, 2)); //AStarNode node = null; //if(m_path != null) //node = (AStarNode) m_path; //int counter = 0; //while (node != null) //{ // Console.WriteLine("" + counter + ": " + node.GetNodePosition()); // counter++; // node = (AStarNode)node.GetNextNode(); //} }
/// <summary> /// Adds a tile a to the layer. /// The position on the layer is caluclated from /// the X,Y position specified. /// </summary> /// <param name="tileID">ID from the tileset.</param> /// <param name="position">Position in pixels where to place this tile.</param> public void AddTile(int tileID, Vector2 position) { if (position == null) return; int x = (int)(position.X); int y = (int)(position.Y); Vector2 newPosition = GetFinalPosition(position); MapTile tile = new MapTile(newPosition, tileID, m_vTileSize); tile.SetTileSet(m_tileSetRef); m_tile2DList[y][x] = tile; }