Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (IsLanding)
        {
            CheckLandingFalse();
            if (IsLanding)
            {
                MoveMng.StopMoveVirtical(MoveManager.MoveType.gravity);
                MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);
            }
        }
//		if (IsExtrusionLanding) {
//			CheckExtrusionLandingFalse();
////			if (IsExtrusionLanding) {
////				MoveMng.StopMoveVirtical(MoveManager.MoveType.gravity);
////				MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);
////			}
//		}

        UpdateWaterFloatLanding();
        if (!isExtrusionLandingChange)
        {
            IsExtrusionLanding = false;
        }
        isExtrusionLandingChange = false;
    }
Ejemplo n.º 2
0
    void HandSpringJump()
    {
        // 前回までの上下方向の加速度を削除
        MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);

        // 左右方向の移動量をジャンプ中速度まで下げる
        MoveMng.PrevMove = new Vector3(Mathf.Sign(MoveMng.PrevMove.x) * Mathf.Clamp(MoveMng.PrevMove.x, -JumpSpd, JumpSpd), MoveMng.PrevMove.y, MoveMng.PrevMove.z);

        // 離地方向に跳ねる
        if (!WaterStt.IsInWater)
        {
            MoveMng.AddMove(new Vector3(0.0f, (HandSpringJumpHeight) * -(RotVec.y * 2.0f - 1.0f), 0.0f));
        }
        else
        {
            MoveMng.AddMove(new Vector3(0.0f, (HandSpringJumpHeightInWater) * -(RotVec.y * 2.0f - 1.0f), 0.0f));
        }

        // 離地
        Land.IsLanding          = false;
        WaterStt.IsWaterSurface = false;
        WaterStt.BeginWaterStopIgnore();

        // サウンド再生
        SoundManager.SPlay(handSpringJumpSE, handSpringJumpSEDeray);
    }
Ejemplo n.º 3
0
    // 接触時にその接触が指定方向への接触かを判定
    public bool GetIsLanding(Vector3 _move)
    {
        if (_move == Vector3.zero)
        {
            return(false);
        }

        //		// 接地方向
        //		float landVec = WeightMng.WeightForce;
        //		// 水中であり水に浮く重さなら
        //		if (WaterStt && WeightMng && WaterStt.IsInWater && !WaterStt.IsWaterSurface && (WeightMng.WeightLv <= WeightManager.Weight.light)) {
        //			landVec = 1.0f;
        //		}

        //		float dot = Vector3.Dot((Vector3.up * landVec).normalized, _move.normalized);
        if (!MoveMng)
        {
            return(false);
        }
        float dot = Vector3.Dot((Vector3.up * MoveMng.GetFallVec()).normalized, _move.normalized);

        //		Debug.LogError(landingCol.localPosition + " " + _move + " " + (dot < 0.0f));

        // 指定方向の反対方向への接触
        if (dot < 0.0f)
        {
            return(false);
        }

        // 指定方向への接触
        return(true);
    }
Ejemplo n.º 4
0
    void FixedUpdate()
    {
        IsInWater = (Support.GetColliderHitInfoList(GetComponent <Collider>(), Vector3.zero, LayerMask.GetMask("WaterArea")).Count > 0);

        // 水中/水上の挙動
        if (IsInWater)
        {
            // 水中なら
            if (!IsWaterSurface)
            {
                // 水による浮上
                MoveMng.AddMove(new Vector3(0.0f, waterFloatSpd[(int)WeightMng.WeightLv], 0.0f));
            }
            // 水上なら
            else
            {
                // 重さに変化が無ければ
                if (WeightMng.WeightLv == WeightManager.Weight.light)
                {
                    // 落下しない
                    MoveMng.StopMoveVirtical(MoveManager.MoveType.gravity);
                    MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);
                }
                // 重さが変化していれば
                else
                {
                    // 水面状態を解除
                    IsWaterSurface = false;
                }
            }
        }
    }
Ejemplo n.º 5
0
    void CheckExtrusionLandingFalse()
    {
        //		// 接地方向の反対方向に移動していなければ接地していない
        //		if (WeightMng.WeightLv != WeightManager.Weight.flying) {
        //			if (MoveMng.PrevMove.y < 0.0f) {
        //				IsExtrusionLanding = false;
        //				return;
        //			}
        //		} else {
        //			if (MoveMng.PrevMove.y > 0.0f) {
        //				IsExtrusionLanding = false;
        //				return;
        //			}
        //		}

        // 接地方向に移動していれば反接地していない
        if (MoveMng && (MoveMng.GetFallVec() == Mathf.Sign(MoveMng.PrevMove.y)) && (MoveMng.PrevMove.y != 0.0f))
        {
            IsExtrusionLanding = false;
            return;
        }

        // 反接地側の判定オブジェクトを取得
        Transform extLandingCol = null;

        if (MoveMng.GetFallVec() > 0.0f)
        {
            extLandingCol = FourSideCol.BottomCol;
        }
        else
        {
            extLandingCol = FourSideCol.TopCol;
        }

        // 離地判定
        landExtrusionColList.Clear();
        landExtrusionColList.AddRange(Physics.OverlapBox(extLandingCol.position, extLandingCol.localScale * 0.5f, extLandingCol.rotation, mask));

        // 自身は反接地対象から除く
        for (int idx = landExtrusionColList.Count - 1; idx >= 0; idx--)
        {
            if (landExtrusionColList[idx].gameObject == gameObject)
            {
                landExtrusionColList.RemoveAt(idx);
            }
        }

        // 反接地しているオブジェクトが存在しなければ離地
        if (landExtrusionColList.Count <= 0)
        {
            IsExtrusionLanding = false;
            Debug.Log("Ext離地");
        }
    }
