Ejemplo n.º 1
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);
        }
    }
Ejemplo n.º 2
0
    // 攻撃処理
    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() + "を行った");
        }
    }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        magicOrItemPanelContent = magicOrItemPanel;
        int size = enemyPartyStatusList.GetPartyMembersList().Count;

        enemyPartyStatus = enemyPartyStatusList.GetPartyMembersList()[(int)(Random.value * 100) % size];
        // 同じ名前の敵がいた場合の処理に使うリスト
        List <string> enemyNameList = new List <string>();

        Transform         characterTransform;
        List <GameObject> instances = new List <GameObject>();
        GameObject        ins;
        string            characterName;

        int positionNum = 0;

        // 味方パーティーのプレハブをインスタンス化
        foreach (AllyStatus allyChara in partyStatus.GetAllyStatus())
        {
            characterTransform = battleBasePosition.Find("AllyPos" + positionNum).transform;
            ins = Instantiate <GameObject>(allyChara.GetBattleObject(), characterTransform.position, characterTransform.rotation);
            ins.AddComponent <CharacterBattleScript>();
            ins.GetComponent <CharacterBattleScript>().characterStatus = allyChara;
            ins.name = allyChara.GetCharacterName();
            if (allyChara.GetHp() > 0)
            {
                allyCharacterInBattleList.Add(ins);
                allCharacterList.Add(ins);
            }
            positionNum++;
        }
        if (enemyPartyStatus == null)
        {
            Debug.LogError("敵パーティーデータが設定されていません。");
        }
        // 敵パーティーのプレハブをインスタンス化
        for (int i = 0; i < enemyPartyStatus.GetEnemyGameObjectList().Count; i++)
        {
            characterTransform = battleBasePosition.Find("EnemyPos" + i).transform;
            ins = Instantiate <GameObject>(enemyPartyStatus.GetEnemyGameObjectList()[i], characterTransform.position, characterTransform.rotation);
            // 既に同じ敵が存在したら文字を付加する
            characterName = ins.GetComponent <CharacterBattleScript>().GetCharacterStatus().GetCharacterName();
            if (!enemyNameList.Contains(characterName))
            {
                ins.name = characterName + 'A';
            }
            else
            {
                ins.name = characterName + (char)('A' + enemyNameList.Count(enemyName => enemyName == characterName));
            }
            enemyNameList.Add(characterName);
            enemyCharacterInBattleList.Add(ins);
            allCharacterList.Add(ins);
        }
        // キャラクターリストをキャラクターの素早さの高い順に並べ替え
        allCharacterList = allCharacterList.OrderByDescending(character => character.GetComponent <CharacterBattleScript>().GetCharacterStatus().GetAgility()).ToList <GameObject>();
        // 現在の戦闘
        allCharacterInBattleList = allCharacterList.ToList <GameObject>();
        Debug.Log(allCharacterInBattleList.Count);
        // 確認の為並べ替えたリストを表示
        foreach (var character in allCharacterInBattleList)
        {
            Debug.Log(character.GetComponent <CharacterBattleScript>().GetCharacterStatus().GetCharacterName() + " : " + character.GetComponent <CharacterBattleScript>().GetCharacterStatus().GetAgility());
        }
        // 戦闘前の待ち時間を設定
        waitTime = firstWaitingTime;
        // ランダム値のシードの設定
        Random.InitState((int)Time.time);

        battleResult = battleResultManager.GetComponent <BattleResult>();

        isStartTarn = false;

        isFailGetAway = false;

        // 最初の全データ表示
        battleStatusScript = GameObject.Find("BattleUICanvas/PlayerUI/StatusPanel").GetComponent <BattleStatusScript>();
        battleStatusScript.DisplayStatus();
        // 選択コマンドボタンを設定
        foreach (GameObject allyCharacterInBattle in allyCharacterInBattleList)
        {
            CharacterStatus allyCharacterStatus = allyCharacterInBattle.GetComponent <CharacterBattleScript>().GetCharacterStatus();
            SetSelectCommand(allyCharacterInBattle, allyCharacterStatus.GetSkillList()[0], enemyCharacterInBattleList[0]);
        }

        //ターンの初期化と表示
        turn          = 1;
        turnText.text = "ターン: " + turn.ToString();
    }