private void HitCell(ClickInfo hit_cell) { if (hit_cell != null && hit_cell.cell != null) { if (!IsDudeSelected()) { UnitImpl hit_dude = hit_cell.cell.cell.unit; if (hit_dude != null && !hit_dude.made_move && hit_dude.command_idx == gameboard_impl.cur_command_idx) //There is dude standing on this cell!!! { hit_cell.cell.SetStatus(CellData.Status.Selected); NewMovesAvailable(hit_dude.GetMoves(gameboard_impl)); } } else { List <Move> sel_move = GetSelectedMove(hit_cell); if (sel_move != null && sel_move.Count == 1) { sel_move[0].MakeMove(gameboard_impl); } ClearAvailableCells(); if (sel_move != null && sel_move.Count > 1) { NewMovesAvailable(sel_move); first_selected_cell = hit_cell.cell.cell; } } } }
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 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); }
//ToDo it could take a time. change dudes_list to Dictionary<UnitImpl, DudeData> public DudeData FindDude(UnitImpl search_unit) { if (search_unit.notificator != null && search_unit.notificator as DudeData != null) { return(search_unit.notificator as DudeData); } return(dudes_list.Find(dude_data => dude_data.unit == search_unit)); }
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 void UnitAdded(UnitImpl unit) { //ToDo get colors from somewhrere Color color = Color.clear; if (unit != null) { color = (unit.command_idx == 0 ? Color.red : Color.green); color.a = 0.5f; } GetComponentInChildren <SpriteRenderer>().color = color; }
public void UnitAdded(UnitImpl unit) { UnityEngine.Object model = Resources.Load(unit.modelName, typeof(GameObject)); if (model == null) { model = Resources.Load("Dude", typeof(GameObject)); //Default model } GameObject clone = Instantiate(model) as GameObject; DudeData dude = clone.GetComponent <DudeData>(); dude.Initialize(unit); dudes_list.Add(dude); }
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 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 void PlayHitAnimation(UnitImpl unit_to_kill) { if (gameObject.tag != "Dude") { ResetAnimations(false, false); //ToDo change only jit animation and so one } DudeData suffered_dude = GameBoard.instance.FindDude(unit_to_kill); if (suffered_dude.gameObject.tag != "Dude" && suffered_dude != this) { //ToDo fliendly fire ??? suffered_dude.ResetAnimations(unit.command_idx == suffered_dude.unit.command_idx, false); } if (cur_animation == null) { GetComponent <Animator> ().SetTrigger("hit"); } dude_to_kill = suffered_dude; first_strike = true; }
public void Initialize(UnitImpl new_unit) { this.unit = new_unit; }