/// ******************************************************* /// <summary>当たり対象追加</summary> /// <param name="target">当たり対象</param> /// ******************************************************* public virtual void AddHitTarget(CharacterControll target) { if (HitTarget.Contains(target) == false) { HitTarget.Add(target); } }
/// ******************************************************* /// <summary>キャラ同士当たり判定</summary> /// <param name="self">判定対象1</param> /// <param name="target">判定対象2</param> /// ******************************************************* private void HitCheckChar(CharacterControll self, CharacterControll target) { if (self.HitTest(target) == true) { self.AddHitTarget(target); target.AddHitTarget(self); } }
/// ******************************************************* /// <summary>当たり判定登録</summary> /// <param name="ctrl">登録アイテム</param> /// ******************************************************* public void EntryHitCheck(CharacterControll ctrl) { Vector2Int areamin = GetPointArea(ctrl.BoundsMinX, ctrl.BoundsMinY); Vector2Int areamax = GetPointArea(ctrl.BoundsMaxX, ctrl.BoundsMaxY); for (int h = areamin.x; h <= areamax.x; h++) { for (int v = areamin.y; v <= areamax.y; v++) { AddHitArea(ctrl, h, v, ctrl.CharType); } } }
/// ******************************************************* /// <summary>エリア登録</summary> /// <param name="ctrl">対象コントロール</param> /// <param name="area_x">X座標</param> /// <param name="area_y">Y座標</param> /// <param name="char_type">キャラクタータイプ</param> /// ******************************************************* private void AddHitArea(CharacterControll ctrl, int area_x, int area_y, CharacterTyep char_type) { if (area_x < 0) { return; } if (area_x >= SPLIT_H) { return; } if (area_y < 0) { return; } if (area_y >= SPLIT_V) { return; } int ctype = (int)char_type; if (ctype < 0) { return; } if (ctype >= CHARACTER_TYPE_COUNT) { return; } List <CharacterControll> area = AreaLists[area_x][area_y][ctype]; if (area.Contains(ctrl) == false) { area.Add(ctrl); } //AreaLists[area_x][area_y][ctype].Add(ctrl); }
/// ******************************************************* /// <summary>当たり判定テスト</summary> /// <param name="target">判定対象</param> /// <returns>true:当たった/false:当たってない</returns> /// ******************************************************* public bool HitTest(CharacterControll target) { return(BarrageCollider.HitTest(target.BarrageCollider)); }