Ejemplo n.º 6
0
    void Walk()
    {
        // 歩行アニメーション
        if ((walkStandbyVec != 0.0f) && CanWalk)
        {
            if (!Lift.IsLifting)
            {
                PlAnim.StartWalk();
            }
            else
            {
                PlAnim.StartHoldWalk();
            }
            PlAnim.SetSpeed(Mathf.Abs(walkStandbyVec));
        }
        // 待機アニメーション
        else
        {
            if (!Lift.IsLifting)
            {
                PlAnim.StartStandBy();
            }
            else
            {
                PlAnim.StartHoldStandBy();
            }
        }

        // 左右移動入力があれば
        if (walkStandbyVec == 0.0f)
        {
            return;
        }

        // 左右移動可能でなければ
        if (!canWalk)
        {
            return;
        }

        // 地上なら
        if (Land.IsLanding)
        {
            // 左右方向へ加速
            MoveMng.AddMove(new Vector3(walkStandbyVec * walkSpd, 0.0f, 0.0f));
        }
        // 空中なら
        else
        {
            // 左右方向へ加速
            MoveMng.AddMove(new Vector3(walkStandbyVec * (JumpDis / JumpTime) * Time.fixedDeltaTime, 0.0f, 0.0f));
        }
    }
Ejemplo n.º 7
0
    void WalkDown()
    {
        // 接地中でなく、水上で安定状態もなければ
        if (!Land.IsLanding && !WaterStt.IsWaterSurface)
        {
            return;
        }

        // 進行方向側への左右入力があれば
        if ((walkStandbyVec != 0.0f) && (Mathf.Sign(MoveMng.PrevMove.x) == Mathf.Sign(walkStandbyVec)))
        {
            return;
        }

        // 減速
        float moveX = (Mathf.Min((walkSpd / walkStopTime), Mathf.Abs(MoveMng.PrevMove.x))) * -Mathf.Sign(MoveMng.PrevMove.x);

        MoveMng.AddMove(new Vector3(moveX, 0.0f, 0.0f));
    }
Ejemplo n.º 8
0
    void WalkDown()
    {
        // 進行方向側への左右入力があるか、接地した際の天井回転待ち状態なら
        if (((walkStandbyVec != 0.0f) && (Mathf.Sign(MoveMng.PrevMove.x) == Mathf.Sign(walkStandbyVec))) && !IsHandSpringWeit)
        {
            return;
        }

        // 接地中、または水上での安定状態、安定状態オブジェクトへの接地であれば
        if (Land.IsLanding || WaterStt.IsWaterSurface || Land.IsWaterFloatLanding)
        {
            // 減速
            float moveX = (Mathf.Min((WalkSpd / WalkStop), Mathf.Abs(MoveMng.PrevMove.x))) * -Mathf.Sign(MoveMng.PrevMove.x);
            MoveMng.AddMove(new Vector3(moveX, 0.0f, 0.0f));
        }
        // 空中であれば
        else if (!WaterStt.IsInWater && !WaterStt.IsWaterSurface)
        {
            // 空中での減速
            float moveX = (Mathf.Min((JumpSpd / JumpStop), Mathf.Abs(MoveMng.PrevMove.x))) * -Mathf.Sign(MoveMng.PrevMove.x);
            MoveMng.AddMove(new Vector3(moveX, 0.0f, 0.0f));
        }
    }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
    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));
        }
    }
Ejemplo n.º 11
0
    public void LiftDownEnd()           // 持っているオブジェクトを強制的に下ろす使い方もできる
    {
        Debug.Log("LiftDownEnd " + LiftObj.name);

        // プレイヤーのモデルに同期していた回転を消去
        LiftObjModel.rotation = Quaternion.identity;

        // 持ち上げ中オブジェクトの判定と挙動を有効化
        LiftObj.GetComponent <BoxCollider>().enabled = true;
        LiftObj.GetComponent <MoveManager>().enabled = true;

        // プレイヤーと持ち上げオブジェクトを風で動かせるように変更
        MoveMng.CanMoveByWind        = true;
        LiftObjMoveMng.CanMoveByWind = true;

        #region
        //		// 通常時のプレイヤー当たり判定を無効化/有効化
        //		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);
        //			}
        //		}
        //		// 持ち上げ中のプレイヤー当たり判定を有効化/無効化
        //		liftingCol.enabled = _liftUp;
        //
        //		// 有効な当たり判定をMoveManagerに登録
        //		if (standbyCol.enabled) {
        //			MoveMng.UseCol = standbyCol;
        //		}else {
        //			MoveMng.UseCol = liftingCol;
        //		}
        #endregion

        // 対象をすり抜けオブジェクトに追加
        MoveMng.AddThroughCollider(LiftObj);

        // プレイヤー当たり判定の設定
        SwitchLiftCollider(false);

        // 対象の水中浮上可能フラグを戻す
        LiftWaterStt.CanFloat = true;

        // 持ち上げオブジェクトをnullに
        LiftObj = null;

        #region
        //			// オブジェクトを離す
        //			ReleaseLiftObject();

        //			// 対象をすり抜けオブジェクトに追加
        //			MoveMng.AddThroughCollider(LiftObj.GetComponent<Collider>());
        //
        //			// 対象の水中浮上可能フラグを戻す
        //			Debug.LogWarning("canFloat = true");
        //			liftWaterStt.CanFloat = true;
        //
        //			// 処理後状態に
        //			St = LiftState.standby;
        //			afterHoldInput = true;
        //
        //			// 持ち上げ中オブジェクトをnullに
        //			Debug.LogWarning("canFloat null");
        //			LiftObj = null;
        //			liftWaterStt = null;
        #endregion

        // 下ろし処理後状態に
        St                      = LiftState.standby;
        afterHoldInput          = true;
        WeightMng.LiftWeightMng = null;

        // プレイヤーの重さ移しを可能に
        Pl.CanShift = true;

        // プレイヤーのジャンプ、振り向きを可能に
        Pl.CanJump         = true;
        Pl.CanRotationTurn = true;
    }
