/// <summary> /// 機体の有効化 /// </summary> protected void Activate_Ship(ToolBox.ShipData shipData) { //機体パーツを結合したMeshを取得 Mesh m = shipData.GetConnectedMesh(); FuncBox.SetMesh(gameObject, m, gm.shipMaterial); //半径を求める Vector3 size = m.bounds.size / 2f; Vector3 center = FuncBox.Vector3Abs(m.bounds.center); collisionRadius = Vector3.Distance(Vector3.zero, center + size); }
//それぞれの設定用関数 public void SetPreview(ToolBox.ShipData shipData) { if (!previewMf) { return; } Mesh m = shipData.GetConnectedMesh(); previewMf.mesh = m; if (!previewCamera) { return; } Vector3 size = m.bounds.size / 2f; Vector3 center = FuncBox.Vector3Abs(m.bounds.center); previewCamera.orthographicSize = Vector3.Distance(Vector3.zero, center + size); }
/// <summary> /// ターゲッティング /// </summary> protected void Targeting() { if (mainTarget == null) { return; } //カメラ位置 Vector3 myPos = mainTarget.transform.position; Vector3 cameraPos = new Vector3(myPos.x, myPos.y, camera.transform.position.z); camera.transform.position = FuncBox.Vector3Lerp(camera.transform.position, cameraPos, aimingLerp * Time.deltaTime); if (otherTargets.Count <= 0) { targetSize = minSize; return; } //メインから一番遠いターゲットを求める float dis, maxDis = 0f; int index = 0; Vector2 pos; for (int i = 0; i < otherTargets.Count; i++) { pos = otherTargets[i].transform.position; dis = Vector2.Distance(myPos, pos); if (maxDis < dis) { maxDis = dis; index = i; } } //カメラサイズ Vector2 size = otherTargets[index].transform.position - myPos; size = FuncBox.Vector3Abs(size); targetSize = (size.x < size.y ? size.y :size.x); //最小サイズ確認 targetSize = (targetSize < minSize ? minSize : targetSize) * spacePer; }