Пример #1
0
    /// <summary>
    /// Adds all necessary keywords to the keywordRecognizer with Lambda expressions doing the next steps
    /// </summary>
    void Start()
    {
        for (int i = 0; i < possibleKeywords.Length; i++)
        {
            switch (possibleKeywords[i])
            {
            case "Start Game":
                keywords.Add("Start Game", () => { NavigateToScene.GoToScene("Levels"); print("Start Game"); });
                break;

            case "Exit Game":
                keywords.Add("Exit Game", () => { Application.Quit(); });
                break;

            case "Restart Game":
                keywords.Add("Restart Game", () => { NavigateToScene.GoToScene("Levels"); });
                break;
            }
        }

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
Пример #2
0
    /// <summary>
    /// This function gets called if the user collides with spikes or the level border and it resets the player to it's origin.
    /// </summary>
    void die()
    {
        data.DeathCount++;
        if (data.DeathCount == maxLives)
        {
            NavigateToScene.GoToScene("Highscore");
        }
        else
        {
            if (transform.position != startPosition.transform.position)
            {
                // Instantiate explosion particle system
                if (ParticleSpawner.Instance != null)
                {
                    ParticleSpawner.Instance.SpawnParticleSystem(0, gameObject.transform);
                }
            }
            // Play explosion sound effect
            if (SoundManager.Instance != null)
            {
                SoundManager.Instance.playSoundAt(1, gameObject.transform);
            }

            // Reset Player Position and velocity
            playerObject.transform.position = startPosition.transform.position;
            playerObject.transform.rotation = startRotation;
            Rigidbody playerBody = playerObject.GetComponent <Rigidbody>();
            playerBody.velocity        = Vector3.zero;
            playerBody.angularVelocity = Vector3.zero;
        }
    }
Пример #3
0
 /// <summary>
 /// This function is called when the portal is reached and loads the next level or the highscore scene.
 /// </summary>
 void win()
 {
     if (LevelManager.Instance != null)
     {
         data.Score += (LevelManager.Instance.CurrentLevel + 1) * 100;
         //navigates to the next level or the highscore view
         if (!LevelManager.Instance.LoadNextLevel())
         {
             NavigateToScene.GoToScene("Highscore");
         }
     }
     else
     {
         NavigateToScene.GoToScene("Highscore");
     }
 }