public void StartRoute(ModCity city, ModCity homeCity, IsoGrid isogrid, Path path) { // calculate a path for movement running = true; drawPath = path.PathList(homeCity.gridposition + new Vector2(2, 2), city.gridposition + new Vector2(2, 2), isogrid); pathStep = 1; walkingTarget = drawPath[pathStep]; gridPosition = drawPath[0]; position = isogrid.gridCoords( homeCity.position); }
public void Draw(SpriteBatch sbatch, Path path, GraphicsDevice graphicsDevice,IsoGrid isogrid) { if (running == true) { if (drawPaths == true) { path.Draw(graphicsDevice, sbatch, drawPath, Vector2.Zero, isogrid); } sbatch.Draw(tex, position + drawOffset, rect, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); } }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // grid & camera isoGrid = new IsoGrid(GraphicsDevice,Math.PI/6.0,30,new Vector2(100,100)); cameraPosition = isoGrid.cameraCentre(new Vector2(11,12),graphics); // initial camera position! scrollSpeed = 10.0f; // fonts font = Content.Load<SpriteFont>("font"); // cursor cursor = new Cursor(Content.Load<Texture2D>("cursor")); // HUD buttons = new List<Button> { }; // random seed random = new Random(); // spacescape tiles = new GridTileRegion(Content.Load<Texture2D>("starTiles"), new Vector2(-1, 0),new Vector2(100,100), isoGrid,random); // --- game objects ---------- // ships trader = new Ship("Trading Ship", Content.Load<Texture2D>("cargoShip")); transport = new Ship("Transport Ship", Content.Load<Texture2D>("cargoShip")); // materials metal = new Material("Metal"); rock = new Material("Rock"); gems = new Material("Gemstones"); // buildings dwellBlock = new Building("Dwelling Block",Content.Load<Texture2D>("building2"),3,new Vector2(0,0),new Vector2(1,1)); dwellBlockLarge = new Building("Large Dwelling Block",Content.Load<Texture2D>("building5"), 3, new Vector2(0, 0), new Vector2(1, 1)); govTower = new Building("Goverment Central Tower",Content.Load<Texture2D>("building3"), 1, new Vector2(0, 0), new Vector2(3, 3)); hugeGovTower = new Building("Huge Governemnt Central Tower", Content.Load<Texture2D>("hugeGovernmentTower"), 1, new Vector2(0, 0), new Vector2(12, 12)); Factory = new Building("Factory",Content.Load<Texture2D>("building4"), 2, new Vector2(0, 0), new Vector2(2, 1)); Arena = new Building("Entertainment Arena",Content.Load<Texture2D>("building1"), 1, new Vector2(0, 0), new Vector2(2, 2)); // cities modCity = new ModCity("Customisable City", Content.Load<Texture2D>("smallcity"), Content.Load<Texture2D>("smallcityHigh"), Content.Load<Texture2D>("smallcityClick"), new Vector2(20, 3),new Vector2(20, 85),8, isoGrid, new Tuple<float, float, float>(0.33f, 0.33f, 0.34f), new List<Ship> { trader }, new List<Material> { metal }, new List<Tuple<Building, int>> { new Tuple<Building, int>(dwellBlock, 4), new Tuple<Building, int>(dwellBlockLarge, 4), new Tuple<Building, int>(govTower, 1), new Tuple<Building, int>(Arena, 1),new Tuple<Building,int>(Factory,3) }, GraphicsDevice, random); modCity2 = new ModCity("Another Customisable City", Content.Load<Texture2D>("smallcity"), Content.Load<Texture2D>("smallcityHigh"), Content.Load<Texture2D>("smallcityClick"), new Vector2(30, 5),new Vector2(20, 85),8, isoGrid, new Tuple<float, float, float>(0.33f, 0.33f, 0.34f), new List<Ship> { trader }, new List<Material> { metal }, new List<Tuple<Building, int>> { new Tuple<Building, int>(dwellBlock, 4), new Tuple<Building, int>(dwellBlockLarge, 4), new Tuple<Building, int>(govTower, 1), new Tuple<Building, int>(Arena, 1), new Tuple<Building, int>(Factory, 3) }, GraphicsDevice, random); homeModCity = new ModCity("Home Customisable City", Content.Load<Texture2D>("smallcity"), Content.Load<Texture2D>("smallcityHigh"), Content.Load<Texture2D>("smallcityClick"), new Vector2(10, 10),new Vector2(20, 85),8, isoGrid, new Tuple<float, float, float>(0.33f, 0.33f, 0.34f), new List<Ship> { trader }, new List<Material> { metal }, new List<Tuple<Building, int>> { new Tuple<Building, int>(dwellBlock, 4), new Tuple<Building, int>(dwellBlockLarge, 4), new Tuple<Building, int>(govTower, 1), new Tuple<Building, int>(Arena, 1), new Tuple<Building, int>(Factory, 3) }, GraphicsDevice, random, true); hugeCity = new ModCity("Huge City", Content.Load<Texture2D>("hugecity"), Content.Load<Texture2D>("hugecityHigh"), Content.Load<Texture2D>("hugecityClick"), new Vector2(30, 30), new Vector2(-100,280), 90, isoGrid, new Tuple<float, float, float>(0.30f, 0.30f, 0.4f), new List<Ship> { trader }, new List<Material> { metal }, new List<Tuple<Building, int>> {new Tuple<Building, int>(hugeGovTower,1), new Tuple<Building, int>(dwellBlock, 1000), new Tuple<Building, int>(dwellBlockLarge, 400), new Tuple<Building, int>(govTower, 1), new Tuple<Building, int>(Arena, 50), new Tuple<Building, int>(Factory, 300) }, GraphicsDevice, random); fullCity = new ModCity("A Full City", Content.Load<Texture2D>("smallcity"), Content.Load<Texture2D>("smallcityHigh"), Content.Load<Texture2D>("smallcityClick"), new Vector2(10, 15), new Vector2(7, 90), 9, isoGrid, new Tuple<float, float, float>(0.33f, 0.33f, 0.34f), new List<Ship> { trader }, new List<Material> { metal }, new List<Tuple<Building, int>> { new Tuple<Building, int>(dwellBlock, 64)}, GraphicsDevice, random); modCities = new List<ModCity> { modCity, modCity2,homeModCity,hugeCity,fullCity }; universe = new DeadObject(Content.Load<Texture2D>("universe"), new Vector2(90, 94), isoGrid); uiball = new DeadUIObject(Content.Load<Texture2D>("rball"), new Vector2(10, 10)); // accesible region and paths reach = new ReachableArea(isoGrid, modCities); path = new Path(reach); }
public void Update(Cursor cursor, Matrix cameraTransform, List<Button> buttons, GraphicsDevice graphicsDevice, Path path,IsoGrid isogrid, City homeCity) { Vector2 translation = new Vector2(cameraTransform.Translation.X,cameraTransform.Translation.Y); screenPosition = position + translation; if (cursor.position.X >= screenPosition.X && cursor.position.X <= screenPosition.X + rect.Width && cursor.position.Y >= screenPosition.Y && cursor.position.Y <= screenPosition.Y + rect.Height) { tex = highTex; if (cursor.mstate.LeftButton == ButtonState.Pressed) { if (cursor.click == false) { cursor.click = true; clicked = true; if (player == false && tradeDeal == false) { tradeButton = new Button(new Vector2(10, 350), 150, 40, "Trade", graphicsDevice); buttons.Add(tradeButton); } } } } else { tex = lowTex; if (tradeButton != null) { if (tradeButton.pressed == true) { buttons.Clear(); tradeDeal = true; tradeButton = null; ships[0].StartRoute(this,homeCity,isogrid,path); } else if (cursor.mstate.LeftButton == ButtonState.Pressed) { if (cursor.click == false) { cursor.click = true; if (clicked == true) { clicked = false; buttons.Clear(); } } } } else if (cursor.mstate.LeftButton == ButtonState.Pressed) { if (cursor.click == false) { if (clicked == true) { cursor.click = true; clicked = false; buttons.Clear(); } } } } if (clicked == true) { tex = clickTex; } }