Ejemplo n.º 12
0
    void Walk()
    {
        prevIsWaterSurfaceStandby = IsWaterSurfaceStandby;
        prevIsWaterSurfaceSwiming = IsWaterSurfaceSwiming;
        IsWaterSurfaceStandby     = false;
        IsWaterSurfaceSwiming     = false;

        // 持ち下ろしアニメーション中、または天井回転待ち中であれば処理しない
        if (Lift.IsLiftCantMove || IsHandSpringWeit)
        {
            return;
        }

        // 重さ0のプレイヤーが重さ2の持ち上げオブジェクトを離す時の回転中も処理しない
        if (isHeavyReleaseRotate)
        {
            return;
        }

        // 歩行アニメーション
        if ((walkStandbyVec != 0.0f) && CanWalk)
        {
            if (!WaterStt.IsWaterSurface)
            {
                if (Land.IsLanding || Land.IsExtrusionLanding || Land.IsWaterFloatLanding)
                {
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartWalk();
                    }
                    else
                    {
                        PlAnim.StartHoldWalk();
                    }
                }
                float walkAnimSpd = Mathf.Max((Mathf.Abs(MoveMng.PrevMove.x) * walkAnimRatio), walkAnimMinSpd);
                //float walkAnimSpd = (walkStandbyVec * walkAnimRatio);
                PlAnim.SetSpeed(walkAnimSpd);
            }
            // 泳ぎアニメーション
            else
            {
                IsWaterSurfaceSwiming = true;
                if (IsWaterSurfaceSwiming && !prevIsWaterSurfaceSwiming)
                {
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartSwim();
                    }
                    else
                    {
                        PlAnim.StartHoldSwim();
                    }
                }
            }
        }
        // 待機アニメーション
        else
        {
            if (!WaterStt.IsWaterSurface)
            {
                if (!Lift.IsLifting)
                {
                    PlAnim.StartStandBy();
                }
                else
                {
                    PlAnim.StartHoldStandBy();
                }
            }
            else
            {
                IsWaterSurfaceStandby = true;
                if (IsWaterSurfaceStandby && !prevIsWaterSurfaceStandby)
                {
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartWaterStandBy();
                    }
                    else
                    {
                        PlAnim.StartHoldWaterStandBy();
                    }
                }
            }
        }

        // 左右移動入力があれば
        if (walkStandbyVec == 0.0f)
        {
            return;
        }

        // 左右移動可能でなければ
        if (!canWalk)
        {
            return;
        }

        // 地上なら
        if (Land.IsLanding)
        {
            // 左右方向へ加速
            MoveMng.AddMove(new Vector3(walkStandbyVec * WalkSpd, 0.0f, 0.0f));
        }
        // 空中なら
        else
        {
            // 左右方向へ加速
            MoveMng.AddMove(new Vector3(walkStandbyVec * JumpSpd, 0.0f, 0.0f));
        }
    }
