Ejemplo n.º 1
0
 public void Start()
 {
     DisplayStatus();
     foreach (var member in partyStatus.GetAllyStatus())
     {
         UpdateEquipButton(member);
         AllyStatusDictionary[member].Find("ChangeWeaponPanel/ChangeEquipButton").GetComponent <Button>().onClick.AddListener(() => SelectEquip(member, EquipType.Weapon));
         AllyStatusDictionary[member].Find("ChangeArmorPanel/ChangeEquipButton").GetComponent <Button>().onClick.AddListener(() => SelectEquip(member, EquipType.Armor));
         AllyStatusDictionary[member].Find("ChangeAccessoryPanel1/ChangeEquipButton").GetComponent <Button>().onClick.AddListener(() => SelectEquip(member, EquipType.Accessory1));
         AllyStatusDictionary[member].Find("ChangeAccessoryPanel2/ChangeEquipButton").GetComponent <Button>().onClick.AddListener(() => SelectEquip(member, EquipType.Accessory2));
     }
     okButton.GetComponent <Button>().onClick.AddListener(() => UpdateEquip());
 }
Ejemplo n.º 2
0
    //選択したコマンドで処理分け
    public void SelectCommand(string command)
    {
        if (command == "Status")
        {
            currentCommand = CommandMode.StatusPanelSelectCharacter;
            //UIのオン・オフや選択アイコンの設定
            commandPanelCanvasGroup.interactable = false;
            selectedGameObjectStack.Push(EventSystem.current.currentSelectedGameObject);

            GameObject characterButtonIns;

            //パーティーメンバー分のボタンを作成
            foreach (var member in partyStatus.GetAllyStatus())
            {
                characterButtonIns = Instantiate <GameObject>(characterPanelButtonPrefab, selectCharacterPanel.transform);
                characterButtonIns.GetComponentInChildren <Text>().text = member.GetCharacterName();
                characterButtonIns.GetComponent <Button>().onClick.AddListener(() => ShowStatus(member));
            }
        }
        else if (command == "Item")
        {
            currentCommand = CommandMode.ItemPanelSelectCharacter;
            statusPanel.SetActive(false);
            commandPanelCanvasGroup.interactable = false;
            selectedGameObjectStack.Push(EventSystem.current.currentSelectedGameObject);

            GameObject characterButtonIns;

            //パーティメンバー分のボタンを作成
            foreach (var member in partyStatus.GetAllyStatus())
            {
                characterButtonIns = Instantiate <GameObject>(characterPanelButtonPrefab, selectCharacterPanel.transform);
                characterButtonIns.GetComponentInChildren <Text>().text = member.GetCharacterName();
                characterButtonIns.GetComponent <Button>().onClick.AddListener(() => CreateItemPanelButton(member));
            }
        }
        //階層を一番最後に並べ替え
        selectCharacterPanel.transform.SetAsLastSibling();
        selectCharacterPanel.SetActive(true);
        selectCharacterPanelCanvasGroup.interactable = true;
        EventSystem.current.SetSelectedGameObject(selectCharacterPanel.transform.GetChild(0).gameObject);
    }
Ejemplo n.º 3
0
    private void Start()
    {
        GameObject characterPanel;

        // パーティーメンバー分のステータスを作成
        foreach (var member in partyStatus.GetAllyStatus())
        {
            characterPanel = Instantiate <GameObject>(characterPanelPrefab, characterStatusPanel.transform);
            characterPanel.transform.Find("CharacterName").GetComponent <Text>().text = member.GetCharacterName();
            characterPanel.transform.Find("HPSlider").GetComponent <Slider>().value   = (float)member.GetHp() / member.GetMaxHp();
            characterPanel.transform.Find("MPSlider").GetComponent <Slider>().value   = (float)member.GetMp() / member.GetMaxMp();
        }
    }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        statusPanel.Add(statusPanel1);
        // ステータス用テキスト
        characterNameText.Add(statusPanel[0].transform.Find("CharacterNamePanel/Text").GetComponent <Text>());
        statusTitleText.Add(statusPanel[0].transform.Find("StatusParamPanel/Title").GetComponent <Text>());
        statusParam1Text.Add(statusPanel[0].transform.Find("StatusParamPanel/Param1").GetComponent <Text>());
        statusParam2Text.Add(statusPanel[0].transform.Find("StatusParamPanel/Param2").GetComponent <Text>());
        ShowStatus(partyStatus.GetAllyStatus()[0], statusPanel[0], characterNameText[0], statusTitleText[0], statusParam1Text[0], statusParam2Text[0]);

        statusPanel.Add(statusPanel2);
        // ステータス用テキスト
        characterNameText.Add(statusPanel[1].transform.Find("CharacterNamePanel/Text").GetComponent <Text>());
        statusTitleText.Add(statusPanel[1].transform.Find("StatusParamPanel/Title").GetComponent <Text>());
        statusParam1Text.Add(statusPanel[1].transform.Find("StatusParamPanel/Param1").GetComponent <Text>());
        statusParam2Text.Add(statusPanel[1].transform.Find("StatusParamPanel/Param2").GetComponent <Text>());
        ShowStatus(partyStatus.GetAllyStatus()[1], statusPanel[1], characterNameText[1], statusTitleText[1], statusParam1Text[1], statusParam2Text[1]);

        // 各画面への移動ボタンに関数をセット
        GameObject.Find("ToItemButton").GetComponent <Button>().onClick.AddListener(() => MoveToAnotherCanvas(TopCanvas, ItemCanvas));
        GameObject.Find("ToFormButton").GetComponent <Button>().onClick.AddListener(() => MoveToAnotherCanvas(TopCanvas, FormCanvas));
        GameObject.Find("ToSystemButton").GetComponent <Button>().onClick.AddListener(() => MoveToAnotherCanvas(TopCanvas, SystemCanvas));
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        // シーン遷移途中とユニティちゃんの状態によっては表示しない
        if (sceneManager.IsTransition() ||
            baseCommand.GetState() == BaseCommand.State.Talk ||
            baseCommand.GetState() == BaseCommand.State.Command
            )
        {
            elapsedTime = 0f;
            characterStatusPanel.SetActive(false);
            return;
        }

        // 何らかのキーが押された時
        if (Input.GetMouseButtonDown(0))
        {
            elapsedTime = 0f;
            // キャラクターステータスパネルの子要素があれば削除する
            for (int i = characterStatusPanel.transform.childCount - 1; i >= 0; i--)
            {
                Destroy(characterStatusPanel.transform.GetChild(i).gameObject);
            }
            characterStatusPanel.SetActive(false);
            isOpenCharacterStatusPanel = false;
            // キャラクターステータスパネルを開いていない時だけ
        }
        else if (!isOpenCharacterStatusPanel)
        {
            elapsedTime += Time.deltaTime;
            // 経過時間が一定時間を越えたらキャラクターステータスパネルを表示
            if (elapsedTime >= idleTime)
            {
                GameObject characterPanel;
                // パーティーメンバー分のステータスを作成
                foreach (var member in partyStatus.GetAllyStatus())
                {
                    characterPanel = Instantiate <GameObject>(characterPanelPrefab, characterStatusPanel.transform);
                    characterPanel.transform.Find("CharacterName").GetComponent <Text>().text   = member.GetCharacterName();
                    characterPanel.transform.Find("HPSlider").GetComponent <Slider>().value     = (float)member.GetHp() / member.GetMaxHp();
                    characterPanel.transform.Find("HPSlider/HPText").GetComponent <Text>().text = member.GetHp().ToString();
                    characterPanel.transform.Find("MPSlider").GetComponent <Slider>().value     = (float)member.GetMp() / member.GetMaxMp();
                    characterPanel.transform.Find("MPSlider/MPText").GetComponent <Text>().text = member.GetMp().ToString();
                }
                characterStatusPanel.SetActive(true);
                elapsedTime = 0f;
                isOpenCharacterStatusPanel = true;
            }
        }
    }
