Esempio n. 1
0
        public override void Shoot(Aim aim, EventArgs args)
        {
            var ratio = ((IWrapper <float>)args).Value;

            damage = Mathf.Lerp(damages.x, damages.y, ratio);

            actualSpeed = Mathf.Lerp(speed, maxSpeed, ratio);
            var size = Mathf.Lerp(range.x, range.y, ratio);

            sizeTarget.localScale = Vector3.one * range.x;

            if (routine != null)
            {
                StopCoroutine(routine);
            }
            var margin = new Vector2(range.x, size);

            routine = StartCoroutine(Routines.RepeatFor(time, ratio =>
            {
                var scale             = Mathf.Lerp(margin.x, margin.y, map.Evaluate(ratio));
                sizeTarget.localScale = Vector3.one * scale;
            }, new YieldFrame()).Chain(Routines.Do(() => routine = null)));

            bounceCounter     = bounceCount;
            deactivationTimer = deactivationTime;

            base.Shoot(aim, args);
        }
Esempio n. 2
0
        protected override EventArgs OnUpdate(Aim aim, EventArgs args)
        {
            progress = Mathf.Clamp(aim.pressTime, 0.0f, time);
            HUD.Set(progress / time);

            var ratio = Mathf.InverseLerp(threshold, time, progress);

            Events.ZipCall(PlayerEvent.OnShake, shakeFactor * ratio, maxShake);

            return(args);
        }
Esempio n. 3
0
        public override void End(Aim aim, EventArgs args)
        {
            if (progress < threshold)
            {
                progress = 0.0f;
                HUD.Set(0.0f);

                return;
            }

            base.End(aim, args);
        }
Esempio n. 4
0
        public virtual void End(Aim aim, EventArgs args)
        {
            var modifiedArgs = OnEnd(aim, args);

            foreach (var followingPart in followingParts)
            {
                if (!followingPart.IsActive)
                {
                    continue;
                }
                followingPart.End(aim, modifiedArgs);
            }
        }
Esempio n. 5
0
        public override void Shoot(Aim aim, EventArgs args)
        {
            deactivationTimer = deactivationTime;
            hasHit            = false;

            base.Shoot(aim, args);

            trail.enabled = true;
            routine       = StartCoroutine(Routines.DoAfter(() =>
            {
                graph.SetActive(true);
                routine = null;
            }, 0.15f));
        }
Esempio n. 6
0
        protected override EventArgs OnUpdate(Aim aim, EventArgs args)
        {
            counter -= Time.deltaTime;

            if (counter <= 0)
            {
                counter = time + counter;
                foreach (var followingPart in FollowingParts)
                {
                    if (!followingPart.IsActive)
                    {
                        continue;
                    }
                    followingPart.End(aim, args);
                }
            }

            return(args);
        }
Esempio n. 7
0
        protected override EventArgs OnEnd(Aim aim, EventArgs args)
        {
            animator.SetTrigger("Shoot");

            var bulletPool     = Repository.Get <GenericPool>(Pool.Bullet);
            var bulletInstance = bulletPool.CastSingle <Bullet>(bullet);

            bulletInstance.Shoot(aim, args);

            if (args is IWrapper <float> forceArgs)
            {
                Events.ZipCall(PlayerEvent.OnFire, Mathf.Lerp(force * 0.25f, force, forceArgs.Value));
            }
            else
            {
                Events.ZipCall(PlayerEvent.OnFire, force);
            }

            return(args);
        }
Esempio n. 8
0
        protected override EventArgs OnEnd(Aim aim, EventArgs args)
        {
            var muzzleFlashPool     = Repository.Get <VfxPool>(Pool.MuzzleFlash);
            var muzzleFlashInstance = muzzleFlashPool.RequestSinglePoolable(muzzleFlash);

            if (args is IWrapper <float> sizeWrapper)
            {
                muzzleFlashInstance.transform.localScale = Vector3.one * Mathf.Lerp(0.3f, 1.0f, sizeWrapper.Value);
            }
            else
            {
                muzzleFlashInstance.transform.localScale = Vector3.one;
            }

            muzzleFlashInstance.transform.parent   = Control.Firepoint;
            muzzleFlashInstance.transform.position = aim.firepoint;
            muzzleFlashInstance.transform.rotation = Quaternion.LookRotation(aim.firingDirection);
            muzzleFlashInstance.Value.Play();

            return(args);
        }
Esempio n. 9
0
 protected virtual EventArgs OnEnd(Aim aim, EventArgs args) => args;
Esempio n. 10
0
 protected virtual EventArgs OnUpdate(Aim aim, EventArgs args) => args;
Esempio n. 11
0
 protected virtual EventArgs OnStart(Aim aim, EventArgs args) => args;
Esempio n. 12
0
 public virtual void Shoot(Aim aim, EventArgs args)
 {
     transform.position = aim.firepoint;
     direction          = aim.direction.normalized;
 }
Esempio n. 13
0
 protected override EventArgs OnEnd(Aim aim, EventArgs args)
 {
     Routines.Start(CooldownRoutine());
     return(new WrapperArgs <float>(Mathf.InverseLerp(threshold, time, progress)));
 }
Esempio n. 14
0
 protected override EventArgs OnEnd(Aim aim, EventArgs args)
 {
     MoveControl.canShowWalk = true;
     return(args);
 }
Esempio n. 15
0
 public override void End(Aim aim, EventArgs args)
 {
     OnEnd(aim, args);
     return;
 }
Esempio n. 16
0
 protected override EventArgs OnStart(Aim aim, EventArgs args)
 {
     MoveControl.canShowWalk = false;
     return(args);
 }