Ejemplo n.º 13
0
    void FixedUpdate()
    {
        // 持ち上げ/下げ
        if (liftInputFlg)
        {
            liftInputFlg = false;
            if ((Land.IsLanding || WaterStt.IsWaterSurface || land.IsWaterFloatLanding) /*&& !IsRotation*/ && !IsHandSpring)
            {
                //			if ((Input.GetAxis("Lift") != 0.0f)) {
                //if (!liftTrg) {
                if (!(IsRotation && Lift.St == Lifting.LiftState.standby))
                {
                    Lift.Lift();
                }
                //}
                //	liftTrg = true;
                //} else {
                //	liftTrg = false;
            }
        }

        // 浮かびアニメーション
        bool flyFlg = false;

        // 水中以外で落下方向と体の上下向きが逆の場合
        if ((!WaterStt.IsInWater && !WaterStt.IsWaterSurface) && (Mathf.Sign(RotVec.y * 2 - 1) != MoveMng.GetFallVec()))
        {
            // 落下方向に移動していれば
            if (MoveMng.GetFallVec() == Mathf.Sign(MoveMng.PrevMove.y))
            {
                // 浮かびアニメーションを行わないコライダーに足場や水場が触れていない
                if (Physics.OverlapBox(noFlyAnimCol.position, noFlyAnimCol.lossyScale * 0.5f, noFlyAnimCol.rotation, noFlyAnimColMask).Length == 0)
                {
                    flyFlg = true;
                    if (!prevFlyFlg)
                    {
                        if (!Lift.IsLifting)
                        {
                            Debug.Log("Fly");
                            PlAnim.StartFly();
                        }
                        else
                        {
                            Debug.Log("HoldFly");
                            PlAnim.StartHoldFly();
                        }
                    }
                }
            }
        }
        prevFlyFlg = flyFlg;

        // 落下アニメーション
        bool fallFlg = ((!Land.IsLanding && !Land.IsWaterFloatLanding && !WaterStt.IsWaterSurface && !Land.IsExtrusionLanding) && (Mathf.Sign(MoveMng.PrevMove.y) == (MoveMng.GetFallVec())));

        // 持ち上げ/下しの最中は落下しない
        if (Lift.IsLiftCantMove)
        {
            fallFlg = false;
        }
        if (fallFlg && !prevFallFlg)
        {
            if (!flyFlg)
            {
                Debug.Log("Fall");
                if (!Lift.IsLifting)
                {
                    PlAnim.StartFall();
                }
                else
                {
                    PlAnim.StartHoldFall();
                }
            }
        }
        prevFallFlg = fallFlg;

        bool landTrueChangeFlg = ((land.IsLanding && (land.IsLanding != prevIsLanding)) ||
                                  (land.IsWaterFloatLanding && (land.IsWaterFloatLanding != prevIsWaterFloatLanding)));

        Collider[] topOverlapCols    = Physics.OverlapBox(TopCol.position, TopCol.lossyScale * 0.5f, TopCol.rotation, sandwitchMask);
        Collider[] bottomOverlapCols = Physics.OverlapBox(BottomCol.position, TopCol.lossyScale * 0.5f, TopCol.rotation, sandwitchMask);
        bool       topColOverlap     = (topOverlapCols.Length > 0);
        bool       bottomColOverlap  = (bottomOverlapCols.Length > 0);

        IsSandwitch = (topColOverlap && bottomColOverlap);
        if (IsSandwitch)
        {
            SandwitchCols.Clear();
            SandwitchCols.AddRange(topOverlapCols);
            SandwitchCols.AddRange(bottomOverlapCols);
        }
        bool landColOverlap = false;

        if (MoveMng.GetFallVec() <= 0.0f)
        {
            landColOverlap = bottomColOverlap;
        }
        else
        {
            landColOverlap = topColOverlap;
        }

        // 着地時、入/出水時の戻り回転時
        //		if ((Land.IsLandingTrueChange || Land.IsWaterFloatLandingTrueChange) ||   // 着地時の判定
        if ((landTrueChangeFlg && !IsSandwitch) ||                                                                                              // 通常の着地時
            //(IsLanding && !prevIsExtrusionLanding && Land.IsExtrusionLanding) ||													// 上下を挟まれている時の落下方向変化時
            (prevIsSandwitch && !IsSandwitch && landColOverlap) ||                                                                              // 上下を挟まれている状態から解放された時
            ((WaterStt.IsInWater != prevIsInWater) && (WeightMng.WeightLv == WeightManager.Weight.light) && (RotVec.y != 0.0f)))                // 反転したまま水上に落ちた時

        // 入水時の戻り回転なら天井回転アニメーションは行わない
        {
            bool notHandSpring = (WaterStt.IsInWater != prevIsInWater);

            // 必要なら回転アニメーション
            float nowRotVec  = RotVec.y;
            float landRotVec = 0.0f;

            //if (MoveMng.PrevMove.y > 0.0f) {
            if (MoveMng.GetFallVec() > 0.0f)
            {
                if ((WeightMng.WeightLv == WeightManager.Weight.flying) ||
                    ((WeightMng.WeightLv == WeightManager.Weight.light) && (WaterStt.IsInWater)))
                {
                    landRotVec = 1.0f;
                }
            }

            if (nowRotVec != landRotVec)
            {
                RotVec = new Vector3(RotVec.x, landRotVec, RotVec.z);

                if (!notHandSpring)
                {
                    // 天井回転アニメーション
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartHandSpring();
                    }
                    else
                    {
                        PlAnim.StartHoldHandSpring();
                    }
                    HandSpringEndTime = (Time.time + handSpringWeitTime);
                    IsHandSpring      = true;
                }
            }
        }

        // 左右移動
        Walk();

        // ジャンプ
        if (!Land.noticeLandEffect)
        {
            if (jumpReserveInput)
            {
                if (Jump())
                {
                    prevJumpStandbyFlg = true;
                }
                if (!jumpStandbyFlg)
                {
                    prevJumpStandbyFlg = false;
                }
            }
            else
            {
                Jump();
                prevJumpStandbyFlg = jumpStandbyFlg;
            }
        }

        // 立ち止まり
        WalkDown();

        // 左右上下回転
        Rotate();

        // 自動ジャンプ
        ClimbJump();

        // 着地アニメーション
        //		if ((Land.IsLanding && Land.IsLandingTrueChange) ||
        //			(Land.IsWaterFloatLanding && Land.IsWaterFloatLandingTrueChange)) {
        //if (landTrueChangeFlg) {
        if ((landTrueChangeFlg || Land.IsExtrusionLanding) && !PlAnim.IsLandOnlyAnim)
        {
            //			Land.IsLandingTrueChange = false;
            //			Land.IsWaterFloatLandingTrueChange = false;
            if (!Lift.IsLifting)
            {
                PlAnim.StartLand();
            }
            else
            {
                PlAnim.StartHoldLand();
            }
            if (WeightMng.WeightLv <= WeightManager.Weight.light)
            {
                PlAnim.SetLandSpeed(lightLandAnimSpd);
            }
            else
            {
                PlAnim.SetLandSpeed(heavyLandAnimSpd);
            }
        }

        // 出水時アニメーション
        if (WaterStt.IsWaterSurfaceChange)
        {
            WaterStt.IsWaterSurfaceChange = false;
            // 着水解除時
            if (!WaterStt.IsWaterSurface)
            {
                // 落下の場合
                if (WeightMng.WeightLv == WeightManager.Weight.heavy)
                {
                    // 落下アニメーションに遷移
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartFall();
                    }
                    else
                    {
                        PlAnim.StartHoldFall();
                    }
                }
                // 浮遊の場合
                else if (WeightMng.WeightLv == WeightManager.Weight.flying)
                {
                    // 浮遊アニメーションに遷移
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartFly();
                    }
                    else
                    {
                        PlAnim.StartHoldFly();
                    }
                }
                // ジャンプでの出水の場合
                else
                {
                    // ジャンプアニメーションに遷移
                    if (!Lift.IsLifting)
                    {
                        PlAnim.StartJump();
                    }
                    else
                    {
                        PlAnim.StartHoldJump();
                    }
                }
            }
        }

        //		if ((!Land.IsLanding && Land.IsLandingTrueChange) && (!Land.IsWaterFloatLanding && Land.IsWaterFloatLandingTrueChange)) {
        //			Land.IsLandingTrueChange = false;
        //			if (!isJump) {
        //				if (!Lift.IsLifting) {
        //					PlAnim.StartFall();
        //				} else {
        //					PlAnim.StartHoldFall();
        //				}
        //			}
        //		}

        // 待機時に少しカメラ方向を向く
        UpdateLookCamera();
        LookCamera();

        // 泳ぎサウンドの音量を変更
        if (IsWaterSurfaceSwiming)
        {
            SwimAudioSource.volume += swimSoundVolUpSpd;
        }
        else
        {
            SwimAudioSource.volume -= swimSoundVolDownSpd;
        }
        SwimAudioSource.volume = Mathf.Clamp(SwimAudioSource.volume, swimSoundMinVol, swimSoundMaxVol);

        prevIsLanding           = Land.IsLanding;
        prevIsExtrusionLanding  = Land.IsExtrusionLanding;
        prevIsWaterFloatLanding = Land.IsWaterFloatLanding;
        prevIsInWater           = WaterStt.IsInWater;
        prevIsSandwitch         = isSandwitch;
    }
