示例#1
0
    public void UseItem()
    {
        //currentTarget.GetComponent<Animator>().SetTrigger("Damage");

        // バーティののアイテム数を減らす
        partyStatus.SetItemNum(currentItem, partyStatus.GetItemNum(currentItem) - 1);

        if (currentItem.GetItemType() == Item.Type.HPRecovery)
        {
            // 回復力
            var recoveryPoint = currentItem.GetAmount();
            targetCharacterBattleScript.SetHp(targetCharacterBattleScript.GetHp() + recoveryPoint);
            battleStatusScript.UpdateStatus(targetCharacterStatus, BattleStatusScript.Status.HP, targetCharacterBattleScript.GetHp());
            battleManager.ShowMessage(gameObject.name + "は" + currentItem.GetKanjiName() + "を使って" + currentTarget.name + "のHPを" + recoveryPoint + "回復した。");
        }
        else if (currentItem.GetItemType() == Item.Type.MPRecovery)
        {
            // 回復力
            var recoveryPoint = currentItem.GetAmount();
            targetCharacterBattleScript.SetMp(targetCharacterBattleScript.GetMp() + recoveryPoint);
            battleStatusScript.UpdateStatus(targetCharacterStatus, BattleStatusScript.Status.MP, targetCharacterBattleScript.GetMp());
            battleManager.ShowMessage(gameObject.name + "は" + currentItem.GetKanjiName() + "を使って" + currentTarget.name + "のMPを" + recoveryPoint + "回復した。");
        }
        else if (currentItem.GetItemType() == Item.Type.NumbnessRecovery)
        {
            targetCharacterStatus.SetNumbness(false);
            battleManager.ShowMessage(gameObject.name + "は" + currentItem.GetKanjiName() + "を使って" + currentTarget.name + "の痺れを消した。");
        }
        else if (currentItem.GetItemType() == Item.Type.PoisonRecovery)
        {
            targetCharacterStatus.SetPoisonState(false);
            battleManager.ShowMessage(gameObject.name + "は" + currentItem.GetKanjiName() + "を使って" + currentTarget.name + "の毒を消した。");
        }

        // アイテム数が0になったらItemDictionaryからそのアイテムを削除
        if (partyStatus.GetItemNum(currentItem) == 0)
        {
            partyStatus.GetItemDictionary().Remove(currentItem);
        }
    }
    // 攻撃処理
    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() + "を行った");
        }
    }