示例#1
0
    public NavigationInfo(Transform transform, BoxCollider2D boxCollider2D, TransitionFloorType type)
    {
        this.transform     = transform;
        this.boxCollider2D = boxCollider2D;
        this.type          = type;
        colliderBounds     = new ColliderBounds();

        UpdateColliderBounds(boxCollider2D);
    }
示例#2
0
 public PatrolPointInfo(Transform transform, Collider2D collider2D, TransitionFloorType type, Navigation navigation)
 {
     this.transform              = transform;
     this.floorCollider2D        = collider2D;
     this.transitionFloorType    = type;
     this.currentFloor           = new Floor(-1);
     this.currentTransitionFloor = new TransitionFloor();
     navigation.CheckForCurrentFloor(transform, floorCollider2D, ref currentFloor, ref currentTransitionFloor);
     navigation.CheckForCurrentTransitionFloor(transform,
                                               ref currentFloor, ref currentTransitionFloor, type);
 }
示例#3
0
 public TransitionFloor(Floor firstFloor, Floor secondFloor, Transform transform,
                        ColliderBounds colliderBounds,
                        TransitionFloorType type)
 {
     floors = new List <Floor>()
     {
         firstFloor,
         secondFloor
     };
     floors.Sort((floor, floor1) => floor.number - floor1.number);
     this.transform      = transform;
     this.type           = type;
     this.colliderBounds = colliderBounds;
 }
示例#4
0
    public void CheckForCurrentTransitionFloor(Transform transform, CapsuleCollider2D collider2D,
                                               ref Floor currentFloor,
                                               ref TransitionFloor currentTransitionFloor, TransitionFloorType type)
    {
        if (type == TransitionFloorType.Obstacle)
        {
            currentFloor = new Floor(-1);

            currentTransitionFloor = this.transitionFloorList.Find(lambdaExpression =>
                                                                   lambdaExpression.transform != null &&
                                                                   MathHelpers.Approximately(lambdaExpression.transform.position.x, transform.position.x, 0.5f) &&
                                                                   MathHelpers.Approximately(lambdaExpression.transform.position.y, transform.position.y, 3f));
        }
        else if (type == TransitionFloorType.Ladder)
        {
            currentFloor = new Floor(-1);

            currentTransitionFloor = this.transitionFloorList.Find(lambdaExpression =>
                                                                   lambdaExpression.transform != null &&
                                                                   MathHelpers.Approximately(lambdaExpression.transform.position.x, transform.position.x, 0.5f) &&
                                                                   transform.position.y >= lambdaExpression.colliderBounds.bottomMid.y &&
                                                                   transform.position.y <= lambdaExpression.colliderBounds.topMid.y + collider2D.size.y / 2);
        }
        else if (type == TransitionFloorType.Stairs)
        {
            currentFloor = new Floor(-1);

            currentTransitionFloor = this.transitionFloorList.Find(lambdaExpression =>
                                                                   !lambdaExpression.colliderBounds.Equals(null) &&
                                                                   lambdaExpression.colliderBounds.bottomLeft.x <= transform.position.x &&
                                                                   lambdaExpression.colliderBounds.bottomRight.x >= transform.position.x &&
                                                                   lambdaExpression.colliderBounds.boundingBoxBottomY.y <= transform.position.y &&
                                                                   lambdaExpression.colliderBounds.boundingBoxTopY.y >= transform.position.y);
        }
    }
示例#5
0
 public NavigationNode(Transform transform, TransitionFloorType type, List <Floor> floors)
 {
     this.transform = transform;
     this.type      = type;
     this.floors    = floors;
 }