Exemplo n.º 1
0
            public HitBox Init(Transform relativeTransform, bool tracking, Action <HitInfo> onHurtBoxEnter, Action <HitInfo> onHitBoxEnter)
            {
                this.id = HitBox.hitBoxCounter++;

                this.relativeTransform = relativeTransform;
                //this.offset = relativeTransform.position - transform.position;
                this.offset = Vector3.zero;

                // TODO: Set Local Hit Location
                localHitLocation = Vector3.up;

                hitEntities = new List <InGameEntity>();

                this.onHurtBoxEnter = onHurtBoxEnter;
                this.onHitBoxEnter  = onHitBoxEnter;

                hitBoxService.RegisterHitBox(this);

                collider          = GetComponentInChildren <CapsuleCollider>();
                rigidbody         = GetComponent <Rigidbody>();
                colliderTransform = collider.transform;

                deactivatedPosition = hitBoxService.GetEmptyHoldTransform().position;
                Deactivate();

                return(this);
            }
Exemplo n.º 2
0
            public void BuildAttack()
            {
                IHitBoxService hitBoxService = services.GetService <IHitBoxService>();

                builtFrameStates = new List <FrameState>();
                builtHitBoxes    = new List <HitBox>();

                Dictionary <int, HitBox> hitBoxMap = new Dictionary <int, HitBox>();

                foreach (KeyValuePair <int, Action <IHitBoxCallbackObject> > entry in hitBoxCallbackMap)
                {
                    Action <IHitBoxCallbackObject> callback = entry.Value;

                    HitBoxBuilder builder = new HitBoxBuilder(services);

                    callback(builder);
                    // TODO: Pass along the events

                    HitBox hitBox = builder.CreateHitBox(hitBoxService.GetEmptyHoldTransform());

                    hitBoxMap.Add(entry.Key, hitBox);
                    builtHitBoxes.Add(hitBox);
                }

                for (int n = 0; n < frames.Count; ++n)
                {
                    FrameStateBuilder frameStateBuilder = frames[n];
                    builtFrameStates.Add(frameStateBuilder.Build(hitBoxMap));
                }
            }