Ejemplo n.º 6
0
    // ステータスデータの表示
    public void DisplayStatus()
    {
        BaseStatus member;
        Transform  characterPanelTransform;

        for (int i = 0; i < 4; i++)
        {
            characterPanelTransform = transform.Find("CharacterPanel" + i);
            if (i < partyStatus.GetAllyStatus().Count)
            {
                member = partyStatus.GetAllyStatus()[i];
                characterPanelTransform.Find("CharacterName").GetComponent <Text>().text   = member.GetCharacterName();
                characterPanelTransform.Find("HPSlider").GetComponent <Slider>().value     = (float)member.GetHp() / member.GetMaxHp();
                characterPanelTransform.Find("HPSlider/HPText").GetComponent <Text>().text = member.GetHp().ToString();
                characterPanelTransform.Find("MPSlider").GetComponent <Slider>().value     = (float)member.GetMp() / member.GetMaxMp();
                characterPanelTransform.Find("MPSlider/MPText").GetComponent <Text>().text = member.GetMp().ToString();
                characterStatusDictionary.Add(member, characterPanelTransform);
            }
            else
            {
                characterPanelTransform.gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 7
0
    // アイテムを使用するキャラクターを選択する
    public void UseItem(Item item)
    {
        useItemPanelCanvasGroup.interactable = false;
        useItemSelectCharacterPanel.SetActive(true);
        // UseItemPanelでどれを最後に選択していたか
        selectedGameObjectStack.Push(EventSystem.current.currentSelectedGameObject);

        GameObject characterButtonIns;

        // パーティメンバー分のボタンを作成
        foreach (var member in partyStatus.GetAllyStatus())
        {
            characterButtonIns = Instantiate <GameObject>(characterPanelButtonPrefab, useItemSelectCharacterPanel.transform);
            characterButtonIns.GetComponentInChildren <Text>().text = member.GetCharacterName();
            characterButtonIns.GetComponent <Button>().onClick.AddListener(() => UseItemToCharacter(member, item));
        }
        characterButtonIns = Instantiate <GameObject>(characterPanelButtonPrefab, useItemSelectCharacterPanel.transform);
        characterButtonIns.GetComponentInChildren <Text>().text = "やめる";
        characterButtonIns.GetComponent <Button>().onClick.AddListener(() => OnCancelButton());
        // UseItemSelectCharacterPanelに移行する
        currentCommand = CommandMode.UseItemSelectCharacterPanel;
        useItemSelectCharacterPanelCanvasGroup.interactable = true;
    }
Ejemplo n.º 8
0
    // 敗戦時の表示
    public IEnumerator DisplayDefeatResult()
    {
        yield return(new WaitForSeconds(timeToDisplay));

        resultPanel.SetActive(true);
        resultText.text = "ユニティちゃん達は全滅した。";
        isDisplayResult = true;
        yield return(new WaitForSeconds(timeToDisplay));

        var finishText = resultPanel.transform.Find("FinishText");

        finishText.GetComponent <Text>().text = "最初の街へ";
        finishText.gameObject.SetActive(true);

        // 味方が全滅したのでユニティちゃんのHPだけ少し回復しておく
        var unityChanStatus = partyStatus.GetAllyStatus().Find(character => character.GetCharacterName() == "ユニティちゃん");

        if (unityChanStatus != null)
        {
            unityChanStatus.SetHp(1);
        }

        isFinishResult = true;
    }
Ejemplo n.º 9
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();
    }