Ejemplo n.º 14
0
    bool Jump()
    {
        // ジャンプ入力(トリガー)がなければ
        if (!jumpStandbyFlg || prevJumpStandbyFlg)
        {
            return(false);
        }

        // ジャンプ可能でなければ
        if (!canJump)
        {
            return(false);
        }

        // ステージに接地、又は水面で安定していなければ
        Debug.LogWarning("IsLanding:" + Land.IsLanding);
        //if (!Land.IsLanding && !WaterStt.IsWaterSurface) {
        if (!(Land.IsLanding || WaterStt.IsWaterSurface))
        {
            PileWeight pile = GetComponent <PileWeight>();
            // 接地、又は安定しているオブジェクトにも接地していなければ
            List <Transform> pileObjs  = pile.GetPileBoxList(new Vector3(0.0f, MoveMng.GravityForce, 0.0f));
            bool             stagePile = false;
            foreach (var pileObj in pileObjs)
            {
                Landing    pileLand     = pileObj.GetComponent <Landing>();
                WaterState pileWaterStt = pileObj.GetComponent <WaterState>();
                if ((pileLand && (pileLand.IsLanding || pileLand.IsExtrusionLanding)) || (pileWaterStt && (pileWaterStt.IsWaterSurface)))
                {
                    stagePile = true;
                }
            }
            if ((pileObjs.Count == 0) || !stagePile)
            {
                // ジャンプ不可
                return(false);
            }
        }

        // ジャンプ直後であれば
        //		if (jumpLimitTime > Time.time) return;

        Debug.Log("Jump");

        // ジャンプアニメーション
        if (!Lift.IsLifting)
        {
            PlAnim.StartJump();
        }
        else
        {
            PlAnim.StartHoldJump();
        }

        // 前回までの上下方向の加速度を削除
        MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);

        // 左右方向の加速度を削除
        //		MoveMng.StopMoveHorizontalAll();

        // 左右方向の移動量も一更新だけ制限
        MoveMng.OneTimeMaxSpd = jumpStartOneTimeLimitSpd;

        // 上方向へ加速
        //float jumpGravityForce = (0.5f * Mathf.Pow(jumpTime * 0.5f, 2) + jumpHeight);	// ジャンプ中の重力加速度
        //		float jumpGravityForce = -100;   // ジャンプ中の重力加速度

        //		MoveMng.AddMove(new Vector3(0.0f, (-jumpGravityForce * JumpTime * 0.5f), 0.0f));
        //		Debug.Log(jumpGravityForce);

        MoveMng.AddMove(new Vector3(0.0f, (JumpHeight), 0.0f));

        // 離地
        Land.IsLanding          = false;
        WaterStt.IsWaterSurface = false;
        WaterStt.BeginWaterStopIgnore();

        // ジャンプ入力を無効化
        jumpStandbyFlg = false;

        // 通常の重力加速度を一時的に無効
        //MoveMng.GravityCustomTime = (Time.time + JumpTime);
        //MoveMng.GravityForce = jumpGravityForce;

        // 次回ジャンプ可能時間を設定
        //		jumpLimitTime = Time.time + jumpTime * 0.5f;	// ジャンプしてからジャンプ滞空時間の半分の時間まではジャンプ不可

        return(true);
    }
