Ejemplo n.º 1
0
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (groups.Count == 0)
            {
                return;
            }

            switch (switchMode)
            {
            case SwitchWeaponMode.ByKey:
                SelectWeaponByKey();
                break;

            case SwitchWeaponMode.ByMouseWheel:
                SelectWeaponByMouseWheel();
                break;

            case SwitchWeaponMode.Both:
                SelectWeaponByKey();
                SelectWeaponByMouseWheel();
                break;
            }

            if (UInput.GetButtonDown(INC.DROP))
            {
                Drop();
            }
        }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (controller == null)
            {
                return;
            }

            if (controller.IsSprinting())
            {
                animator.SetInteger(SPEED_HASH, 3);
            }
            else if (controller.IsRunning())
            {
                animator.SetInteger(SPEED_HASH, 2);
            }
            else if (controller.IsWalking())
            {
                animator.SetInteger(SPEED_HASH, 1);
            }
            else if (!UInput.GetButton(INC.ATTACK) && !UInput.GetButton(INC.JUMP))
            {
                animator.SetInteger(SPEED_HASH, 0);
            }

            if (UInput.GetButtonDown(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, true);
            }
            else if (UInput.GetButtonUp(INC.SIGHT))
            {
                animator.SetBool(SIGHT_HASH, false);
            }

            if (useRotationSway)
            {
                RotationSwayProcessing(transform);
            }

            if (useJumpSway)
            {
                JumpSwayProcessing(transform);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shooting system processing.
        /// </summary>
        protected virtual IEnumerator ShootingProcessing()
        {
            WaitForSeconds    updateDelay = new WaitForSeconds(delay);
            WaitForEndOfFrame endOfFrame  = new WaitForEndOfFrame();

            while (true)
            {
                if (!weaponReloading.BulletsIsEmpty() && !weaponReloading.IsReloading())
                {
                    if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) || fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK))
                    {
                        DoShoot();
                        yield return(updateDelay);
                    }
                    else if (fireMode == Mode.Queue && UInput.GetButtonDown(INC.ATTACK))
                    {
                        for (int i = 0; i < queueCount; i++)
                        {
                            DoShoot();
                            weaponAnimator.SetAttack(1);
                            yield return(endOfFrame);

                            weaponAnimator.SetAttack(-1);
                            yield return(updateDelay);
                        }
                    }
                }
                else if (UInput.GetButtonDown(INC.ATTACK))
                {
                    AudioClip sound = soundProperties.GetRandomEmptySound();
                    if (sound != null)
                    {
                        audioSource.PlayOneShot(sound);
                    }
                    weaponAnimator.SetAttack(0);
                    yield return(endOfFrame);

                    weaponAnimator.SetAttack(-1);
                }
                yield return(null);
            }
        }
Ejemplo n.º 4
0
        private void AnimatorStateProcessing()
        {
            if (fireMode == Mode.Free && UInput.GetButton(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Free && !UInput.GetButton(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }

            if (fireMode == Mode.Single && UInput.GetButtonDown(INC.ATTACK) && !weaponReloading.BulletsIsEmpty())
            {
                weaponAnimator.SetAttack(1);
            }
            else if (fireMode == Mode.Single && !UInput.GetButtonDown(INC.ATTACK))
            {
                weaponAnimator.SetAttack(-1);
            }
        }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        protected virtual void Update()
        {
            if (UInput.GetButtonDown(INC.RELOAD) &&
                !ClipsIsEmpty() &&
                !isReloading &&
                bulletCount < maxBulletCount)
            {
                isReloading = true;
                switch (reloadMode)
                {
                case ReloadMode.Default:
                    DefaultReload();
                    break;

                case ReloadMode.Sequential:
                    SequentialReload();
                    break;
                }
            }
        }
 /// <summary>
 /// Update is called every frame, if the MonoBehaviour is enabled.
 /// </summary>
 protected virtual void Update()
 {
     if (!isAttacking)
     {
         if (UInput.GetButtonDown(INC.ATTACK))
         {
             weaponAnimator.SetAttack(1);
             StartCoroutine(DoAttack(normalAttack));
         }
         else if (Input.GetKeyDown(specialAttackKey))
         {
             weaponAnimator.SetAttack(2);
             StartCoroutine(DoAttack(specialAttack));
         }
     }
     else if (isAttacking && (Time.time - delayTimer) >= currentDelay)
     {
         isAttacking = false;
     }
 }