예제 #1
0
    /// <summary>
    /// Запускает таймер перезарядки атакующей способности.
    /// После определённого промежутка времени выключает отображение снежка и хвоста снежка
    /// и перемещает снежок на место игрока. После чего снежок снова доступен для использования.
    /// </summary>
    /// <param name="hippoSnowball">GameObject брошенного снежка.</param>
    /// <returns></returns>
    IEnumerator AttackTimer(GameObject hippoSnowball)
    {
        SoundThrow.Run(Vault.instance.audioSourceThrow, Vault.instance.audioClipThrow);

        float       timer = 0f;
        Rigidbody2D rb    = hippoSnowball.GetComponent <Rigidbody2D>();

        do
        {
            if (PauseButtonController.isPause == false)
            {
                rb.simulated = true;
                timer       += 0.018f;
            }
            else
            {
                rb.simulated = false;
            }
            yield return(new WaitForSeconds(0.001f));
        }while (timer <= 3.5f);

        hippoSnowball.GetComponent <SpriteRenderer>().color = new Vector4(1, 1, 1, 0);
        hippoSnowball.transform.GetChild(0).gameObject.SetActive(false);
        hippoSnowball.GetComponent <CircleCollider2D>().enabled = false;
        hippoSnowball.transform.position = spawnPlace.position;

        yield return(new WaitForSeconds(0.5f));

        hippoSnowball.SetActive(false);
        hippoSnowball.transform.GetChild(0).gameObject.SetActive(true);
        hippoSnowball.GetComponent <Rigidbody2D>().constraints  = RigidbodyConstraints2D.None;
        hippoSnowball.GetComponent <CircleCollider2D>().enabled = true;
        hippoSnowball.GetComponent <SpriteRenderer>().color     = new Vector4(1, 1, 1, 1);
        yield break;
    }
