public void show_move_range(int id) { Game_Unit unit = units[id]; check_update_unit_move_range(unit); Move_Range.UnionWith(unit.move_range); //Move_Range = Move_Range.Distinct().ToList(); //ListOrEquals //HashSet if (unit.is_active_team) { Talk_Range.UnionWith(unit.talk_range); //Talk_Range = Talk_Range.Distinct().ToList(); //ListOrEquals //HashSet } ValidateMoveArrow(); range_start_timer = 0; }
public void clear_move_range(bool resetMoveArrow = true) { lock (Move_Range_Lock) { Move_Range.Clear(); Attack_Range.Clear(); Staff_Range.Clear(); Talk_Range.Clear(); if (resetMoveArrow) { Move_Arrow.Clear(); Selected_Move_Total = 0; } } }
public void draw_basic_ranges(SpriteBatch sprite_batch, Texture2D move_range_texture, Texture2D attack_range_texture, Texture2D staff_range_texture, Texture2D talk_range_texture, Vector2 move_range_draw_vector, Color color) { lock (Move_Range_Lock) { int width = move_range_texture.Width / 4; int timer = Math.Min(range_start_timer, width - 1);//15); //Debug Rectangle rect = new Rectangle(((move_range_anim_count / 4) / 4) * width, ((move_range_anim_count / 4) % 4) * width + (width - timer), timer, timer); Vector2 display_loc = this.display_loc; // Move Range foreach (Vector2 loc in Move_Range.Except(talk_range)) { sprite_batch.Draw(move_range_texture, loc * TILE_SIZE + move_range_draw_vector - display_loc + new Vector2(0, width - timer), rect, color); } // Attack Range foreach (Vector2 loc in Attack_Range) { sprite_batch.Draw(attack_range_texture, loc * TILE_SIZE + move_range_draw_vector - display_loc + new Vector2(0, width - timer), rect, color); } // Staff Range foreach (Vector2 loc in Staff_Range) { sprite_batch.Draw(staff_range_texture, loc * TILE_SIZE + move_range_draw_vector - display_loc + new Vector2(0, width - timer), rect, color); } // Talk Range foreach (Vector2 loc in Talk_Range) { sprite_batch.Draw(talk_range_texture, loc * TILE_SIZE + move_range_draw_vector - display_loc + new Vector2(0, width - timer), rect, color); } } }
public void update_move_arrow() { if (Global.game_temp.menu_call || Global.game_state.is_menuing || (get_scene_map() != null && ((Scene_Map)Global.scene).changing_formation)) { return; } if (Global.game_system.Selected_Unit_Id == -1) { Move_Arrow.Clear(); } else { Game_Unit selected_unit = get_selected_unit(); int range = selected_unit.canto_mov; // If the cursor is in the move range if (Move_Range.Contains(Global.player.loc)) { if (Global.player.loc == selected_unit.loc) { Move_Arrow.Clear(); } else { int x = (int)Global.player.loc.X; int y = (int)Global.player.loc.Y; // Test if the cursor location already exists in the move arrow if (Move_Arrow.Count > 0) { // Test if the cursor is already at the endpoint if (x == Move_Arrow[Move_Arrow.Count - 1].X && y == Move_Arrow[Move_Arrow.Count - 1].Y) { return; } // Test if the cursor is somewhere else on the list bool already_on_list = false; int i; for (i = 0; i < Move_Arrow.Count - 1; i++) { if (Move_Arrow[i].X == x && Move_Arrow[i].Y == y) { already_on_list = true; break; } } if (already_on_list) { int j = Move_Arrow.Count - 1; while (j >= i) { Move_Arrow_Data loc = Move_Arrow[j]; Selected_Move_Total -= selected_unit.move_cost(new Vector2(loc.X, loc.Y)); if (Move_Arrow.Count >= 3) { Move_Arrow[Move_Arrow.Count - 2].Frame = unfix_arrow_turn(Move_Arrow[Move_Arrow.Count - 1].Frame, Move_Arrow[Move_Arrow.Count - 2].Frame); } Move_Arrow.pop(); j--; } } } bool adjacent = Move_Arrow.Count == 1; if (Move_Arrow.Count > 1) { Vector2 test_loc = new Vector2( Move_Arrow[Move_Arrow.Count - 1].X, Move_Arrow[Move_Arrow.Count - 1].Y); foreach (int[] test in new int[][] { new int[] { -1, 0 }, new int[] { 1, 0 }, new int[] { 0, -1 }, new int[] { 0, 1 } }) { if (test[0] + x == test_loc.X && test[1] + y == test_loc.Y) { adjacent = true; break; } } } if (!adjacent) { } Selected_Move_Total += selected_unit.move_cost(Global.player.loc); if (Selected_Move_Total > range || !adjacent) { reset_move_arrow(Global.player.loc, range); } else { Vector2 dir = new Vector2(x, y) - new Vector2( Move_Arrow[Move_Arrow.Count - 1].X, Move_Arrow[Move_Arrow.Count - 1].Y); Move_Arrow.Add(new Move_Arrow_Data(x, y, move_arrow_facing(dir))); Move_Arrow[Move_Arrow.Count - 2].Frame = fix_arrow_turn(Move_Arrow[Move_Arrow.Count - 1].Frame, Move_Arrow[Move_Arrow.Count - 2].Frame); } } } } }