Ejemplo n.º 15
0
    public GameObject Lift()
    {
        // 処理後状態なら入力が解除されるまで処理しない
        if (afterHoldInput)
        {
            return(null);
        }

        Debug.Log("lift");
        switch (St)
        {
        case LiftState.standby:
            // 重さ変更中は処理しない
            if (Pl.IsShift)
            {
                return(null);
            }

            // 範囲内で最も近い持ち上げられるオブジェクトを取得
            List <RaycastHit> hitInfos = new List <RaycastHit>();
            //			hitInfos.AddRange(Physics.BoxCastAll(transform.position, liftUpCol.localScale * 0.5f, (liftUpCol.position - transform.position),
            //				liftPoint.rotation, Vector3.Distance(transform.position, liftUpCol.position), boxMask));
            hitInfos.AddRange(Physics.BoxCastAll(liftUpCol.transform.position, liftUpCol.localScale * 0.5f, (transform.position - liftUpCol.position), liftPoint.rotation, float.Epsilon, boxMask));

            // 浮いているオブジェクトは持ち上げられない
            for (int idx = hitInfos.Count - 1; idx >= 0; idx--)
            {
                Landing    hitInfoLand     = hitInfos[idx].collider.GetComponent <Landing>();
                WaterState hitInfoWaterStt = hitInfos[idx].collider.GetComponent <WaterState>();
                if ((!hitInfoLand || !hitInfoWaterStt) ||
                    (!hitInfoLand.IsLanding && !hitInfoLand.IsWaterFloatLanding && !hitInfoWaterStt.IsWaterSurface))
                {
                    hitInfos.RemoveAt(idx);
                }
            }

            // 上下をオブジェクトに挟まれている場合
            if (Pl.IsSandwitch)
            {
                // 挟んでいるオブジェクト以外は持ち上げ対象から除外
                for (int idx = hitInfos.Count - 1; idx >= 0; idx--)
                {
                    if (!Pl.SandwitchCols.Contains(hitInfos[idx].collider))
                    {
                        hitInfos.RemoveAt(idx);
                    }
                }
            }

            GameObject liftableObj = null;
            float      dis         = float.MaxValue;
            //			Debug.LogWarning(hitInfos.Count);

            foreach (var hitInfo in hitInfos)
            {
                //				Debug.LogWarning(hitInfo.collider.name + " " + hitInfo.collider.tag);
                if (!underPriority)
                {
                    if ((hitInfo.collider.tag == "LiftableObject") && (hitInfo.distance < dis))
                    {
                        liftableObj = hitInfo.collider.gameObject;
                        dis         = hitInfo.distance;
                    }
                }
                else
                {
                    if ((hitInfo.collider.tag == "LiftableObject") && (!liftableObj || (hitInfo.transform.position.y < liftableObj.transform.position.y)))
                    {
                        liftableObj = hitInfo.collider.gameObject;
                    }
                }
            }

            // 持ち上げれるオブジェクトがあれば
            if (liftableObj != null)
            {
                if (!canHeavyLift)
                {
                    // 重さがプレイヤーより重ければ失敗フラグを立てる
                    heavyFailedFlg = (Pl.GetComponent <WeightManager>().WeightLv < liftableObj.GetComponent <WeightManager>().WeightLv);
                }

                // ジャンプ、重さ変更、振り向きを不可に
                Pl.CanJump         = false;
                Pl.CanShift        = false;
                Pl.CanRotationTurn = false;

                // 移動量を削除
                MoveMng.StopMoveVirticalAll();
                MoveMng.StopMoveHorizontalAll();

                // 持ち上げ中のオブジェクトが水で浮かないように
                WaterState liftWaterStt = liftableObj.GetComponent <WaterState>();
                liftWaterStt.CanFloat = false;

                // 持ち上げ開始
                return(LiftUpStart(liftableObj));
            }
            else
            {
                // 持ち上げキャンセル
                LiftObj = null;
            }
            break;

        case LiftState.lifting:
            // 重さ変更中は処理しない
            if (Pl.IsShift)
            {
                return(null);
            }

            //// 持ち上げ中オブジェクト以外のすり抜け中のオブジェクトがある場合は処理しない
            //foreach (var throughObj in MoveMng.ThroughObjList) {
            //	if (throughObj != LiftObj) {
            //		return null;
            //	}
            //}

            // ジャンプ、重さ変更、振り向きを不可に
            Pl.CanJump         = false;
            Pl.CanShift        = false;
            Pl.CanRotationTurn = false;

            // 下ろし始める
            LiftDownStart();

            // 移動量を削除
            MoveMng.StopMoveVirticalAll();
            MoveMng.StopMoveHorizontalAll();

            break;

        default:
            break;
        }
        return(null);
    }
