public void CanMove_MoveCauseCheck_ShouldReturnFalse() { // arrange var gameManger = new MoveManager(); var whitePawnStart = new Position(6, 4); var whitePawnEnd = new Position(4, 4); var blackPawn2Start = new Position(1, 6); var blackPawn2End = new Position(3, 6); var whiteQueenStart = new Position(7, 3); var whiteQueenEnd = new Position(3, 7); gameManger.Move(whitePawnStart, whitePawnEnd); gameManger.Move(blackPawn2Start, blackPawn2End); gameManger.Move(whiteQueenStart, whiteQueenEnd); var blackPawn1Start = new Position(1, 5); var blackPawn1End = new Position(2, 5); // act var result = gameManger.CanMove(blackPawn1Start, blackPawn1End); // assert Assert.False(result.Item1); }
public void Undo_CanUndo_Kill_ShouldReturnTrue() { // arrange var moveManager = new MoveManager(); moveManager.Move(new Position(1, 1), new Position(2, 1)); moveManager.Move(new Position(6, 4), new Position(5, 4)); Position from = new Position(7, 5); Position dest = new Position(2, 0); moveManager.Move(new Position(0, 2), dest); moveManager.Move(from, dest); // act bool before = moveManager.CanMove(from, dest).Item1; bool result = moveManager.Undo(); bool after = moveManager.CanMove(from, dest).Item1; bool afterKilled = moveManager.CanMove(dest, from).Item1; // assert Assert.False(before); Assert.True(result); Assert.True(after); Assert.True(afterKilled); }
private IEnumerator MoveToWithMultipleTries(RoadData destination, float delay, RetryData retryData) { if (delay > 0.0f) { yield return(new WaitForSeconds(delay)); } string currentOrientation = _moveManager.orientation; Stack <RoadData> moveKeyPoints = null; int tries = 0; while (moveKeyPoints == null) { if (tries > 0) { yield return(new WaitForSeconds(UnityEngine.Random.Range(0.5f, 3.0f))); } moveKeyPoints = RoadsPathfinding.RouteStar(destination, occupiedRoad, _keyPointsModulo, currentOrientation); tries++; } _moveManager.Move(FollowMoveKeyPoints(moveKeyPoints, destination, retryData)); }
public void MoveByDice(DiceResult diceResult) { LastDiceResult = diceResult; //If the player is in the well if (TurnInfo.InWell) { if (!diceResult.HasDone(6)) { GameManager.EndTurn(); return; } //Pass turn.. TurnInfo = TurnInfo.Builder().Build(); } //If the player is on begin cell if (TurnInfo.OnBeginCell) { //6 and 3 if (diceResult.HasDone(6, 3)) { MoveManager.MoveAt(this, 26, true); return; } //5 and 4 if (diceResult.HasDone(5, 4)) { MoveManager.MoveAt(this, 53, true); return; } } MoveManager.Move(this, diceResult.Total); }
public void EnableMove() { if (!_moveEnabled) { _moveEnabled = true; _moveManager.Move(PlayerMovement()); } }
private void Update() { GetAxisDirection(); if (Input.GetKey(KeyCode.Space)) { _jumpManager.Jump(); } _moveManager.Move(GetAxisDirection()); _playerRotateManager.Rotate(-Input.GetAxis("Mouse X")); _cameraRotateManager.Rotate(-Input.GetAxis("Mouse Y")); }
private void Update() { if (Input.GetKeyDown(KeyCode.M)) { _movemanager = FindObjectOfType <MoveManager>(); if (!_movemanager) { Debug.LogError("No Movemanager"); } _movemanager.Move(); } }
Vector3 MoveFloorByMoveManager(Vector3 aToLocalPosition) { Vector3 lWorldPosition = transform.TransformPoint(aToLocalPosition); Vector3 lWorldMoveDelta = lWorldPosition - mFloor.transform.position; Vector3 lBeforeColliderPosition = mFloor.transform.position; //行けるところを計算する MoveManager.Move(lWorldMoveDelta, mFloor.GetComponent <BoxCollider>(), LayerMask.GetMask(new string[] { "Box", "Stage", "Player" }), false, true); //コライダーの位置をもとに戻す return(mFloor.transform.position - lBeforeColliderPosition); }
public void Undo_CanNotUndo_ShouldReturnFalse() { // arrange var moveManager = new MoveManager(); Position from = new Position(1, 1); Position mid = new Position(2, 1); Position dest = new Position(3, 1); moveManager.Move(from, mid); moveManager.Move(mid, dest); // act bool firstUndo = moveManager.Undo(); bool secondUndo = moveManager.Undo(); bool canMoveValid = moveManager.CanMove(mid, dest).Item1; bool canMoveInvalid = moveManager.CanMove(from, mid).Item1; // assert Assert.True(firstUndo); Assert.False(secondUndo); Assert.True(canMoveValid); Assert.False(canMoveInvalid); }
Vector3 MoveFloorByMoveManager(Vector3 aToLocalPosition) { Vector3 lWorldPosition = transform.TransformPoint(aToLocalPosition); Vector3 lWorldMoveDelta = lWorldPosition - mFloor.transform.position; Vector3 lBeforeColliderPosition = mFloor.transform.position; //乗っているオブジェクトが、一緒に動くようにする //例えば下向きに動くなら、上に乗っているものも同じ分だけ動かす var lPileList = GetComponentInChildren <PileWeight>().GetPileBoxList(-lWorldMoveDelta, false); IEnumerable <Transform> lPileListOrderNear; //下向きに動くなら if (lWorldMoveDelta.y <= 0.0f) { lPileListOrderNear = lPileList.OrderBy(x => x.transform.position.y); //下から順にソート } //上向きに動くなら else { lPileListOrderNear = lPileList.OrderBy(x => - x.transform.position.y); //上から順にソート } //行けるところを計算する MoveManager.Move(lWorldMoveDelta, mFloor.GetComponent <BoxCollider>(), LayerMask.GetMask(new string[] { "Box", "Stage", "Player", "Fence" }), false, true); //コライダーの位置をもとに戻す Vector3 lMoveDelta = mFloor.transform.position - lBeforeColliderPosition; //乗っているオブジェクトが一緒に動くようにする foreach (var lObject in lPileListOrderNear) { var lMoveMng = lObject.GetComponent <MoveManager>(); //同じ方向に動くなら if (lMoveMng.GravityForce * lWorldMoveDelta.y > 0.0f) { MoveManager.Move(lWorldMoveDelta * 2.0f, (BoxCollider)(lMoveMng.UseCol), LayerMask.GetMask(new string[] { "Box", "Stage", "Player", "Fence" }), false, false); } } return(lMoveDelta); }
public void Undo_CanUndo_OrdinaryMove_ShouldReturnTrue() { // arrange var moveManager = new MoveManager(); Position from = new Position(1, 1); Position dest = new Position(2, 1); moveManager.Move(from, dest); // act bool before = moveManager.CanMove(from, dest).Item1; bool result = moveManager.Undo(); bool after = moveManager.CanMove(from, dest).Item1; // assert Assert.False(before); Assert.True(result); Assert.True(after); }
//風に当たっているオブジェクトを動かす 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); } } } }
public void RunAway() { manager.Move(Random.Range(0, 4)); }
protected void Start() { _moveManager.Move(RandomMove()); }
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 UpdateLifting() { switch (St) { case LiftState.liftUp: // 移動不可 MoveMng.StopMoveVirticalAll(); MoveMng.StopMoveHorizontalAll(); // 持ち上げ中オブジェクトを動かさない LiftObjMoveMng.StopMoveVirticalAll(); LiftObjMoveMng.StopMoveHorizontalAll(); // 持つオブジェクトの補間位置が現在のオブジェクトより高ければ bool liftMoveFlg = false; //float landVec = MoveMng.GravityForce; //WeightManager liftWeightMng = LiftObj.GetComponent<WeightManager>(); //// 水中で水に浮く重さなら上方向に接地 //if (LiftWaterStt && liftWeightMng && LiftWaterStt.IsInWater && !LiftWaterStt.IsWaterSurface && liftWeightMng.WeightLv <= WeightManager.Weight.light) { // landVec = 1.0f; //} //if (landVec < 0.0f) { // 接地方向が下 if (Pl.RotVec.y == 0.0f) { if (PlAnim.GetBoxPosition().y > LiftObj.transform.position.y) { liftMoveFlg = true; } } else // 接地方向が上 { if (PlAnim.GetBoxPosition().y < LiftObj.transform.position.y) { liftMoveFlg = true; } } // オブジェクトの位置を同期 if (liftMoveFlg) { if (heavyFailedFlg || (!MoveManager.Move(GetLiftUpBoxMove(), LiftObj.GetComponent <BoxCollider>(), liftingColMask, false, true) && (Pl.transform.position.x != LiftObj.transform.position.x))) { Debug.Log("持ち上げ失敗"); // // 持ち上げ中オブジェクトの強制押し出しフラグを戻す // LiftObjMoveMng.enabled = false; // 持ち上げ移動中フラグをfalseに LiftObjMoveMng.IsLiftUpMove = false; // 対象をすり抜けオブジェクトに追加 MoveMng.AddThroughCollider(LiftObj); // 同期できなければ下ろす St = LiftState.liftUpFailed; // 失敗アニメーションへの遷移 PlAnim.FailedCatch(); return; } // プレイヤーのモデルと同じ回転をオブジェクトに加える LiftObjModel.transform.rotation = cameraLookTransform.rotation; } // 持ち上げ完了時 if (PlAnim.CompleteCatch()) { LiftUpEnd(); // // 持ち上げ中オブジェクトの判定と挙動を無効化 // LiftObj.GetComponent<BoxCollider>().enabled = false; // LiftObj.GetComponent<MoveManager>().enabled = false; // // // 持ち上げ中のプレイヤー当たり判定を有効化 // standbyCol.enabled = false; // liftingCol.enabled = true; plAnim.ExitCatch(); // // 持ち上げ後処理状態 // St = LiftState.liftUpAfterHoldInput; } break; case LiftState.liftDown: // Debug.LogWarning(St.ToString() + " " + PlAnim.GetBoxPosition()); // 移動不可 MoveMng.StopMoveVirticalAll(); MoveMng.StopMoveHorizontalAll(); // 持ち上げ中オブジェクトを動かさない LiftObjMoveMng.StopMoveVirticalAll(); LiftObjMoveMng.StopMoveHorizontalAll(); // 回転終了待ち if (liftDownWeit) { if (Pl.CameraLookRatio == 0.0f) { liftDownWeit = false; // 持ち上げ中オブジェクトの判定を有効化 LiftObj.GetComponent <BoxCollider>().enabled = true; // 下ろしアニメーションへの遷移 PlAnim.StartRelease(); // サウンド再生 SoundManager.SPlay(liftSE, liftDownSoundDeray); } } else { // オブジェクトの位置を同期 if (!MoveManager.MoveTo(GetLiftDownBoxPosition(), LiftObj.GetComponent <BoxCollider>(), liftingColMask)) { Debug.Log("下ろし失敗"); if (Pl.RotVec.y == 1.0f) { Debug.LogWarning("下ろし失敗補正"); failedPosUpFlg = true; } LiftDownEnd(); // アニメーション遷移 PlAnim.ExitRelease(); return; } } // プレイヤーのモデルと同じ回転をオブジェクトに加える LiftObjModel.transform.rotation = cameraLookTransform.rotation; // 下ろし完了時 if (!liftDownWeit && PlAnim.CompleteRelease()) { Debug.LogWarning("下ろし完了"); // オブジェクトを離す LiftDownEnd(); // // 持ち上げ中オブジェクトの判定と挙動を有効化 // LiftObj.GetComponent<BoxCollider>().enabled = true; // LiftObj.GetComponent<MoveManager>().enabled = true; // // // 持ち上げ中のプレイヤー当たり判定を無効化 // standbyCol.enabled = true; // liftingCol.enabled = false; // // // 持ち上げ中オブジェクトを下ろし切る // MoveManager.MoveTo(liftPoint.position, LiftObj.GetComponent<BoxCollider>(), LayerMask.GetMask(new string[] { "" })); // LiftObj = null; // // // 下ろし処理後状態に // St = LiftState.standby; // afterHoldInput = true; // アニメーション遷移 PlAnim.ExitRelease(); } break; case LiftState.liftUpFailed: // 移動不可 MoveMng.StopMoveVirticalAll(); MoveMng.StopMoveHorizontalAll(); // 持ち上げ中オブジェクトを動かさない LiftObjMoveMng.StopMoveVirticalAll(); LiftObjMoveMng.StopMoveHorizontalAll(); // オブジェクトの位置を同期 if (!MoveManager.MoveTo(GetLiftDownBoxPosition(), LiftObj.GetComponent <BoxCollider>(), liftingColMask)) { Debug.Log("持ち上げ失敗に失敗"); // オブジェクトを離す LiftDownEnd(); // アニメーション遷移 PlAnim.ExitRelease(); return; } // プレイヤーのモデルと同じ回転をオブジェクトに加える LiftObjModel.transform.rotation = cameraLookTransform.rotation; // 移動不可 MoveMng.StopMoveVirticalAll(); MoveMng.StopMoveHorizontalAll(); // 持ち上げ失敗完了時 if (PlAnim.CompleteCatchFailed()) { Debug.Log("持ち上げ失敗完了"); // 持ち上げオブジェクトを離す LiftDownEnd(); // アニメーション遷移 PlAnim.ExitCatchFailed(); } break; /// 現状の仕様では下ろし失敗状態に遷移する事はない // case LiftState.liftDownFailed: // // 移動不可 // MoveMng.StopMoveVirticalAll(); // MoveMng.StopMoveHorizontalAll(); // // // オブジェクトの位置を同期 // if (!MoveManager.MoveTo(liftPoint.position, LiftObj.GetComponent<BoxCollider>(), LayerMask.GetMask(new string[] { "Stage", "Box" }))) { // Debug.Log("下ろし失敗"); // // // 同期できなければ持ち上げる // LiftUp(LiftObj); // return; // } // // // 下ろし完了時 // if (PlAnim.CompleteRelease()) { // // 持ち上げ中オブジェクトの判定と挙動を有効化 // LiftObj.GetComponent<BoxCollider>().enabled = true; // LiftObj.GetComponent<MoveManager>().enabled = true; // // // 持ち上げ中のプレイヤー当たり判定を無効化 // standbyCol.enabled = true; // liftingCol.enabled = false; // // // 持ち上げ中オブジェクトを下ろし切る // MoveManager.MoveTo(liftPoint.position, LiftObj.GetComponent<BoxCollider>(), LayerMask.GetMask(new string[] { "" })); // LiftObj = null; // } // break; case LiftState.lifting: // オブジェクトの位置を同期 // MoveManager.MoveTo(PlAnim.GetBoxPosition(), LiftObj.GetComponent<BoxCollider>(), liftingColMask); LiftObj.transform.position = PlAnim.GetBoxPosition(); // プレイヤーのモデルと同じ回転をオブジェクトに加える LiftObjModel.transform.rotation = cameraLookTransform.rotation; break; default: break; } }