void onHitPlayer(ColliderData s) { if (GameMaster.isFailed()) {return;} got = true; switch (type) { case ItemType.NoEffect: break; case ItemType.Gain: age=0f; lifeSpan = 0.5f; Gain (s.Obj.GetComponent<PlayerControl>()); break; case ItemType.Recovery: age=0f; lifeSpan = 0.5f; s.Obj.GetComponent<PlayerControl>().Recovery(number); break; case ItemType.GameClear: age=0f; lifeSpan = 0.5f; GameMaster.Instance.onClear(); break; } PlayerHitAct = null; Debug.Log ("Clear"); }
void onHitPlayer(ColliderData s) { Debug.Log ("Hit"); Vector3 d = s.Obj.transform.position - transform.position; d.y = 0f; s.Obj.GetComponent<PlayerControl> ().onAttacked (d.normalized, 1); }
public JointData(Transform _transform) { connectedTo = null; transform = _transform; collision = new ColliderData(); joint = new CharacterJointConfig(); }
/** * Determines if an object is overlapping with this collider or not. * Returns true if colliding. **/ public bool CheckOverlap(ColliderData other) { if (mins.x > other.maxs.x) { return(false); } if (maxs.x < other.mins.x) { return(false); } if (mins.y > other.maxs.y) { return(false); } if (maxs.y < other.mins.y) { return(false); } if (mins.z > other.maxs.z) { return(false); } if (maxs.z < other.mins.z) { return(false); } return(true); }
static void ApplyTransformations(ColliderData data, ref Vector3 translation, ref Quaternion rotation, ref Vector4 scale) { switch (data.primitive) { case PrimitiveType.Sphere: ApplySphereTransformations(data.collider as SphereCollider, data.transform, ref translation, ref rotation, ref scale); break; case PrimitiveType.Capsule: ApplyCapsuleTransformations(data.collider as CapsuleCollider, data.transform, ref translation, ref rotation, ref scale); break; case PrimitiveType.Cube: ApplyCubeTransformations(data.collider as BoxCollider, data.transform, ref translation, ref rotation, ref scale); break; case PrimitiveType.Cylinder: case PrimitiveType.Plane: case PrimitiveType.Quad: break; } }
private static bool BoxCircleCollision(ref ColliderData box, ref ColliderData circle) { var boxCollider = (BoxCollider)box.collider; if (IsPointInBoxCollider(ref circle.center, ref boxCollider.Points)) { return(true); } if (IsLineInCircle(ref circle.center, circle.sortDistance, ref boxCollider.Points.a, ref boxCollider.Points.b)) { return(true); } if (IsLineInCircle(ref circle.center, circle.sortDistance, ref boxCollider.Points.b, ref boxCollider.Points.c)) { return(true); } if (IsLineInCircle(ref circle.center, circle.sortDistance, ref boxCollider.Points.c, ref boxCollider.Points.d)) { return(true); } if (IsLineInCircle(ref circle.center, circle.sortDistance, ref boxCollider.Points.d, ref boxCollider.Points.a)) { return(true); } return(false); }
private BoxGizmo CreateEntityGizmo(EntityData entityData) { YHDebug.LogFormat("create gizmo {0}", entityData.id); if (entityData.id <= 0) //|| entityData.beltId != 0 { return(null); } BoxGizmo gizmo = null; ItemProto itemProto2 = LDB.items.Select(entityData.protoId); Vector3 position = entityData.pos; float num = itemProto2.prefabDesc.buildCollider.ext.magnitude * 0.7f; if (entityData.inserterId == 0) { gizmo = BoxGizmo.Create(entityData.pos, entityData.rot, itemProto2.prefabDesc.selectCenter, itemProto2.prefabDesc.selectSize); } else { ColliderData colliderData2 = player.planetData.physics.GetColliderData(entityData.colliderId); colliderData2.ext.x += 0.1f; gizmo = BoxGizmo.Create(colliderData2.pos, colliderData2.q, Vector3.zero, colliderData2.ext * 2f); } gizmo.multiplier = 1f; gizmo.alphaMultiplier = itemProto2.prefabDesc.selectAlpha; gizmo.fadeInScale = 1.3f; gizmo.fadeInTime = 0.05f; gizmo.fadeInFalloff = 0.5f; gizmo.fadeOutScale = 1.3f; gizmo.fadeOutTime = 0.05f; gizmo.fadeOutFalloff = 0.5f; gizmo.color = Color.white; return(gizmo); }
Material GetMaterial(ColliderData data) { PowerSetting powerSetting; try { powerSetting = settings.PowerProfile?.GetBoneSetting(data.boneName) ?? PowerSetting.Unpowered; } catch (InvalidRagdollProfileException) { powerSetting = PowerSetting.Unpowered; } switch (powerSetting) { case PowerSetting.Kinematic: return(kinematicMaterial); case PowerSetting.Powered: return(poweredMaterial); case PowerSetting.Unpowered: return(unpoweredMaterial); default: return(null); } }
public JointData(string path, Transform _connectedTo) { connectedTo = _connectedTo; transform = connectedTo.Find(path); collision = new ColliderData(); joint = new CharacterJointConfig(); }
List <ColliderData> GatherData(Collider[] uColliders) { var allData = new List <ColliderData>(); names.Clear(); foreach (var collider in uColliders) { if (!collider.enabled) { continue; } names.Add(collider.name); var scale = collider.transform.localScale; var data = new ColliderData(); if (collider is BoxCollider) { if (collider.name == testName) { int i = 0; } var col = collider as BoxCollider; data.pos = (col.transform.TransformPoint(col.center)).ToLVector2XZ(); data.y = (col.transform.position.y + col.center.y * scale.y).ToLFloat(); //var val = col.transform.TransformVector(col.size).ToLVector3(); var val = col.size; data.size = new Vector2(val.x * scale.x, val.z * scale.z).ToLVector2() * LFloat.half; data.high = (col.size.y * scale.y).ToLFloat(); data.deg = CTransform2D.ToDeg(col.transform.forward.ToLVector2XZ()); } else if (collider is SphereCollider) { var col = collider as SphereCollider; data.pos = (col.transform.TransformPoint(col.center)).ToLVector2XZ(); data.y = (col.transform.position.y + col.center.y * scale.y).ToLFloat(); data.radius = col.radius.ToLFloat() * scale.x.ToLFloat(); data.high = (col.radius * 2 * scale.y).ToLFloat(); } else if (collider is CapsuleCollider) { var col = collider as CapsuleCollider; data.pos = (col.transform.TransformPoint(col.center)).ToLVector2XZ(); data.y = (col.transform.position.y + col.center.y * scale.y).ToLFloat(); data.radius = col.radius.ToLFloat() * scale.x.ToLFloat(); data.high = (col.height * 2 * scale.y).ToLFloat(); } else { UnityEngine.Debug.LogError($"{ collider.name} unknow colliderType { collider.GetType().Name}"); continue; } allData.Add(data); } return(allData); }
// Update is called once per frame void OnDrawGizmos() { Gizmos.color = Color.blue; var p1 = Vector3.zero; var p2 = Vector3.forward * 3; Gizmos.DrawLine(p1, p2); Gizmos.color = Color.green; Matrix4x4 matrix2 = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(angel, rot), Vector3.one); p1 = matrix2.MultiplyPoint(p1); p2 = matrix2.MultiplyPoint(p2); Gizmos.DrawLine(p1, p2); foreach (Collider collider in GetComponents <Collider>()) { var colliderData = new ColliderData { //Name = collider.name, Position = collider.transform.position }; switch (@collider) { case BoxCollider boxCollider: colliderData.Type = ColliderType.Box; colliderData.Position += boxCollider.center; colliderData.Size = boxCollider.size; var x1 = colliderData.Position.x - (colliderData.Size.x * 0.5f); var x2 = colliderData.Position.x + (colliderData.Size.x * 0.5f); var y1 = colliderData.Position.z - (colliderData.Size.z * 0.5f); var y2 = colliderData.Position.z + (colliderData.Size.z * 0.5f); var min = new Vector3(x1, 0, y1).RotateAroundPivot(collider.transform.position, collider.transform.rotation); var max = new Vector3(x2, 0, y2).RotateAroundPivot(collider.transform.position, collider.transform.rotation); colliderData.Min = new Vector2(min.x, min.z); colliderData.Max = new Vector2(max.x, max.z); GizmoDrawCollider(colliderData, Color.red, collider.gameObject, boxCollider); break; case SphereCollider sphereCollider: colliderData.Type = ColliderType.Sphere; colliderData.Position -= sphereCollider.center; colliderData.Size = (sphereCollider.radius * Vector3.one); break; default: Debug.LogError($"Unsupported type of collider {collider.name} => {collider.GetType()}", collider); break; } } }
public void CopyFrom(ColliderData src) { name = src.name; type = src.type; origin = src.origin; size = src.size; angle = src.angle; }
public bool CompareTo(ColliderData src) { return(name == src.name && type == src.type && origin == src.origin && size == src.size && angle == src.angle); }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { colliders = GetComponents <Collider2D> (); data = BuildData(); collidedDanmaku = new MutableDanmakuCollisionList(); foreach (var collider in colliders) { ColliderMap.Add(collider, this); } }
/// <summary> /// Filter building whether inside frame /// </summary> public static void FrameInsideFilter(ColliderData colliderData) { if (selectedFrame.inside(Camera.main.WorldToScreenPoint(colliderData.pos))) { //Extract from int entityId = colliderData.objType != EObjectType.Entity ? -colliderData.objId : colliderData.objId; entityIdList.Add(entityId); //entityIdList.Add(colliderData.objId); entityTypeList.Add(colliderData.objType); } }
private static List <Mesh> BuildColliders(ColliderData colliderData) { List <Mesh> colliderMeshes = new List <Mesh>(); foreach (PartGeometry geo in colliderData.geometry) { colliderMeshes.Add(BuildObjMesh(geo.vertices, geo.faces)); } return(colliderMeshes); }
public JointData(string path, Transform _connectedTo) { connectedTo = _connectedTo; transform = connectedTo.Find(path); if (!transform) { Debug.Log("Can't find " + path + " on " + _connectedTo.name); } collision = new ColliderData(); joint = new CharacterJointConfig(); }
void ProcessParentCollider(ArchetypeChunk chunk) { var count = chunk.Count; var parents = chunk.GetNativeArray(ParentType); var entities = chunk.GetNativeArray(EntityType); var bounds = chunk.GetNativeArray(BoundsType); var shapes = chunk.GetNativeArray(ShapeType); var tags = chunk.GetNativeArray(TagType); var cellSize = Constants.CellSize; for (int i = 0; i < count; i++) { var entity = entities[i]; var aabb = bounds[i]; var shape = shapes[i]; var tag = tags[i]; var parent = parents[i]; var sourceCollider = new ColliderData { Bounds = aabb, Entity = parent.Value, ColliderEntity = entity, Shape = shape.Value, Tags = tag.Target, }; var targetCollider = new ColliderData { Bounds = aabb, Entity = parent.Value, ColliderEntity = entity, Shape = shape.Value, Tags = tag.Self, }; // Add collider to where its center is inside collider map var hash = HashUtil.Hash(aabb.Center, cellSize); ColliderSourceMap.Add(hash, sourceCollider); // Add collider to every cell it stays in + neighbour cells inside target map var gridBounds = PhysicsUtil.GetGridBounds(aabb, cellSize); for (int x = gridBounds.x; x < gridBounds.z; x++) { for (int y = gridBounds.y; y < gridBounds.w; y++) { hash = HashUtil.Hash(new int2(x, y)); ColliderTargetMap.Add(hash, targetCollider); } } } }
public void AddColliderData(Mode mode, int frameCount, Rect spriteRect) { var colliderData = new ColliderData(); colliderData.Mode = mode; colliderData.Rects = new List <ColliderFrameData>(); for (int i = 0; i < frameCount; i++) { colliderData.Rects.Add(new ColliderFrameData(false, spriteRect, Rect.zero)); } Colliders.Add(colliderData); }
// Token: 0x06000002 RID: 2 RVA: 0x000020E0 File Offset: 0x000002E0 public static ColliderData[] ReadFromFile(string path) { byte[] source = File.ReadAllBytes(path); Deserializer deserializer = new Deserializer(source); ushort num = deserializer.ReadUInt16(); ColliderData[] array = new ColliderData[(int)num]; for (int i = 0; i < (int)num; i++) { array[i] = new ColliderData(); } return(array); }
void GatherColliders() { List <Collider> foundColliders = new List <Collider>(); foreach (Collider collider in GetComponentsInChildren <Collider>(true)) { if (collider is CapsuleCollider || collider is SphereCollider || collider is BoxCollider) { foundColliders.Add(collider); } } List <ColliderData> dataList = new List <ColliderData>(); foreach (Collider collider in foundColliders) { ConfigurableJoint bindingJoint = collider.transform.GetComponentInParent <ConfigurableJoint>(); bool isPartOfABone = bindings.TryGetBoundBoneName(bindingJoint, out BoneName boneName); if (!isPartOfABone) { continue; } ColliderData data = new ColliderData { collider = collider, transform = collider.transform, boneName = boneName }; System.Type type = collider.GetType(); if (type == typeof(CapsuleCollider)) { data.primitive = PrimitiveType.Capsule; } else if (type == typeof(SphereCollider)) { data.primitive = PrimitiveType.Sphere; } else if (type == typeof(BoxCollider)) { data.primitive = PrimitiveType.Cube; } dataList.Add(data); } colliderData = dataList.ToArray(); }
// Double the size of the array, if the array is full public void Expand() { if (Count < Elements.Length) { return; } var newList = new ColliderData[Elements.Length * 2]; for (int i = 0; i < Elements.Length; i++) { newList[i] = Elements[i]; } Elements = newList; }
/// <summary> /// Computes the grid. /// </summary> /// <param name="geometry">The geometry.</param> /// <param name="data"><see cref="ColliderData"/> that contains the size of the grid cell.</param> /// <exception cref="ArgumentNullException"><c>geometry</c> is null.</exception> public void Prepare(Geom geometry, ColliderData data) { float gridCellSize = data.GridCellSize; if (geometry == null) { throw new ArgumentNullException("geometry", "Geometry can't be null"); } if (gridCellSize <= 0) { throw new ArgumentNullException("data", "The grid cell size must be larger than 0"); } //Prepare the geometry. Matrix old = geometry.Matrix; //Note: Changed in 2.1 //Matrix identity = Matrix.Identity; //geometry.Matrix = identity; //to: geometry.Matrix = Matrix.Identity; //Copy the AABB to the grid field _aabb = new AABB(geometry.AABB); _gridCellSize = gridCellSize; _gridCellSizeInv = 1 / gridCellSize; //Note: Physics2d have +2 int xSize = (int)Math.Ceiling((double)(_aabb.Max.X - _aabb.Min.X) * _gridCellSizeInv) + 1; int ySize = (int)Math.Ceiling((double)(_aabb.Max.Y - _aabb.Min.Y) * _gridCellSizeInv) + 1; _nodes = new float[xSize, ySize]; Vector2 vector = _aabb.Min; for (int x = 0; x < xSize; ++x, vector.X += gridCellSize) { vector.Y = _aabb.Min.Y; for (int y = 0; y < ySize; ++y, vector.Y += gridCellSize) { _nodes[x, y] = geometry.GetNearestDistance(vector); // shape.GetDistance(vector); } } //restore the geometry geometry.Matrix = old; }
private static bool BoxBoxCollision(ref ColliderData collider1, ref ColliderData collider2) { var box1 = (BoxCollider)collider1.collider; var box2 = (BoxCollider)collider2.collider; if (IsPointInBoxCollider(ref box1.Points.a, ref box2.Points)) { return(true); } if (IsPointInBoxCollider(ref box1.Points.b, ref box2.Points)) { return(true); } if (IsPointInBoxCollider(ref box1.Points.c, ref box2.Points)) { return(true); } if (IsPointInBoxCollider(ref box1.Points.d, ref box2.Points)) { return(true); } if (IsPointInBoxCollider(ref box2.Points.a, ref box1.Points)) { return(true); } if (IsPointInBoxCollider(ref box2.Points.b, ref box1.Points)) { return(true); } if (IsPointInBoxCollider(ref box2.Points.c, ref box1.Points)) { return(true); } if (IsPointInBoxCollider(ref box2.Points.d, ref box1.Points)) { return(true); } return(false); }
// private void OnDrawGizmos() // { // if (Container.TryResolve(typeof(List<ColliderData>), out object obj)) // { // List<ColliderData> colliders = (List<ColliderData>)obj; // foreach (var collider in colliders) // { // GizmoDrawCollider(collider, Color.magenta); // //break; // } // } // } public static void GizmoDrawCollider(ColliderData collider, Color color) { if (collider.Type == ColliderType.Box) { Gizmos.color = color; // var p1 = new Vector3(collider.Position.x - collider.Min.x, 0, collider.Position.y - collider.Min.y); // var p2 = new Vector3(collider.Position.x + collider.Max.x, 0, collider.Position.y - collider.Min.y); // var p3 = new Vector3(collider.Position.x + collider.Max.x, 0, collider.Position.y + collider.Max.y); // var p4 = new Vector3(collider.Position.x - collider.Min.x, 0, collider.Position.y + collider.Max.y); var p1 = new Vector3(collider.Min.x, 0, collider.Min.y); var p2 = new Vector3(collider.Max.x, 0, collider.Min.y); var p3 = new Vector3(collider.Max.x, 0, collider.Max.y); var p4 = new Vector3(collider.Min.x, 0, collider.Max.y); Gizmos.DrawLine(p1, p2); Gizmos.DrawLine(p2, p3); Gizmos.DrawLine(p3, p4); Gizmos.DrawLine(p4, p1); } }
//[ButtonGroup] //[Button("获取物体数据")] public void GetObjectData() { var equipment = gameObject.GetComponent <EquipmentBase>(); if (equipment == null) { return; } EquipmentName = name; Type type = equipment.GetType(); Namespaces = type.Namespace; scriptName = type.Name; colliderData = new ColliderData(equipment.FeaturesObject.Collider); transformData = new TransformData(transform); //获取到根目录下的 for (int i = 0; i < modelDatas.Count; i++) { modelDatas[i].geneterItem.Assignment(); modelDatas[i].resourcesItem.Assignment(modelDatas[i].geneterItem.modelObject.transform); } for (int i = 0; i < effectDatas.Count; i++) { effectDatas[i].geneterItem.Assignment(); effectDatas[i].resourcesItem.Assignment(effectDatas[i].geneterItem.modelObject.transform); } childs = gameObject.GetComponentsInChildren <EquipmentGenerateInfo>().Where(arg => !arg.Equals(this)).ToList(); }
private void Awake() { SpriteRenderer[] spriteRenderers = GetComponentsInChildren <SpriteRenderer>(); foreach (SpriteRenderer sr in spriteRenderers) { RendererData rendererData = new RendererData() { Renderer = sr, Size = sr.size }; m_RendererDatas.Add(rendererData); } BoxCollider2D[] boxCollider2Ds = GetComponentsInChildren <BoxCollider2D>(); foreach (BoxCollider2D bc in boxCollider2Ds) { ColliderData colliderData = new ColliderData() { Collider = bc, size = bc.size }; m_ColliderDatas.Add(colliderData); } }
public void AddColliderData(ColliderData data) { _colliderData.Add(data); }
public static void SaveToJson() { GameObject selected = Selection.activeObject as GameObject; if (selected == null) { EditorUtility.DisplayDialog( "Select root object", "You Must Select some root object first!", "Ok"); return; } var colliders = selected.GetComponentsInChildren <Collider>(includeInactive: false); var list = new List <ColliderData>(); foreach (Collider collider in colliders) { var colliderData = new ColliderData { //Name = collider.name, Position = collider.transform.position }; switch (@collider) { case BoxCollider boxCollider: colliderData.Type = ColliderType.Box; colliderData.Position += boxCollider.center; colliderData.Size = boxCollider.size; var x1 = colliderData.Position.x - (colliderData.Size.x * 0.5f); var x2 = colliderData.Position.x + (colliderData.Size.x * 0.5f); var y1 = colliderData.Position.z - (colliderData.Size.z * 0.5f); var y2 = colliderData.Position.z + (colliderData.Size.z * 0.5f); var xx1 = new Vector3(x1, 0, y1).RotateAroundPivot(collider.transform.position, collider.transform.rotation); var xx2 = new Vector3(x2, 0, y2).RotateAroundPivot(collider.transform.position, collider.transform.rotation); colliderData.Min = new float2(math.min(xx1.x, xx2.x), math.min(xx1.z, xx2.z)); colliderData.Max = new float2(math.max(xx1.x, xx2.x), math.max(xx1.z, xx2.z)); list.Add(colliderData); break; case SphereCollider sphereCollider: colliderData.Type = ColliderType.Sphere; colliderData.Position -= sphereCollider.center; colliderData.Size = (sphereCollider.radius * Vector3.one); list.Add(colliderData); break; default: Debug.LogError($"Unsupported type of collider {collider.name} => {collider.GetType()}", collider); break; } } fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(list, out fsData data); var json = fsJsonPrinter.PrettyJson(data); var path = EditorUtility.SaveFilePanel( "Save as JSON", "", selected.name + ".json", "json"); if (path.Length == 0) { return; } File.WriteAllBytes(path, Encoding.ASCII.GetBytes(json)); AssetDatabase.ImportAsset(path); AssetDatabase.Refresh(); }
public void CopyFrom(tk2dSpriteCollectionDefinition src) { this.name = src.name; this.disableTrimming = src.disableTrimming; this.additive = src.additive; this.scale = src.scale; this.texture = src.texture; this.materialId = src.materialId; this.anchor = src.anchor; this.anchorX = src.anchorX; this.anchorY = src.anchorY; this.overrideMesh = src.overrideMesh; this.doubleSidedSprite = src.doubleSidedSprite; this.customSpriteGeometry = src.customSpriteGeometry; this.geometryIslands = src.geometryIslands; this.dice = src.dice; this.diceUnitX = src.diceUnitX; this.diceUnitY = src.diceUnitY; this.diceFilter = src.diceFilter; this.pad = src.pad; this.source = src.source; this.fromSpriteSheet = src.fromSpriteSheet; this.hasSpriteSheetId = src.hasSpriteSheetId; this.spriteSheetX = src.spriteSheetX; this.spriteSheetY = src.spriteSheetY; this.spriteSheetId = src.spriteSheetId; this.extractRegion = src.extractRegion; this.regionX = src.regionX; this.regionY = src.regionY; this.regionW = src.regionW; this.regionH = src.regionH; this.regionId = src.regionId; this.colliderType = src.colliderType; this.boxColliderMin = src.boxColliderMin; this.boxColliderMax = src.boxColliderMax; this.polyColliderCap = src.polyColliderCap; this.colliderColor = src.colliderColor; this.colliderConvex = src.colliderConvex; this.colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions; this.extraPadding = src.extraPadding; this.colliderData = new List<ColliderData>(src.colliderData.Count); foreach (ColliderData data in src.colliderData) { ColliderData item = new ColliderData(); item.CopyFrom(data); this.colliderData.Add(item); } if (src.polyColliderIslands != null) { this.polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length]; for (int i = 0; i < this.polyColliderIslands.Length; i++) { this.polyColliderIslands[i] = new tk2dSpriteColliderIsland(); this.polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]); } } else { this.polyColliderIslands = new tk2dSpriteColliderIsland[0]; } if (src.geometryIslands != null) { this.geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length]; for (int j = 0; j < this.geometryIslands.Length; j++) { this.geometryIslands[j] = new tk2dSpriteColliderIsland(); this.geometryIslands[j].CopyFrom(src.geometryIslands[j]); } } else { this.geometryIslands = new tk2dSpriteColliderIsland[0]; } this.attachPoints = new List<tk2dSpriteDefinition.AttachPoint>(src.attachPoints.Count); foreach (tk2dSpriteDefinition.AttachPoint point in src.attachPoints) { tk2dSpriteDefinition.AttachPoint point2 = new tk2dSpriteDefinition.AttachPoint(); point2.CopyFrom(point); this.attachPoints.Add(point2); } }
void onStay(ColliderData s) { }
void onExit(ColliderData s) { }
void onEnter(ColliderData s) { string tagName = s.Obj.tag; if (tagName == "Player" && PlayerHitAct!=null) { PlayerHitAct(s); } else if (tagName == "Enemy" && EnemyHitAct!=null) { EnemyHitAct(s); } else if ((tagName == "Player" || tagName == "Enemy") && LivingHitAct!=null) { LivingHitAct(s); } else if ((tagName == "Gimmick") && ObjectHitAct!=null) { ObjectHitAct(s); } else if (AnythingHitAct !=null) { AnythingHitAct(s); } }
public void CopyFrom(tk2dSpriteCollectionDefinition src) { name = src.name; disableTrimming = src.disableTrimming; additive = src.additive; scale = src.scale; texture = src.texture; materialId = src.materialId; anchor = src.anchor; anchorX = src.anchorX; anchorY = src.anchorY; overrideMesh = src.overrideMesh; doubleSidedSprite = src.doubleSidedSprite; customSpriteGeometry = src.customSpriteGeometry; geometryIslands = src.geometryIslands; dice = src.dice; diceUnitX = src.diceUnitX; diceUnitY = src.diceUnitY; diceFilter = src.diceFilter; pad = src.pad; source = src.source; fromSpriteSheet = src.fromSpriteSheet; hasSpriteSheetId = src.hasSpriteSheetId; spriteSheetX = src.spriteSheetX; spriteSheetY = src.spriteSheetY; spriteSheetId = src.spriteSheetId; extractRegion = src.extractRegion; regionX = src.regionX; regionY = src.regionY; regionW = src.regionW; regionH = src.regionH; regionId = src.regionId; colliderType = src.colliderType; boxColliderMin = src.boxColliderMin; boxColliderMax = src.boxColliderMax; polyColliderCap = src.polyColliderCap; colliderColor = src.colliderColor; colliderConvex = src.colliderConvex; colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions; extraPadding = src.extraPadding; colliderData = new List <ColliderData>(src.colliderData.Count); foreach (ColliderData srcCollider in src.colliderData) { ColliderData data = new ColliderData(); data.CopyFrom(srcCollider); colliderData.Add(data); } if (src.polyColliderIslands != null) { polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length]; for (int i = 0; i < polyColliderIslands.Length; ++i) { polyColliderIslands[i] = new tk2dSpriteColliderIsland(); polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]); } } else { polyColliderIslands = new tk2dSpriteColliderIsland[0]; } if (src.geometryIslands != null) { geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length]; for (int i = 0; i < geometryIslands.Length; ++i) { geometryIslands[i] = new tk2dSpriteColliderIsland(); geometryIslands[i].CopyFrom(src.geometryIslands[i]); } } else { geometryIslands = new tk2dSpriteColliderIsland[0]; } attachPoints = new List <tk2dSpriteDefinition.AttachPoint>(src.attachPoints.Count); foreach (tk2dSpriteDefinition.AttachPoint srcAp in src.attachPoints) { tk2dSpriteDefinition.AttachPoint ap = new tk2dSpriteDefinition.AttachPoint(); ap.CopyFrom(srcAp); attachPoints.Add(ap); } }
/// <summary> /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. /// </summary> void FixedUpdate() { data = BuildData(); }
public bool CompareTo(ColliderData src) { return (name == src.name && type == src.type && origin == src.origin && size == src.size && angle == src.angle); }
private void StockData(float forceSignal, GameObject collider) { ColliderData colliderData = new ColliderData(forceSignal, collider); dataList.Add(colliderData); }
public void CopyFrom(tk2dSpriteCollectionDefinition src) { name = src.name; disableTrimming = src.disableTrimming; additive = src.additive; scale = src.scale; texture = src.texture; materialId = src.materialId; anchor = src.anchor; anchorX = src.anchorX; anchorY = src.anchorY; overrideMesh = src.overrideMesh; doubleSidedSprite = src.doubleSidedSprite; customSpriteGeometry = src.customSpriteGeometry; geometryIslands = src.geometryIslands; dice = src.dice; diceUnitX = src.diceUnitX; diceUnitY = src.diceUnitY; diceFilter = src.diceFilter; pad = src.pad; source = src.source; fromSpriteSheet = src.fromSpriteSheet; hasSpriteSheetId = src.hasSpriteSheetId; spriteSheetX = src.spriteSheetX; spriteSheetY = src.spriteSheetY; spriteSheetId = src.spriteSheetId; extractRegion = src.extractRegion; regionX = src.regionX; regionY = src.regionY; regionW = src.regionW; regionH = src.regionH; regionId = src.regionId; colliderType = src.colliderType; boxColliderMin = src.boxColliderMin; boxColliderMax = src.boxColliderMax; polyColliderCap = src.polyColliderCap; colliderColor = src.colliderColor; colliderConvex = src.colliderConvex; colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions; extraPadding = src.extraPadding; colliderData = new List<ColliderData>( src.colliderData.Count ); foreach ( ColliderData srcCollider in src.colliderData ) { ColliderData data = new ColliderData(); data.CopyFrom(srcCollider); colliderData.Add(data); } if (src.polyColliderIslands != null) { polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length]; for (int i = 0; i < polyColliderIslands.Length; ++i) { polyColliderIslands[i] = new tk2dSpriteColliderIsland(); polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]); } } else { polyColliderIslands = new tk2dSpriteColliderIsland[0]; } if (src.geometryIslands != null) { geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length]; for (int i = 0; i < geometryIslands.Length; ++i) { geometryIslands[i] = new tk2dSpriteColliderIsland(); geometryIslands[i].CopyFrom(src.geometryIslands[i]); } } else { geometryIslands = new tk2dSpriteColliderIsland[0]; } attachPoints = new List<tk2dSpriteDefinition.AttachPoint>(src.attachPoints.Count); foreach (tk2dSpriteDefinition.AttachPoint srcAp in src.attachPoints) { tk2dSpriteDefinition.AttachPoint ap = new tk2dSpriteDefinition.AttachPoint(); ap.CopyFrom(srcAp); attachPoints.Add(ap); } }
public void GizmoDrawCollider(ColliderData collider, Color color, GameObject obg, BoxCollider collider2) { if (collider.Type == ColliderType.Box) { Gizmos.color = Color.blue; var x1 = collider.Position.x - (collider.Size.x * 0.5f); var x2 = collider.Position.x + (collider.Size.x * 0.5f); var y1 = collider.Position.z - (collider.Size.z * 0.5f); var y2 = collider.Position.z + (collider.Size.z * 0.5f); var px1 = new Vector3(x1, 0, y1); var px2 = new Vector3(x2, 0, y2); Gizmos.DrawLine(px1, px2); Gizmos.color = Color.green; var pxx1 = px1.RotateAroundPivot(obg.transform.position, obg.transform.rotation); var pxx2 = px2.RotateAroundPivot(obg.transform.position, obg.transform.rotation); Gizmos.DrawLine(pxx1, pxx2); /*var p1 = new Vector3(collider.Min.x, 0, collider.Min.y); * var p2 = new Vector3(collider.Max.x, 0, collider.Min.y); * var p3 = new Vector3(collider.Max.x, 0, collider.Max.y); * var p4 = new Vector3(collider.Min.x, 0, collider.Max.y);*/ Gizmos.color = Color.red; // var p1 = new Vector3(collider.Position.x - collider.Min.x, 0, collider.Position.y - collider.Min.y); // var p2 = new Vector3(collider.Position.x + collider.Max.x, 0, collider.Position.y - collider.Min.y); // var p3 = new Vector3(collider.Position.x + collider.Max.x, 0, collider.Position.y + collider.Max.y); // var p4 = new Vector3(collider.Position.x - collider.Min.x, 0, collider.Position.y + collider.Max.y); var p1 = new Vector3(collider.Min.x, 0, collider.Min.y); var p2 = new Vector3(collider.Max.x, 0, collider.Min.y); var p3 = new Vector3(collider.Max.x, 0, collider.Max.y); var p4 = new Vector3(collider.Min.x, 0, collider.Max.y); //var center = p1 //obg.transform.rotation //Matrix4x4 matrix = RotationMatrixAroundAxis(new Ray(collider.Position, obg.transform.up), angel); //var matrix = obg.transform.localToWorldMatrix; //Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(angel, rot), Vector3.one); // p1 = matrix.MultiplyPoint(p1); // p2 = matrix.MultiplyPoint(p2); // p3 = matrix.MultiplyPoint(p3); // p4 = matrix.MultiplyPoint(p4); // p1 = transformRotation * p1; // p2 = transformRotation * p2; // p3 = transformRotation * p3; // p4 = transformRotation * p4; //p1 = p1.RotateAroundPivot(collider.Position, Quaternion.AngleAxis(angel, rot)); //p2 = p2.RotateAroundPivot(collider.Position, Quaternion.AngleAxis(angel, rot)); //p3 = p3.RotateAroundPivot(collider.Position, Quaternion.AngleAxis(angel, rot)); //p4 = p4.RotateAroundPivot(collider.Position, Quaternion.AngleAxis(angel, rot)); Gizmos.DrawLine(p1, p2); Gizmos.DrawLine(p2, p3); Gizmos.DrawLine(p3, p4); Gizmos.DrawLine(p4, p1); } }
void onHitEnemy(ColliderData s) { Debug.Log (s.Obj.name); Vector3 d = s.Obj.transform.position - transform.position; d.y = 0f; s.Obj.GetComponent<Enemy> ().onAttacked (d,1); transform.eulerAngles = new Vector3(0, Mathf.Atan2 (d.x, d.z) * 180 / Mathf.PI,0); //e.onAttacked (d.normalized, 1); }