예제 #2
0
    /// <summary>
    /// Движение снежка противника
    /// </summary>
    /// <param name="enemySnowball">Брошеный снежок</param>
    /// <param name="target">Бесконечно отдаляющаяся цель</param>
    /// <returns></returns>
    IEnumerator MoveSnowball(GameObject enemySnowball, Transform target)
    {
        SoundThrow.Run(Vault.instance.audioSourceThrow, Vault.instance.audioClipThrow);

        float     timer = 0f;
        Transform enemySnowballTransform = enemySnowball.transform;

        do
        {
            if (PauseButtonController.isPause == false)
            {
                timer += 0.015f;
                enemySnowballTransform.position = Vector3.MoveTowards(enemySnowballTransform.position, target.position, characterSettings.speedSnowball / correctionSpeedEnemySnowball);
                enemySnowballTransform.Rotate(0, 0, speedRotateEnemySnowball);
                target.position = Vector3.MoveTowards(target.position, enemySnowballTransform.position, -characterSettings.speedSnowball / correctionSpeedEnemySnowball);
                yield return(new WaitForSeconds(0.015f));
            }
            else
            {
                yield return(new WaitForSeconds(0.2f));
            }
        } while (enemySnowball.GetComponent <CircleCollider2D>().enabled == true && timer <= snowballUpdateTimeAccess);
        enemySnowball.GetComponent <SpriteRenderer>().color = new Vector4(1, 1, 1, 0);
        enemySnowball.transform.GetChild(0).gameObject.SetActive(false);
        enemySnowball.transform.position = spawnPlace.position;

        yield return(new WaitForSeconds(timeReturningSnowballPosition));

        enemySnowball.SetActive(false);
        enemySnowball.transform.GetChild(0).gameObject.SetActive(true);
        enemySnowball.GetComponent <CircleCollider2D>().enabled = true;
        enemySnowball.GetComponent <SpriteRenderer>().color     = new Vector4(1, 1, 1, 1);
        yield break;
    }
    void OnTriggerEnter2D(Collider2D enemySnowball)
    {
        if (enemySnowball.CompareTag("EnemySnowball"))
        {
            SoundThrow.Run(Vault.instance.audioSourceHit, Vault.instance.audioClipHit);
            enemySnowball.GetComponent <CircleCollider2D>().enabled = false;
            enemySnowball.GetComponent <SpriteRenderer>().color     = new Vector4(1, 1, 1, 0);
            for (int i = 0; i < Vault.instance.gameObjectsEnemySetParticleSystems.Length; i++)
            {
                if (Vault.instance.gameObjectsEnemySetParticleSystems[i].activeInHierarchy == false)
                {
                    Vault.instance.gameObjectsEnemySetParticleSystems[i].transform.position = enemySnowball.gameObject.transform.position;
                    Vault.instance.gameObjectsEnemySetParticleSystems[i].SetActive(true);
                    StartCoroutine(TurnOffParticles(Vault.instance.gameObjectsEnemySetParticleSystems[i]));

                    InitSettings.healthPoints--;
                    switch (InitSettings.healthPoints)
                    {
                    case 2:
                        Vault.instance.imageUIHearts[0].sprite        = Vault.instance.spriteBrokenHeart;
                        Vault.instance.spriteRendererStarRight.sprite = Vault.instance.spriteStarRightOff;
                        break;

                    case 1:
                        Vault.instance.imageUIHearts[1].sprite         = Vault.instance.spriteBrokenHeart;
                        Vault.instance.spriteRendererStarCenter.sprite = Vault.instance.spriteStarCenterOff;
                        break;

                    case 0:
                        Vault.instance.imageUIHearts[2].sprite = Vault.instance.spriteBrokenHeart;
                        PauseButtonController.instance.ClickOnPause();
                        Vault.instance.gameObjectVictoryBoard.SetActive(true);
                        Vault.instance.gameObjectVictoryBoardRunLevel.SetActive(false);
                        Vault.instance.gameObjectStarLeft.SetActive(true);
                        Vault.instance.gameObjectStarCenter.SetActive(true);
                        Vault.instance.gameObjectStarRight.SetActive(true);
                        Vault.instance.spriteRendererStarLeft.sprite         = Vault.instance.spriteStarLeftOff;
                        Vault.instance.spriteRendererTextVictoryBoard.sprite = LanguageController.ChangeLanguage(SpriteName.Fiasco);    //Vault.instance.spriteLivesEndedRus;
                        StartCoroutine(SoundWinFail.Run(Vault.instance.audioClipFail));
                        break;
                    }
                    break;
                }
            }
        }
    }
    void OnTriggerEnter2D(Collider2D hippoSnowball)
    {
        if (hippoSnowball.CompareTag("Snowball"))
        {
            SoundThrow.Run(Vault.instance.audioSourceHit, Vault.instance.audioClipHit);
            Vault.instance.particleSystemHippoSnowball.transform.position = hippoSnowball.gameObject.transform.position;
            hippoSnowball.GetComponent <Rigidbody2D>().constraints        = RigidbodyConstraints2D.FreezePosition;
            hippoSnowball.GetComponent <CircleCollider2D>().enabled       = false;
            hippoSnowball.GetComponent <SpriteRenderer>().color           = new Vector4(1, 1, 1, 0);
            Vault.instance.particleSystemHippoSnowball.gameObject.SetActive(true);
            StartCoroutine(TurnOffParticles());

            if (ScoreSetController.scorePlayer < Vault.instance.settings.pointsForVictory)
            {
                if (GetComponent <EnemyController>().isMoveOut == false)
                {
                    ScoreSetController.instance.RefreshPoints(points.enemyPoints);
                    StartCoroutine(MoveEnemy(transform, GetComponent <EnemyController>()));
                }
                else
                {
                    ScoreSetController.instance.RefreshPoints(bonusPoint);
                }
            }
            if (ScoreSetController.scorePlayer >= Vault.instance.settings.pointsForVictory)
            {
                PauseButtonController.instance.ClickOnPause();
                Vault.instance.gameObjectVictoryBoard.SetActive(true);
                Vault.instance.gameObjectVictoryBoardRunLevel.SetActive(false);
                Vault.instance.gameObjectStarLeft.SetActive(true);
                Vault.instance.gameObjectStarCenter.SetActive(true);
                Vault.instance.gameObjectStarRight.SetActive(true);
                Vault.instance.spriteRendererTextVictoryBoard.sprite = LanguageController.ChangeLanguage(SpriteName.Excellent);//Vault.instance.spriteExcellentRus;

                Vault.instance.particleSystemVictoryBoard.gravityModifier = gravityValue;

                StartCoroutine(SoundWinFail.Run(Vault.instance.audioClipWin));
            }
        }
    }