public void DeleteEnemyCharacterInBattleList(GameObject deleteObj) { enemyCharacterInBattleList.Remove(deleteObj); deleteObj.SetActive(false); if (enemyCharacterInBattleList.Count == 0) { Debug.Log("敵が全滅"); ShowMessage("敵が全滅"); battleIsOver = true; battleIsOver = true; playerUI.SetActive(false); CharacterBattleScript characterBattleScript; foreach (var character in allCharacterList) { // 味方キャラクターの戦闘で増減したHPとMPを通常のステータスに反映させる characterBattleScript = character.GetComponent <CharacterBattleScript>(); if (characterBattleScript.GetCharacterStatus() as AllyStatus != null) { characterBattleScript.GetCharacterStatus().SetHp(characterBattleScript.GetHp()); characterBattleScript.GetCharacterStatus().SetMp(characterBattleScript.GetMp()); characterBattleScript.GetCharacterStatus().SetNumbness(characterBattleScript.IsNumbness()); characterBattleScript.GetCharacterStatus().SetPoisonState(characterBattleScript.IsPoison()); } } // 勝利時の結果表示 battleResult.InitialProcessingOfVictoryResult(allCharacterList, allyCharacterInBattleList); } else { //選択対象のリセット foreach (GameObject allyCharacterInBattle in allyCharacterInBattleList) { CharacterStatus allyCharacterStatus = allyCharacterInBattle.GetComponent <CharacterBattleScript>().GetCharacterStatus(); if (nextActs[allyCharacterStatus.GetCharacterName()].targetChara == deleteObj) { nextActs[allyCharacterStatus.GetCharacterName()].targetChara = enemyCharacterInBattleList[0]; } } } }
// キャラクターの攻撃の選択処理 public void MakeAttackChoise(GameObject character) { CharacterStatus characterStatus = character.GetComponent <CharacterBattleScript>().GetCharacterStatus(); // EnemyStatusにキャスト出来る場合は敵の攻撃処理 if (characterStatus as EnemyStatus != null) { // 敵の行動アルゴリズム int randomValue = (int)(Random.value * characterStatus.GetSkillList().Count); var targetNum = (int)(Random.value * allyCharacterInBattleList.Count); AttackProcess(character, characterStatus.GetSkillList()[randomValue], allyCharacterInBattleList[targetNum]); } else { AttackProcess(character, nextActs[characterStatus.GetCharacterName()].skill, nextActs[characterStatus.GetCharacterName()].targetChara, nextActs[characterStatus.GetCharacterName()].item); } }
//選択したコマンドをセットする private void SetSelectCommand(GameObject allyCharacterInBattle, Skill skill, GameObject targetChara = null, Item item = null) { CharacterStatus allyCharacterStatus = allyCharacterInBattle.GetComponent <CharacterBattleScript>().GetCharacterStatus(); NextAct nextAct = new NextAct(); nextAct.skill = skill; nextAct.targetChara = targetChara; nextAct.item = item; nextActs[allyCharacterStatus.GetCharacterName()] = nextAct; battleStatusScript.UpdateSelect(allyCharacterStatus, skill.GetKanjiName(), AllySelectCommand, allyCharacterInBattle); commandPanel.gameObject.SetActive(false); magicOrItemPanel.gameObject.SetActive(false); ResetCharacterPanel(); //キャンセルボタンを使用不可能に cancelButton.interactable = false; //攻撃ボタンを使用可能に attackButton.interactable = true; //逃げるボタンを使用可能に getAwayButton.interactable = true; }
// 攻撃処理 public void AttackProcess(GameObject character, Skill nowSkill, GameObject targetChara, Item item = null) { CharacterBattleScript characterBattleScript = character.GetComponent <CharacterBattleScript>(); CharacterStatus characterStatus = characterBattleScript.GetCharacterStatus(); if (characterStatus.GetSkillList().Count <= 0) { return; } // 敵がガード状態であればガードを解く /* * if (character.GetComponent<Animator>().GetBool("Guard")) * { * character.GetComponent<CharacterBattleScript>().UnlockGuard(); * } */ character.GetComponent <CharacterBattleScript>().UnlockGuard(); //味方で逃走失敗なら何もしない if (isFailGetAway && characterStatus as AllyStatus != null) { ChangeNextChara(); return; } ShowMessage(characterStatus.GetCharacterName() + "の攻撃"); if (nowSkill.GetSkillType() == Skill.Type.DirectAttack) { // 攻撃相手のCharacterBattleScript characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.DirectAttack, targetChara, nowSkill); Debug.Log(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); ShowMessage(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); } else if (nowSkill.GetSkillType() == Skill.Type.MagicAttack) { if (characterBattleScript.GetMp() >= ((Magic)nowSkill).GetAmountToUseMagicPoints()) { // 攻撃相手のCharacterBattleScript characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.MagicAttack, targetChara, nowSkill); Debug.Log(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); ShowMessage(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); } else { Debug.Log("MPが足りない!"); ShowMessage("MPが足りない!"); // MPが足りない場合は直接攻撃を行う characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.DirectAttack, targetChara, characterStatus.GetSkillList().Find(skill => skill.GetSkillType() == Skill.Type.DirectAttack)); Debug.Log(character.name + "は攻撃を行った"); ShowMessage(character.name + "は攻撃を行った"); } } else if (nowSkill.GetSkillType() == Skill.Type.RecoveryMagic) { if (characterBattleScript.GetMp() >= ((Magic)nowSkill).GetAmountToUseMagicPoints()) { // 回復相手のCharacterBattleScript characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.Healing, targetChara, nowSkill); Debug.Log(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); ShowMessage(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); } else { Debug.Log("MPが足りない!"); ShowMessage("MPが足りない!"); // MPが足りない場合は直接攻撃を行う characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.DirectAttack, targetChara, characterStatus.GetSkillList().Find(skill => skill.GetSkillType() == Skill.Type.DirectAttack)); Debug.Log(character.name + "は攻撃を行った"); ShowMessage(character.name + "は攻撃を行った"); } } else if (nowSkill.GetSkillType() == Skill.Type.Item) { //characterBattleScript.ChooseAttackOptions(CharacterBattleScript.BattleState.UseHPRecoveryItem, targetChara, nowSkill, item); UseItem(character, targetChara, item); } else if (nowSkill.GetSkillType() == Skill.Type.Guard) { characterBattleScript.Guard(); // Guardアニメはboolなのでアニメーション遷移させたらすぐに次のキャラクターに移行させる ChangeNextChara(); Debug.Log(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); ShowMessage(character.name + "は" + nowSkill.GetKanjiName() + "を行った"); } }