Ejemplo n.º 1
0
    //物理攻撃のダメージ処理
    public void DirectAttack()
    {
        var damage = 0;

        // 攻撃相手のStatus
        if (targetBaseStatus as AllyStatus != null)
        {
            var castedTargetStatus = (AllyStatus)targetCharacterBattleScript.GetCharacterStatus();
            // 攻撃相手の通常の防御力+相手のキャラの補助値
            var targetDefencePower = castedTargetStatus.GetStrikingStrength() + (castedTargetStatus.GetEquipArmor()?.GetAmount() ?? 0);
            damage = Mathf.Max(0, (baseStatus.GetPower() * auxiliaryPower) - targetDefencePower * targetCharacterBattleScript.GetAuxiliaryStrikingStrength());
            battleManager.ShowMessage(currentTarget.name + "は" + damage + "のダメージを受けた。");
            // 相手のステータスのHPをセット
            targetCharacterBattleScript.SetHp(targetCharacterBattleScript.GetHp() - damage);
            // ステータスUIを更新
            battleStatusScript.UpdateStatus(targetBaseStatus, BattleStatus.Status.HP, targetCharacterBattleScript.GetHp());
        }
        else if (targetBaseStatus as EnemyStatus != null)
        {
            var castedTargetStatus = (EnemyStatus)targetCharacterBattleScript.GetCharacterStatus();
            // 攻撃相手の通常の防御力+相手のキャラの補助値
            var targetDefencePower = castedTargetStatus.GetStrikingStrength() * targetCharacterBattleScript.GetAuxiliaryStrikingStrength();
            damage = Mathf.Max(0, (baseStatus.GetPower() + (((AllyStatus)baseStatus).GetEquipWeapon()?.GetAmount() ?? 0) * auxiliaryPower) - targetDefencePower);
            battleManager.ShowMessage(currentTarget.name + "は" + damage + "のダメージを受けた。");
            // 敵のステータスのHPをセット
            targetCharacterBattleScript.SetHp(targetCharacterBattleScript.GetHp() - damage);
        }
    }
Ejemplo n.º 2
0
    // 敵の攻撃処理
    public void EnemyAttack(GameObject character)
    {
        CharacterBattle characterBattleScript = character.GetComponent <CharacterBattle>();
        BaseStatus      characterStatus       = characterBattleScript.GetCharacterStatus();

        if (characterStatus.GetSkillList().Count <= 0)
        {
            return;
        }
        // 敵の行動アルゴリズム
        int randomValue = (int)(Random.value * characterStatus.GetSkillList().Count);
        var nowSkill    = characterStatus.GetSkillList()[randomValue];

        // テスト用(特定のスキルで確認)
        //nowSkill = characterStatus.GetSkillList()[0];

        if (nowSkill.GetSkillType() == Skill.Type.DirectAttack)
        {
            var targetNum = (int)(Random.value * allyCharacterInBattleList.Count);
            // 攻撃相手のCharacterBattleScript
            characterBattleScript.ChooseAttackOptions(CharacterBattle.BattleState.DirectAttack, allyCharacterInBattleList[targetNum], nowSkill);
        }
        else if (nowSkill.GetSkillType() == Skill.Type.MagicAttack)
        {
            var targetNum = (int)(Random.value * allyCharacterInBattleList.Count);
            if (characterBattleScript.GetMp() >= ((Magic)nowSkill).GetAmountToUseMagicPoints())
            {
                // 攻撃相手のCharacterBattleScript
                characterBattleScript.ChooseAttackOptions(CharacterBattle.BattleState.MagicAttack, allyCharacterInBattleList[targetNum], nowSkill);
            }
            else
            {
                // MPが足りない場合は直接攻撃を行う
                ShowMessage("MPが足りない!");
                characterBattleScript.ChooseAttackOptions(CharacterBattle.BattleState.DirectAttack, allyCharacterInBattleList[targetNum], characterStatus.GetSkillList().Find(skill => skill.GetSkillType() == Skill.Type.DirectAttack));
            }
        }
        else if (nowSkill.GetSkillType() == Skill.Type.RecoveryMagic)
        {
            if (characterBattleScript.GetMp() >= ((Magic)nowSkill).GetAmountToUseMagicPoints())
            {
                var targetNum = (int)(Random.value * enemyCharacterInBattleList.Count);
                // 回復相手のCharacterBattleScript
                characterBattleScript.ChooseAttackOptions(CharacterBattle.BattleState.Healing, enemyCharacterInBattleList[targetNum], nowSkill);
            }
            else
            {
                ShowMessage("MPが足りない!");
                var targetNum = (int)(Random.value * allyCharacterInBattleList.Count);
                // MPが足りない場合は直接攻撃を行う
                characterBattleScript.ChooseAttackOptions(CharacterBattle.BattleState.DirectAttack, allyCharacterInBattleList[targetNum], characterStatus.GetSkillList().Find(skill => skill.GetSkillType() == Skill.Type.DirectAttack));
            }
        }
    }
Ejemplo n.º 3
0
    // 選択肢から選んだモードを実行
    public void ChooseAttackOptions(BattleState selectOption, GameObject target, Skill skill = null, Item item = null)
    {
        // スキルやターゲットの情報をセット
        currentTarget = target;
        currentSkill  = skill;
        targetCharacterBattleScript = target.GetComponent <CharacterBattle>();
        targetBaseStatus            = targetCharacterBattleScript.GetCharacterStatus();

        // 選択したキャラクターの状態を設定
        battleState = selectOption;

        if (selectOption == BattleState.DirectAttack)
        {
            battleManager.ShowMessage(gameObject.name + "は" + currentTarget.name + "に" + currentSkill.GetKanjiName() + "を行った。");
        }
        else if (selectOption == BattleState.MagicAttack ||
                 selectOption == BattleState.Healing ||
                 selectOption == BattleState.IncreaseAttackPowerMagic ||
                 selectOption == BattleState.IncreaseDefencePowerMagic
                 )
        {
            // 魔法使用者のMPを減らす
            SetMp(GetMp() - ((Magic)skill).GetAmountToUseMagicPoints());
            battleManager.ShowMessage(gameObject.name + "は" + currentTarget.name + "に" + currentSkill.GetKanjiName() + "を使った。");
            // 使用者が味方キャラクターであればStatusPanelの更新
            if (GetCharacterStatus() as AllyStatus != null)
            {
                battleStatusScript.UpdateStatus(GetCharacterStatus(), BattleStatus.Status.MP, GetMp());
            }
            //Instantiate(((Magic)skill).GetSkillUserEffect(), transform.position, ((Magic)skill).GetSkillUserEffect().transform.rotation);
        }
        else if (selectOption == BattleState.UseHPRecoveryItem ||
                 selectOption == BattleState.UseMPRecoveryItem ||
                 selectOption == BattleState.UseParalyzeRecoveryItem ||
                 selectOption == BattleState.UsePoisonRecoveryItem
                 )
        {
            currentItem = item;
            battleManager.ShowMessage(gameObject.name + "は" + currentTarget.name + "に" + item.GetKanjiName() + "を使った。");
        }
    }