Ejemplo n.º 16
0
    void FixedUpdate()
    {
        List <RaycastHit> waterAreaList = Support.GetColliderHitInfoList(waterCol, Vector3.zero, LayerMask.GetMask("WaterArea"));

        if (waterAreaList.Count > 0)
        {
            // 入った水エリアを保持する
            float nearDis = float.MaxValue;
            foreach (var waterArea in waterAreaList)
            {
                BoxCollider waterBox = waterArea.transform.GetComponent <BoxCollider>();
                float       cmpDis   = Mathf.Abs((waterBox.bounds.center.y + waterBox.bounds.size.y * 0.5f) - (waterCol.bounds.center.y));
                if (cmpDis < nearDis)
                {
                    nearDis    = cmpDis;
                    inWaterCol = waterBox;
                }
            }
            IsInWater = true;
        }
        else
        {
            IsInWater = false;
        }

        // 水中なら
        if (isInWater && !IsWaterSurface)
        {
            if (CanFloat)
            {
//				// 押し付けられていない場合
//				if (!(Land && Land.IsExtrusionLanding)) {
                // 水による浮上
                //Debug.LogWarning("waterfloat");
                MoveMng.AddMove(new Vector3(0.0f, waterFloatSpd[(int)WeightMng.WeightLv], 0.0f), MoveManager.MoveType.waterFloat);
//				}
                // 自身が宙に浮く重さであり、水上に浮く以上の重さのオブジェクトに抑えられている場合
                if ((WeightMng.WeightLv == WeightManager.Weight.flying) && (WeightMng.PileMaxWeightLv >= WeightManager.Weight.light))
                {
                    // 重力による移動と前回の移動量をなくす
                    MoveMng.StopMoveVirtical(MoveManager.MoveType.gravity);
                    MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);
                }
            }
        }
        // 水上なら
        else if (IsWaterSurface)
        {
            // 重さや位置に変化が無ければ
            if ((WeightMng.WeightLv == WeightManager.Weight.light) && (transform.position.y == prevHeight) && (WeightMng.PileMaxWeightLv != WeightManager.Weight.heavy))
            {
                // 落下しない
                MoveMng.StopMoveVirtical(MoveManager.MoveType.gravity);
                MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);
                MoveMng.StopMoveVirtical(MoveManager.MoveType.waterFloat);
            }
            // 重さや位置が変化していれば
            else
            {
                // 水面状態を解除
                IsWaterSurface = false;

                // 上に乗っているオブジェクトに沈められた場合
                if (WeightMng.PileMaxWeightLv == WeightManager.Weight.heavy)
                {
                    // 下方向への移動が続く限り、水面状態にならない
                    IsSubmerge = true;
                }
            }
        }

        // 上に乗っているオブジェクトに沈められた後、上方向に移動していれば
        if (IsSubmerge && MoveMng.PrevMove.y > 0.0f)
        {
            // 沈められていない
            IsSubmerge = false;
        }
    }
Ejemplo n.º 17
0
    bool Jump()
    {
        if (!useManualJump)
        {
            return(false);
        }
        if (IsHandSpringWeit)
        {
            return(false);
        }

        // ジャンプ入力(トリガー)がなければ
        if (!jumpStandbyFlg || prevJumpStandbyFlg)
        {
            return(false);
        }
        // ジャンプ可能でなければ
        if (!canJump)
        {
            return(false);
        }
        // 天井反転中なら
        if (IsHandSpring)
        {
            return(false);
        }

        // 着地していなければ
        if (!IsLanding && !WaterStt.IsWaterSurface && !Land.IsWaterFloatLanding)
        {
            return(false);
        }

        // 水面で安定した瞬間であれば
        if (WaterStt.IsWaterSurfaceChange && WaterStt.IsWaterSurface)
        {
            return(false);
        }

        // ステージに接地、又は水面で安定していなければ
        //		Debug.LogWarning("IsLanding:" + Land.IsLanding);
        //if (!Land.IsLanding && !WaterStt.IsWaterSurface) {
        if (!(Land.IsLanding || WaterStt.IsWaterSurface))
        {
            // 接地、又は安定しているオブジェクトにも接地していなければ
            List <Transform> pileObjs  = Pile.GetPileBoxList(new Vector3(0.0f, MoveMng.GravityForce, 0.0f));
            bool             stagePile = false;
            foreach (var pileObj in pileObjs)
            {
                Landing    pileLand     = pileObj.GetComponent <Landing>();
                WaterState pileWaterStt = pileObj.GetComponent <WaterState>();
                //				WaterState pileWaterStt = pileObj.GetComponent<WaterState>();
                //				if ((pileLand && (pileLand.IsLanding || pileLand.IsExtrusionLanding)) || (pileWaterStt && (pileWaterStt.IsWaterSurface))) {
                if ((pileLand && (pileLand.IsLanding || pileLand.IsExtrusionLanding || pileWaterStt.IsWaterSurface)))
                {
                    stagePile = true;
                    break;
                }
            }
            if ((pileObjs.Count == 0) || !stagePile)
            {
                // ジャンプ不可
                return(false);
            }
        }

        // 水面の場合
        if (WaterStt.IsWaterSurface)
        {
            // 自身の上にオブジェクトが乗っていればジャンプできない
            if (Pile.GetPileBoxList(Vector3.up).Count > 0)
            {
                return(false);
            }
        }

        // ジャンプ直後であれば
        //		if (jumpLimitTime > Time.time) return;

        Debug.Log("Jump");

        // パーティクル生成
        if (IsLanding)
        {
            GetComponent <GeneratePlayerJumpJet>().GenerateInGroundEffect();
        }
        else if (WaterStt.IsWaterSurface)
        {
            GetComponent <GeneratePlayerJumpJet>().GenerateInWaterSurfaceEffect();
        }
        else
        {
            GetComponent <GeneratePlayerJumpJet>().GenerateInWaterEffect();
        }

        // ジャンプアニメーション
        if (!Lift.IsLifting)
        {
            PlAnim.StartJump();
        }
        else
        {
            PlAnim.StartHoldJump();
        }

        if (!WaterStt.IsWaterSurface)
        {
            // サウンド再生
            SoundManager.SPlay(jumpSE, jumpSEDeray);
        }

        // 前回までの上下方向の加速度を削除
        MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);

        // 左右方向の移動量をジャンプ中速度まで下げる
        MoveMng.PrevMove = new Vector3(Mathf.Clamp(MoveMng.PrevMove.x, -JumpSpd, JumpSpd), MoveMng.PrevMove.y, MoveMng.PrevMove.z);

        // 左右方向の加速度を削除
        //		MoveMng.StopMoveHorizontalAll();

        // 左右方向の移動量も一更新だけ制限
        //		MoveMng.OneTimeMaxSpd = jumpStartOneTimeLimitSpd;

        // 上方向へ加速
        //float jumpGravityForce = (0.5f * Mathf.Pow(jumpTime * 0.5f, 2) + jumpHeight);	// ジャンプ中の重力加速度
        //		float jumpGravityForce = -100;   // ジャンプ中の重力加速度

        //		MoveMng.AddMove(new Vector3(0.0f, (-jumpGravityForce * JumpTime * 0.5f), 0.0f));
        //		Debug.Log(jumpGravityForce);

        // 離地方向に移動
        if (!WaterStt.IsInWater || WaterStt.IsWaterSurface)
        {
//			Debug.LogWarning("landJump");
            MoveMng.AddMove(new Vector3(0.0f, (JumpHeight), 0.0f));
        }
        else
        {
//			Debug.LogWarning("inWaterJump");
            MoveMng.AddMove(new Vector3(0.0f, (JumpHeightInWater), 0.0f));
        }

        // 離地
        Land.IsLanding          = false;
        WaterStt.IsWaterSurface = false;
        WaterStt.BeginWaterStopIgnore();

        //// ジャンプ入力を無効化
        //prevJumpStandbyFlg = jumpStandbyFlg;
        //jumpStandbyFlg = false;

        // 通常の重力加速度を一時的に無効
        //MoveMng.GravityCustomTime = (Time.time + JumpTime);
        //MoveMng.GravityForce = jumpGravityForce;

        // 次回ジャンプ可能時間を設定
        //		jumpLimitTime = Time.time + jumpTime * 0.5f;	// ジャンプしてからジャンプ滞空時間の半分の時間まではジャンプ不可

        return(true);
    }
