//ユニットとアイテムを渡すとユニットにアイテムの効果を与える public void UseItem(PlayerModel playerModel, Potion potion) { Unit unit = playerModel.unit; //回復系 if (potion.potionType == PotionType.HEAL) { //数字を表示 GameObject healText = Instantiate(effectManager.healText, playerModel.transform.position, Quaternion.identity) as GameObject; healText.GetComponent <DamageText>().Init(potion.amount.ToString()); //エフェクト表示 GameObject effect = Instantiate(effectManager.healEffectList[0], new Vector3(playerModel.transform.position.x, playerModel.transform.position.y + 1, playerModel.transform.position.z), Quaternion.identity) as GameObject; int maxHp = unit.maxhp + unit.job.statusDto.jobHp; StatusCalculator statusCalculator = new StatusCalculator(); maxHp = statusCalculator.CalcHpBuff(maxHp, unit.job.skills); //210227 スキル「よくきく薬」反映 if (unit.job.skills.Contains(Skill.よくきく薬)) { unit.hp += potion.amount * 2; Debug.Log($"{unit.name}: スキル{Skill.よくきく薬} 効果{Skill.よくきく薬.GetStringValue()}"); } else { unit.hp += potion.amount; } if (unit.hp >= maxHp) { unit.hp = maxHp; } Debug.Log($"{unit.name}は{potion.name}で体力を{potion.amount}回復した"); Debug.Log($"回復後のHP:{unit.hp}"); } else if (potion.potionType == PotionType.STATUSUP) { //ステータスアップ系のアイテムだった場合 string text = StatusUp(potion, unit); //メッセージウィンドウ表示 battleMapManager.OpenMessageWindow(text); battleMapManager.SetMapMode(MapMode.MESSAGE); } //使用回数を減らす potion.useCount -= 1; //空になったポーションを削除する処理 EmptyPotionDelete(playerModel.unit.carryItem); playerModel.isMoved = true; playerModel.SetBeforeAction(false); //モードを戻す battleMapManager.mapMode = MapMode.NORMAL; Debug.Log("MapMode : " + battleMapManager.mapMode); }
//210216 回復を受ける public void receiveHeal(int healAmount) { this.hp += healAmount; //ここで回復最大HPよりも回復しない機能を追加 int maxHp = maxhp + job.statusDto.jobHp; StatusCalculator statusCalc = new StatusCalculator(); //スキルによるバフ反映しないと全回復しない maxHp = statusCalc.CalcHpBuff(maxHp, job.skills); if (hp >= maxHp) { hp = maxHp; } }
/// <summary> /// 200712 ユニットの体力回復 /// </summary> public void rest() { var tmpList = new List <Unit>(); StatusCalculator statusCalc = new StatusCalculator(); foreach (var unit in unitList) { //体力全回復 200719 職業補正を反映 int maxHp = unit.maxhp + unit.job.statusDto.jobHp; maxHp = statusCalc.CalcHpBuff(maxHp, unit.job.skills); unit.hp = maxHp; tmpList.Add(unit); } unitList = tmpList; }
/// <summary> /// 210216 仲間を回復する値を求める 効果量のみ求めるので内容が少ない /// </summary> public HealParameterDTO CalculateHealParameter(Unit unit, Weapon healRod, Unit targetUnit) { HealParameterDTO healParameterDTO = new HealParameterDTO(); JobStatusDto jobstatusDto = unit.job.statusDto; int unitMaxHp = unit.maxhp + jobstatusDto.jobHp; int unitLatk = unit.latk + jobstatusDto.jobLatk; //必要な値はHPと遠攻 不要な値は使用しないでバフを受ける StatusDto buffedStatus = new StatusDto(unitMaxHp, unitLatk, 0, 0, 0, 0, 0, 0); StatusCalculator statusCalculator = new StatusCalculator(); //武器、装飾品、スキルのバフ反映 最大値を上回らないようにして返される buffedStatus = statusCalculator.GetBuffedStatus(buffedStatus, unit.name, unit.equipWeapon, unit.equipAccessory, unit.job.skills, false); unitMaxHp = buffedStatus.hp; unitLatk = buffedStatus.latk; //戦闘にも使用するので本クラスに値を設定しておく healAmount = unitLatk + healRod.attack; //210226 スキル「癒し手」 if (unit.job.skills.Contains(Skill.癒し手)) { healAmount += 10; } //表示用DTO healParameterDTO.unitName = unit.name; healParameterDTO.unitHp = unit.hp; healParameterDTO.unitMaxHp = unitMaxHp; //Attackと表記してしまっているが回復量 healParameterDTO.healAmount = healAmount; healParameterDTO.unitHealRodName = healRod.name; //回復対象のステータスも設定する JobStatusDto TargetjobstatusDto = targetUnit.job.statusDto; healParameterDTO.targetName = targetUnit.name; healParameterDTO.targetHp = targetUnit.hp; healParameterDTO.targetMaxHp = statusCalculator.CalcHpBuff(targetUnit.maxhp + TargetjobstatusDto.jobHp, targetUnit.job.skills); return(healParameterDTO); }
public void UpdateText(Unit unit) { StatusCalculator statusCalc = new StatusCalculator(); JobStatusDto statusDto = unit.job.statusDto; this.nameText.text = unit.name; this.lvNum.text = unit.lv.ToString(); this.hp.text = unit.hp.ToString(); this.job.text = unit.job.jobName.ToString(); this.exp.text = unit.exp.ToString(); //威風堂々等、HPバフも有り得るので int maxHp = statusCalc.CalcHpBuff(unit.maxhp + statusDto.jobHp, unit.job.skills);; this.maxHp.text = string.Format("/ {0}", (maxHp).ToString()); this.image.sprite = Resources.Load <Sprite>("Image/Charactors/" + unit.pathName + "/status"); }
/// <summary> /// ユニット、敵、武器を受け取るとダメージ、命中率などを計算してDTOに詰めて返してくれる /// </summary> /// <param name="unit">ユニット名</param> /// <param name="unitWeapon">ユニットの武器</param> /// <param name="unitCell">ユニットの地形</param> /// <param name="enemy">敵</param> /// <param name="enemyCell">敵の地形</param> /// <param name="isPlayerAttack">プレイヤーからの攻撃か</param> /// <returns></returns> public BattleParameterDTO CalculateBattleParameter(Unit unit, Weapon unitWeapon, Main_Cell unitCell, Enemy enemy, Main_Cell enemyCell, bool isPlayerAttack) { //戻り値を詰めるクラス BattleParameterDTO battleParameterDTO = new BattleParameterDTO(); //職業ステータス補正が入ったクラス JobStatusDto jobstatusDto = unit.job.statusDto; //スキル「狂化」判定 ステータスに反映するので最初に判定 bool isUnitBerserk = false; bool isEnemyBerserk = false; bool isCloseAttack; //近接攻撃フラグ ///ユニットの計算 //210218 ステータスと職業による基礎値の計算 他に装備品補正、バフ、デバフ、スキル判定が必要 int unitMaxHp = unit.maxhp + jobstatusDto.jobHp; int unitLatk = unit.latk + jobstatusDto.jobLatk; int unitCatk = unit.catk + jobstatusDto.jobCatk; int unitDex = unit.dex + jobstatusDto.jobDex; int unitAgi = unit.agi + jobstatusDto.jobAgi; int unitLuk = unit.luk + jobstatusDto.jobLuk; int unitLdef = unit.ldef + jobstatusDto.jobLdef; int unitCdef = unit.cdef + jobstatusDto.jobCdef; //210218 バフを反映する処理を追加 StatusDto buffedStatus = new StatusDto(unitMaxHp, unitLatk, unitCatk, unitAgi, unitDex, unitLdef, unitCdef, unitLuk); StatusCalculator statusCalculator = new StatusCalculator(); //スキル「狂化」判定 if (unit.hp != statusCalculator.CalcHpBuff(unitMaxHp, unit.job.skills) && unit.job.skills.Contains(Skill.狂化)) { isUnitBerserk = true; } //武器、装飾品、スキルのバフ反映 最大値を上回らないようにして返される buffedStatus = statusCalculator.GetBuffedStatus(buffedStatus, unit.name, unit.equipWeapon, unit.equipAccessory, unit.job.skills, isUnitBerserk); //値を更新 unitMaxHp = buffedStatus.hp; unitLatk = buffedStatus.latk; unitCatk = buffedStatus.catk; unitDex = buffedStatus.dex; this.unitDex = buffedStatus.dex; unitAgi = buffedStatus.agi; //スキル発動計算の為DTOにもセット unitLuk = buffedStatus.luk; this.unitLuk = buffedStatus.luk; unitLdef = buffedStatus.ldef; unitCdef = buffedStatus.cdef; ///敵の計算 //210227 敵のステータスも上級職補正等は職業から取得する用に変更 JobStatusDto enemyJobStatusDto = enemy.job.statusDto; //210218 ステータスと職業による基礎値の計算 他に装備品補正、バフ、デバフ、スキル判定が必要 int enemyMaxHp = enemy.maxhp + enemyJobStatusDto.jobHp; int enemyLatk = enemy.latk + enemyJobStatusDto.jobLatk; int enemyCatk = enemy.catk + enemyJobStatusDto.jobCatk; int enemyDex = enemy.dex + enemyJobStatusDto.jobDex; int enemyAgi = enemy.agi + enemyJobStatusDto.jobAgi; int enemyLuk = enemy.luk + enemyJobStatusDto.jobLuk; int enemyLdef = enemy.ldef + enemyJobStatusDto.jobLdef; int enemyCdef = enemy.cdef + enemyJobStatusDto.jobCdef; //210218 敵のバフを反映する処理 StatusDto enemyBuffedStatus = new StatusDto(enemyMaxHp, enemyLatk, enemyCatk, enemyAgi, enemyDex, enemyLdef, enemyCdef, enemyLuk); //スキル「狂化」判定 if (enemy.hp != statusCalculator.CalcHpBuff(enemyMaxHp, enemy.job.skills) && enemy.job.skills.Contains(Skill.狂化)) { isEnemyBerserk = true; } //武器、装飾品、スキルのバフ反映 最大値を上回らないようにして返される enemyBuffedStatus = statusCalculator.GetBuffedStatus(enemyBuffedStatus, enemy.name, enemy.equipWeapon, enemy.equipAccessory, enemy.job.skills, isEnemyBerserk); //値を更新 enemyMaxHp = enemyBuffedStatus.hp; enemyLatk = enemyBuffedStatus.latk; enemyCatk = enemyBuffedStatus.catk; enemyDex = enemyBuffedStatus.dex; this.enemyDex = enemyBuffedStatus.dex; enemyAgi = enemyBuffedStatus.agi; //スキル発動計算の為DTOにもセット enemyLuk = enemyBuffedStatus.luk; this.enemyLuk = enemyBuffedStatus.luk; enemyLdef = enemyBuffedStatus.ldef; enemyCdef = enemyBuffedStatus.cdef; //210226 自分から攻撃した場合、ダメージが上がるスキル //これはステータス画面には表示しないのでstatusCalculator不使用 //プレイヤーから攻撃した時 if (isPlayerAttack) { if (unit.job.skills.Contains(Skill.飛燕の一撃)) { unitAgi += 5; Debug.Log($"{unit.name}スキル{Skill.飛燕の一撃} 速さ+5"); } if (unit.job.skills.Contains(Skill.金剛の一撃)) { unitCdef += 10; Debug.Log($"{unit.name}スキル{Skill.金剛の一撃} 近防-10"); } if (unit.job.skills.Contains(Skill.鬼神の一撃)) { unitCatk += 6; Debug.Log($"{unit.name}スキル{Skill.鬼神の一撃} 近攻+6"); } if (unit.job.skills.Contains(Skill.魔女の一撃)) { unitLatk += 6; Debug.Log($"{unit.name}スキル{Skill.魔女の一撃} 遠攻+6"); } } else { //敵の〇〇の一撃判定 if (enemy.job.skills.Contains(Skill.飛燕の一撃)) { enemyAgi += 5; Debug.Log($"{unit.name}スキル{Skill.飛燕の一撃} 速さ+5"); } if (enemy.job.skills.Contains(Skill.金剛の一撃)) { enemyCdef += 10; Debug.Log($"{unit.name}スキル{Skill.金剛の一撃} 近防-10"); } if (enemy.job.skills.Contains(Skill.鬼神の一撃)) { enemyCatk += 6; Debug.Log($"{unit.name}スキル{Skill.鬼神の一撃} 近攻+6"); } if (enemy.job.skills.Contains(Skill.魔女の一撃)) { enemyLatk += 6; Debug.Log($"{unit.name}スキル{Skill.魔女の一撃} 遠攻+6"); } } //慧眼の一撃(命中率上がるやつ)はまた別の場所で実装 //210219 地形効果を味方、敵のセルから取得 int unitTerrainHit; int unitTerrainDef; //通常は有り得ないが、セルが無ければ0 if (unitCell == null) { Debug.Log("ERROR:ユニットの居るセルの情報が有りません"); unitTerrainHit = 0; unitTerrainDef = 0; } else { unitTerrainHit = unitCell.AvoidRate; unitTerrainDef = unitCell.Defence; } int enemyTerrainHit; int enemyTerrainDef; if (enemyCell == null) { Debug.Log("ERROR:敵の居るセル情報が有りません"); enemyTerrainHit = 0; enemyTerrainDef = 0; } else { enemyTerrainHit = enemyCell.AvoidRate; enemyTerrainDef = enemyCell.Defence; } //スキル判定 目隠し 攻撃を受けた時、回避+20%、守備+2 bool isUnitBlind = false; bool isEnemyBlind = false; if (!isPlayerAttack && unit.job.skills.Contains(Skill.目隠し)) { Debug.Log($"{unit.name} スキル :{Skill.目隠し.ToString()}, {Skill.目隠し.GetStringValue()}"); isEnemyBlind = true; } if (isPlayerAttack && enemy.job.skills.Contains(Skill.目隠し)) { Debug.Log($"{enemy.name} スキル :{Skill.目隠し.ToString()}, {Skill.目隠し.GetStringValue()}"); isUnitBlind = true; } //210220 攻撃可否を確認 //座標の絶対値の合計が距離で、その値が武器の射程距離以下なら反撃可能となる //射程距離が1の場合、武器が近距離攻撃可能の場合は反撃可能となる //距離を取得 int distance = Mathf.Abs(unitCell.X - enemyCell.X) + Mathf.Abs(unitCell.Y - enemyCell.Y); Debug.Log($"ユニットと敵との距離:{distance}"); Debug.Log($"ユニット:X={unitCell.X},Y={unitCell.Y} 敵:X={enemyCell.X},Y={enemyCell.Y}"); //近距離攻撃か遠距離か判定 isCloseAttack = (distance == 1) ? true : false; Debug.Log($"近距離攻撃か:{isCloseAttack}"); //武器の射程距離が距離よりも少ない場合は攻撃不可 if (unitWeapon.range < distance) { isUnitAttackable = false; } else if (distance == 1 && !unitWeapon.isCloseAttack) { //武器の射程距離内だが、射程が1で近距離攻撃可能ではない場合 //(射程2以上の武器は、近距離攻撃フラグが無い場合は近距離攻撃出来ない) isUnitAttackable = false; } else { isUnitAttackable = true; } //天狗のカメラは反撃不可 if (enemy.equipWeapon.name == "天狗のカメラ" && !isPlayerAttack) { isUnitAttackable = false; } battleParameterDTO.isUnitAttackable = isUnitAttackable; Debug.Log($"ユニットの攻撃可否:{battleParameterDTO.isUnitAttackable}"); //敵の攻撃可否判定 プレイヤーと同じ if (enemy.equipWeapon.range < distance) { isEnemyAttackable = false; } else if (distance == 1 && !enemy.equipWeapon.isCloseAttack) { isEnemyAttackable = false; } else { isEnemyAttackable = true; } if (unit.equipWeapon.name == "天狗のカメラ" && isPlayerAttack) { //ユニットの武器が天狗のカメラ、かつ文ちゃんから攻撃した場合 isEnemyAttackable = false; } battleParameterDTO.isEnemyAttackable = isEnemyAttackable; Debug.Log($"敵の攻撃可否:{battleParameterDTO.isEnemyAttackable}"); ///攻撃力計算 //TODO 武器を持っていない状態で攻撃される場合を考慮する int unitWeaponAttack = unitWeapon.attack; //NONE以外の場合は何かしら特効対象が有るということ //かつ武器の特効対象と敵の種族が一致した場合は特効 if (unitWeapon.slayer != RaceType.NONE && unitWeapon.slayer == enemy.race) { //武器威力を3倍にして特効フラグを立てる 特効時は文字の色が変わる unitWeaponAttack *= 3; battleParameterDTO.isUnitAttackSlayer = true; } //210301 攻撃力計算 遠距離、近距離の概念を反映 int unitRefAttack = isCloseAttack ? unitCatk : unitLatk; int enemydef = isCloseAttack ? enemyCdef : enemyLdef; //力+武器威力*特効なら3倍 - 敵防御 - 地形効果 unitAttack = (unitRefAttack + unitWeaponAttack) - enemydef - enemyTerrainDef; //スキル目隠し 敵の回避+20、守備+2 if (isUnitBlind) { unitAttack -= 2; } //スキル「密室の守り」自分が地形効果0以外の場所で戦闘時、受けるダメージ-3 if ((enemyTerrainHit != 0 || enemyTerrainDef != 0) && enemy.job.skills.Contains(Skill.密室の守り)) { unitAttack -= 3; Debug.Log($"{enemy.name}: スキル{Skill.密室の守り} 効果{Skill.密室の守り.GetStringValue()}"); } //スキル「死線」 敵に与えるダメージ+10、敵から受けるダメージ+10 if (unit.job.skills.Contains(Skill.死線)) { //ユニットが持っていれば攻撃力アップ unitAttack += 10; Debug.Log($"{unit.name}: スキル{Skill.死線} 効果{Skill.死線.GetStringValue()}"); } if (enemy.job.skills.Contains(Skill.死線)) { //敵が持っていれば受けるダメージアップ unitAttack += 10; Debug.Log($"{enemy.name}: スキル{Skill.死線} 効果{Skill.死線.GetStringValue()}"); } //0~100の間に訂正 unitAttack = CorrectParameter(unitAttack); battleParameterDTO.unitAttack = unitAttack; //敵の攻撃力計算 プレイヤーと同じ //TODO 敵は武器を持っていない可能性が有るけどまだ考慮してない if (enemy.equipWeapon != null) { //敵も特効の計算 int enemyWeaponAttack = enemy.equipWeapon.attack; if (enemy.equipWeapon.slayer != RaceType.NONE && enemy.equipWeapon.slayer == unit.race) { enemyWeaponAttack *= 3; battleParameterDTO.isEnemyAttackSlayer = true; } int enemyRefAttack = isCloseAttack ? enemyCatk : enemyLatk; int unitdef = isCloseAttack ? unitCdef : unitLdef; enemyAttack = (enemyRefAttack + enemyWeaponAttack) - unitdef - unitTerrainDef; //スキル目隠し 敵の回避+20、守備+2 if (isEnemyBlind) { enemyAttack -= 2; } //スキル「密室の守り」自分が地形効果0以外の場所で戦闘時、受けるダメージ-3 if ((unitTerrainHit != 0 || unitTerrainDef != 0) && unit.job.skills.Contains(Skill.密室の守り)) { enemyAttack -= 3; Debug.Log($"{unit.name}: スキル{Skill.密室の守り} 効果{Skill.密室の守り.GetStringValue()}"); } //スキル「死線」 if (unit.job.skills.Contains(Skill.死線)) { enemyAttack += 10; Debug.Log($"{unit.name}: スキル{Skill.死線} 効果{Skill.死線.GetStringValue()}"); } if (enemy.job.skills.Contains(Skill.死線)) { enemyAttack += 10; Debug.Log($"{enemy.name}: スキル{Skill.死線} 効果{Skill.死線.GetStringValue()}"); } battleParameterDTO.enemyAttack = CorrectParameter(enemyAttack); } ///命中率計算 //物理命中率=物理命中-敵物理回避-地形効果 //3すくみの乗っていない命中率計算 まだマイナス、100%以上になってもよい unitHitRate = (unitDex + unitWeapon.hitRate) - enemyAgi - enemyTerrainHit; //敵が武器を持っていれば、敵の命中率計算 if (enemy.equipWeapon != null) { enemyHitRate = (enemyDex + enemy.equipWeapon.hitRate) - unitAgi - unitTerrainHit; } else { //無ければUI表示は「-」となり参照されることは無いが一旦0 enemyHitRate = 0; } //210226 スキル「一撃離脱反映」自分から攻撃時、回避+30 //プレイヤーの一撃離脱反映 if (isPlayerAttack && unit.job.skills.Contains(Skill.一撃離脱)) { enemyHitRate -= 30; Debug.Log($"{unit.name}: スキル{Skill.一撃離脱} 回避+30"); } else if (!isPlayerAttack && enemy.job.skills.Contains(Skill.一撃離脱)) { //敵の一撃離脱反映 unitHitRate -= 30; Debug.Log($"{enemy.name}: スキル{Skill.一撃離脱} 回避+30"); } //スキル「慧眼の一撃」判定 自分から攻撃時命中+40% if (isPlayerAttack && unit.job.skills.Contains(Skill.慧眼の一撃)) { unitHitRate += 40; Debug.Log($"{unit.name}: スキル{Skill.慧眼の一撃} 命中+40"); } else if (!isPlayerAttack && enemy.job.skills.Contains(Skill.慧眼の一撃)) { enemyHitRate += 40; Debug.Log($"{enemy.name}: スキル{Skill.慧眼の一撃} 命中+40"); } //スキル「自信満々」HPが100%の時命中・回避+15 if (unitMaxHp == unit.hp) { if (unit.job.skills.Contains(Skill.自信満々)) { enemyHitRate -= 15; unitHitRate += 15; Debug.Log($"{unit.name}: スキル{Skill.自信満々} 命中・回避+15"); } if (unit.job.skills.Contains(Skill.完璧主義)) { enemyHitRate -= 15; unitHitRate += 15; Debug.Log($"{unit.name}: スキル{Skill.完璧主義} 命中・回避+15"); } } if (enemyMaxHp == enemy.hp) { if (enemy.job.skills.Contains(Skill.自信満々)) { enemyHitRate += 15; unitHitRate -= 15; Debug.Log($"{unit.name}: スキル{Skill.自信満々} 命中・回避+15"); } if (unit.job.skills.Contains(Skill.完璧主義)) { enemyHitRate += 15; unitHitRate -= 15; Debug.Log($"{enemy.name}: スキル{Skill.完璧主義} 命中・回避+15"); } } //スキル「狂気の瞳」 無条件で回避+20 if (unit.job.skills.Contains(Skill.狂気の瞳)) { enemyHitRate -= 20; Debug.Log($"{unit.name}: スキル{Skill.狂気の瞳} 効果{Skill.狂気の瞳.GetStringValue()}"); } if (enemy.job.skills.Contains(Skill.狂気の瞳)) { unitHitRate -= 20; Debug.Log($"{enemy.name}: スキル{Skill.狂気の瞳} 効果{Skill.狂気の瞳.GetStringValue()}"); } //スキル「狂化」 命中率 - 10% if (isUnitBerserk) { unitHitRate -= 10; Debug.Log($"{unit.name}: スキル{Skill.狂化} 効果{Skill.狂化.GetStringValue()}"); } if (isEnemyBerserk) { enemyHitRate -= 10; Debug.Log($"{enemy.name}: スキル{Skill.狂化} 効果{Skill.狂化.GetStringValue()}"); } //スキル「目隠し」判定 敵の回避+20、守備+2 if (isUnitBlind) { unitHitRate -= 20; } else if (isEnemyBlind) { enemyHitRate -= 20; } //戻り値に計算した値を設定 battleParameterDTO.unitHitRate = unitHitRate; battleParameterDTO.enemyHitRate = enemyHitRate; battleParameterDTO.unitWeapon = unitWeapon; battleParameterDTO.enemyWeapon = enemy.equipWeapon; //3すくみ補正を含めた攻撃力、命中率の補正 battleParameterDTO.affinity = BattleWeaponAffinity.EQUAL; if (enemy.equipWeapon != null) { battleParameterDTO = getWeaponAffinity(battleParameterDTO); } ///必殺率計算 ///必殺率=(技+幸運)/2+武器の必殺 - 敵の幸運 unitCriticalRate = (unitDex + unitLuk) / 2 + unitWeapon.criticalRate - enemyLuk; //210226 スキル「蒐集家」反映 if (SkillUtil.isCollector(unit)) { unitCriticalRate += 10; } //210227 スキル「必殺」 if (unit.job.skills.Contains(Skill.必殺)) { unitCriticalRate += 15; Debug.Log($"{unit.name}: スキル{Skill.必殺} 効果{Skill.必殺.GetStringValue()}"); } //スキル「狂化」 if (isUnitBerserk) { unitCriticalRate += 20; Debug.Log($"{unit.name}: スキル{Skill.狂化} 効果{Skill.狂化.GetStringValue()}"); } unitCriticalRate = CorrectParameter(unitCriticalRate); battleParameterDTO.unitCriticalRate = unitCriticalRate; if (enemy.equipWeapon != null) { enemyCriticalRate = (enemyDex + enemyLuk) / 2 + enemy.equipWeapon.criticalRate - unitLuk; //敵の「蒐集家」判定 if (SkillUtil.isCollector(enemy)) { enemyCriticalRate += 10; } //210227 スキル「必殺」 if (enemy.job.skills.Contains(Skill.必殺)) { enemyCriticalRate += 15; Debug.Log($"{enemy.name}: スキル{Skill.必殺} 効果{Skill.必殺.GetStringValue()}"); } if (isEnemyBerserk) { enemyCriticalRate += 20; Debug.Log($"{enemy.name}: スキル{Skill.狂化} 効果{Skill.狂化.GetStringValue()}"); } enemyCriticalRate = CorrectParameter(enemyCriticalRate); battleParameterDTO.enemyCiritcalRate = enemyCriticalRate; } ///追撃の計算 追撃は攻速差4以上 攻速 = 速さ-{武器の重さ-(力/5)} ///勇者武器は今はガン無視で int unitAttackSpeed = unitAgi - unitWeapon.delay; int enemyAttackSpeed = enemyAgi; if (enemy.equipWeapon != null) { enemyAttackSpeed -= enemy.equipWeapon.delay; } unitChaseFlag = false; enemyChaseFlag = false; //ユニットも敵も追撃可能という状況は有り得ないのでelse //210220 追撃不可武器を作成 if ((unitAttackSpeed - enemyAttackSpeed) >= 4 && unitWeapon.isChaseInvalid == false) { unitChaseFlag = true; } else if ((enemyAttackSpeed - unitAttackSpeed) >= 4 && enemy.equipWeapon.isChaseInvalid == false) { enemyChaseFlag = true; } //自分か敵が宵闇の守りを持っていれば互いに追撃不可 if (unit.job.skills.Contains(Skill.宵闇の守り) || enemy.job.skills.Contains(Skill.宵闇の守り)) { Debug.Log($"スキル{Skill.宵闇の守り}発動 : 互いに追撃不可"); unitChaseFlag = false; enemyChaseFlag = false; } //スキル「切り返し」実装 一旦、宵闇の守りより優先度高い if (!isPlayerAttack && unit.job.skills.Contains(Skill.切り返し)) { //敵から攻撃された時 unitChaseFlag = true; Debug.Log($"{unit.name}: スキル{Skill.切り返し} 効果{Skill.切り返し.GetStringValue()}"); } else if (isPlayerAttack && enemy.job.skills.Contains(Skill.切り返し)) { //敵を攻撃した時 enemyChaseFlag = true; Debug.Log($"{enemy.name}: スキル{Skill.切り返し} 効果{Skill.切り返し.GetStringValue()}"); } battleParameterDTO.unitName = unit.name; battleParameterDTO.enemyName = enemy.name; battleParameterDTO.unitWeaponName = unitWeapon.name; //210220 雑に勇者フラグをDTOに入れる //自分から攻撃した場合のみ2回攻撃なので、そうでなければフラグを倒してしまう if (unitWeapon.isYuusha && isPlayerAttack) { battleParameterDTO.isUnitYuusha = true; } else { battleParameterDTO.isUnitYuusha = false; } if (enemy.equipWeapon != null) { battleParameterDTO.enemyWeaponName = enemy.equipWeapon.name; if (enemy.equipWeapon.isYuusha && !isPlayerAttack) { battleParameterDTO.isEnemyYuusha = true; } else { battleParameterDTO.isEnemyYuusha = false; } } battleParameterDTO.unitHp = unit.hp; battleParameterDTO.unitMaxHp = unitMaxHp; battleParameterDTO.enemyHp = enemy.hp; battleParameterDTO.enemyMaxHp = enemyMaxHp; battleParameterDTO.unitChaseFlag = unitChaseFlag; battleParameterDTO.enemyChaseFlag = enemyChaseFlag; Debug.Log("unitAttackSpeed" + unitAttackSpeed.ToString()); Debug.Log("enemyAttackSpeed" + enemyAttackSpeed.ToString()); return(battleParameterDTO); }
/// <summary> /// 210301 周囲に回復出来るユニットが居るかを返す /// </summary> /// <param name="startCell"></param> /// <returns></returns> public List <PlayerModel> GetHealableUnit(Main_Cell startCell, Unit unit) { if (startCell == null) { Debug.Log("warn:セルが存在しません"); //画面端だとセルが無い場合がある return(null); } List <PlayerModel> healableUnitList = new List <PlayerModel>(); //ユニットの持つ武器で最も長い射程を取得 //TODO これ、射程距離 = 遠攻撃 / 2のリブローが有るのでその内実装する事 int maxRange = 1 - 1; //座標と移動可能距離を持つリストを用意する まずは現在位置で最大の移動可能距離 var infos = new List <MoveAmountInfo>(); infos.Add(new MoveAmountInfo(startCell.X, startCell.Y, maxRange)); //残り移動可能距離を1ずつ減らしていって、0になるまでループまわす for (var i = maxRange; i >= 0; i--) { //追加していく移動可能距離リスト作成 var appendInfos = new List <MoveAmountInfo>(); //amountはそのセルでの残り移動可能距離 まずは現在位置からスタート foreach (var calcTargetInfo in infos.Where(info => info.amount == i)) { // 四方のマスの座標配列を作成 var calcTargetCoordinate = calcTargetInfo.coordinate; //TODO ??? var aroundCellCoordinates = new Coordinate[] //上下左右の座標配列 { new Coordinate(calcTargetCoordinate.x - 1, calcTargetCoordinate.y), //左 new Coordinate(calcTargetCoordinate.x + 1, calcTargetCoordinate.y), //右 new Coordinate(calcTargetCoordinate.x, calcTargetCoordinate.y - 1), //上 new Coordinate(calcTargetCoordinate.x, calcTargetCoordinate.y + 1), //下 }; // 四方のマスの残移動力を計算 上下左右マスの座標を順に取り出し foreach (var aroundCellCoordinate in aroundCellCoordinates) { //FirstOrDefaultとは? 現在地から上下左右の座標を元にマップの座標を取得 var targetCell = cells.FirstOrDefault(c => c.X == aroundCellCoordinate.x && c.Y == aroundCellCoordinate.y); //nullはマイナス座標などでマップの範囲外とか infoとappendInfosにもう同じ座標のセルが有ればスルー //もうそのセルは移動可能にならないし if (null == targetCell || infos.Any(info => info.coordinate.x == aroundCellCoordinate.x && info.coordinate.y == aroundCellCoordinate.y) || appendInfos.Any(info => info.coordinate.x == aroundCellCoordinate.x && info.coordinate.y == aroundCellCoordinate.y)) { // マップに存在しない、または既に計算済みの座標はスルー continue; } PlayerModel playerModel = unitContainer.GetComponentsInChildren <PlayerModel>().FirstOrDefault( c => c.x == aroundCellCoordinate.x && c.z == aroundCellCoordinate.y); if (i >= maxRange) { //仲間が存在したら if (playerModel != null) { StatusCalculator statusCalc = new StatusCalculator(); int maxHp = playerModel.unit.maxhp + playerModel.unit.job.statusDto.jobHp; maxHp = statusCalc.CalcHpBuff(maxHp, playerModel.unit.job.skills); //回復出来る仲間が居ればリストに入れる if (playerModel.unit.hp < maxHp) { healableUnitList.Add(playerModel); Debug.Log($"回復出来る仲間を発見 X:{aroundCellCoordinate.x}, Y:{aroundCellCoordinate.y}"); } } } //残りの移動可能距離を取得、対象セルから移動可能コストを引く int remainingMoveAmount; remainingMoveAmount = i - 1; appendInfos.Add(new MoveAmountInfo(aroundCellCoordinate.x, aroundCellCoordinate.y, remainingMoveAmount)); }//四方のマス取得ループ } infos.AddRange(appendInfos); } //ここまで処理が入れば攻撃可能範囲内に敵は存在しない return(healableUnitList); }
//ステータス表示(敵) public void updateText(Enemy enemy) { //職業補正を取得 JobStatusDto jobStatusDto = enemy.job.statusDto; //名前、レベル、職業、移動力 this.name.text = enemy.name; this.race.text = enemy.race.GetStringValue(); this.lvNum.text = enemy.lv.ToString(); this.job.text = enemy.job.jobName.ToString(); this.exp.text = "-"; //敵に経験値やレベルアップは存在しない this.move.text = enemy.job.move.ToString(); //210226移動力計算と文字の色変更 StatusCalculator statusCalculator = new StatusCalculator(); int move = statusCalculator.calcMove(enemy); this.move.text = move.ToString(); //経験値ゲージ this.expGauge.maxValue = 100; this.expGauge.value = 0; //敵に経験値やレベルアップは存在しない //ステータス ユニット基礎値と職業補正の合算を表示する int hp = enemy.maxhp + jobStatusDto.jobHp; int latk = enemy.latk + jobStatusDto.jobLatk; int catk = enemy.catk + jobStatusDto.jobCatk; int agi = enemy.agi + jobStatusDto.jobAgi; int dex = enemy.dex + jobStatusDto.jobDex; int luk = enemy.luk + jobStatusDto.jobLuk; int ldef = enemy.ldef + jobStatusDto.jobLdef; int cdef = enemy.cdef + jobStatusDto.jobCdef; //キャラの画像を取得 if (enemy.isBoss) { statusImage.enabled = true; this.statusImage.sprite = Resources.Load <Sprite>("Image/Charactors/" + enemy.pathName + "/status"); } else { statusImage.enabled = false; } //武器レベルを反映 this.shotLevel.text = enemy.shotLevel.GetStringValue(); this.laserLevel.text = enemy.laserLevel.GetStringValue(); this.strikeLevel.text = enemy.strikeLevel.GetStringValue(); this.healLevel.text = enemy.healLevel.GetStringValue(); //敵に技能経験値は存在しないので、ゲージ自体非表示 shotGaugeFrame.SetActive(false); laserGaugeFrame.SetActive(false); strikeGaugeFrame.SetActive(false); healGaugeFrame.SetActive(false); if (move != enemy.job.move) { //バフが掛かってたら色変更 this.move.color = highLightColor; } else { this.move.color = Color.white; } //210218 武器、装飾品による増加分を反映する スキルのバフもいずれ実装 StatusDto normalStatus = new StatusDto(hp, latk, catk, agi, dex, ldef, cdef, luk); //武器、装飾品、スキルのバフ反映 最大値を上回らないようにして返される bool isberserk = false; if (enemy.hp != statusCalculator.CalcHpBuff(hp, enemy.job.skills) && enemy.job.skills.Contains(Skill.狂化)) { isberserk = true; } StatusDto buffedStatus = statusCalculator.GetBuffedStatus(normalStatus, enemy.name, enemy.equipWeapon, enemy.equipAccessory, enemy.job.skills, isberserk); GetStatus(normalStatus, buffedStatus); }
//テキスト更新 //200719 職業のステータスを反映 public void updateText(Unit unit) { //職業補正を取得 JobStatusDto jobStatusDto = unit.job.statusDto; //名前、レベル、職業、移動力 this.name.text = unit.name; this.race.text = unit.race.GetStringValue(); this.lvNum.text = unit.lv.ToString(); this.job.text = unit.job.jobName.ToString(); this.exp.text = unit.exp.ToString(); this.move.text = unit.job.move.ToString(); //210226移動力計算と文字の色変更 StatusCalculator statusCalculator = new StatusCalculator(); int move = statusCalculator.calcMove(unit); this.move.text = move.ToString(); //経験値ゲージ this.expGauge.maxValue = 100; this.expGauge.value = unit.exp; //ステータス ユニット基礎値と職業補正の合算を表示する int hp = unit.maxhp + jobStatusDto.jobHp; int latk = unit.latk + jobStatusDto.jobLatk; int catk = unit.catk + jobStatusDto.jobCatk; int agi = unit.agi + jobStatusDto.jobAgi; int dex = unit.dex + jobStatusDto.jobDex; int luk = unit.luk + jobStatusDto.jobLuk; int ldef = unit.ldef + jobStatusDto.jobLdef; int cdef = unit.cdef + jobStatusDto.jobCdef; //キャラの画像を取得 statusImage.enabled = true; this.statusImage.sprite = Resources.Load <Sprite>("Image/Charactors/" + unit.pathName + "/status"); //武器レベルを反映 this.shotLevel.text = unit.shotLevel.GetStringValue(); this.laserLevel.text = unit.laserLevel.GetStringValue(); this.strikeLevel.text = unit.strikeLevel.GetStringValue(); this.healLevel.text = unit.healLevel.GetStringValue(); //210218 やっと技能経験値を表示するように設定した shotGauge.value = unit.shotExp; laserGauge.value = unit.laserExp; strikeGauge.value = unit.strikeExp; healGauge.value = unit.healExp; //ゲージの必要経験値(maxValue)をスキルレベルより設定する shotGauge.maxValue = unit.shotLevel.GetIntValue(); laserGauge.maxValue = unit.laserLevel.GetIntValue(); strikeGauge.maxValue = unit.strikeLevel.GetIntValue(); healGauge.maxValue = unit.healLevel.GetIntValue(); if (move != unit.job.move) { //バフが掛かってたら色変更 this.move.color = highLightColor; } else { this.move.color = Color.white; } //スキルレベルがNONEかSの場合はゲージ自体を表示しない if (unit.shotLevel == SkillLevel.NONE || unit.shotLevel == SkillLevel.S) { shotGaugeFrame.SetActive(false); } else { shotGaugeFrame.SetActive(true); } if (unit.laserLevel == SkillLevel.NONE || unit.laserLevel == SkillLevel.S) { laserGaugeFrame.SetActive(false); } else { laserGaugeFrame.SetActive(true); } if (unit.strikeLevel == SkillLevel.NONE || unit.strikeLevel == SkillLevel.S) { strikeGaugeFrame.SetActive(false); } else { strikeGaugeFrame.SetActive(true); } if (unit.healLevel == SkillLevel.NONE || unit.healLevel == SkillLevel.S) { healGaugeFrame.SetActive(false); } else { healGaugeFrame.SetActive(true); } //210218 武器、装飾品による増加分を反映する スキルのバフもいずれ実装 StatusDto normalStatus = new StatusDto(hp, latk, catk, agi, dex, ldef, cdef, luk); //武器、装飾品、スキルのバフ反映 最大値を上回らないようにして返される bool isberserk = false; if (unit.hp != statusCalculator.CalcHpBuff(hp, unit.job.skills) && unit.job.skills.Contains(Skill.狂化)) { isberserk = true; } StatusDto buffedStatus = statusCalculator.GetBuffedStatus(normalStatus, unit.name, unit.equipWeapon, unit.equipAccessory, unit.job.skills, isberserk); GetStatus(normalStatus, buffedStatus); }