Example #1
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);
    }
Example #2
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離地");
        }
    }
Example #3
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));
        }
    }
Example #4
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;
    }