★Aoi Murakami

(2024年5月8日)

<ラウンドのタイマー>

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TimeController : MonoBehaviour
{
    public AudioClip sound;
    public Text timeLabel;
    private int count = 180;
    private int min;
    private int sec;

    void Start()
    {
        min = count / 60;
        sec = count % 60;
        timeLabel.text = "TIME " + min + ":" + sec.ToString("D2");

        StartCoroutine(Timer());
    }

    private IEnumerator Timer()
    {
        yield return new WaitForSeconds(5);

        while (true)
        {
            yield return new WaitForSeconds(0.2f);

            count -= 1;
            min = count / 60;
            sec = count % 60;
            timeLabel.text = "TIME " + min + ":" + sec.ToString("D2");

            if (count == 0)
            {
                AudioSource.PlayClipAtPoint(sound, transform.position);
                break;
            }
        }
    }
}

 


(2024年4月24日)

<パワーを設定する>

1)BaseHPスクリプトの改良

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public abstract class BaseHP : MonoBehaviour
{
    public GameObject effectPrefab { get; set; }
    public int HP { get; set; }
    public Slider HPSlider { get; set; }

    public Text winnerLabel { get; set; }
    public string winnerName { get; set; }

    protected AudioSource audioX;
    public AudioClip endingSound { get; set; }
    public AudioClip hitSound { get; set; }

    // ★4月24日・追加(パワー)
    public int oppnentPower; // 対戦相手のパワー

    protected virtual void Start()
    {
        HPSlider.maxValue = HP;
        HPSlider.value = HP;

        audioX = this.gameObject.AddComponent();
    }

    protected virtual void OnTriggerEnter(Collider other)
    {
        
    }
}

2) P1_HPスクリプトの改良

P2_HPスクリプトも同じ場所を改良する。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class P1_HP : BaseHP
{
    protected override void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("P2_Punch"))
        {
            GameObject effect = Instantiate(effectPrefab, other.transform.position, Quaternion.identity);
            Destroy(effect, 0.5f);

            audioX.PlayOneShot(hitSound);

            // ★4月24日・改良(パワー)
            HP -= oppnentPower;

            HPSlider.value = HP;

            if (HP < 1)
            {
                transform.root.GetComponent().SetTrigger("Down");

                transform.root.GetComponent().isGong = false;

                other.transform.root.GetComponent().isGong = false;

                other.transform.root.GetComponent().SetTrigger("Victory");

                audioX.PlayOneShot(endingSound);

                winnerLabel.enabled = true;
                winnerLabel.text = "勝者は" + winnerName;
            }
        }
    }
}

3)CharaSpawnスクリプトの改良

