Example #1
0
 IEnumerator TeleportPlayer(MKPlayer player)
 {
     MKSceneManager.instance.inputLocked = true;
     actionParticles.Play();
     GetComponent<AudioSource>().Play();
     player.Stop();
     yield return new WaitForSeconds(0.5f);
     targets[destination].actionParticles.Play();
     targets[destination].GetComponent<AudioSource>().Play();
     player.Reposition(targets[destination].gameObject, offsetVector);
     yield return new WaitForSeconds(0.5f);
     MKSceneManager.instance.inputLocked = false;
 }
Example #2
0
    IEnumerator MoveDown(MKPlayer player)
    {
        StopCoroutine("MoveUp");

        float duration = moveTime;
        float timer = 0.0f;

        // Move the switch to the down position
        while (transform.localPosition != downPosition) {
            timer += Time.deltaTime;
            transform.localPosition = Vector3.Lerp (upPosition,downPosition,timer/duration);
            yield return null;
        }

        // If the switch isn't already down, handle the calls to tell the target that it was
        // pressed.
        if (!switchDown) {
            GetComponent<AudioSource>().Play();

            // Switch to the target camera if it exists
            if (targetCamera != null)
                StartCoroutine("ShowCamera", player);

            switchDown = true;
            switch(action) {
            case SwitchAction.SwitchOn:
                target.SwitchOn();
                break;
            case SwitchAction.SwitchOff:
                target.SwitchOff();
                break;
            default:
                target.SwitchToggle();
                break;
            }
        }
    }
Example #3
0
    IEnumerator MoveUp(MKPlayer player)
    {
        if (player.GetComponent<Rigidbody>().isKinematic)
            yield break;

        StopCoroutine("MoveDown");

        float duration = moveTime;
        float timer = 0.0f;

        // Move to the move up position
        while (transform.localPosition != upPosition) {
            timer += Time.deltaTime;
            transform.localPosition = Vector3.Lerp (downPosition,upPosition,timer/duration);
            yield return null;
        }

        // If it is a momentary switch, we need to tell the target object that is has been
        // switched again
        if (switchDown) {
            if (targetCamera != null && action == SwitchAction.Momentary)
                StartCoroutine("ShowCamera", player);

            switchDown = false;
            if (action == SwitchAction.Momentary) {
                GetComponent<AudioSource>().Play();
                target.SwitchToggle();
            }
        }
    }
Example #4
0
    IEnumerator ShowCamera(MKPlayer player)
    {
        MKSceneManager.instance.inputLocked = true;

        // Stop the player so they aren't controlling themselves while they
        // are not visible.
        player.GetComponent<Rigidbody>().isKinematic = true;
        player.playerCamera.enabled = false;
        targetCamera.enabled = true;

        yield return new WaitForSeconds(cutsceneTime);

        targetCamera.enabled = false;
        player.playerCamera.enabled = true;
        player.GetComponent<Rigidbody>().isKinematic = false;
        MKSceneManager.instance.inputLocked = false;
    }