private void OnValidate()
 {
     LockedPosition = new Vector2Int((int)transform.position.x, (int)transform.position.y);
     if (ColliderSize.x < 0)
     {
         ColliderSize.x = 0;
     }
     if (ColliderSize.y < 0)
     {
         ColliderSize.y = 0;
     }
     if (!AssociatedCollier)
     {
         AssociatedCollier = GetComponent <EHBox2DCollider>();
     }
     AssociatedCollier.ColliderSize       = ColliderSize;
     AssociatedCollier.transform.position = new Vector3(LockedPosition.x, LockedPosition.y);
     if (ColliderSize.x % 2 != 0)
     {
         AssociatedCollier.ColliderOffset.x = .5f;
     }
     else
     {
         AssociatedCollier.ColliderOffset.x = 0;
     }
     if (ColliderSize.y % 2 != 0)
     {
         AssociatedCollier.ColliderOffset.y = .5f;
     }
     else
     {
         AssociatedCollier.ColliderOffset.y = 0;
     }
 }
 private void Awake()
 {
     if (!AssociatedCollier)
     {
         Debug.LogWarning("Please Be Sure To Assign the Associated Box Collider");
         AssociatedCollier = GetComponent <EHBox2DCollider>();
     }
 }
Esempio n. 3
0
    public override bool PushOutCollider(EHBaseCollider2D ColliderToPushOut)
    {
        EHBox2DCollider OtherRectCollier = (EHBox2DCollider)ColliderToPushOut;

        if (OtherRectCollier == null)
        {
            return(false);
        }

        if (RectGeometry.IsOverlappingRect(OtherRectCollier.PhysicsSweepGeometry))
        {
            FHitData HitData = new FHitData();
            HitData.OwningCollider = this;
            HitData.OtherCollider  = ColliderToPushOut;

            EHBounds2D ThisCurrentBounds   = RectGeometry.GetBounds();
            EHBounds2D OtherCurrentBounds  = OtherRectCollier.RectGeometry.GetBounds();
            EHBounds2D ThisPreviousBounds  = PreviousRectGeometry.GetBounds();
            EHBounds2D OtherPreviousBounds = OtherRectCollier.PreviousRectGeometry.GetBounds();

            Vector2 RightUpOffset    = ThisCurrentBounds.MaxBounds - OtherCurrentBounds.MinBounds;
            Vector2 LeftBottomOffset = ThisCurrentBounds.MinBounds - OtherCurrentBounds.MaxBounds;



            if (ThisPreviousBounds.MaxBounds.y < OtherPreviousBounds.MinBounds.y && RightUpOffset.y > 0 && (CollisionMask & (byte)ECollisionDirection.UP) != 0)
            {
                ColliderToPushOut.transform.position += Vector3.up * RightUpOffset.y;
                HitData.HitDirection = Vector2.down;
            }
            else if (ThisPreviousBounds.MaxBounds.x < OtherPreviousBounds.MinBounds.x && RightUpOffset.x > 0 && (CollisionMask & (byte)ECollisionDirection.RIGHT) != 0)
            {
                ColliderToPushOut.transform.position += Vector3.right * RightUpOffset.x;
                HitData.HitDirection = Vector2.left;
            }
            else if (ThisPreviousBounds.MinBounds.x > OtherPreviousBounds.MaxBounds.x && LeftBottomOffset.x < 0 && (CollisionMask & (byte)ECollisionDirection.LEFT) != 0)
            {
                ColliderToPushOut.transform.position += Vector3.right * LeftBottomOffset.x;
                HitData.HitDirection = Vector2.right;
            }
            else if (ThisPreviousBounds.MinBounds.y > OtherPreviousBounds.MaxBounds.y && LeftBottomOffset.y < 0 && (CollisionMask & (byte)ECollisionDirection.DOWN) != 0)
            {
                ColliderToPushOut.transform.position += Vector3.up * LeftBottomOffset.y;
                HitData.HitDirection = Vector2.up;
            }

            if (!ContainOverlappingCollider(ColliderToPushOut) || MatchesOverlappingHitData(ColliderToPushOut, ref HitData))
            {
                AddColliderToHitSet(ColliderToPushOut, HitData);
            }

            HitCollisionStay(ColliderToPushOut, HitData);

            return(true);
        }
        return(false);
    }
Esempio n. 4
0
 private void Awake()
 {
     DialogueBoxCollider = GetComponent <EHBox2DCollider>();
     if (!DialogueBoxCollider)
     {
         Debug.LogWarning("No Box Collider trigger was found for our dialogue trigger component");
         return;
     }
     DialogueBoxCollider.OnTrigger2DEnter += OnPlayerEnterDialogueTrigger;
     DialogueBoxCollider.OnTrigger2DExit  += OnPlayerExitDialogueTrigger;
 }
Esempio n. 5
0
 private void Awake()
 {
     CharacterMovement = GetComponent <EHCharacterMovementComponent>();
     CharacterCollider = GetComponent <EHBox2DCollider>();
     Physics2D         = GetComponent <EHPhysics2D>();
     CharacterAnim     = GetComponent <Animator>();
     if (CharacterCollider)
     {
         CharacterCollider.OnCollision2DBegin += OnCharacterCollision;
         CharacterCollider.OnCollision2DEnd   += OnCharacterCollisionEnd;
     }
 }
Esempio n. 6
0
    protected override void Awake()
    {
        base.Awake();
        AssociatedCollider = GetComponent <EHBox2DCollider>();
        StandingHeight     = AssociatedCollider.ColliderSize.y;

        if (Physics2D == null)
        {
            Debug.LogError("There is no associated physics component with our movement component");
        }
        if (AssociatedCollider == null)
        {
            Debug.LogError("There is no associated Collider2D component associated with our movement component");
            return;
        }
        AssociatedCollider.OnCollision2DBegin += OnEHCollisionEnter;
        CachedGravityScale   = Physics2D.GravityScale;
        RemainingDoubleJumps = DoubleJumpCount;
    }
Esempio n. 7
0
 public override void OnStateBegin()
 {
     TargetTransform = BaseGameOverseer.Instance.PlayerController.transform;
     PlayerCollider  = BaseGameOverseer.Instance.PlayerController.GetComponent <EHBox2DCollider>();
 }