// pull元からpush先へ指定数の重さレベルを移し、移す事に成功したレベル数を返す public int PullWeight(WeightManager _from, int _num = 1) { int cnt = 0; // 指定数のレベルを移しきるか、値が変更できなくなるまでループ while ((_num > 0) && _from.SubWeightLevel(true) && AddWeightLevel(true)) { // 値を変更 _from.SubWeightLevel(false); AddWeightLevel(false); // 変更回数を加算 cnt++; // 残り変更回数を減算 _num--; } // 変更回数を返す return(cnt); }
void DebugTargetting() { // デバッグターゲットの選択 if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.Mouse1)) { RaycastHit hitInfo; Physics.Raycast(Camera.main.transform.position, (debugCursor.position - Camera.main.transform.position), out hitInfo, debugTargetMask); // Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, LayerMask.GetMask(new string[] { "Player", "Stage", "Box" })); if (hitInfo.collider == null) { DebugTarget = null; } else { DebugTarget = hitInfo.collider.transform; } // デバッグテキストの更新 UpdateDebugText(); } // デバッグターゲットカーソルの追従 if (debugTargetCursorViewer != null) { if (DebugTarget == null) { if (debugCursor != null) { debugTargetCursorViewer.position = debugCursor.position; } } else { debugTargetCursorViewer.position = DebugTarget.position; } } // デバッグターゲット位置にコピーオブジェクト生成 if (Input.GetKeyDown(KeyCode.V)) { if (debugCopyObject == null) { GameObject newObj = Instantiate(debugDefaultCopyObject); newObj.transform.position = debugCursor.position; // デバッグリソースに変更を追加 AddDebugResource(newObj.name, 1); if (newObj.GetComponent <WeightManager>()) { AddDebugResource("Weight", (int)newObj.GetComponent <WeightManager>().WeightLv); } } else { GameObject newObj = Instantiate(debugCopyObject); newObj.transform.position = debugCursor.position; // デバッグリソースに変更を追加 AddDebugResource(newObj.name, 1); if (newObj.GetComponent <WeightManager>()) { AddDebugResource("Weight", (int)newObj.GetComponent <WeightManager>().WeightLv); } } } // デバッグターゲットが選択されていなければ以降の処理を行わない if (DebugTarget == null) { return; } // デバッグターゲットの重さ変更 if (Input.GetKeyDown(KeyCode.Q)) { WeightManager weightMng = DebugTarget.GetComponent <WeightManager>(); if (weightMng != null) { // 重さ変更 if (weightMng.SubWeightLevel(false)) { // 成功したらデバッグリソースに変更を追加 AddDebugResource("Weight", -1); } } } if (Input.GetKeyDown(KeyCode.E)) { WeightManager weightMng = DebugTarget.GetComponent <WeightManager>(); if (weightMng != null) { // 重さ変更 if (weightMng.AddWeightLevel(false)) { // 成功したらデバッグリソースに変更を追加 AddDebugResource("Weight", 1); } } } // デバッグターゲットの移動 if (Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.Mouse1)) { DebugTarget.position = debugCursor.position; } // デバッグターゲットをコピー if (Input.GetKeyDown(KeyCode.C)) { debugCopyObject = DebugTarget.gameObject; // デバッグテキストの更新 UpdateDebugText(); } // デバッグターゲットの削除 if (Input.GetKeyDown(KeyCode.R)) { // デバッグリソースに変更を追加 AddDebugResource(DebugTarget.name, -1); if (DebugTarget.GetComponent <WeightManager>()) { AddDebugResource("Weight", -(int)DebugTarget.GetComponent <WeightManager>().WeightLv); } // 削除 Destroy(DebugTarget.gameObject); } // タイムスケール変更 bool timeSclRepeat = false; // 継続入力チェック if (Input.GetKey(KeyCode.T)) { timeSclRepeat = true; if ((Input.GetKeyDown(KeyCode.T)) || (timeSclNowRepeatTime > timeSclRepeatTime)) { timeScl -= timeSclSpd; if (timeScl < 0.0f) { timeScl = 0.0f; } } } if (Input.GetKey(KeyCode.Y)) { timeSclRepeat = true; if ((Input.GetKeyDown(KeyCode.Y)) || (timeSclNowRepeatTime > timeSclRepeatTime)) { timeScl += timeSclSpd; if (timeScl > 100.0f) // Time.timeScaleの最大値 { timeScl = 100.0f; } } } if (timeSclRepeat) { timeSclNowRepeatTime += Time.deltaTime; } else { timeSclNowRepeatTime = 0.0f; } }