Пример #1
0
 private void Start()
 {
     BulletCreator = GetComponent <BulletCreator>();
     for (int i = 0; i < BulletCount; i++)
     {
         AddPool();
     }
 }
Пример #2
0
    private void ShootPlayer()
    {
        if (Utility.IsOver(fireRateCd))
        {
            // float angle = Mathf.Atan2(lastAngleToPlayer.y, lastAngle.x) * Mathf.Rad2Deg + 90.0f;

            bulletData.position  = transform.position;
            bulletData.direction = -lastAngleToPlayer.normalized;
            BulletCreator.CreateBullet(bulletPrefab, bulletData);

            fireRateCd = Utility.StartTimer(fireRate);
        }
    }
Пример #3
0
    private void ManageInputs()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            fireRateCd -= spamClickReductionFireRate;
        }

        if (Input.GetButton("Fire1"))
        {
            var v3 = Input.mousePosition;
            v3.z = 10.0f;
            v3   = Camera.main.ScreenToWorldPoint(v3);

            if (Utility.IsOver(fireRateCd))
            {
                bulletData.position  = gunCannon.position;
                bulletData.direction = -lastAngle.normalized;
                BulletCreator.CreateBullet(bulletPrefab, bulletData);

                fireRateCd = Utility.StartTimer(fireRate);
                smInstance.PlaySound(SoundManager.SoundList.GUN_FIRE);
            }
        }

        if (Input.GetButtonDown("Action") && onStairs)
        {
            gmInstance.EndLevel();
            smInstance.PlaySound(SoundManager.SoundList.STAIRS);
        }

        if (Input.GetButton("slowDownTime") && !blockedSlowTimeTimer)
        {
            if (clockSound == null)
            {
                clockSound = smInstance.PlaySound(SoundManager.SoundList.CLOCK, slowTimeTimer);
            }

            slowTimeTimer -= Time.deltaTime / Time.timeScale;

            if (slowTimeTimer > 0.0f)
            {
                Time.timeScale = 0.5f;
                if (!isTimeSlown)
                {
                    moveSpeed  += moveSpeedBonucWhileSlown;
                    isTimeSlown = true;
                }
            }
            else
            {
                Time.timeScale       = 1.0f;
                blockedSlowTimeTimer = true;
                if (isTimeSlown)
                {
                    moveSpeed  -= moveSpeedBonucWhileSlown;
                    isTimeSlown = false;
                }
            }
        }
        else
        {
            if (clockSound != null)
            {
                smInstance.StopSound(clockSound);
                clockSound = null;
            }

            slowTimeTimer += Time.deltaTime * slowTimeRecoveryScale;
            Time.timeScale = 1.0f;

            if (slowTimeTimer > slowTime)
            {
                slowTimeTimer        = slowTime;
                blockedSlowTimeTimer = false;
            }

            if (isTimeSlown)
            {
                moveSpeed  -= moveSpeedBonucWhileSlown;
                isTimeSlown = false;
            }
        }
        clock.fillAmount = slowTimeTimer / slowTime;

        if (blockedSlowTimeTimer)
        {
            clockBackground.color = Color.red;
        }
        else
        {
            clockBackground.color = Color.white;
        }

        float horizontal = Input.GetAxisRaw("Horizontal");
        float verticale  = Input.GetAxisRaw("Vertical");

        rigid.velocity = new Vector2(horizontal, verticale) * moveSpeed;
    }