Ejemplo n.º 18
0
    //	}

    void ClimbJump()
    {
        if (!useAutoClimbJump)
        {
            return;
        }

        // 持ち上げ中や持ち上げ入力があれば処理しない
        //		if (Lift.IsLifting || (Input.GetAxis("Lift") != 0.0f)) return;
        if (Lift.IsLifting || (VirtualController.GetAxis(VirtualController.CtrlCode.Lift) != 0.0f))
        {
            return;
        }

        // ジャンプ可能でなければ処理しない
        if (!canJump)
        {
            return;
        }

        // 接地中でも水上安定中でもなく、水上安定中ブロックに乗ってもいなければ処理しない
        if (!Land.IsLanding && !WaterStt.IsWaterSurface && !Land.IsWaterFloatLanding)
        {
            return;
        }

        // 左右への移動入力がなければ処理しない
        if (walkStandbyVec == 0.0f)
        {
            return;
        }

        // 自動ジャンプ判定がなければ処理しない
        if ((ClimbJumpWeightLvCollider == null) || (ClimbJumpWeightLvCollider.Count <= (int)WeightMng.WeightLv) || (ClimbJumpWeightLvCollider[(int)WeightMng.WeightLv] == null) ||
            (ClimbJumpWeightLvInWaterCollider == null) || (ClimbJumpWeightLvInWaterCollider.Count <= (int)WeightMng.WeightLv) || (ClimbJumpWeightLvInWaterCollider[(int)WeightMng.WeightLv] == null))
        {
            return;
        }

        Transform climbJumpCol;

        if (!WaterStt.IsInWater)
        {
            climbJumpCol = ClimbJumpWeightLvCollider[(int)WeightMng.WeightLv];
        }
        else
        {
            climbJumpCol = ClimbJumpWeightLvInWaterCollider[(int)WeightMng.WeightLv];
        }

        // 自動ジャンプ判定内に対象オブジェクトがなければ処理しない
        if (Physics.OverlapBox(climbJumpCol.transform.position,
                               climbJumpCol.lossyScale * 0.5f,
                               climbJumpCol.rotation, climbJumpMask).Length <= 0)
        {
            return;
        }

        // 現在の向きと移動入力方向が異なれば処理しない
        if (Vector3.Dot((climbJumpCol.position - transform.position), (Vector3.right * walkStandbyVec)) <= 0.0f)
        {
            return;
        }

        // ジャンプアニメーション
        if (!Lift.IsLifting)
        {
            PlAnim.StartJump();
        }
        else
        {
            PlAnim.StartHoldJump();
        }

        // 前回までの上下方向の加速度を削除
        MoveMng.StopMoveVirtical(MoveManager.MoveType.prevMove);

        // 左右方向の移動量も一更新だけ制限
        MoveMng.OneTimeMaxSpd = jumpStartOneTimeLimitSpd;

        // 上方向へ加速
        if (!WaterStt.IsInWater)
        {
            MoveMng.AddMove(new Vector3(0.0f, ClimbJumpWeightLvHeight[(int)WeightMng.WeightLv], 0.0f));
        }
        // 水中
        else
        {
            MoveMng.AddMove(new Vector3(0.0f, ClimbJumpWeightLvHeightInWater[(int)WeightMng.WeightLv], 0.0f));
        }

        // 離地
        Land.IsLanding          = false;
        WaterStt.IsWaterSurface = false;
        WaterStt.BeginWaterStopIgnore();
    }
Ejemplo n.º 19
0
    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;
        }
    }