예제 #1
0
    public void CastRay(Vector2 origin)
    {
        Vector2 rayVector = Vector2.down;
        float   skinWidth = Constants.SKIN_WIDTH;
        float   rayLength = this.rayLength + skinWidth;

        if (debug)
        {
            Debug.DrawLine(origin, origin + (rayVector * rayLength), Color.red);
        }
        RaycastHit2D hit = Physics2D.Raycast(origin, rayVector, rayLength, layerMask);

        if (hit)
        {
            PlayerUnitController player = InteractiveHelpers.GetPlayer(hit.collider);
            if (player)
            {
                float collideDistance = 1f;
                float allowedMove     = player.di.physics.movement.GetAllowedMovement(collideDistance, Dir4.down);
                if (allowedMove < collideDistance)
                {
                    PlayerDamageModule damage = player.di.damage;
                    damage.TakeFullDamage();
                }
            }
        }
    }
 public override void OnMoveInto(PhysicsMove move)
 {
     if (IsCrushingComponent(move.moving) && move.dir == Dir4.down)
     {
         float allowedMove = physics.movement.GetAllowedMovement(move.collideDistance, move.dir);
         if (allowedMove < move.collideDistance)
         {
             damage.TakeFullDamage();
         }
     }
 }