public async Task <IActionResult> PutWeightManager(long id, WeightManager weightManager) { if (id != weightManager.Id) { return(BadRequest()); } _context.Entry(weightManager).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WeightManagerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void CorrectFourSideCollider(bool _liftUp) { WeightManager weightMng = GetComponent <WeightManager>(); if (!weightMng) { Debug.LogError("WeightManagerが見つかりませんでした。"); } // 四辺当たり判定の位置を調整 if (_liftUp) { // if (weightMng.WeightLv > WeightManager.Weight.flying) { if (Pl.RotVec.y == 0.0f) { fourSideTransform.localPosition = new Vector3(fourSideTransform.localPosition.x, upStdFourSidePos, fourSideTransform.localPosition.z); } else { fourSideTransform.localPosition = new Vector3(fourSideTransform.localPosition.x, upRevFourSidePos, fourSideTransform.localPosition.z); } fourSideTopColTransform.localPosition = new Vector3(fourSideTopColTransform.localPosition.x, upTopColPos, fourSideTopColTransform.localPosition.z); } else { fourSideTransform.localPosition = new Vector3(fourSideTransform.localPosition.x, downFourSidePos, fourSideTransform.localPosition.z); fourSideTopColTransform.localPosition = new Vector3(fourSideTopColTransform.localPosition.x, downTopColPos, fourSideTopColTransform.localPosition.z); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { _baby = await BabyManager.Load(); _weights = await WeightManager.Load(); if (string.IsNullOrEmpty(_baby.Name)) { this.pageTitle.Text = "请输入宝宝信息"; return; } else { string title = string.Format("{0}的体重是:", _baby.NickName); this.pageTitle.Text = title; } if (0 == _weights.Count) { _weights = MockWeights(); } if (_weights.Count > 0) { listWeight.ItemsSource = _weights; UpdateCharts(); } }
public async Task <ActionResult <WeightManager> > PostWeightManager(WeightManager weightManager) { _context.WeightManagers.Add(weightManager); await _context.SaveChangesAsync(); //return CreatedAtAction("GetWeightManager", new { id = weightManager.Id }, weightManager); return(CreatedAtAction(nameof(GetWeightManager), new { id = weightManager.Id }, weightManager)); }
void Init() { mWeightManager = GetComponent <WeightManager>(); mBeforeWeight = mWeightManager.WeightLvSeem; //見かけの重さでエフェクトを出す if (OnWeightChange != null) { OnWeightChange(mBeforeWeight); } }
void Shot() { // ショット // 対象オブジェクトをリセット fromMng = null; toMng = null; }
/// <summary> /// 测试按钮事件(衡器功能) /// </summary> private void TestMethod(object sender, RoutedEventArgs e) { string path = AppDomain.CurrentDomain.BaseDirectory + "ClientConfig"; curWeightManager = new WeightManager(System.IO.Path.Combine(path, xmlFileName)); curWeightManager.OnReceivedWeightData += new ReceivedWeightData(SetWeightData); curWeightManager.OnShowErrorMsg += curWeightController_OnShowErrorMsg; curWeightManager.Open(); curWeightManager.Start(); }
// Use this for initialization void Start() { mLanding = GetComponent <Landing>(); mWeightManager = GetComponent <WeightManager>(); mWaterState = GetComponent <WaterState>(); mMoveManager = GetComponent <MoveManager>(); mHighestPosition = transform.position; //最高地点を更新 mBeforePosition = transform.position; }
// 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 ApplyWindMove() { //TODO foreach (var windHit in mWindHitList) { MoveManager hitMoveMng = windHit.GetComponent <MoveManager>(); WeightManager hitWeightMng = windHit.GetComponent <WeightManager>(); if (hitMoveMng && hitWeightMng && (hitWeightMng.WeightLv < WeightManager.Weight.heavy)) { Vector3 lBeforePosition = hitMoveMng.transform.position; // 左右移動を加える MoveManager.Move(GetDirectionVector(mDirection) * mWindMoveSpeed, (BoxCollider)hitMoveMng.UseCol, LayerMask.GetMask(new string[] { "Stage", "Player", "Box", "Fence" })); //風で少しでも移動出来ていたら、オブジェクトの重力の動きを無くす Vector3 lAfterPosition = hitMoveMng.transform.position; if (Mathf.Approximately(lAfterPosition.x, lBeforePosition.x) == false) { // 上下の移動量を削除 hitMoveMng.StopMoveVirticalAll(); // 左右の移動量を削除 hitMoveMng.StopMoveHorizontalAll(); //風に飛ばされているフラグをtrueにする SetPlayerWindMove(windHit, true); } else { //風に飛ばされているフラグをfalseにする SetPlayerWindMove(windHit, false); } } } }
void CheckLandingFalse() { LandColList.Clear(); // // 接地方向を求める // float landVec = -1.0f; // // 宙に浮かぶ重さ、又は水中での水面に浮かぶ重さなら // if ((WeightMng.WeightLv == WeightManager.Weight.flying) || // (WaterStt.IsInWater && WeightMng.WeightLv <= WeightManager.Weight.light)) { // // 上方向に接地 // landVec = 1.0f; // } if (!MoveMng) { return; } float landVec = MoveMng.GetFallVec(); // 接地方向の逆方向に移動していれば接地していない if (landVec == -1.0f) { if (MoveMng.PrevMove.y > 0.0f) { IsLanding = false; return; } } else { if (MoveMng.PrevMove.y < 0.0f) { IsLanding = false; return; } } // 接地側の判定オブジェクトを取得 if (landVec < 0.0f) { LandingCol = FourSideCol.BottomCol; } else { LandingCol = FourSideCol.TopCol; } // 離地判定 LandColList.AddRange(Physics.OverlapBox(LandingCol.position, LandingCol.localScale * 0.5f, LandingCol.rotation, mask)); // 自身は接地対象から除く for (int idx = LandColList.Count - 1; idx >= 0; idx--) { if (LandColList[idx].gameObject == gameObject) { LandColList.RemoveAt(idx); } } // 一致方向のすり抜け床の除外 for (int idx = LandColList.Count - 1; idx >= 0; idx--) { OnewayFloor oneway = LandColList[idx].GetComponent <OnewayFloor>(); if (MoveMng.PrevMove.y != 0.0f) { if (oneway && oneway.IsThrough(Vector3.up * MoveMng.PrevMove.y, gameObject)) { LandColList.RemoveAt(idx); } } else { if (oneway && oneway.IsThrough(Vector3.up * MoveMng.GetFallVec(), gameObject)) { LandColList.RemoveAt(idx); } } } // // 自身が上方向に移動する重さの際に、下方向に移動する重さオブジェクトを除外(MoveFloorは除外しない) // if (MoveMng.GetFallVec() == 1.0f) { // for (int idx = LandColList.Count - 1; idx >= 0; idx--) { // if (LandColList[idx].tag != "MoveFloor") { // MoveFloorは除外しない // MoveManager landMoveMng = LandColList[idx].GetComponent<MoveManager>(); // if (landMoveMng && (landMoveMng.GetFallVec() == -1.0f)) // LandColList.RemoveAt(idx); // } // } // } // // 自身が重さ1で水中にない時、水中の重さ0には着地できない // if ((WeightMng.WeightLv == WeightManager.Weight.light) && !WaterStt.IsInWater) { // for (int idx = LandColList.Count - 1; idx >= 0; idx--) { // WeightManager colWeightMng = LandColList[idx].GetComponent<WeightManager>(); // WaterState colWaterStt = LandColList[idx].GetComponent<WaterState>(); // if (colWeightMng && colWaterStt && colWaterStt.IsInWater && (colWeightMng.WeightLv == WeightManager.Weight.flying)) { // LandColList.RemoveAt(idx); // } // } // } // // // 自身が重さ1以上で水中にない時、水中の自身の重さ未満のオブジェクトには着地できない // if ((WeightMng.WeightLv == WeightManager.Weight.heavy) && !WaterStt.IsInWater) { // for (int idx = LandColList.Count - 1; idx >= 0; idx--) { // WeightManager colWeightMng = LandColList[idx].GetComponent<WeightManager>(); // WaterState colWaterStt = LandColList[idx].GetComponent<WaterState>(); // if (colWeightMng && colWaterStt && colWaterStt.IsInWater && (colWeightMng.WeightLv < WeightMng.WeightLv)) { // LandColList.RemoveAt(idx); // } // } // } // 自身の重さ未満の浮いているオブジェクトには着地できない for (int idx = LandColList.Count - 1; idx >= 0; idx--) { WeightManager colWeightMng = LandColList[idx].GetComponent <WeightManager>(); Landing colLand = LandColList[idx].GetComponent <Landing>(); if (WeightMng && colWeightMng && colLand && (WeightMng.WeightLv > colWeightMng.WeightLv) && !colLand.IsLanding && !colLand.IsExtrusionLanding) { LandColList.RemoveAt(idx); } } // 自身にしか着地していない自身より軽いオブジェクトを除外 List <Collider> thisOnlyLandList = new List <Collider>(); for (int idx = LandColList.Count - 1; idx >= 0; idx--) { WeightManager colWeightMng = LandColList[idx].GetComponent <WeightManager>(); Landing colLand = LandColList[idx].GetComponent <Landing>(); if (colLand && WeightMng && colWeightMng && ((colLand.LandColList.Count == 1) && colLand.LandColList.Contains(MoveMng.UseCol)) && (WeightMng.WeightLv > colWeightMng.WeightLv)) { thisOnlyLandList.Add(LandColList[idx]); } } // 接地しているオブジェクトが存在しなければ離地 if ((LandColList.Count - thisOnlyLandList.Count) == 0) { IsLanding = false; Debug.Log("離地 " + Support.ObjectInfoToString(gameObject)); } }
// Start is called before the first frame update void Start() { weightManager = gameObject.GetComponent <WeightManager>(); }
// Use this for initialization void Start() { mWeightManager = GetComponent <WeightManager>(); mBeforeWeight = mWeightManager.WeightLvSeem; //見かけの重さでエフェクトを出す OnWeightChange(mBeforeWeight); }
/// <summary> /// Preserves state associated with this page in case the application is suspended or the /// page is discarded from the navigation cache. Values must conform to the serialization /// requirements of <see cref="SuspensionManager.SessionState"/>. /// </summary> /// <param name="pageState">An empty dictionary to be populated with serializable state.</param> protected override void SaveState(Dictionary <String, Object> pageState) { WeightManager.Save(); }
void SwitchLiftCollider(bool _liftUp) { // 通常時のプレイヤー当たり判定を無効化/有効化 standbyCol.enabled = !_liftUp; // // 持ち上げ中のプレイヤー当たり判定有効化時に接地方向によって判定位置を移動 // if (_liftUp) { // BoxCollider liftingBoxCol = ((BoxCollider)liftingCol); // float dis = Mathf.Abs(liftingBoxCol.center.y - colCenterPoint); // // if (Pl.GetComponent<WeightManager>().WeightForce < 0.0f) { // liftingBoxCol.center = new Vector3(liftingBoxCol.center.x, colCenterPoint + dis, liftingBoxCol.center.z); // // liftingBoxCol.center = new Vector3(liftingBoxCol.center.x, stdLiftingColPoint, liftingBoxCol.center.z); // } else { // liftingBoxCol.center = new Vector3(liftingBoxCol.center.x, colCenterPoint - dis, liftingBoxCol.center.z); // // liftingBoxCol.center = new Vector3(liftingBoxCol.center.x, revLiftingColPoint, liftingBoxCol.center.z); // } // } WeightManager weightMng = GetComponent <WeightManager>(); if (!weightMng) { Debug.LogError("WeightManagerが見つかりませんでした。"); } Debug.LogWarning("liftUp" + _liftUp + "\nbef isPosUp " + isPosUp); // プレイヤー当たり判定とモデルの位置を調整 if (_liftUp) { offsetTransform.localPosition = new Vector3(offsetTransform.localPosition.x, upStdOffsetPos, offsetTransform.localPosition.z); rotationTransform.localPosition = new Vector3(rotationTransform.localPosition.x, upRotationPos, rotationTransform.localPosition.z); modelTransform.localPosition = new Vector3(modelTransform.localPosition.x, upModelPos, modelTransform.localPosition.z); // if ((weightMng.WeightLv == WeightManager.Weight.flying) || (WaterStt.IsInWater && (WeightMng.WeightLv <= WeightManager.Weight.light))) { if ((Pl.RotVec.y == 1.0f && !isPosUp)) { MoveManager.Move(new Vector3(0.0f, liftingPosOffset, 0.0f), GetComponent <BoxCollider>(), LayerMask.GetMask(new string[] { "Stage", "Box", "Fance" })); //transform.position += new Vector3(0.0f, liftingPosOffset, 0.0f); Debug.LogWarning("MoveA"); } } else { offsetTransform.localPosition = new Vector3(offsetTransform.localPosition.x, downOffsetPos, offsetTransform.localPosition.z); rotationTransform.localPosition = new Vector3(rotationTransform.localPosition.x, downRotationPos, rotationTransform.localPosition.z); modelTransform.localPosition = new Vector3(modelTransform.localPosition.x, downModelPos, modelTransform.localPosition.z); // if ((weightMng.WeightLv == WeightManager.Weight.flying) || (WaterStt.IsInWater && (WeightMng.WeightLv <= WeightManager.Weight.light))) { if ((Pl.RotVec.y == 1.0f && isPosUp) || failedPosUpFlg || (WeightMng.HeavyRot)) // 重さ0で重さ2の重さオブジェクトを持ち上げている状態になった時の反転時 { List <GameObject> throughObjList = new List <GameObject>(); foreach (var throughCol in MoveMng.ThroughObjList) { throughObjList.Add(throughCol.gameObject); } MoveManager.Move(new Vector3(0.0f, -liftingPosOffset, 0.0f), GetComponent <BoxCollider>(), LayerMask.GetMask(new string[] { "Stage", "Box", "Fance" }), false, true, throughObjList); Debug.LogWarning("MoveB"); //transform.position -= new Vector3(0.0f, liftingPosOffset, 0.0f); isPosUp = false; WeightMng.HeavyRot = false; } failedPosUpFlg = false; } Debug.LogWarning("aft isPosUp " + isPosUp); // 四辺コライダーの位置を調整 CorrectFourSideCollider(_liftUp); // 持ち上げ中のプレイヤー当たり判定を有効化/無効化 liftingCol.enabled = _liftUp; // 有効な当たり判定をMoveManagerに登録 if (standbyCol.enabled) { MoveMng.UseCol = standbyCol; } else { MoveMng.UseCol = liftingCol; } }
void DragAim() { if (fromMng == null) { // 移し元選択 if (Input.GetAxis("Shot0") > 0.0f) { RaycastHit hitInfo; Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, layerMask); // マウスカーソルが対象となるオブジェクトを指していれば if (hitInfo.collider != null) { // 対象オブジェクトのWeightManagerを保持 fromMng = hitInfo.collider.GetComponent <WeightManager>(); // 確認 if (fromMng == null) { Debug.LogError("WeightManagerが付いていないオブジェクトが移し元対象として選択されました。"); failedFlg = true; return; } } else { // 選択失敗 failedFlg = true; } } else { // 選択失敗解除 failedFlg = false; } } else { // マウスカーソルが指しているオブジェクトを取得 RaycastHit hitInfo; Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, layerMask); // ホールド選択がまだ行われていないなら if (holdingTime < holdTime) { // ホールド選択 if (hitInfo.collider.GetComponent <WeightManager>() == fromMng) { holdingTime += Time.deltaTime; if (holdingTime >= holdTime) { holdingTime = holdTime; } } // ホールド完了前にマウスカーソルが移し元オブジェクトから外れたら else { holdingTime = 0.0f; } } // 移し先選択 if (Input.GetAxis("Shot0") <= 0.0f) { // マウスカーソルが対象となるオブジェクトを指していれば if (hitInfo.collider != null) { // 対象オブジェクトのWeightManagerを保持 toMng = hitInfo.collider.GetComponent <WeightManager>(); // 確認 if (toMng == null) { Debug.LogError("WeightManagerが付いていないオブジェクトが移し先対象として選択されました。"); return; } } } } }
// pull元とpush先を指定しての処理 static public int ShiftWeight(WeightManager _from, WeightManager _to, int _num = 1) { return(_from.PushWeight(_to, _num)); }
// 相手側のpull処理を行う事で間接的なpush処理を実装 public int PushWeight(WeightManager _to, int _num = 1) { return(_to.PullWeight(this, _num)); }
// Update is called once per frame void FixedUpdate() { // 重力加速度 if (useGravity /* && !Land.IsLanding*/) { AddMove(new Vector3(0.0f, GravityForce * Time.fixedDeltaTime, 0.0f), MoveType.gravity); // float maxGravityForce = GravityForce; // // 積み重なっている重さオブジェクトから最も重いオブジェクトを取得 // if (Pile) { // WeightManager maxWeightMng = WeightMng; // 最も重い重さ // List<Transform> pileObjs = Pile.GetPileBoxList(new Vector3(0.0f, GravityForce, 0.0f)); //// Debug.LogError("pile:" + name + " " + pileObjs.Count); // // foreach (var pileObj in pileObjs) { // WeightManager pileWeight = pileObj.GetComponent<WeightManager>(); // if (!pileWeight) continue; // // 積み重なっている重さオブジェクトの重さと比較 // if (pileWeight.WeightLv > maxWeightMng.WeightLv) { // maxWeightMng = pileWeight; // maxGravityForce = pileWeight.WeightForce; //// Debug.LogError("pileWeight>" + pileWeight.name); // prevWeight = pileWeight.WeightLv; // prevWeightForce = pileWeight.WeightForce; // } // } // } // // AddMove(new Vector3(0.0f, maxGravityForce * Time.deltaTime, 0.0f), MoveType.gravity); } // 前回の加速度 AddMove(prevMove, MoveType.prevMove); // 無効指定種類の移動を削除 for (int idx = 0; idx < moveList.Count; idx++) { if (stopHorizontalMoveType.Contains(moveList[idx].type)) { moveList[idx].vec = new Vector3(0.0f, moveList[idx].vec.y, moveList[idx].vec.z); } if (stopVirticalMoveType.Contains(moveList[idx].type)) { moveList[idx].vec = new Vector3(moveList[idx].vec.x, 0.0f, moveList[idx].vec.z); } } stopVirticalMoveType.Clear(); stopHorizontalMoveType.Clear(); // 今回の移動量を求める Vector3 move = TotalMove; // 空気抵抗 if (useAirResistance) { move -= (move.normalized * move.magnitude * airResistance); } // 最高速度制限 move = move.normalized * Mathf.Min(move.magnitude, CurMaxSpd); OneTimeMaxSpd = null; if (!extrusionIgnore && Pile) { // 上に積まれている自身より重い重さオブジェクトの方が速ければそれに合わせる foreach (var pileObj in Pile.GetPileBoxList(Vector3.up)) { MoveManager pileObjMoveMng = pileObj.GetComponent <MoveManager>(); WeightManager pileObjWeight = pileObj.GetComponent <WeightManager>(); if (pileObjMoveMng && pileObjWeight && (pileObjWeight.WeightLv > WeightMng.WeightLv) && (pileObjMoveMng.PrevMove.y < 0.0f) && (pileObjMoveMng.PrevMove.y < move.y)) { move = new Vector3(move.x, pileObjMoveMng.PrevMove.y, move.z); } } } // 移動 Vector3 resMove; // 実際に移動出来た移動量 Move(move * Time.fixedDeltaTime, (BoxCollider)useCol, mask, out resMove); // 今回の移動量を保持 //prevMove = resMove; PrevMove = move; // 計算済みの力を削除 moveList.Clear(); //test // if (!Input.GetKey(KeyCode.Tab)) { // //UnityEditor.EditorApplication.isPaused = true; // } }
void Rotate() { if (!CanRotation) { IsRotation = false; return; } // 回転待ち if (IsHandSpringWeit) { IsRotation = true; IsHandSpring = true; return; } else { // 回転待ち終了時 if (IsHandSpring) { IsHandSpring = false; // 離地方向に跳ねる HandSpringJump(); } } // // 持ち上げモーション中は処理しない // if ((Lift.St == Lifting.LiftState.invalid) || // (Lift.St == Lifting.LiftState.standby)) { // // 接地中なら // if (Land.IsLanding || WaterStt.IsWaterSurface) { if (CanRotationTurn) { // 左右入力中なら if (walkStandbyVec != 0.0f) { // 一定の移動がある方向に向きを設定 if (MoveMng.PrevMove.x > turnRotBorderSpd) { RotVec = new Vector3(1.0f, RotVec.y, RotVec.z); } else if (MoveMng.PrevMove.x < -turnRotBorderSpd) { RotVec = new Vector3(-1.0f, RotVec.y, RotVec.z); } else { // 移動量が一定以下なら入力方向に向く if (walkStandbyVec > 0.0f) { RotVec = new Vector3(1.0f, RotVec.y, RotVec.z); } else if (walkStandbyVec < 0.0f) { RotVec = new Vector3(-1.0f, RotVec.y, RotVec.z); } } } } // } // RotVec = new Vector3(RotVec.x, 0.0f, RotVec.z); // // 接地方向によって向きを設定 // if (WeightMng.WeightLv == WeightManager.Weight.flying) { // RotVec = new Vector3(RotVec.x, 1.0f, RotVec.z); // } // if ((WeightMng.WeightLv == WeightManager.Weight.light) && // (WaterStt.IsInWater && false)) { // RotVec = new Vector3(RotVec.x, 1.0f, RotVec.z); ; // } // 自身が重さ0であり、重さ2のブロックを持ち上げている場合 if (WeightMng.WeightLv == WeightManager.Weight.flying) { if (Lift && Lift.LiftObj) { WeightManager liftWeightMng = Lift.LiftObj.GetComponent <WeightManager>(); if (liftWeightMng && (liftWeightMng.WeightLv == WeightManager.Weight.heavy)) { if (!isHeavyReleaseRotate) { // 接地変更を指定 RotVec = new Vector3(RotVec.x, 1.0f, RotVec.z); isHeavyReleaseRotate = true; MoveMng.StopMoveHorizontal(MoveManager.MoveType.prevMove); } } } } // 結果の姿勢を求める Quaternion qt = Quaternion.Euler(RotVec.y * 180.0f, -90.0f + RotVec.x * 90.0f, 0.0f); // 現在の向きと結果の向きとの角度が一定以内なら float angle = Quaternion.Angle(rotTransform.rotation, qt); if (angle < correctionaAngle) { // 向きを合わせる rotTransform.rotation = Quaternion.Lerp(rotTransform.rotation, qt, 1); // 回転終了 IsRotation = false; isHeavyReleaseRotate = false; // 自身が重さ0であり、重さ2のブロックを持ち上げている場合 if (WeightMng.WeightLv == WeightManager.Weight.flying) { if (Lift && Lift.LiftObj && (Lift.St == Lifting.LiftState.lifting)) { WeightManager liftWeightMng = Lift.LiftObj.GetComponent <WeightManager>(); if (liftWeightMng && (liftWeightMng.WeightLv == WeightManager.Weight.heavy)) { WeightMng.HeavyRot = true; // 持っているブロックを離す Debug.Log("強制離し"); // Lift.ReleaseLiftObject(); Lift.LiftDownEnd(); // アニメーション遷移 PlAnim.ExitRelease(); } } } } // 角度が一定以上なら else { // 設定された向きにスラープ rotTransform.rotation = Quaternion.Slerp(rotTransform.rotation, qt, rotSpd); IsRotation = true; } colRotTransform.rotation = rotTransform.rotation; // 重さに合わせてモデルと当たり判定位置を補正 Lift.CorrectFourSideCollider(Lift.IsLifting); }
protected virtual void Start() { this.name = this.gameObject.name; weight = FindObjectOfType <WeightManager>(); renderer = this.GetComponent <Renderer>(); }
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; } }