public override bool MakeMove(GameboardImpl gameboard) { UnitImpl new_unit = gameboard.cells[unit_place.board_x, unit_place.board_y].unit; UnitImpl new_unit_to_kill = gameboard.cells[unit_to_kill_place.board_x, unit_to_kill_place.board_y].unit; if (new_unit == null || new_unit_to_kill == null) { return(false); } if (steps > 0) { if (!base.MakeMove(gameboard)) { return(false); } } new_unit.made_move = true; if (new_unit.notificator != null) { new_unit.notificator.PlayHitAnimation(new_unit_to_kill); } GetDamage(gameboard, new_unit_to_kill, new_unit); if (!new_unit.isRangedAttack && new_unit.healing == 0 && new_unit_to_kill.hp > 0) { GetDamage(gameboard, new_unit, new_unit_to_kill); } return(true); }
public void LoadGame(GameboardImpl new_gameboard) { foreach (DudeData dude in dudes_list) { gameboard_impl.SetUnitPlace(dude.unit.oriented_cell, null); Destroy(dude.gameObject); } dudes_list.Clear(); GameboardCell[,] save_cells = gameboard_impl.cells; gameboard_impl = (GameboardImpl)new_gameboard; gameboard_impl.SetNotificator(this); gameboard_impl.cells = save_cells; foreach (CommandInfo command in gameboard_impl.commands) { foreach (UnitImpl unit in command.staff) { unit.oriented_cell.cell = gameboard_impl.cells[unit.oriented_cell.cell.board_x, unit.oriented_cell.cell.board_y]; gameboard_impl.SetUnitPlace(unit.oriented_cell, unit); UnitAdded(unit); } } DisplayCurrentCommand(); }
public override bool MakeMove(GameboardImpl gameboard) { UnitImpl new_unit = gameboard.cells[unit_place.board_x, unit_place.board_y].unit; GameboardCell new_cell = gameboard.cells[target_cell.board_x, target_cell.board_y]; if (new_unit == null || new_cell.unit != null) { return(false); } OrientedCell or_cell = new OrientedCell { cell = new_cell, orientation = orient }; new_unit.made_move = true; if (new_unit.notificator != null) { new_unit.notificator.PlayRunAnimation(this); } gameboard.SetUnitPlace(new_unit.oriented_cell, null); new_unit.oriented_cell = or_cell; gameboard.SetUnitPlace(new_unit.oriented_cell, new_unit); return(true); }
// Use this for initialization void Start() { gameboard_impl = new GameboardImpl(); gameboard_impl.SetNotificator(this); instance = this; int X_SIZE = gameboard_impl.cells.GetLength(0); int Y_SIZE = gameboard_impl.cells.GetLength(1); //ToDo move it to CellData float offset_x = ((Y_SIZE - 1) * CellData.cell_width + ((X_SIZE - 1) % 2) * CellData.cell_width / 2) / 2; float offset_y = ((X_SIZE - 1) * CellData.cell_radius * 1.5f) / 2; foreach (GameboardCell cell in gameboard_impl.cells) { if (cell.active) { float x = cell.board_y * CellData.cell_width + (cell.board_x % 2) * CellData.cell_width / 2 - offset_x; float y = cell.board_x * CellData.cell_radius * 1.5f - offset_y; Vector3 offset = new Vector3(x, 0.02f, y); GameObject cll_obj = Instantiate(cell_obj) as GameObject; CellData cell_data = cll_obj.GetComponent <CellData>(); cll_obj.transform.position = offset; cell_data.cell = cell; cell.notificator = cell_data; cells_list.Add(cell_data); } } for (gameboard_impl.cur_command_idx = 0; gameboard_impl.cur_command_idx < GameboardImpl.players_qty; ++gameboard_impl.cur_command_idx) { gameboard_impl.commands[gameboard_impl.cur_command_idx] = new CommandInfo(); } for (gameboard_impl.cur_command_idx = 0; gameboard_impl.cur_command_idx < GameboardImpl.players_qty; ++gameboard_impl.cur_command_idx) { Figure boss = DataBase.Bosses[0]; GameboardCell cur_cell = gameboard_impl.cells[gameboard_impl.cells.GetLength(0) / 2, (gameboard_impl.cur_command_idx == 0) ? 0 : (gameboard_impl.cells.GetLength(1) - 2)]; var boss_card = new CardImpl(boss); gameboard_impl.commands[gameboard_impl.cur_command_idx].hand.Add(boss_card); OnCardSelected(boss_card); HitCell(new ClickInfo(FindCell(cur_cell))); } ChangeCommand(); var command = gameboard_impl.commands [gameboard_impl.cur_command_idx]; foreach (UnitImpl unit in command.staff) { unit.made_move = true;//ToDo this is hack! } //gameboard_impl.GetCards () [0].GetMoves () [3].MakeMove (gameboard_impl); }
public override bool MakeMove(GameboardImpl gameboard) { UnitImpl new_unit = gameboard.cells[unit_place.board_x, unit_place.board_y].unit; if (new_unit == null) { return(false); } new_unit.made_move = true; return(true); }
public override bool MakeMove(GameboardImpl gameboard) { GameboardCell new_cell = gameboard.cells[target_cell.board_x, target_cell.board_y]; if (new_cell.unit != null) { return(false); } OrientedCell or_cell = new OrientedCell { cell = new_cell, orientation = orient }; gameboard.AddUnit(gameboard.commands[gameboard.cur_command_idx].hand[card_idx], or_cell); return(true); }
static protected void GetDamage(GameboardImpl gameboard_ref, UnitImpl me, UnitImpl who_hit_me) { int dammage = who_hit_me.strength; if (who_hit_me.command_idx != me.command_idx) { dammage -= me.armor; if (dammage < 0) { dammage = 0; } if (who_hit_me.isVampire && dammage > 0) { who_hit_me.hp += dammage; if (who_hit_me.hp > who_hit_me.defaultHP) { who_hit_me.hp = who_hit_me.defaultHP; } } me.hp -= dammage; } else { me.hp += who_hit_me.healing; //ToDo frendly fire ??? } if (me.hp > me.defaultHP) { me.hp = me.defaultHP; } if (me.hp <= 0) { me.hp = 0; gameboard_ref.SetUnitPlace(me.oriented_cell, null); gameboard_ref.commands [me.command_idx].staff.Remove(me); if (me.IsBoss) { gameboard_ref.commands [me.command_idx].is_won = false; gameboard_ref.is_game_finished = true; } } }
public void OnItemChanged() { Dropdown dropdown = saved_games.GetComponent <Dropdown> (); XmlSerializer serializer = new XmlSerializer(typeof(GameboardImpl)); string path = Path.Combine(Application.persistentDataPath, dropdown.options[dropdown.value].text); FileStream stream = new FileStream(path, FileMode.Open); DebugConsole.Log("Game loaded from the " + path); GameboardImpl new_gameboard = (GameboardImpl)serializer.Deserialize(stream); GameBoard.instance.LoadGame(new_gameboard); stream.Close(); Destroy(this.gameObject); }
public override bool MakeMove(GameboardImpl gameboard) { UnitImpl new_unit_to_kill = gameboard.cells[unit_to_kill_place.board_x, unit_to_kill_place.board_y].unit; if (new_unit_to_kill == null) { return(false); } UnitImpl new_unit = new UnitImpl(gameboard.commands [gameboard.cur_command_idx].hand [card_idx], gameboard.cur_command_idx, new_unit_to_kill.oriented_cell); gameboard.AddUnit(gameboard.commands[gameboard.cur_command_idx].hand[card_idx], null); if (new_unit_to_kill.notificator != null) { new_unit_to_kill.notificator.PlayBlockAnimation(isHealing); } GetDamage(gameboard, new_unit_to_kill, new_unit); return(true); }
public static void SaveGame(GameboardImpl gameboard) { string path = null; int count = 1; do { path = Path.Combine(Application.persistentDataPath, count + ".xml"); ++count; }while(File.Exists(path)); XmlSerializer serializer = new XmlSerializer(typeof(GameboardImpl)); DebugConsole.Log("Game saved to the " + path); Encoding encoding = Encoding.GetEncoding("UTF-8"); using (StreamWriter sw = new StreamWriter(path, false, encoding)) { serializer.Serialize(sw, gameboard); } }
public override OrientedCell GetUnitPlace(GameboardImpl gameboard) { return(unit_place == null ? null : gameboard.cells[unit_place.board_x, unit_place.board_y].unit.oriented_cell); }
public override OrientedCell GetTargetCell(GameboardImpl gameboard) { return(GetUnitPlace(gameboard)); }
public abstract OrientedCell GetUnitPlace(GameboardImpl gameboard);
public abstract OrientedCell GetTargetCell(GameboardImpl gameboard);
// Modifies gameboard according to the move. // Returns falce if such move is not possible for yhis board public abstract bool MakeMove(GameboardImpl gameboard);
public override OrientedCell GetTargetCell(GameboardImpl gameboard) { return(new OrientedCell { cell = gameboard.cells[target_cell.board_x, target_cell.board_y], orientation = orient }); }