private void initialize() { menus = new Dictionary <string, Menu>(); currentSelection = HexCoord.Zero; currentType = InputType.menu; hud = new HUD(Game); }
public override bool Equals(object obj) { HexCoord h = obj as HexCoord; if (h == null) { return(false); } return(x == h.x && y == h.y); }
private void parseMapXML(string fileName) { XmlReader reader = XmlReader.Create(fileName); while (reader.Read()) { if (!reader.IsStartElement()) { continue; } if (reader.Name != "terrain") { continue; } string terrainType = reader.GetAttribute("type"); Tile.TileType terrainEnum = (Tile.TileType)Enum.Parse(typeof(Tile.TileType), terrainType); Tile currentTile; reader.ReadToDescendant("coord"); do { reader.MoveToNextAttribute(); int X = Convert.ToInt32(reader.Value); reader.MoveToNextAttribute(); int Y = Convert.ToInt32(reader.Value); reader.MoveToNextAttribute(); int Z = Convert.ToInt32(reader.Value); string ownerString = reader.GetAttribute("owner"); Player owner = null; if (ownerString == "1") { owner = WoPR.players[0]; } if (ownerString == "2") { owner = WoPR.players[1]; } Debug.Print(X + " " + Y + " " + Z); HexCoord position = new HexCoord(X, Y, Z); /* CHANGED*/ currentTile = new Tile(WoPR, terrainEnum, position, owner);/* CHANGED*/ tiles.Add(position, currentTile); } while (reader.ReadToNextSibling("coord")); } }
public bool move(HexCoord a, HexCoord b) { Tile tempA; Tile tempB; if (tiles.TryGetValue(a, out tempA)) { if (tiles.TryGetValue(b, out tempB)) { if (tempA.getUnit() != null) { if (tempB.getUnit() == null) { tempB.unit = tempA.unit; tempA.unit = null; } } } } return(false); }
private void mapInput(button pressedButton) { // If the button pressed is A, confirm the selection and send it to the game. if (pressedButton == button.A) { Game.MapSelection(Game.currentMap.tiles[currentSelection]); return; } // Else assume a direction change is emminent if (pressedButton == button.B) { if (Game.subSelection != null) { foreach (Tile t in Game.subSelection) { t.highlight = Tile.Highlight.none; } } Game.activeTile = null; Game.subSelection = null; return; } HexCoord target = currentSelection; // Set the target to a niave location if (pressedButton == button.up) { target += HexCoord.Up; } if (pressedButton == button.down) { target += HexCoord.Down; } if (pressedButton == button.left) { target += HexCoord.DownLeft; } if (pressedButton == button.right) { target += HexCoord.UpRight; } // If the location is valid, make it the current selection and return if (Game.currentMap.tiles.ContainsKey(target)) { currentSelection = target; return; } // Else if the direction is to the side, try the other option target = currentSelection; if (pressedButton == button.left) { target += HexCoord.UpLeft; } if (pressedButton == button.right) { target += HexCoord.DownRight; } // And check to move the selection one last time if (Game.currentMap.tiles.ContainsKey(target)) { currentSelection = target; return; } }
private void initialize(Game game, TileType Type, HexCoord xyz, Player owner) { Game = (WoPR)game; position = xyz; this.owner = owner; unit = null; t = Type; highlight = Highlight.none; switch (Type) { case TileType.plain: name = "Plain"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 0; capturehp = 10; dBonus = .1; capturable = false; build = null; break; case TileType.water: name = "Water"; moveCosts = new int[] { -1, -1, 1 }; hpHealed = 0; capturehp = 10; dBonus = 0; capturable = false; build = null; break; case TileType.road: name = "Road"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 0; capturehp = 10; dBonus = 0; capturable = false; build = null; break; case TileType.forest: name = "Forest"; moveCosts = new int[] { 1, 2, 1 }; hpHealed = 0; capturehp = 10; dBonus = .3; capturable = false; build = null; break; case TileType.headquarters: name = "Headquarters"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 20; capturehp = 10; dBonus = .4; capturable = true; build = new Building(Building.buildType.headquarters); break; case TileType.barracks: name = "Barracks"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 20; capturehp = 10; dBonus = .4; capturable = true; build = new Building(Building.buildType.barracks); break; case TileType.garage: name = "Garage"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 20; capturehp = 10; dBonus = 0.4; capturable = true; build = new Building(Building.buildType.garage); break; case TileType.supplyDepot: name = "Supply Depot"; moveCosts = new int[] { 1, 1, 1 }; hpHealed = 20; capturehp = 10; dBonus = 0.6; capturable = true; build = new Building(Building.buildType.supplyDepot); break; } }
public Tile(Game game, TileType Type, HexCoord xyz, Player owner) { initialize(game, Type, xyz, owner); }
public Tile(Game game, TileType Type, HexCoord xyz) { initialize(game, Type, xyz, null); }