private void CreateStatusContent(BattlerSerializable battler) { foreach (Transform child in statusContent.transform) { Destroy(child.gameObject); } CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.HP, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.MP, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.ATK, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.DEF, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.MAT, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.MDF, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.SPD, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.HIT, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.DODGE, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.CRIT, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.EFC, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.RES, battler); CreateTextContentInstantiate().GetComponent <StatusContentBehaviour>() .Create(StatusTypeEnum.StatusType.HOS, battler); }
/// <summary> /// 回避判定 /// 味方に対するスキル、もしくは必中でない限り回避チェックを行う /// 物理属性が含まれる場合は命中率-回避率 /// 魔法属性のみの場合は100%-魔法回避率 /// </summary> /// <param name="skill"></param> /// <param name="fromBattler"></param> /// <param name="toBattler"></param> /// <returns></returns> private static bool HitCheck(string skillId, BattlerSerializable fromBattler, BattlerSerializable toBattler) { var skill = SkillsDicionary.GetSkillById(skillId); if (skill.target == SkillConsts.MEMBER || skill.target == SkillConsts.ALL_MEMBER || skill.target == SkillConsts.RANDOM_MEMBER) { return(true); } float hitRate = fromBattler.parameter.hit; hitRate = hitRate * (skill.effect.hitRate / 100); if (skill.effect.elements.Contains(SkillConsts.ELEMENTS_PHYSICS)) { hitRate -= toBattler.parameter.dodge; } else if (skill.effect.elements.Contains(SkillConsts.ELEMENTS_MAGIC)) { hitRate -= toBattler.parameter.magicDodge; } if (Random.Range(0, 100) < hitRate) { return(true); } return(false); }
public void Create(StatusTypeEnum.StatusType type, BattlerSerializable battler) { switch (type) { case StatusTypeEnum.StatusType.HP: SetValue("HP", $"{battler.parameter.hp} / {battler.parameter.maxHp}"); break; case StatusTypeEnum.StatusType.MP: SetValue("MP", $"{battler.parameter.mp} / {battler.parameter.maxMp}"); break; case StatusTypeEnum.StatusType.ATK: SetValue("攻撃力", $"{battler.parameter.atk}"); break; case StatusTypeEnum.StatusType.DEF: SetValue("防御力", $"{battler.parameter.def}"); break; case StatusTypeEnum.StatusType.MAT: SetValue("魔法攻撃力", $"{battler.parameter.mat}"); break; case StatusTypeEnum.StatusType.MDF: SetValue("魔法防御力", $"{battler.parameter.mdf}"); break; case StatusTypeEnum.StatusType.SPD: SetValue("速度", $"{battler.parameter.spd}"); break; case StatusTypeEnum.StatusType.HIT: SetValue("命中率", $"{battler.parameter.hit}"); break; case StatusTypeEnum.StatusType.DODGE: SetValue("回避率", $"{battler.parameter.dodge}"); break; case StatusTypeEnum.StatusType.CRIT: SetValue("クリティカル率", $"{battler.parameter.crit}"); break; case StatusTypeEnum.StatusType.EFC: SetValue("効果的中率", $"{battler.parameter.efc}"); break; case StatusTypeEnum.StatusType.RES: SetValue("効果抵抗率", $"{battler.parameter.res}"); break; case StatusTypeEnum.StatusType.HOS: SetValue("敵対率", $"{battler.parameter.hostile}"); break; } SetDescription(type, battler); }
/// <summary> /// 覚えているスキルをすべて装備する /// TODO 仕様がふわふわ /// </summary> /// <param name="battler"></param> /// <returns></returns> public static List <string> AllSkillEquipment(BattlerSerializable battler) { battler.learning.ForEach(x => { battler.skills.Add(x); }); return(battler.skills); }
public static BattlerSerializable Create(string monsterId, int level = 1) { BattlerSerializable enemy = new BattlerSerializable(); enemy = BattlerLogic.Create(monsterId, level); enemy.battlerType = BattlerEnum.BattlerType.Enemy; return(enemy); }
public static bool IsDead(BattlerSerializable battler) { if (battler.status.Find(x => x.type == StatusConsts.DEAD) != null) { return(true); } return(false); }
private void DeadCheck(BattlerSerializable battler) { if (BattleLogic.DeadCheck(battler) && BattlerDictionary.IsDead(battler) == false) { BattleLogic.Dead(battler); BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Dead.OnNext(true); } }
private string DeadText(BattlerSerializable battler) { var color = GuiDictionary.GetBattlerNameColor(battler.battlerType); StringBuilder sb = new StringBuilder(); sb.Append($"<color={color}>{battler.name}</color>は死亡した"); return(sb.ToString()); }
private static void Damage(int damage, BattlerSerializable battler) { battler.parameter.hp -= damage; if (battler.parameter.hp < 0) { battler.parameter.hp = 0; } BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Hp.OnNext(battler.parameter.hp); }
public static void RemoveAnnounce(string type, BattlerSerializable battler) { switch (type) { case StatusConsts.SLEEP: AnnounceTextView.Instance.WakeUpText(battler); break; } }
/// <summary> /// ダメージ処理 /// </summary> /// <param name="damage"></param> /// <param name="battler"></param> public static void SkillDamage(int damage, BattlerSerializable battler) { Damage(damage, battler); //睡眠状態なら睡眠状態を解除する if (DeadCheck(battler) == false && StatusDictionary.IsSleep(battler)) { RemoveStatus(StatusConsts.SLEEP, battler); } }
private static bool IsStateJudgment(int damage, BattlerSerializable toBattler) { if (Random.Range(0, 100) < damage - toBattler.parameter.res) { return(true); } return(false); }
public void Refresh(BattlerSerializable battler) { monsterName.GetComponent <TextMeshProUGUI>().text = battler.name; var sprite = MonsterDicionary.GetSprite(battler.monsterId); monsterImage.GetComponent <Image>().sprite = sprite; monsterLevel.GetComponent <TextMeshProUGUI>().text = "レベル " + battler.level; CreateStatusContent(battler); }
public static BattlerSerializableStatus GetStatus(BattlerSerializable battler, string type) { var status = battler.status.Find(x => x.type == type); if (status != null) { return(status); } return(null); }
public void WakeUpText(BattlerSerializable battler) { StringBuilder sb = new StringBuilder(); var nameColor = GuiDictionary.GetBattlerNameColor(battler.battlerType); var texts = new List <string>(); sb.Append($"<color={nameColor}>{battler.name}</color>は目を覚ました"); texts.Add(sb.ToString()); AddText(texts); }
public void Add(BattlerSerializable battler, int memberIndex = 0) { MemberSerializable member = new MemberSerializable(); member.index = battler.index; member.memberIndex = memberIndex; member.uniqId = battler.uniqId; _data.Add(member); Sort(); }
public static bool DeadCheck(BattlerSerializable battler) { //死亡判定 if (battler.parameter.hp <= 0) { battler.parameter.hp = 0; return(true); } return(false); }
public static int GetDamage(SkillSerializableEffectDamageRates skillRate, BattlerSerializable battler) { float val = 0; float rate = skillRate.rate; switch (skillRate.dependence) { case SkillConsts.ATK: val = battler.parameter.atk * rate; break; case SkillConsts.DEF: val = battler.parameter.def * rate; break; case SkillConsts.MAT: val = battler.parameter.mat * rate; break; case SkillConsts.MDF: val = battler.parameter.mdf * rate; break; case SkillConsts.SPD: val = battler.parameter.spd * rate; break; case SkillConsts.HP: val = battler.parameter.hp * rate; break; case SkillConsts.MP: val = battler.parameter.mp * rate; break; case SkillConsts.MAX_HP: val = battler.parameter.maxHp * rate; break; case SkillConsts.MAX_MP: val = battler.parameter.maxMp * rate; break; case SkillConsts.EFC: val = battler.parameter.efc * rate; break; } if (skillRate.addValue != 0) { val += skillRate.addValue; } return((int)val); }
public static SkillsSerializable GetEquippedSkillByIndex(BattlerSerializable battler, int index) { var eqSkills = battler.skills; if (IListExtensions.IsDefinedAt(eqSkills, index)) { return(GetSkillById(eqSkills[index])); } return(null); }
private static void RemoveStatus(string type, BattlerSerializable battler) { var state = battler.status.Find(x => x.type == type); if (state != null) { battler.status.Remove(state); BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Status.OnNext(Unit.Default); StatusLogic.RemoveAnnounce(type, battler); } }
public void TurnStartText(int uniqId) { StringBuilder sb = new StringBuilder(); BattlerSerializable battler = BattlerDictionary.GetBattlerByUniqId(uniqId); var nameColor = GuiDictionary.GetBattlerNameColor(battler.battlerType); sb.Append($"<color={nameColor}>{battler.name}</color>のターン"); var texts = new List <string>(); texts.Add(sb.ToString()); AddText(texts); }
/// <summary> /// ランダムの対象にスキル発動 /// </summary> /// <param name="skillId"></param> /// <param name="fromBattler"></param> /// <param name="uniqIds"></param> /// <returns></returns> public static AsyncSubject <Unit> SkillToRandom(string skillId, BattlerSerializable fromBattler, List <int> uniqIds) { AsyncSubject <Unit> subject = new AsyncSubject <Unit>(); List <SkillDamages> damageses = new List <SkillDamages>(); var skill = SkillsDicionary.GetSkillById(skillId); var strikeSize = 1; if (skill.strikeSize.min != 0 && skill.strikeSize.max != 0) { strikeSize = Random.Range(skill.strikeSize.min, skill.strikeSize.max); } List <BattlerSerializable> toBattlers = new List <BattlerSerializable>(); uniqIds.ForEach(uniqId => { toBattlers.Add(BattlerDictionary.GetBattlerByUniqId(uniqId)); }); for (int i = 0; i < strikeSize; i++) { var toBattler = BattleDictionary.GetAliveBattlerByRandom(toBattlers); if (toBattler == null) { break; } var isHit = HitCheck(skillId, fromBattler, toBattler); List <SkillDamage> damages = new List <SkillDamage>(); if (isHit) { damages = SkillToBattler(skillId, fromBattler, toBattler); } var isDead = DeadCheck(toBattler); damageses.Add(new SkillDamages { SkillDamage = damages, targetUniqId = toBattler.uniqId, isHit = isHit, isDead = isDead }); } //ダメージテキストの表示 AnnounceTextView.Instance.AddDamageText(fromBattler, skill.name, damageses); EffectManager.Instance.SkillToTarget(skillId, damageses).Subscribe(_ => { subject.OnNext(Unit.Default); subject.OnCompleted(); }); return(subject); }
public static void SetState(string type, BattlerSerializable battler, int turn = 0) { var state = battler.status.Find(x => x.type == type); if (state == null) { BattlerSerializableStatus battlerSerializableStatus = new BattlerSerializableStatus(); battlerSerializableStatus.type = type; battlerSerializableStatus.value = 1; battlerSerializableStatus.turn = turn; battler.status.Add(battlerSerializableStatus); BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Status.OnNext(Unit.Default); } }
/// <summary> /// ダメージと敵ステータスを比較してダメージ計算し反映する /// </summary> /// <returns></returns> private static int CalcDamage(SkillDamage damage, BattlerSerializable toBattler) { var _damage = damage.damage; switch (damage.valueTarget) { //通常ダメージ計算 // TODO case SkillValueTarget.HP: _damage = _damage - toBattler.parameter.def; //ダメージは25%以下に減らない if (_damage < damage.damage * 0.25) { _damage = (int)(damage.damage * 0.25); } //ダメージのブレ _damage += Random.Range(_damage, (int)(_damage * 0.1)); SkillDamage(_damage, toBattler); return(_damage); //毒計算 case SkillValueTarget.TARGET_POISON: damage.damage = damage.damage - (int)(damage.damage * (toBattler.resistRate.poison / 100)); StatusDamage(damage, toBattler); return(damage.damage); //睡眠判定 case SkillValueTarget.SLEEP: if (IsStateJudgment(damage.damage, toBattler)) { damage.damage = 1; SetState(SkillValueTarget.SLEEP, toBattler, 20); } else { damage.isResist = true; damage.damage = 0; } return(damage.damage); //再生計算 case SkillValueTarget.TARGET_REGENERATION_HP: StatusDamage(damage, toBattler); return(damage.damage); } return(damage.damage); }
private void SetDescription(StatusTypeEnum.StatusType type, BattlerSerializable battler) { //TODO switch (type) { case StatusTypeEnum.StatusType.HP: _descriptionText = $"最大HP\n{battler.parameter.maxHp}\n基礎値:{battler.parameter.maxHp}\n補正値:0"; break; case StatusTypeEnum.StatusType.MP: _descriptionText = $"最大MP\n{battler.parameter.maxMp}\n基礎値:{battler.parameter.maxMp}\n補正値:0"; break; } }
/// <summary> /// スキル説明テキストの作成 /// </summary> /// <param name="skillId"></param> /// <param name="battler"></param> /// <returns></returns> public static string CreateSkillDescription(string skillId, BattlerSerializable battler) { var skill = SkillsDicionary.GetSkillById(skillId); StringBuilder sb = new StringBuilder(); string name = skill.name; sb.Append("<b><size=18>"); sb.Append(name); sb.Append("</size></b>"); sb.Append("\n--------------------\n"); sb.Append(skill.description); sb.Append("\n--------------------\n"); sb.Append(SkillsDicionary.SkillTargetText(skill.target)); if (skill.strikeSize.min == 0 && skill.strikeSize.max == 0) { //敵単体(敵全体)に sb.Append("に\n"); } else { //敵単体をx回から sb.Append("を"); if (skill.strikeSize.min == skill.strikeSize.max) { sb.Append(skill.strikeSize.min).Append("回\n"); } else { sb.Append(skill.strikeSize.min).Append("回から").Append(skill.strikeSize.max).Append("回\n"); } } skill.effect.value.ForEach(item => { item.rates.ForEach(rate => { StringBuilder msb = new StringBuilder(); msb.Append(SkillsDicionary.SkillDependenceText(rate.dependence)).Append("(").Append(rate.rate * 100) .Append("%)\n").Append(SkillsDicionary.SkillDamageDescriptionTargetText(item.valueTarget)).Append("\n"); sb.Append(msb); }); }); //属性 sb.Append("\n--------------------\n"); skill.effect.elements.ForEach(x => { sb.Append(SkillsDicionary.SkillElementsText(x)).Append("\n"); }); return(sb.ToString()); }
private static void SleepLogic(BattlerSerializable battler, ref List <StatusUpdateResult> results) { if (BattleLogic.DeadCheck(battler) == false) { var state = battler.status.Find(x => x.type == StatusConsts.SLEEP); if (state != null) { results.Add(new StatusUpdateResult() { StatusType = state.type }); StateTurnCount(state); } } }
/// <summary> /// ターン毎の状態異常処理 /// </summary> public static List <StatusUpdateResult> StatusUpdate(BattlerSerializable battler) { List <StatusUpdateResult> results = new List <StatusUpdateResult>(); //ダメージ系の異常処理を先に行う //毒 PoisonDamageLogic(battler, ref results); // SleepLogic(battler, ref results); //ターン系の状態異常の削除処理 StateTurnDelete(battler.status); BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Status.OnNext(Unit.Default); return(results); }
public void PoisonText(BattlerSerializable battler, int value, bool isDead) { StringBuilder sb = new StringBuilder(); var nameColor = GuiDictionary.GetBattlerNameColor(battler.battlerType); var skillColor = SkillsDicionary.SkillColor(SkillValueTarget.TARGET_POISON); var texts = new List <string>(); sb.Append($"<color={nameColor}>{battler.name}は</color><color={skillColor}>{value}</color>の毒ダメージを受けた"); texts.Add(sb.ToString()); if (isDead) { texts.Add(DeadText(battler)); } AddText(texts); }
private WindowManager.WindowItem CreateStatusWindow(GameObject button, BattlerSerializable battler) { var windows = _modal.transform.Find("Content/Content/MonsterStatusWindowManager/Windows"); var statusWindow = Object.Instantiate( (GameObject)Resources.Load("Prefabs/Modal/MonsterStatus/MonsterStatus"), windows); WindowManager.WindowItem item = new WindowManager.WindowItem { buttonObject = button, windowName = battler.uniqId.ToString(), windowObject = statusWindow }; statusWindow.GetComponent <MonsterStatus>().Refresh(battler); return(item); }