void Resize() { Undo.RecordObjects(targets, "Resize"); foreach (var t in targets) { OnewayFloor lOnewayFloor = t as OnewayFloor; lOnewayFloor.Resize(); } }
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)); } }
//射線が通っているか public bool ThroughShotLine(Vector3 aFrom, Vector3 aTo, List <GameObject> aIgnoreList = null) { Vector3 lDir = (aTo - aFrom); if (lDir.magnitude == 0.0f) { lDir = Vector3.up; } //LayerMask l = LayerMask.GetMask(new string[] { "Box", "Stage" }); //Stageだけが、重さを移すのを遮る LayerMask l = LayerMask.GetMask(new string[] { "Stage" }); List <RaycastHit> rcs = Physics.SphereCastAll(aFrom, mCollider.transform.lossyScale.x / 2.0f, lDir, (aTo - aFrom).magnitude, l).ToList(); //通り抜けられるオブジェクトを、判定から除外する for (int i = rcs.Count - 1; i >= 0; i--) { //一方向からすり抜ける床の判定 OnewayFloor o = rcs[i].collider.GetComponent <OnewayFloor>(); if (o != null) { //もし通り抜けられるなら、判定から除外 if (o.IsThrough(lDir)) { rcs.RemoveAt(i); continue; } } //ボタンは通り抜けるので、判定から除外 if (rcs[i].collider.CompareTag("Button")) { rcs.RemoveAt(i); continue; } //ファンは通り抜けるので、判定から除外 if (rcs[i].collider.CompareTag("Fan")) { rcs.RemoveAt(i); continue; } } //近い順にソートする rcs = rcs.OrderBy(x => x.distance).ToList(); foreach (var rc in rcs) { bool lHit = false; if (aIgnoreList == null) { lHit = true; } if (aIgnoreList.Contains(rc.collider.gameObject) == false) { lHit = true; } if (lHit == true) { mHitPosition = rc.point; mHitDirection = aTo - aFrom; return(false); } } return(true); }