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