private void btnAdd_Click(object sender, EventArgs e) { Model.Unit u = new Model.Unit(txtID.Text, txtName.Text); Controller.Connector.insertUnit(u); MessageBox.Show("Thêm mới thành công đơn vị " + txtID.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private SupportPanel MakeSiblingSupportPanel(Model.Unit siblingUnit) { var panel = new SupportPanel(); panel.LoadSiblingSupport(_unit, siblingUnit); return(panel); }
private SupportPanel MakeChildSupportPanel(Model.Unit childUnit) { var panel = new SupportPanel(); panel.LoadChildSupport(_unit, childUnit); return(panel); }
// TODO: Revert Corrin // Remove marriage byte (otherwise paralogue 2 stays available) /// <summary> /// Level a unit, giving them the average gains that their growth rates would dictate /// </summary> public void LevelUp(Model.Unit unit, int levels) { var characterGrowthRates = Data.Database.Characters.GetByID(unit.CharacterID).GrowthRates; var classGrowthRates = Data.Database.Classes.GetByID(unit.ClassID).GrowthRates; var combinedGrowthRates = characterGrowthRates + classGrowthRates; int hp; int str; int mag; int skl; int spd; int lck; int def; int res; hp = str = mag = skl = spd = lck = def = res = 0; for (var i = 0; i < levels; i++) { hp += combinedGrowthRates.HP; str += combinedGrowthRates.Str; mag += combinedGrowthRates.Mag; skl += combinedGrowthRates.Skl; spd += combinedGrowthRates.Spd; lck += combinedGrowthRates.Lck; def += combinedGrowthRates.Def; res += combinedGrowthRates.Res; } unit.Level += (byte)levels; unit.GainedStats.HP += (sbyte)(hp / 100); unit.GainedStats.Str += (sbyte)(str / 100); unit.GainedStats.Mag += (sbyte)(mag / 100); unit.GainedStats.Skl += (sbyte)(skl / 100); unit.GainedStats.Spd += (sbyte)(spd / 100); unit.GainedStats.Lck += (sbyte)(lck / 100); unit.GainedStats.Def += (sbyte)(def / 100); unit.GainedStats.Res += (sbyte)(res / 100); }
private SupportPanel MakeMainSupportPanel(Model.Unit partnerUnit, int supportIndex) { var panel = new SupportPanel(); panel.LoadMainSupport(_unit, partnerUnit, supportIndex); return(panel); }
/// <summary> /// Calculate base stats for a unit. /// </summary> /// <param name="character"></param> /// <returns></returns> public static Model.Stat CalculateBaseStats(Model.Unit character) { Model.Stat baseStats = new Model.Stat(); var characterData = Data.Database.Characters.GetByID(character.CharacterID); var classData = Data.Database.Classes.GetByID(character.ClassID); if (characterData == null || classData == null) { return(null); } // Corrin and Bond units if (character.CorrinName != null) { if (Enum.IsDefined(typeof(Enums.Stat), character.Boon) && Enum.IsDefined(typeof(Enums.Stat), character.Bane)) { return(characterData.BaseStats + Data.Database.Stats.GetByID(character.Boon).BaseBoonModifiers + Data.Database.Stats.GetByID(character.Bane).BaseBaneModifiers + classData.BaseStats); } else { return(null); } } else // All other units { return(characterData.BaseStats + classData.BaseStats); } }
public void LoadSiblingSupport(Model.Unit unit, Model.Unit siblingUnit) { _unit = unit; _siblingUnit = siblingUnit; BindEventsSibling(); PopulateControlsSibling(); }
public void LoadChildSupport(Model.Unit unit, Model.Unit childUnit) { _unit = unit; _childUnit = childUnit; BindEventsChild(); PopulateControlsChild(); }
private void ShowInfo(int _id) { BLL.Unit bll = new BLL.Unit(); Model.Unit model = bll.GetModel(_id); txtName.Text = model.Name; txtRemark.Text = model.Remark; }
private void DeselectUnit() { _Map.ClearPath(); _GameManager.GetUnitObject(_SelectedUnit).HideUI(); _SelectedUnit = null; _UnitPurchasePanel.gameObject.SetActive(false); }
public Traits(Model.Unit unit) { _unit = unit; InitializeComponent(); PopulateControls(); BindEvents(); }
public UnitEditViewModel(Model.Unit unit) { this.id = unit.UnitId; this.name = unit.Name; this.symbol = unit.Symbol; Edit = new Command(EditUnit); }
private void InstantiateUnit(Unit prefab, Model.Unit modelUnit) { var unitInstance = Instantiate(prefab, Map.ConvertToWorldPos(_Map.ModelMap.GetUnitPos(modelUnit)), Quaternion.identity, transform); unitInstance.Initialize(modelUnit, this, _UIManager, _Map); _Units.Add(unitInstance); modelUnit.Died.AddSubscriber(() => Unit_Died(modelUnit)); }
/// <summary> /// Load support level from raw support bytes. /// </summary> /// <param name="unit"></param> /// <param name="supportIndex">Support index.</param> public void LoadMainSupport(Model.Unit unit, Model.Unit partnerUnit, int supportIndex) { _unit = unit; _partnerUnit = partnerUnit; _supportIndex = supportIndex; BindEventsMain(); PopulateControlsMain(); }
public Supports(Model.ChapterSave chapterSave, Model.Unit unit) { _chapterSave = chapterSave; _unit = unit; InitializeComponent(); SetTitle(); BindEvents(); }
public static void Undeploy(Model.Unit unit) { if (unit.UnitBlock == Enums.UnitBlock.Deployed) { unit.UnitBlock = Enums.UnitBlock.Living; unit.Position_FromLeft = Model.Unit.PositionIfNotDeployed; unit.Position_FromTop = Model.Unit.PositionIfNotDeployed; unit.RawDeployedUnitInfo = Model.Unit.GetEmptyDeployedInfoBlock(); } }
public void DeselectUnit() { lstLiving.SelectedItem = null; lstDead.SelectedItem = null; _selectedUnit = null; var message = "No unit is selected."; _unitViewerBlanket.SetMessage(message); _unitViewerBlanket.Cover(); }
public void SelectUnit(Model.Unit unit) { if (lstLiving.Items.IndexOf(unit) > -1) { lstLiving.SelectedItem = unit; } else if (lstDead.Items.IndexOf(unit) > -1) { lstDead.SelectedItem = unit; } }
private void SelectDeadUnit(object sender, EventArgs e) { var unit = (Model.Unit)lstDead.SelectedItem; if (unit == null) { return; } _selectedUnit = unit; LoadUnit(unit); lstLiving.ClearSelected(); }
private void ModelMap_UnitBanished(Model.Unit unit) { if (unit == null) { throw new System.ArgumentNullException(nameof(unit)); } if (ModelUnit == unit) { DestroySelf(); } }
/// <summary> /// Calculate the true stats for a character /// </summary> /// <returns>A character's true stats</returns> public static Model.Stat CalculateTrueStats(Model.Unit character) { Model.Stat baseStats = CalculateBaseStats(character); if (baseStats != null) { return(baseStats + character.GainedStats); } else { return(null); } }
/// <summary> /// Method for calculating of mana-pool in accordance to the mana-graphic /// See "CalculateHp" for more comments within the method /// </summary> /// <param name="unit">Unit object</param> /// <returns></returns> private int CalculateMana(Model.Unit unit) { float manaWidth = 169; if (unit.CurrentMana < unit.TotalMana) { float percentManaLeft = (unit.CurrentMana / unit.TotalMana); manaWidth = percentManaLeft * manaWidth; return((int)manaWidth); } return((int)manaWidth); }
private void ModelMap_UnitSpawned(Model.Unit unit, Model.Map.IUnitTemplate template) { if (unit == null) { throw new System.ArgumentNullException(nameof(unit)); } if (template == null) { throw new System.ArgumentNullException(nameof(template)); } InstantiateUnit((Unit)template, unit); }
public async Task OnTileLeftClick(Tile tile) { if (tile == null) { throw new System.ArgumentNullException(nameof(tile)); } if (DisableUIInteraction) { return; } if (_SpawnedUnit != null) { _GameManager.DebugSpawnUnit(_SpawnedUnit, tile.ModelTile, _SpawnedUnitFaction); _SpawnedUnit = null; _SpawnedUnitFaction = null; } else if (_SelectedUnit == null) { if (tile.ModelTile.Unit != null && tile.ModelTile.Unit.Faction == _GameManager.Game.CurrentTurnFaction) { _SelectedUnit = tile.ModelTile.Unit; var unitObject = _GameManager.GetUnitObject(_SelectedUnit); unitObject.ShowUI(); _UnitInfoPanel.gameObject.SetActive(true); _UnitInfoPanel.Setup(unitObject); } } else if (_SelectedUnit == tile.ModelTile.Unit) { DeselectUnit(); } else if (tile.ModelTile.Unit != null) { if (_SelectedUnit.CanAttack(tile.ModelTile.Unit)) { await _SelectedUnit.Attack(tile.ModelTile.Unit); } } else { await _SelectedUnit.Move(tile.ModelTile); _Map.ClearPath(); } }
private bool DoAdd() { bool result = false; Model.Unit model = new Model.Unit(); BLL.Unit bll = new BLL.Unit(); model.Name = txtName.Text; model.Remark = txtRemark.Text; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加计量单位:" + model.Name); //记录日志 result = true; } return(result); }
//Metod för utritning av konversations-text public void DrawNPCText(Model.Unit a_friend, bool a_isQuestDialog) { //TextRektangel m_textRect = m_camera.VisualizeRectangle(new Rectangle(a_friend.ThisUnit.Bounds.X, a_friend.ThisUnit.Bounds.Y, 300, 50)); //Visualiserar mapobjektets rektangel m_speakerRect = m_camera.VisualizeRectangle(new Rectangle(a_friend.ThisUnit.Bounds.X, a_friend.ThisUnit.Bounds.Y, a_friend.ThisUnit.Bounds.Width, a_friend.ThisUnit.Bounds.Height)); //Hämtar meddelande string message = null; int state = 0; //Om det är en QuestDialog if (a_isQuestDialog) { message = GetQuestMessage(m_textRect); } //Annars en vanlig dialog else { //Om spelet passerat q3 befinner sig dialogstaten i state 1, annars 0 if (m_questSystem.CurrentQuest.Id > 2) { state = 1; } message = GetMessage(a_friend.UnitId, state); } //Om textrektangeln överlappar med talaren flyttas den i yled if (m_textRect.Intersects(m_speakerRect)) { int overlap = m_textRect.Bottom - m_speakerRect.Top; m_textRect.Y -= overlap; } //Ritar textruta + text if (m_drawDialog) { m_spriteBatch.Draw(m_dialogueWindow, m_textRect, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f); m_spriteBatch.DrawString(m_spriteFont, message, new Vector2(m_textRect.X + 12, m_textRect.Y + 12), Color.White); if (a_isQuestDialog) { DrawQuestButtons(); } } }
/// <summary> /// Method for rendering of conversation text /// </summary> /// <param name="targetNpc">The source npc unit</param> /// <param name="isQuestDialog">Type of converation</param> public void DrawNPCText(Model.Unit targetNpc, bool isQuestDialog) { //Text rectangle _textRect = _camera.VisualizeRectangle(new Rectangle(targetNpc.ThisUnit.Bounds.X, targetNpc.ThisUnit.Bounds.Y, 300, 50)); //Vizualizing the map-objects rectangle _speakerRect = _camera.VisualizeRectangle(new Rectangle(targetNpc.ThisUnit.Bounds.X, targetNpc.ThisUnit.Bounds.Y, targetNpc.ThisUnit.Bounds.Width, targetNpc.ThisUnit.Bounds.Height)); string message = null; int state = 0; //Quest dialog if (isQuestDialog) { message = GetQuestMessage(_textRect); } //Standard dialog else { //If the game have passed the 3rd quest the dialog-state is 1, else 0 if (_questSystem.CurrentQuest.Id > 2) { state = 1; } message = GetMessage(targetNpc.UnitId, state); } //Moving the text box verticaly if it overlaps the speaker if (_textRect.Intersects(_speakerRect)) { int overlap = _textRect.Bottom - _speakerRect.Top; _textRect.Y -= overlap; } //Drawing textbox and text if (_drawDialog) { _spriteBatch.Draw(_dialogueWindow, _textRect, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f); _spriteBatch.DrawString(_spriteFont, message, new Vector2(_textRect.X + 12, _textRect.Y + 12), Color.White); if (isQuestDialog) { DrawQuestButtons(); } } }
private bool DoEdit(int _id) { bool result = false; BLL.Unit bll = new BLL.Unit(); Model.Unit model = bll.GetModel(_id); model.Name = txtName.Text; model.Remark = txtRemark.Text; if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改计量单位:" + model.Name); //记录日志 result = true; } return(result); }
public void Initialize(Model.Unit unit, GameManager gameManager, UIManager uiManager, Map map) { _GameManager = gameManager != null ? gameManager : throw new System.ArgumentNullException(nameof(gameManager)); _UIManager = uiManager != null ? uiManager : throw new System.ArgumentNullException(nameof(uiManager)); _Map = map != null ? map : throw new System.ArgumentNullException(nameof(map)); ModelUnit = unit ?? throw new System.ArgumentNullException(nameof(unit)); ModelUnit.MovingAlongPath.AddSubscriber(ModelUnit_MovingAlongPath); ModelUnit.Attacked.AddSubscriber(ModelUnit_Attacked); ModelUnit.TookHit += ModelUnit_TookHit; ModelUnit.Healed += ModelUnit_Healed; ModelUnit.Died.AddSubscriber(ModelUnit_Died); map.ModelMap.UnitBanished += ModelMap_UnitBanished; SetOwnerColor(); }
/// <summary> /// Calculate stat caps for a character /// </summary> /// <returns>Character's stat caps</returns> public static Model.Stat CalculateStatCaps(Model.Unit character) { if (!Enum.IsDefined(typeof(Enums.Character), character.CharacterID) || !Enum.IsDefined(typeof(Enums.Class), character.ClassID)) { return(null); } var characterData = Data.Database.Characters.GetByID(character.CharacterID); var classData = Data.Database.Classes.GetByID(character.ClassID); if (character.CorrinName != null) // Corrin and bond units { if (Enum.IsDefined(typeof(Enums.Stat), character.Boon) && Enum.IsDefined(typeof(Enums.Stat), character.Bane)) { return(classData.MaximumStats + Data.Database.Stats.GetByID(character.Boon).MaxBoonModifiers + Data.Database.Stats.GetByID(character.Bane).MaxBaneModifiers + character.StatueBonusStats); } else { return(null); } } else if (characterData.IsChild) // Children { var childBonusStats = new Model.Stat { HP = 0, Str = 1, Mag = 1, Skl = 1, Spd = 1, Lck = 1, Def = 1, Res = 1 }; return(classData.MaximumStats + Data.Database.Characters.GetByID(character.FatherID).Modifiers + Data.Database.Stats.GetByID(character.FatherBoon).MaxBoonModifiers + Data.Database.Stats.GetByID(character.FatherBane).MaxBaneModifiers + Data.Database.Characters.GetByID(character.MotherID).Modifiers + Data.Database.Stats.GetByID(character.MotherBoon).MaxBoonModifiers + Data.Database.Stats.GetByID(character.MotherBane).MaxBaneModifiers + childBonusStats + character.StatueBonusStats); } else // All other units { return(classData.MaximumStats + characterData.Modifiers + character.StatueBonusStats); } }