コード例 #1
0
    private void StartSpecialMode()
    {
        // Allow to reset Special mode if it's activated again
        // while already in special mode.
        if (specialCo != null)
        {
            StopCoroutine(specialCo);
        }

        inSpecialMode = true;
        candyAcquired = false;
        candy.GetComponent <Candy>().Die();
        slider.StartSlider();
        CandySound.PlayCandyUse();
        MusicPlayer.SetSpeed(1.2f);
        foreach (GameObject go in vfx)
        {
            go.SetActive(true);
        }
        specialCo = StartCoroutine(StopSpecialMode());
    }
コード例 #2
0
    private void ShootEnemy()
    {
        if (gm.IsInSpecialMode())
        {
            canHold = true;
        }
        else
        {
            canHold = false;
        }

        // Check if we hit any enemies.
        Collider2D[] objectsHit = Physics2D.OverlapCircleAll(cursorPosition, crossairRadius, targetLayer);

        int numberOfGhosts = 0; // To Check for bonus points.

        // Check if the player missed.
        if (objectsHit.Length <= 0)
        {
            if (canSpawnBullet)
            {
                Instantiate(bulletHole, cursorPosition, Quaternion.identity);
                CrosshairAudio.PlayShoot(true, 1);
                canSpawnBullet = false;
            }

            if (!gm.IsInSpecialMode())
            {
                gm.score--;

                if (!vampire.laughing)
                {
                    vampire.StartLaugh();
                }

                Instantiate(miss, cursorPosition, Quaternion.identity);
            }
        }
        else
        {
            if (canSpawnBullet)
            {
                CrosshairAudio.PlayShoot(true, 1);
                canSpawnBullet = false;
            }

            foreach (Collider2D col in objectsHit)
            {
                if (col.CompareTag("Ghost"))
                {
                    numberOfGhosts++;
                    col.GetComponent <EnemyHealth>().ReceiveDamage(1);

                    if (col == null || col.GetComponent <EnemyHealth>().GetCurrentHealth() <= 0)
                    {
                        if (gm.IsInSpecialMode())
                        {
                            gm.score += 1;
                            Instantiate(hitOnePoint, cursorPosition, Quaternion.identity);
                        }
                        else
                        {
                            gm.score += 3;
                            Instantiate(hit, cursorPosition, Quaternion.identity);
                        }
                    }
                }
                else if (col.CompareTag("Witch"))
                {
                    col.GetComponent <EnemyHealth>().ReceiveDamage(1);

                    if (col == null || col.GetComponent <EnemyHealth>().GetCurrentHealth() <= 0)
                    {
                        gm.score += 3;

                        if (!gm.candyAcquired)
                        {
                            // Drop candy for special mode.
                            Vector3 worldPos = new Vector3(cursorPosition.x, cursorPosition.y, 0);
                            gm.candy         = Instantiate(candyPrefab, cursorPosition, Quaternion.identity);
                            gm.candyAcquired = true;
                            CandySound.PlayCandyGet();
                            Instantiate(hit, cursorPosition, Quaternion.identity);
                        }
                    }
                }
            }

            if (numberOfGhosts >= 2)
            {
                gm.score += 5;

                Instantiate(bonusPoint, cursorPosition, Quaternion.identity);
            }
        }
    }