示例#1
0
 /// <summary>
 /// 子の弾道を生成する
 /// </summary>
 public void AddChildBullet()
 {
     //既に子がいるなら子の下に子を生成
     if (childBullet)
     {
         childBullet.AddChildBullet();
     }
     else
     {
         childBullet = Instantiate(gameObject).GetComponent <Bullet>();
         childBullet.SetParentBullet(this);
     }
 }
示例#2
0
    /// <summary>
    /// 各GUIの描画
    /// </summary>
    void OnGUI()
    {
#if UNITY_EDITOR
        //GUI配置基準点設定
        Vector2 pos = new Vector2(DEFAULT_POSITION_X, DEFAULT_POSITION_Y);

        GUILabel_refPosition(ref pos, 35, 20, "名称");
        bullet.name = GUITextField_refPosition(ref pos, 100, 20, bullet.name);

        if (GUIButton_refPosition(ref pos, 40, 20, "保存"))
        {
            if (manager.isBulletExist(bullet.name) >= 0)
            {
                isSaveCheck = true;
            }
            else
            {
                bullet.CreatePrefab();
            }
        }

        if (GUIButton_refPosition(ref pos, 70, 20, "読み込み"))
        {
            if ((loadBullet = manager.Load(bullet.name)))
            {
                isLoadCheck = true;
                Debug.Log("プレファブを発見しました");
            }
            else if (!loadBullet)
            {
                Debug.Log(bullet.name + "プレファブが見つかりませんでした");
            }
        }

        //データ読み込み確認
        if (isLoadCheck)
        {
            GUILabel_refPosition(ref pos, 400, 20, "現在作成中のデータを破棄し、他のデータを読み込みますか?");
            pos = GetNewLinePosition(pos);
            if (GUIButton_refPosition(ref pos, 35, 20, "はい"))
            {
                isLoadCheck = false;
                Destroy(bullet.gameObject);
                bullet = Instantiate(loadBullet.gameObject).GetComponent <Bullet>();
            }
            if (GUIButton_refPosition(ref pos, 50, 20, "いいえ"))
            {
                isLoadCheck = false;
            }
        }
        if (GUIButton_refPosition(ref pos, 140, 20, "新しい弾道を作成"))
        {
            loadBullet  = defaultBullet.gameObject;
            isLoadCheck = true;
        }

        pos = GetNewLinePosition(pos);//改行

        if (GUIButton_refPosition(ref pos, 70, 20, "発射"))
        {
            bullet.Enter(true);
        }

        GUILabel_refPosition(ref pos, 50, 20, "消費MP");
        int.TryParse(GUITextField_refPosition(ref pos, 35, 20, bullet.useMP.ToString()), out bullet.useMP);

        pos = AllBulletsDateGUI(pos);

        pos = GetNewLinePosition(pos);//改行

        if (GUIButton_refPosition(ref pos, 140, 20, "次の弾道を設定"))
        {
            bullet.AddChildBullet();
        }

        pos = GetNewLinePosition(pos);//改行

        //弾道の種類を設定
        if (GUIButton_refPosition(ref pos, 140, 20, bullet.bulletType.ToString()))
        {
            isBulletListOpen = !isBulletListOpen;
        }

        //弾道リストの表示
        if (isBulletListOpen)
        {
            BulletType?type = EnumButtonListGUI <BulletType>(ref pos, 110, 20, 3);
            if (type.HasValue)
            {
                bullet.bulletType = type.Value;
                isBulletListOpen  = false;
            }
        }

        pos = GetNewLinePosition(pos);

        //データ保存確認
        if (isSaveCheck)
        {
            GUILabel_refPosition(ref pos, 360, 20, "既に同じ名前のプレファブが存在します。上書きしますか?");
            if (GUIButton_refPosition(ref pos, 50, 20, "はい"))
            {
                isSaveCheck = false;
                bullet.CreatePrefab();
            }
            else if (GUIButton_refPosition(ref pos, 50, 20, "いいえ"))
            {
                isSaveCheck = false;
            }
        }
#endif
    }