★★★の部分を追加する。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CharaSpawn : MonoBehaviour
{
    // *データベース
    public CharaDataBase charaDataBase;

    public Vector3 point_P1;
    public Vector3 point_P2;

    public int p1Num;
    public int p2Num;

    // サウンド
    public AudioClip punchSound;
    public AudioClip hitSound;
    public AudioClip endingSound;

    // エフェクト
    public GameObject hitEffectPrefab;

    // UI
    public Text p1NameLabel;
    public Text p2NameLabel;

    public Slider p1HPSlider;
    public Slider p2HPSlider;

    public Slider p1StaminaSlider;
    public Slider p2StaminaSlider;

    // スタミナ切れ
    public Image p1FillImage;
    public Image p2FillImage;

    public Text winnerLabel;

    // カメラ
    public GameObject p1Camera;
    public GameObject p2Camera;

    // HP
    private List allChildren1 = new List();
    private List allChildren2 = new List();

    private void Awake()
    {
        p1Num = SelectManager.instance.selectNumber_P1;
        p2Num = SelectManager.instance.selectNumber_P2;
    }

    void Start()
    {
        // <<Player1>>
        // ①生成
        GameObject player1 = Instantiate(charaDataBase.charaList[p1Num].charaPrefab, point_P1, Quaternion.Euler(0, 135, 0));

        // ②移動
        player1.AddComponent();
        player1.GetComponent().moveSpeed = charaDataBase.charaList[p1Num].moveSpeed;

        // ③パンチ効果音
        player1.GetComponent().punchSound = punchSound;

        // スタミナ
        player1.GetComponent().stamina = charaDataBase.charaList[p1Num].stamina;
        player1.GetComponent().staminaSlider = p1StaminaSlider;

        // スタミナ切れ
        player1.GetComponent().fillImage = p1FillImage;
        player1.GetComponent().initialColor = p1FillImage.color;


        // ④HP
        // (テクニック)全階層の子供オブジェクトの取得(再帰的な処理の実行)
        Transform p1Transform = player1.transform;

        GetAllChildren(p1Transform, allChildren1);

        // 取得した全オブジェクトの名前を照合する
        foreach (GameObject g in allChildren1)
        {
            if (g.name == "J_Bip_C_Neckck")
            {
                g.AddComponent();

                g.GetComponent().effectPrefab = hitEffectPrefab;

                g.GetComponent().HP = charaDataBase.charaList[p1Num].charaHP; // データベースからHP情報の取得

                g.GetComponent().HPSlider = p1HPSlider;

                // ヒットサウンド
                g.GetComponent().hitSound = hitSound;

                // エンディングサウンド
                g.GetComponent().endingSound = endingSound;

                // 勝者
                g.GetComponent().winnerLabel = winnerLabel;
                g.GetComponent().winnerName = charaDataBase.charaList[p2Num].charaName;

           
                // ★★★4月24日・追加(パワー)
                // 対戦相手のパワーを設定する(重要ポイント)
                g.GetComponent().oppnentPower = charaDataBase.charaList[p2Num].power;
            }
        }

        // 子供オブジェクトのTagを変更する
        foreach (GameObject g in allChildren1)
        {
            if (g.name == "J_Bip_R_Hand" || g.name == "J_Bip_L_Hand")
            {
                g.tag = "P1_Punch";
            }
        }

        // ⑤名前表示
        p1NameLabel.text = "" + charaDataBase.charaList[p1Num].charaName;

        // ⑥カメラ(親子関係)
        p1Camera.transform.parent = player1.transform;

        // <<Player2>>
        // ①生成
        GameObject player2 = Instantiate(charaDataBase.charaList[p2Num].charaPrefab, point_P2, Quaternion.Euler(0, -45, 0));

        // ②移動・旋回
        player2.AddComponent();
        player2.GetComponent().moveSpeed = charaDataBase.charaList[p2Num].moveSpeed;

        // ③パンチ効果音
        player2.GetComponent().punchSound = punchSound;

        // スタミナ
        player2.GetComponent().stamina = charaDataBase.charaList[p2Num].stamina;
        player2.GetComponent().staminaSlider = p2StaminaSlider;

        // スタミナ切れ
        player2.GetComponent().fillImage = p2FillImage;
        player2.GetComponent().initialColor = p2FillImage.color;

        // ④HP
        Transform p2Transform = player2.transform;

        GetAllChildren(p2Transform, allChildren2);

        foreach (GameObject g in allChildren2)
        {
            if (g.name == "J_Bip_C_Neckck")
            {
                g.AddComponent();

                g.GetComponent().effectPrefab = hitEffectPrefab;

                g.GetComponent().HP = charaDataBase.charaList[p2Num].charaHP;

                g.GetComponent().HPSlider = p2HPSlider;

                // ヒットサウンド
                g.GetComponent().hitSound = hitSound;

                // エンディングサウンド
                g.GetComponent().endingSound = endingSound;

                // 勝者
                g.GetComponent().winnerLabel = winnerLabel;
                g.GetComponent().winnerName = charaDataBase.charaList[p1Num].charaName;

                // ★★★4月24日・追加(パワー)
                // 対戦相手のパワーを設定する(重要ポイント)
                g.GetComponent().oppnentPower = charaDataBase.charaList[p1Num].power;
            }
        }

        foreach (GameObject g in allChildren2)
        {
            if (g.name == "J_Bip_R_Hand" || g.name == "J_Bip_L_Hand")
            {
                g.tag = "P2_Punch";
            }
        }

        // ⑤名前表示
        p2NameLabel.text = "" + charaDataBase.charaList[p2Num].charaName;

        // ⑥カメラ(親子関係)
        p2Camera.transform.parent = player2.transform;

        // 相手の方に向く
        player1.GetComponent().target = player2;
        player2.GetComponent().target = player1;
    }

    // HP
    // 再帰的に子供オブジェクトを取得する
    void GetAllChildren(Transform parent, List childList)
    {
        // 親の子オブジェクト(1階層下のオブジェクト)の数だけ処理を繰り返す
        foreach (Transform t in parent)
        {
            // 子オブジェクトをリストに追加
            childList.Add(t.gameObject);

            // ★再帰的処理
            // 子オブジェクトにさらに子オブジェクトがある場合には再帰的に処理を行う
            GetAllChildren(t, childList);
        }
    }
}

 


(2024年4月10日)

<一人称視点のカメラの設定>

・TestCameraをオフにする。

・「P1_Camera」「P2_Camera」をオンにする。

*各カメラの位置を合わせる。

CharaSpawnスクリプトの改良

・下記のコメントアウトを解除する。(2箇所)

 

 


(2024年2月7日)

<宮田一郎の設定>

・AudioSourceの追加

・Canvasの中にある鷹村のHPスライダー等を宮田専用に名前を変える。

・Miyata HPの空欄を埋める(設定する)

・宮田カメラの修正

・宮田アニメーターの修正

・宮田キャラクターコントローラーの修正

・宮田パンチの設定

*左パンチのダメージが成功したら、次は、右パンチの設定を行う。

 

<ファイトマネージャーの設定>

・スクリプトの修正(FightManager_Ippo_VS_Miyata)

 

・オブジェクトの名前を「FightManager」から「FightManager_Ippo_VS_Miyata」に変更

・これに「FightManager_Ippo_VS_Miyata」スクリプトを追加(FightManagerスクリプトは外す)

・空欄を設定する。

 


(2024年1月24日)

<宮田一郎の設定ポイント>


(2023年4月17日)

*最初にDanmakuプロジェクトに「Pro Builder」をインストールすること

・EnemyCの「くちばし」が「EnemyB」の子供になっているのが原因

・なので、親子関係をしっかり整えればOK

<敵に引き寄せられるの実装>

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Catch : MonoBehaviour
{
    private void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.name == "Player")
        {
            other.transform.parent = this.gameObject.transform;
        }
    }
}

・スクリプトをLeftArmオブジェクトに追加する。

(実行結果)

・敵のレフトアームに触れると、親子関係が発生して、自動的に近くまで引き寄せられれば成功