/// <summary> /// 更新処理 /// </summary> /// <param name="collision_construction"></param> public void Update(BaseCollisionConstruction collision_construction) { foreach (var details in list_rpg_collision_details_) { details.Update(collision_construction); } }
/// <summary> /// 更新処理(当たり判定) /// </summary> /// <param name="collision_construction"></param> public void UpdateCollision(BaseCollisionConstruction collision_construction, List <BaseCollisionConstruction> opponent_collider) { foreach (var details in list_rpg_collision_details_) { details.UpdateCollision(collision_construction, this, opponent_collider); } }
/// <summary> /// 自動的に追加する(レイヤー指定あり) /// </summary> /// <returns></returns> public bool AutoAddCollisionDetails(BaseCollisionConstruction collision_construction, int layer) { if (list_rpg_collision_details_ == null) { list_rpg_collision_details_ = new List <RpgCollisionDetails>(); } Collider[] colliders = collision_construction.ThisObject.AllComponents <Collider>(); foreach (var col in colliders) { if (col.gameObject.layer != layer) { continue; } if (SearchCollisionDetails(col) != null) { continue; } RpgCollisionDetails details = new RpgCollisionDetails(); details.Init(collision_construction, col, collision_construction.ThisObject); list_rpg_collision_details_.Add(details); } return(true); }
/// <summary> /// 検索用Collision /// </summary> /// <param name="search_collision"></param> /// <returns></returns> public BaseCollisionConstruction SearchCollisionConstruction(BaseCollisionConstruction search_collision) { if (list_all_collision_construction_.Count == 0) { return(null); } return(list_all_collision_construction_.Find(collision => collision == search_collision)); }
/// <summary> /// 当たり判定の計算 /// </summary> /// <param name="this_collison"></param> /// <param name="collision_details"></param> /// <param name="collider"></param> public static void CollisionCorrection(BaseCollisionConstruction this_collison, RpgCollisionDetailsControl this_collision_control, RpgCollisionDetails collision_details, List <BaseCollisionConstruction> opponent_collider, Collider[] colliders) { if (this_collison == null || collision_details == null) { return; } if (opponent_collider.Count == 0) { return; } //強制終了用のカウント int cnt = 0; for (int i = 0; i < opponent_collider.Count; i++) { cnt++; Exit(cnt); Vector3 pushBackVector = Vector3.zero; float pushBackDistance = 0.0f; if (this_collision_control == opponent_collider[i].RpgCollisionDetailsControl) { continue; } List <RpgCollisionDetails> detaile = opponent_collider[i].RpgCollisionDetailsControl.ListRpgCollisionDetaile; foreach (var opponent_col in detaile) { if (opponent_col == collision_details) { continue; } string name = opponent_col.RpgCollision.gameObject.name; string name2 = collision_details.RpgCollision.gameObject.name; ///めり込んでいた場合 if (ComputePenetration(this_collison.CollisionPushType, collision_details.RpgCollision, RpgCollisionDetailsAccessor.CalculationPosition(collision_details) , opponent_col.RpgCollision, RpgCollisionDetailsAccessor.SaveCollisionPosition(opponent_col) , ref pushBackVector, ref pushBackDistance)) { if (pushBackDistance >= float.Epsilon) { Vector3 updatedPostion = (pushBackVector) * (pushBackDistance); this_collison.ThisObject.transform.position += new Vector3(updatedPostion.x, updatedPostion.y, updatedPostion.z); RpgCollisionDetailsAccessor.SaveCollisionPosition(collision_details, this_collison.ThisObject.transform.position); RpgCollisionDetailsAccessor.CalculationPosition(collision_details, this_collison.ThisObject.transform.position); this_collision_control.CollisionHitEnter(opponent_col.RpgCollision, opponent_col); opponent_collider[i].RpgCollisionDetailsControl.CollisionHitEnter(collision_details.RpgCollision, collision_details); } } } } }
/// <summary> /// 更新処理(当たり判定) /// </summary> /// <param name="collision"></param> public void UpdateCollision(BaseCollisionConstruction collision, RpgCollisionDetailsControl this_collision_control, List <BaseCollisionConstruction> opponent_collider) { if (collision == null) { return; } if (rpg_collision_ == null) { return; } Collider[] colliders = CollisionTypeOverLap(); RpgCollisionCalculation.CollisionCorrection(collision, this_collision_control, this, opponent_collider, colliders); }
/// <summary> /// 初期化 /// </summary> /// <param name="collision"></param> /// <param name="value_collider"></param> public void Init(BaseCollisionConstruction collision, Collider value_collider, GameObject value_object) { if (collision == null) { return; } if (position_collision_ == null) { position_collision_ = new RpgCollisionPosition(); } rpg_collision_ = value_collider; position_collision_.Update(collision.ThisObject.transform.position); this_object_ = value_object; }
/// <summary> /// 削除コリジョン /// </summary> /// <param name="erasure_collision"></param> /// <returns></returns> public bool ErasureCollisionConstruction(BaseCollisionConstruction erasure_collision) { if (erasure_collision == null) { return(false); } if (list_all_collision_construction_ == null) { list_all_collision_construction_ = new List <BaseCollisionConstruction>(); } CollisionSort(); return(RemoveCollisionConstruction(erasure_collision)); }
/// <summary> /// 更新処理 /// </summary> /// <param name="collision"></param> public void Update(BaseCollisionConstruction collision) { if (collision == null) { return; } if (position_collision_ == null) { return; } if (rpg_collision_ == null) { return; } position_collision_.Update(rpg_collision_.transform.position); }
/// <summary> /// 追加コリジョン /// </summary> /// <param name="add_collision"></param> /// <returns></returns> public bool AddCollisionConstruction(BaseCollisionConstruction add_collision) { if (add_collision == null) { return(false); } if (list_all_collision_construction_ == null) { list_all_collision_construction_ = new List <BaseCollisionConstruction>(); } BaseCollisionConstruction base_collision = SearchCollisionConstruction(add_collision); if (base_collision != null) { return(false); } list_all_collision_construction_.Add(add_collision); CollisionSort(); return(true); }
/// <summary> /// 削除コリジョン /// </summary> /// <param name="erasure_collision"></param> /// <returns></returns> public static bool ErasureCollisionConstruction(BaseCollisionConstruction erasure_collision) { return(RpgCollisionControl.Instance.RemoveCollisionConstruction(erasure_collision)); }
/// <summary> /// 追加コリジョン /// </summary> /// <param name="add_collision"></param> /// <returns></returns> public static bool AddCollisionConstruction(BaseCollisionConstruction add_collision) { return(RpgCollisionControl.Instance.AddCollisionConstruction(add_collision)); }
// Start is called before the first frame update void Start() { collision_ = new BaseCollisionConstruction(); collision_.Init(gameObject, collision_type_, collision_push_type_, LayerMask.NameToLayer("Player")); collision_.RpgCollisionDetailsControl.HitSecondFunc = Enter; }
/// <summary> /// 削除用Collision /// </summary> /// <param name="search_collision"></param> /// <returns></returns> public bool RemoveCollisionConstruction(BaseCollisionConstruction search_collision) { return(list_all_collision_construction_.Remove(search_collision)); }
/// <summary> /// 検索用Collision /// </summary> /// <param name="search_collision"></param> /// <returns></returns> public static BaseCollisionConstruction SearchCollisionConstruction(BaseCollisionConstruction search_collision) { return(RpgCollisionControl.Instance.SearchCollisionConstruction(search_collision)); }
/// <summary> /// 削除用Collision /// </summary> /// <param name="search_collision"></param> /// <returns></returns> public static bool RemoveCollisionConstruction(BaseCollisionConstruction search_collision) { return(RpgCollisionControl.Instance.RemoveCollisionConstruction(search_collision)); }
void Start() { collision_ = new BaseCollisionConstruction(); collision_.Init(gameObject, collision_type_, collision_push_type_); collision_.RpgCollisionDetailsControl.HitReleaseFunc = Enter; }