Exemplo n.º 1
0
        private void AnimateColour()
        {
            int currentColour = Mathf.RoundToInt(m_CurrentColour);

            if (m_PreviousColour != currentColour)
            {
                if (audioToPlayOnFlash != null)
                {
                    m_Audio.PlayInstance(audioToPlayOnFlash);
                }

                m_Renderer.color = colors[currentColour];
                m_PreviousColour = currentColour;
            }

            m_CurrentColour += FLASH_OFFSET * m_CurrentTime * Time.deltaTime;

            if (m_CurrentColour > colors.Length - 1)
            {
                m_CurrentColour = 0f;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs action if actionable.
        /// </summary>
        /// <param name="action">Action to perform.</param>
        public void DoAction(ShopPurchaseActionableImpl action)
        {
            if (action.IsActionable())
            {
                action.DoAction();

                if (OnPuchase != null)
                {
                    OnPuchase.Invoke();
                }

                m_AudioSource.PlayInstance(audioOnPurchase);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Opens shop when all particles have left scene.
        /// </summary>
        public void OnRoundOver()
        {
            pause.DisableButton();

            m_BGMAudioPlayer.SetPitch(1f, 1f);
            m_BGMAudioPlayer.SetVolume(0.2f, 1f);

            IsPlaying = false;
            m_PlayerShootController.PauseAll();

            m_AudioPlayer.PlayInstance(audioOnWaveComplete);
            m_RoundText.SetWaveCompleteText();
            m_RoundText.ShowForSeconds(2f, 1f, _WaitForParticles);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Shows point text at position.
        /// </summary>
        /// <param name="position">Position to show point text.</param>
        public void ShowAtPosition(Vector3 position)
        {
            if (audioOnPoint != null)
            {
                m_Audio.PlayInstance(audioOnPoint);
            }

            m_PointsPool[m_CurrentIndex].SetScore(1);
            m_PointsPool[m_CurrentIndex].Show(position);

            m_ScoreText.AddScore(1);

            m_CurrentIndex = (m_CurrentIndex + 1) % NUM_TO_SHOW;
        }
Exemplo n.º 5
0
        private void LostLife()
        {
            m_ShootController.PauseAll();

            m_CurrentLives--;

            m_AudioPlayer.PlayInstance(audioOnPlayerDeath);

            WarpGrid.WarpingGrid.Instance.ApplyExplosiveForce(4f, transform.position, 3f);

            SpawnExplosion(transform.position);

            if (OnDeath != null)
            {
                OnDeath();
            }

            foreach (var rend in spriteRenderers)
            {
                rend.enabled = false;
            }

            m_Collider.enabled = false;

            if (m_CurrentLives <= 0) // Game over
            {
                m_PlayerLivesUI.SetItemCount(0);
                m_GameManager.OnPlayerDeathGameOver();
            }
            else
            {
                m_AudioControls.SetVolume(0.2f, secondsToRespawn * 0.4f);
                m_AudioControls.SetVolume(1f, secondsToRespawn * 0.6f);

                m_AudioControls.SetPitch(0.98f, secondsToRespawn * 0.4f);
                m_AudioControls.SetPitch(1f, secondsToRespawn * 0.6f);

                m_PlayerLivesUI.SetItemCount(m_CurrentLives - 1);

                m_GameManager.OnPlayerDied();

                if (gameObject.activeSelf)
                {
                    StartCoroutine(ResetAfterSeconds(secondsToRespawn));
                }
            }
        }
Exemplo n.º 6
0
        private bool ShootProjectileAtPosition(Vector2 position, int projDmg)
        {
            var projectile = GetProjectile();

            if (projectile)
            {
                projectile.transform.position = position;
                projectile.Initialise(this, Vector2.up, projDmg);
                m_Audio.PlayInstance(audioOnShoot);

                if (m_Recoil != null)
                {
                    m_Recoil.Execute();
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2      pos     = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                RaycastHit2D hitInfo = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(pos), Vector2.zero);

                if (hitInfo)
                {
                    var health = hitInfo.collider.gameObject.GetComponent <EnemyHealth>();

                    if (health)
                    {
                        health.Kill(false);
                    }
                }

                AUDIO_PLAYER.PlayInstance(audioOnGridTouch);
                GRID.ApplyImplosiveForce(touchGridForce, Camera.main.ScreenToWorldPoint(Input.mousePosition), touchGridRadius);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Requests to shoot a projectile. A projectile will be released as long as the pool returns a projectile.
        /// </summary>
        public void RequestShoot()
        {
            if (!m_Renderer.isVisible)
            {
                return;
            }

            var projectile = GetProjectile();

            if (projectile)
            {
                Vector2 shootDir = shootDirections[m_CurrentShootDirIndex];

                projectile.transform.position = transform.position;
                projectile.Initialise(
                    this,
                    shootDir,
                    damage);
                m_Audio.PlayInstance(audioOnShoot);

                m_CurrentShootDirIndex = (m_CurrentShootDirIndex + 1) % shootDirections.Length;
            }
        }
Exemplo n.º 9
0
        private IEnumerator Shoot()
        {
            yield return(new WaitForSeconds(Random.Range(0f, secsBetweenShot)));

            while (m_Shooting)
            {
                if (IsVisible() && !m_Paused)
                {
                    var projectile = GetProjectile();

                    if (projectile)
                    {
                        Vector2 shootDir = shootDirections[m_CurrentShootDirIndex];

                        if (shootBasedOnRotation)
                        {
                            shootDir = (Vector2)transform.up;
                        }

                        projectile.transform.position = transform.position;
                        projectile.Initialise(
                            this,
                            shootDir,
                            damage);
                        m_Audio.PlayInstance(audioOnShoot);

                        m_CurrentShootDirIndex = (m_CurrentShootDirIndex + 1) % shootDirections.Length;

                        // Add some randomness to shot order.
                        yield return(new WaitForSeconds(Random.Range(0f, secsBetweenShot * 0.5f)));
                    }
                }

                yield return(new WaitForSeconds(secsBetweenShot));
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Closes the shop and plays audioclip.
 /// </summary>
 public void CloseShop()
 {
     m_AudioSource.PlayInstance(audioOnShopClose);
     gameObject.SetActive(false);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Plays the on death audio.
 /// </summary>
 public void PlayOnDeathAudio()
 {
     m_Audio.PlayInstance(audioOnDeath);
 }