/// <summary> /// Remove an observer from the list /// </summary> /// <param name="obs">Removed observer object</param> public void unregister(ZRTSModel.Scenario.Observer obs) { if (this.observersList.Contains(obs)) { this.observersList.RemoveAt(this.observersList.IndexOf(obs)); } }
/// <summary> /// Check's if the player has enough resources to build the Building /// </summary> /// <param name="b">Building to be built</param> /// <param name="p">Player that is building</param> /// <returns>True if the player has enough resources, false if else</returns> public bool checkResources(Building b, ZRTSModel.Player.Player p) { if (b.stats.waterCost > p.player_resources[0]) return false; if (b.stats.lumberCost > p.player_resources[1]) return false; if (b.stats.foodCost > p.player_resources[2]) return false; if (b.stats.metalCost > p.player_resources[3]) return false; return true; }
/// <summary> /// Trigger event when victor state has changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void onVictory(object sender, ZRTSModel.EventHandlers.GameVictoryStateChangeEventArgs e) { if (e.victoryState == ZRTSModel.GameModel.GameModel.GameVictoryState.PlayerWin) { ((XnaUITestGame)Game).state = XnaUITestGame.gameState.Win; AudioManager.play("music", "victory"); } else if (e.victoryState == ZRTSModel.GameModel.GameModel.GameVictoryState.PlayerLost) { ((XnaUITestGame)Game).state = XnaUITestGame.gameState.Lose; AudioManager.play("music", "victory"); } }
/// <summary> /// Register a new observer /// </summary> /// <param name="obs">Observer object</param> public void register(ZRTSModel.Scenario.Observer obs) { this.observersList.Add(obs); System.Console.Out.WriteLine(obs.GetType().ToString()); // Check if the observer is View observer if (obs.GetType().ToString().Equals("ZRTS.ViewSelect")) { viewSelectObserver = (ZRTSModel.Scenario.ViewSelectObserver) obs; System.Console.Out.WriteLine("Found!!!"); } }
// TODO: Fix this to follow Visitor pattern. Just testing for now. public Bitmap getBitmapImproved(ZRTSModel.Tile tile) { if (tile.GetType() == typeof(Mountain)) { return bitmaps["mountain"]; } else if (tile.GetType() == typeof(Grass)) { return bitmaps["grass"]; } else if (tile.GetType() == typeof(Sand)) { return bitmaps["lightgrass"]; } return null; }
// TODO: Fix this to follow Visitor pattern. Just testing for now. public Bitmap getBitmapImproved(ZRTSModel.Tile tile) { if (tile.GetType() == typeof(Mountain)) { return new Bitmap(TILES_DIRECTORY + "mountain.png"); } else if (tile.GetType() == typeof(Grass)) { return new Bitmap(TILES_DIRECTORY + "grass.png"); } else if (tile.GetType() == typeof(Sand)) { return new Bitmap(TILES_DIRECTORY + "lightgrass.png"); } return null; }
/// <summary> /// Loading game world object for process /// </summary> /// <param name="world">target gameworld object</param> public void LoadMap(ZRTSModel.GameWorld.GameWorld world) { this.WorldMap = world; this.totalWidth = world.map.width; this.totalHeight = world.map.height; }
public void unselectEntity(ZRTSModel.Entities.Entity entity) { selected_entities.Remove(entity); }
public void selectEntity(ZRTSModel.Entities.Entity entity) { selected_entities.Add(entity); }
public void removeEntity(ZRTSModel.Entities.Entity entity) { entities.Remove(entity); }
public Unit createUnit(ZRTSModel.Player.Player owner, string unitType) { Unit unit = new Unit(owner, uFact.getStats(unitType)); return unit; }
/// <summary> /// Unregister the observer from the scenario /// </summary> /// <param name="obs">removed observer</param> public void unregisterObserver(ZRTSModel.Scenario.Observer obs) { scenario.unregister(obs); }
/// <summary> /// Loading game scenario object for process /// </summary> /// <param name="scene"></param> public void LoadScenario(ZRTSModel.Scenario.Scenario scene) { // Need not to load this scenario into View // Basically just return a command corresponding to the clicked icon // i.e. click at attack icon, will return attack command and then process the game logic in the gameloop inside ZRTS update(); this.scenario = scene; }
private CellComponent findEmptyNeighborCell(ZRTSModel.GameModel.GameModel model) { CellComponent insertCell = null; int width = model.GetScenario().GetGameWorld().GetMap().GetWidth(); int height = model.GetScenario().GetGameWorld().GetMap().GetWidth(); foreach (CellComponent cell in building.CellsContainedWithin) { int x = cell.X; int y = cell.Y; if (x < width - 1) { CellComponent c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x + 1, y); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } if (y < height - 1) { c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x + 1, y + 1); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } } if (y > 0) { c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x + 1, y); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } } } if (x > 0) { CellComponent c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x - 1, y); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } if (y < height - 1) { c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x - 1, y + 1); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } } if (y > 0) { c = model.GetScenario().GetGameWorld().GetMap().GetCellAt(x - 1, y); if (c.GetTile().Passable() && c.EntitiesContainedWithin.Count == 0) { insertCell = c; break; } } } } return insertCell; }
/// <summary> /// Loading game scenario object for process /// </summary> /// <param name="scene"></param> public void LoadScenario(ZRTSModel.Scenario.Scenario scene) { this.scenario = scene; }
public void insertEntity(ZRTSModel.Entities.Entity entity) { entities.Add(entity); }
/// <summary> /// Checking if unit is being selected /// </summary> /// <param name="u">Unit object</param> /// <returns>True if it is being selected</returns> private bool isUnitBeingSelected(ZRTSModel.Entities.Unit u) { return this.scenario.getPlayer().SelectedEntities.Count > 0 && this.scenario.getPlayer().SelectedEntities.Contains(u); }
public ChangeCellTileCommand(CellComponent cell, ZRTSModel.Tile tile) { targetCell = cell; targetTile = tile; }