Ejemplo n.º 1
0
        //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);
            }
        }
Ejemplo n.º 2
0
        protected void ProcessCollision(Collider2D col, RexObject.CollisionType collisionType)
        {
            float    waveTop = GetComponent <BoxCollider2D>().bounds.max.y;
            RexActor actor   = col.gameObject.GetComponent <RexActor>();

            if (actor != null)
            {
                if (collisionType == RexObject.CollisionType.Enter)
                {
                    actor.NotifyOfWaterlineContact(collisionType);
                    GenerateEnterSplash(new Vector2(col.gameObject.transform.position.x, waveTop), col.gameObject.transform);
                }
                else if (collisionType == RexObject.CollisionType.Exit)
                {
                    actor.NotifyOfWaterlineContact(collisionType);
                    if (actor.waterProperties.waterBodiesTouched <= 0)
                    {
                        GenerateExitSplash(new Vector2(col.gameObject.transform.position.x, waveTop), col.gameObject.transform);
                    }
                }
            }
        }