public virtual void set_image(Game_Actor actor, Data_Equipment item) { if (item == null) { Icon.texture = null; Name.text = "-----"; } else { // Icon if (Global.content_exists(@"Graphics/Icons/" + item.Image_Name)) { Icon.texture = Global.Content.Load <Texture2D>(string.Format(@"Graphics/Icons/{0}", item.Image_Name)); } Icon.index = item.Image_Index; Icon.columns = (int)(Icon.texture.Width / Icon.size.X); // Name Name.text = item.Name; set_text_color(actor, item); } }
// Give All public void give_all() { Game_Actor actor = this.actor; if (!actor.CanGiveAny) { Global.game_system.play_se(System_Sounds.Buzzer); return; } for (int i = actor.num_items - 1; !Global.battalion.is_convoy_full && i >= 0; i--) { if (!actor.whole_inventory[i].blank_item && actor.can_give(actor.whole_inventory[i])) { Global.game_battalions.add_item_to_convoy(actor.items[i]); actor.discard_item(i); } } Global.game_system.play_se(System_Sounds.Confirm); refresh(); }
public string[] to_string(int team, int ai_priority, int ai_mission) { if (!Generic) { string data = ""; data += Actor_Id.ToString() + "|Actor ID\n"; data += team.ToString() + "|Team\n"; data += ai_priority.ToString() + "|AI Priority\n"; data += ai_mission.ToString() + "|AI Mission"; return(new string[] { "character", Identifier, data }); } else { Game_Actor actor = null; // I don't quite understand this, aren't all generics temporary actors //Yeti bool is_temp_actor = false; if (Global.game_actors.ContainsKey(Actor_Id)) { actor = Global.game_actors[Actor_Id]; } else if (Actor_Id >= 0) { is_temp_actor = true; actor = Global.game_actors[Actor_Id]; actor.class_id = Class_Id; for (int i = 1; i < Global.weapon_types.Count; i++) { if (actor.weapon_level_cap(Global.weapon_types[i]) > 0) { actor.wexp_gain(Global.weapon_types[i], WLvls[i - 1]); } } } string data = ""; data += Name.ToString() + "|Name\n"; data += Class_Id.ToString() + "|Class ID\n"; data += Gender.ToString() + "|Gender\n"; data += Level.ToString() + "|Level\n"; data += "0|Exp\n"; data += team.ToString() + "|Team\n"; data += Prepromote_Levels.ToString() + "|Prepromote Levels\n"; data += ((int)Build).ToString() + "|Build Type\n"; data += Con.ToString() + "|Con\n"; data += ai_priority.ToString() + "|AI Priority\n"; data += ai_mission.ToString() + "|AI Mission\n"; for (int i = 0; i < Global.ActorConfig.NumItems; i++) { int uses = -1; //Debug //if (Items[i].Id > 0) //{ // uses = Items[i].max_uses; //} data += ((int)Items[i].Type).ToString() + ", " + Items[i].Id.ToString() + ", " + uses.ToString() + "|Item " + (i + 1).ToString() + "\n"; } for (int i = 0; i < WLvls.Length; i++) { if (WLvls[i] > 0 && actor != null && !actor.has_rank(Global.weapon_types[i + 1])) { data += "0"; } else { data += WLvls[i].ToString(); } if (i + 1 < WLvls.Length) { data += ", "; } } if (is_temp_actor) { Global.game_actors.temp_clear(Actor_Id); } return(new string[] { "generic", Identifier, data }); } }
protected void initialize(Item_Data item_data, Game_Actor actor) { Data_Weapon weapon = item_data.to_weapon; int stats = !weapon.is_staff() ? 6 : 3; bool effective = false; foreach (int bonus in weapon.Effectiveness) { if (bonus != 1) { effective = true; stats++; break; } } for (int i = 0; i < stats; i++) { Labels.Add(new TextSprite()); Labels[Labels.Count - 1].loc = new Vector2((i % 3) * 60, (i / 3) * 16); if (i % 3 == 2) { Labels[Labels.Count - 1].loc += new Vector2(4, 0); } Labels[Labels.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Yellow"); } //@Yeti: handle weapon type replacement skills better than hardcoding bool knife = (actor != null && actor.has_skill("KNIFE") && weapon.main_type().Name == "Sword" && !weapon.is_magic()); bool crossbow = (actor != null && actor.has_skill("CROSSBOW") && weapon.main_type().Name == "Bow" && !weapon.Ballista()); Labels[0].text = weapon.type; if (knife) { Labels[0].text = "Knife"; } if (crossbow) { Labels[0].text = "Crossbow"; } Labels[1].text = "Rng"; Labels[2].text = "Wgt"; // If not a staff if (!weapon.is_staff()) { Labels[3].text = "Mgt"; Labels[4].text = "Hit"; Labels[5].text = "Crit"; } if (effective) { Labels[Labels.Count - 1].text = "Effective"; } // Rank Rank = new TextSprite(); Rank.loc = new Vector2(32, 0); if (crossbow) { Rank.loc.X += 16; } Rank.SetFont( weapon.Rank == Weapon_Ranks.None ? Config.UI_FONT : Config.UI_FONT + "L", Global.Content, "Blue", Config.UI_FONT); Rank.text = weapon.rank; // Range Stats.Add(new TextSprite()); Stats[Stats.Count - 1].loc = new Vector2(92, 0); Stats[Stats.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Blue"); int min_range = weapon.Min_Range; int max_range = weapon.Max_Range; if (knife && max_range == 1) { max_range = 2; } if (weapon.Mag_Range) { Stats[0].text = min_range.ToString() + "-Mg/2"; Stats[0].offset = new Vector2(15, 0); } else { if (min_range == max_range) { Stats[0].text = min_range.ToString(); } else { Stats[0].text = min_range.ToString() + "-" + max_range.ToString(); } Stats[0].offset = new Vector2(Stats[0].text.Length > 1 ? 12 : 0, 0); } for (int i = 2; i < stats; i++) { Stats.Add(new RightAdjustedText()); Stats[Stats.Count - 1].loc = new Vector2((i % 3) * 60 + 40, (i / 3) * 16); if (i % 3 == 2) { Stats[Stats.Count - 1].loc += new Vector2(4, 0); } Stats[Stats.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Blue"); } // Wgt Stats[1].text = weapon.Wgt.ToString(); if (actor != null) { int actor_wgt = actor.weapon_wgt(weapon); if (actor_wgt != weapon.Wgt) { int difference = actor_wgt - weapon.Wgt; Stat_Bonuses.Add(new TextSprite()); Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[1].loc + new Vector2(0, 0); Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont( Config.UI_FONT + "Bonus", Global.Content, difference <= 0 ? "Green" : "Red", Config.UI_FONT); Stat_Bonuses[Stat_Bonuses.Count - 1].text = difference.ToString(); } } // Stats if (!weapon.is_staff()) { Stats[2].text = weapon.Mgt.ToString(); if (knife) { Stat_Bonuses.Add(new TextSprite()); Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[2].loc + new Vector2(0, 0); Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont( Config.UI_FONT + "Bonus", Global.Content, "Red", Config.UI_FONT); Stat_Bonuses[Stat_Bonuses.Count - 1].text = "-3"; } Stats[3].text = weapon.Hit.ToString(); if (!knife) { Stats[3].offset.X = -((Stats[3].text.Length - 1) / 2) * 8; } if (knife) { Stat_Bonuses.Add(new TextSprite()); Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[3].loc - Stats[3].offset + new Vector2(0, 0); Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont( Config.UI_FONT + "Bonus", Global.Content, "Green", Config.UI_FONT); Stat_Bonuses[Stat_Bonuses.Count - 1].text = "+10"; } Stats[4].text = weapon.Crt == -1 ? "--" : weapon.Crt.ToString(); } if (effective) { for (int i = 0; i < weapon.Effectiveness.Length; i++) { if (weapon.Effectiveness[i] != 1) { Effectiveness_Icons.Add(new Icon_Sprite()); Effectiveness_Icons[Effectiveness_Icons.Count - 1].texture = Global.Content.Load <Texture2D>(@"Graphics/Icons/Class_Types"); Effectiveness_Icons[Effectiveness_Icons.Count - 1].size = new Vector2(16, 16); Effectiveness_Icons[Effectiveness_Icons.Count - 1].columns = 1; Effectiveness_Icons[Effectiveness_Icons.Count - 1].loc = new Vector2( 48 + ((Effectiveness_Icons.Count - 1) * 16), 32); Effectiveness_Icons[Effectiveness_Icons.Count - 1].index = i; Effectiveness_Multipliers.Add(new Effective_WT_Arrow()); Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].loc = new Vector2( 48 + ((Effectiveness_Icons.Count - 1) * 16), 32); Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].draw_offset = new Vector2(8, 8); Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].set_effectiveness(weapon.Effectiveness[i]); } } } }
public Help_Weapon_Data(Item_Data item_data, Game_Actor actor) { initialize(item_data, actor); }
public override void set_image(Game_Actor actor, Item_Data item_data) { set_image(actor, item_data, 1); }
public void set_item(Item_Data item_data, Game_Actor actor) { Weapon_Data = null; Help_Text = new TextSprite(); Help_Text.loc = new Vector2(8, 8); Help_Text.SetFont(Config.CONVO_FONT, Global.Content, "Black"); Help_Text.text = ""; Data_Equipment item = item_data.to_equipment; Help_String = item.Description.Replace("|", "\n"); int width, rows; // If weapon if (item.is_weapon) { // If staff if (!(item as Data_Weapon).is_staff()) { //Help_Text.loc += new Vector2(0, 32); //Debug width = 176; //160; rows = 2; } // Else else { //Help_Text.loc += new Vector2(0, 16); //Debug width = 160; rows = 1; } foreach (int bonus in (item as Data_Weapon).Effectiveness) { if (bonus != 1) { rows++; break; } } Help_Text.loc += new Vector2(0, rows * 16); Weapon_Data = new Help_Weapon_Data(item_data, actor); Weapon_Data.loc = new Vector2(8, 8); string[] text_ary = Help_String.Split('\n'); foreach (string str in text_ary) { width = Math.Max(Font_Data.text_width(str, Config.CONVO_FONT), width); } width = (width % 8 == 0 ? 0 : (8 - width % 8)) + width + 16; } else { width = 16; rows = 0; string[] text_ary = Help_String.Split('\n'); foreach (string str in text_ary) { width = Math.Max(Font_Data.text_width(str, Config.CONVO_FONT), width); } width = (width % 8 == 0 ? 0 : (8 - width % 8)) + width + 16; } size = new Vector2(width, (Math.Max(0, Help_String.Length == 0 ? 0 : Help_String.Split('\n').Length) + rows + 1) * 16); }
public bool is_temp_actor(Game_Actor actor) { return(temp_actors.Contains(actor)); }
public override void set_image( Game_Actor actor, Item_Data item_data, int stock, int price) { base.set_image(actor, item_data, -1, price); Uses.text = stock < 0 ? "--" : stock.ToString(); }
protected void set_images() { Game_Actor actor = unit.actor; // Face set_face(unit); // Map Sprite Map_Sprite.texture = Scene_Map.get_team_map_sprite(unit.team, unit.map_sprite_name); if (Map_Sprite.texture != null) { Map_Sprite.offset = new Vector2( (Map_Sprite.texture.Width / Map_Sprite.frame_count) / 2, (Map_Sprite.texture.Height / Map_Sprite.facing_count) - 8); } Map_Sprite.mirrored = unit.has_flipped_map_sprite; // Lives //Debug Blocked_Help_Indices.Remove("Lives"); if (Global.game_system.Style != Mode_Styles.Casual || !unit.lives_visible) { Blocked_Help_Indices.Add("Lives"); } // Rescue_Icon Rescue_Icon.visible = unit.is_rescued; if (unit.is_rescued) { Rescue_Icon.src_rect = new Rectangle( (Global.game_map.units[unit.rescued].team - 1) * (Rescue_Icon.texture.Width / Constants.Team.NUM_TEAMS), 0, Rescue_Icon.texture.Width / Constants.Team.NUM_TEAMS, Rescue_Icon.texture.Height); } // Pages foreach (Status_Page status_page in Pages) { status_page.set_images(unit); } // Refresh UI nodes foreach (StatusUINode node in TopPanelNodes) { node.refresh(unit); } // Get page UI nodes StatusNodes = new List <UINodeSet <StatusUINode> >(); StatusCursors = new List <UICursor <StatusUINode> >(); for (int i = 0; i < Pages.Count; i++) { var page_nodes = Pages[i].node_union(TopPanelNodes); StatusNodes.Add(new UINodeSet <StatusUINode>(page_nodes)); var cursor = new UICursor <StatusUINode>(StatusNodes.Last()); cursor.draw_offset = new Vector2(-14, 0); cursor.hide_when_using_mouse(false); StatusCursors.Add(cursor); } }
internal void optimize_inventory(Game_Actor actor) { // Store all items; if after getting an inventory the convoy is overfull, // readd old items to make space List <Item_Data> given_items = new List <Item_Data>(); for (int i = actor.num_items - 1; i >= 0; i--) { // Don't give items that can't be given var item = actor.whole_inventory[i]; if (!item.blank_item && actor.can_give(item)) { Data.Add(item); given_items.Insert(0, item); actor.discard_item(i); } } var weapon_types = Global.weapon_types .OrderByDescending(x => actor.weapon_levels(x)) .ToList(); var valid_items = Data.Where(x => actor.can_take(x)); var weapons = valid_items .Where(x => x.is_weapon && !x.to_weapon.is_staff()) .GroupBy(x => x.Id) .SelectMany(x => x.OrderByDescending(y => y.Uses)) .Where(x => actor.is_equippable(x.to_weapon)) .ToList(); var staves = valid_items .Where(x => x.is_weapon && x.to_weapon.is_staff()) .GroupBy(x => x.Id) .SelectMany(x => x.OrderByDescending(y => y.Uses)) .Where(x => actor.is_equippable(x.to_weapon)) .ToList(); var items = valid_items .Where(x => x.is_item) .GroupBy(x => x.Id) .SelectMany(x => x.OrderByDescending(y => y.Uses)) .Where(x => actor.is_useable(x.to_item)) .ToList(); // Vanilla weapon optimize_weapon(InventoryOptimizePasses.VanillaWeapon, actor, weapon_types, weapons); // Healing Items if (actor.can_dance_skill()) { optimize_item(InventoryOptimizePasses.DanceRing, actor, items); } bool staff = false; if (actor.can_staff()) { if (optimize_staff(InventoryOptimizePasses.HealingStaff, actor, weapon_types, staves)) { staff = true; } if (optimize_staff(InventoryOptimizePasses.StatusStaff, actor, weapon_types, staves)) { staff = true; } if (optimize_staff(InventoryOptimizePasses.UtilityStaff, actor, weapon_types, staves)) { staff = true; } } if (!staff) { // Ranged weapon optimize_weapon(InventoryOptimizePasses.RangedWeapon, actor, weapon_types, weapons); // Effect weapon optimize_weapon(InventoryOptimizePasses.EffectWeapon, actor, weapon_types, weapons); // Backup weapon if (actor.weapon_types().Count > 1 && actor.items.Any(x => x.is_weapon)) { WeaponType equipped = actor.items.First(x => x.is_weapon).to_weapon.main_type(); if (actor.items.Where(x => x.is_weapon).All(x => x.to_weapon.main_type() == equipped)) { optimize_weapon(InventoryOptimizePasses.BackupWeapon, actor, weapon_types, weapons); } } } else { if (!optimize_weapon(InventoryOptimizePasses.EffectWeapon, actor, weapon_types, weapons)) { optimize_weapon(InventoryOptimizePasses.RangedWeapon, actor, weapon_types, weapons); } } // Accessories optimize_item(InventoryOptimizePasses.Accessory, actor, items); // Healing Items optimize_item(InventoryOptimizePasses.HealingItem, actor, items); // If the convoy is overfull while (Data.Count > this.convoy_size && !actor.is_full_items && given_items.Any()) { var item = given_items[0]; given_items.RemoveAt(0); int index = Data.IndexOf(item); if (index != -1) { actor.gain_item(Data[index]); Data.RemoveAt(index); } } }
internal void optimize_inventory(Game_Actor actor) { Global.game_battalions.optimize_inventory(Convoy_Id, actor); }
internal void optimize_inventory(int id, Game_Actor actor) { Convoys[id].optimize_inventory(actor); }
private bool optimize_weapon(InventoryOptimizePasses pass, Game_Actor actor, List <WeaponType> weapon_types, List <Item_Data> weapons) { if (weapons.Any() && !actor.is_full_items) { var weapon_subset = weapons .Select(x => Tuple.Create(x, optimize_actor_weapon_value(pass, actor, x.to_weapon, weapon_types))) .OrderByDescending(x => x.Item2) .AsEnumerable(); int minimum = weapon_subset.First().Item2; var weapon_list = weapon_subset .Where(x => x.Item2 == minimum) .Select(x => x.Item1) .ToList(); weapon_list.Sort(delegate(Item_Data a, Item_Data b) { return(item_sort(b, a, false)); }); if (weapon_subset.Any()) { Item_Data best_match = weapon_list.First(); switch (pass) { case InventoryOptimizePasses.VanillaWeapon: break; // If the actor already has a weapon, and the best match is already // better as this type, skip it case InventoryOptimizePasses.RangedWeapon: case InventoryOptimizePasses.EffectWeapon: case InventoryOptimizePasses.BackupWeapon: bool already_has_better = actor.items.Any(x => { if (x.is_weapon && !x.to_weapon.is_staff()) { return(optimize_actor_weapon_value(pass, actor, x.to_weapon, weapon_types) > optimize_actor_weapon_value(pass, actor, best_match.to_weapon, weapon_types)); } else { return(false); } }); if (already_has_better) { return(false); } break; default: return(false); } actor.gain_item(best_match); Data.Remove(best_match); // Removes from weapon set weapons.Remove(best_match); weapon_types.Remove(best_match.to_weapon.main_type()); return(true); } } return(false); }
public override void set_image(Game_Actor actor, Data_Equipment item) { #if DEBUG throw new NotImplementedException(); #endif }