//If we have a rexObject slotted, this will notify it of any collisions and enable it to act accordingly private void NotifyOfCollision(Collider2D col, RexObject.Side side, RexObject.CollisionType collisionType) { if (rexObject != null) { rexObject.OnPhysicsCollision(col, side, collisionType); } RexObject otherObject = col.GetComponent <RexObject>(); if (otherObject != null) { RexObject.Side otherSide; if (side == RexObject.Side.Bottom) { otherSide = RexObject.Side.Top; } else if (side == RexObject.Side.Top) { otherSide = RexObject.Side.Bottom; } else if (side == RexObject.Side.Left) { otherSide = RexObject.Side.Right; } else { otherSide = RexObject.Side.Left; } otherObject.NotifyOfCollisionWithPhysicsObject(boxCol, otherSide, collisionType); } }
void Awake() { previousFrameProperties.position = transform.position; properties.position = transform.position; collisionLayerMask = 1 << LayerMask.NameToLayer("Terrain"); collisionLayerMaskDown = collisionLayerMask; FlagsHelper.Set(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); if (gameObject.tag == "Player") { AddToCollisions("Boundaries"); } if (rexObject == null) { rexObject = GetComponent <RexObject>(); } }
protected override void OnDeath() { DropSpawner dropSpawner = GetComponent <DropSpawner>(); if (dropSpawner != null) { GameObject drop = dropSpawner.DropObject(); RexObject rexObject = drop.GetComponent <RexObject>(); if (rexObject != null) { float yPosition = transform.position.y; if (slots.collider != null) { yPosition = slots.collider.bounds.max.y; if (rexObject.slots.collider) { yPosition = slots.collider.bounds.max.y + rexObject.slots.collider.bounds.size.y * 0.5f; } } rexObject.SetPosition(new Vector2(transform.position.x, yPosition)); } } }
private void ProcessCollision(Collider2D col) { RexObject rexObject = col.GetComponent <RexObject>(); if (rexObject != null) { RexActor actor = col.GetComponent <RexActor>(); if (actor != null && actor.isDead) { return; } if (rexObject.willDespawnOnSceneExit || isBottomlessPit) { float buffer = 0.5f * GlobalValues.tileSize; float warningBuffer = 0.15f * GlobalValues.tileSize; if (edge == Edge.Right) { if (rexObject.transform.position.x > transform.position.x + buffer) { rexObject.Clear(); } else if (rexObject.transform.position.x > transform.position.x + warningBuffer) { rexObject.OnSceneBoundaryCollisionInsideBuffer(); } } else if (edge == Edge.Left) { if (rexObject.transform.position.x < transform.position.x - buffer) { rexObject.Clear(); } else if (rexObject.transform.position.x < transform.position.x - warningBuffer) { rexObject.OnSceneBoundaryCollisionInsideBuffer(); } } else if (edge == Edge.Top) { if (rexObject.transform.position.y > transform.position.y + buffer) { rexObject.Clear(); } else if (rexObject.transform.position.y > transform.position.y + warningBuffer) { rexObject.OnSceneBoundaryCollisionInsideBuffer(); } } else if (edge == Edge.Bottom) { if (rexObject.transform.position.y < transform.position.y - buffer) { rexObject.Clear(); } else if (rexObject.transform.position.y < transform.position.y - warningBuffer) { rexObject.OnSceneBoundaryCollisionInsideBuffer(); } } } } }