예제 #1
0
            public HitBox CreateHitBox(Transform hitBoxEmptyParentTransform)
            {
                // default means Vector3.zero in this case
                if (collider != null)
                {
                    HitBox hitBox = GameObject.Instantiate <HitBox>(hitBoxPrefab, hitBoxEmptyParentTransform.position, Quaternion.identity, hitBoxEmptyParentTransform);
                    callbacks.TryGetValue(onHurtBoxEventKey, out Action <HitInfo> onHurtBoxCallback);
                    callbacks.TryGetValue(onHitBoxEventKey, out Action <HitInfo> onHitBoxCallback);

                    hitBox.SetServices(hitBoxService, fgService);
                    hitBox.Init(transform, tracking, onHurtBoxCallback, onHitBoxCallback);

                    switch (collider.direction)
                    {
                    case 0:     // X-axis
                        hitBox.SetColliderPosition(collider.transform.position, collider.transform.position + collider.transform.right * collider.height, collider.radius);
                        break;

                    case 1:     // Y-axis
                        hitBox.SetColliderPosition(collider.transform.position, collider.transform.position + collider.transform.up * collider.height, collider.radius);
                        break;

                    case 2:     // Z-axis
                        hitBox.SetColliderPosition(collider.transform.position, collider.transform.position + collider.transform.forward * collider.height, collider.radius);
                        break;
                    }
                    return(hitBox);
                }
                else if (radius > 0)
                {
                    HitBox hitBox = GameObject.Instantiate <HitBox>(hitBoxPrefab, hitBoxEmptyParentTransform.position, Quaternion.identity, hitBoxEmptyParentTransform);
                    callbacks.TryGetValue(onHurtBoxEventKey, out Action <HitInfo> onHurtBoxCallback);
                    callbacks.TryGetValue(onHitBoxEventKey, out Action <HitInfo> onHitBoxCallback);

                    hitBox.SetServices(hitBoxService, fgService);
                    hitBox.Init(transform, tracking, onHurtBoxCallback, onHitBoxCallback);

                    hitBox.SetColliderPosition(point0, point1, radius);
                    return(hitBox);
                }
                else
                {
                    throw new NotSupportedException("Attempting to create a hitbox with no collider to base on or no values provided");
                }
            }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        rb2d = GetComponent <Rigidbody2D>();



        mHitBox = GetComponentInChildren <HitBox>();
        mHitBox.Init(this);

        animCtrl = new ActStateCtrl();
        animCtrl.LogicAnimator = transform.Find("AtkBoxes").GetComponent <Animator>();
        animCtrl.ViewAnimator  = transform.Find("Sprite").GetComponent <Animator>();

        mActCtrl = transform.Find("AtkBoxes").GetComponent <ActCtrl>();
        mActCtrl.Init(controller, animCtrl);

        moveCollider  = transform.Find("MoveBox").GetComponent <CapsuleCollider2D>();
        moveBoxHeight = moveCollider.size.y * moveCollider.transform.localScale.y;

        mFootDetector = transform.Find("MoveBox").GetChild(0).GetComponent <FootDetector>();

        climbLayer = LayerMask.GetMask("Climbable");
        wallLay    = LayerMask.GetMask("Wall");
    }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     mHitBox = GetComponentInChildren <HitBox>();
     mHitBox.Init(this);
 }