public void CreateBullet(Vector3 startingPosition, BulletDirection bulletDirection) { GameObject go = Utility.InstantiatePrefab(prefab, content, startingPosition); BulletGUI bulletGUI = go.GetComponent <BulletGUI>(); bulletGUI.Initialize(bulletDirection); }
/// <summary> /// 弾道のデータ表示(移動時間・経路・速度オプション) /// </summary> /// <param name="posx">基準点x</param> /// <param name="posy">基準点y</param> /// <returns>縦軸でどこまで描画したか</returns> private Vector2 BulletDateGUI(BulletGUI date, Vector2 pos) { if (GUIButton_refPosition(ref pos, 110, 20, date.isDateOpen ? "データを閉じる" : "データを開く")) { date.isDateOpen = !date.isDateOpen; } if (GUIButton_refPosition(ref pos, 40, 20, "消去")) { //現在選択中のBulletを削除し、自身に子があるならそれを親の子にする Bullet child = date.bul.GetChildBullet(); Bullet parent = date.bul.GetParentBullet(); ///1.自身以外がない場合 自身を初期化する ///2.自身以外がいる場合 自身を削除する ///2.1.親がいる場合 自身を削除する ///2.1.1.子がいる場合 子を親につける ///2.2.親がおらず子がいる場合 子を独立させる if (!parent && !child) { date.bul.Init(); } else { if (parent && child) { child.SetParentBullet(parent, false); child.transform.SetParent(parent.transform); } else if (child) { //自身の子が存在し親がいない(自身が一番親)とき、子を独立させる child.SetParentBullet(null, false); bullet = child; //名前を親と同じにする(子は(Clone)が付いているため) bullet.name = date.bul.name; } Destroy(date.bul.gameObject); return(pos);//これ以上の描画は必要無いため抜ける } } if (!date.isDateOpen) { return(pos); //データが閉じられているなら終了 } //// GUILabel_refPosition(ref pos, 60, 20, "移動時間"); //string s = GUITextField_refPosition(ref pos, 20, 20, date.bul.moveTime.ToString()); date.sTime = GUITextField_refPosition(ref pos, 20, 20, date.sTime); float parse; if (float.TryParse(date.sTime, out parse)) { date.bul.ChangeMoveTime(parse); } pos = GetNewLinePosition(pos); GUILabel_refPosition(ref pos, 140, 20, "現在設定中の経路"); if (GUIButton_refPosition(ref pos, 120, 20, "新しい経路を追加")) { date.bul.AddPath(Vector3.zero); } for (int i = 0; i < date.bul.movePath.GetLength(0); i++) { pos = GetNewLinePosition(pos); //座標表示 var sPos = new BulletGUI.String2();//List内の構造体を書き換えられない為、一度新しく宣言 if (date.sPos.Count <= i) { date.sPos.Add(new BulletGUI.String2(date.bul.movePath[i])); } //x座標表示 GUILabel_refPosition(ref pos, 10, 20, "x"); //string s = GUITextField_refPosition(ref pos, 35, 20, date.bul.movePath[i].x.ToString()); sPos.x = GUITextField_refPosition(ref pos, 35, 20, date.sPos[i].x); if (float.TryParse(date.sPos[i].x, out parse)) { date.bul.movePath[i].x = parse; } //z座標表示 GUILabel_refPosition(ref pos, 10, 20, "z"); sPos.y = GUITextField_refPosition(ref pos, 35, 20, date.sPos[i].y); if (float.TryParse(date.sPos[i].y, out parse)) { date.bul.movePath[i].z = parse; } //座標代入 Listが足りなかったら最後尾に追加 date.sPos[i] = sPos; if (GUIButton_refPosition(ref pos, 75, 20, "一段上げる") && i != 0) { date.bul.ReplacePath(i, i - 1); } if (GUIButton_refPosition(ref pos, 75, 20, "一段下げる") && i != date.bul.movePath.GetLength(0) - 1) { date.bul.ReplacePath(i, i + 1); } if (GUIButton_refPosition(ref pos, 75, 20, "削除")) { date.bul.RemovePath(i); } } pos = GetNewLinePosition(pos); GUILabel_refPosition(ref pos, 120, 20, "速度オプション"); if (GUIButton_refPosition(ref pos, 120, 20, date.bul.type.ToString())) { date.isEaseTimeOpen = !date.isEaseTimeOpen; } //EaseTime設定ウィンドウを開く if (date.isEaseTimeOpen) { //EaseTypeの一覧をボタンで表示・押されたボタンの要素を取得する iTween.EaseType?type = EnumButtonListGUI <iTween.EaseType>(ref pos, 110, 20, 4); //ボタンが押されたならそのボタンの要素を代入してEaseTime設定ウィンドウを閉じる if (type.HasValue) { date.isEaseTimeOpen = false; date.bul.type = type.Value; } } return(pos); }