コード例 #1
0
    private void Start()
    {
        animator = GetComponent <Animator>();
        // 元データから設定
        hp         = characterStatus.GetHp();
        mp         = characterStatus.GetMp();
        isNumbness = characterStatus.IsNumbnessState();
        isPoison   = characterStatus.IsPoisonState();

        // 状態の設定
        battleState = BattleState.Idle;
        //ガードの状態
        guardPercentage = 1;
        // コンポーネントの取得
        battleManager      = GameObject.Find("BattleManager").GetComponent <BattleManager>();
        partyStatus        = battleManager.partyStatus;
        battleStatusScript = GameObject.Find("BattleUICanvas/PlayerUI/StatusPanel").GetComponent <BattleStatusScript>();
        // 既に死んでいる場合は倒れている状態にする
        if (characterStatus.GetHp() <= 0)
        {
            animator.CrossFade("Dead", 0f, 0, 1f);
            isDead = true;
        }
    }
コード例 #2
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();
    }