Ejemplo n.º 1
0
    void LateUpdate()
    {
        if (!recording || GameObject.Find("Player").GetComponent <Renderer>().enabled == false)
        {
            lineRenderer.enabled = false;
        }
        else
        {
            lineRenderer.enabled = true;
        }

        // Automatically dequeue old points
        int pointsToKeep = (int)(maxLineTime * fps);

        while (linePoints.Count > pointsToKeep)
        {
            linePoints.Dequeue();
        }

        // Add all vertices to line renderer
        int i = 0;

        lineRenderer.SetColors(Color.clear, lineColour);
        lineRenderer.SetVertexCount(linePoints.Count + 1);
        foreach (Vector3 point in linePoints)
        {
            lineRenderer.SetPosition(i, point);
            i++;
        }

        if (enableLine && linePoints.Count > 0)
        {
            lineRenderer.SetPosition(i, transform.position + offset);
        }

        if (playback && current != null)
        {
            if (!TutorialCamera.Enabled())
            {
                GUIController.GUIPlaybackRecording();

                ControlManager.Disabled = true;

                GUIController.ShowText("Replay", "Replay Mode");
            }

            time += Time.deltaTime;

            if (time < current.score.time)
            {
                transform.position = current.GetPosition(time);
                if (!GetComponent <Rigidbody>().isKinematic)
                {
                    GetComponent <Rigidbody>().velocity = current.GetVelocity(time);
                }

                transform.LookAt(transform.position + GetComponent <Rigidbody>().velocity);

                if (current.IsGrappling(time) && current.GetGrapplePos(lastTime) != current.GetGrapplePos(time))
                {
                    if (!current.IsGrappling(lastTime))
                    {
                        SoundManager.Play("attach");
                    }

                    RaycastHit hit = new RaycastHit();
                    hit.point = current.GetGrapplePos(time);

                    grappleScript.Attach(hit, -1, true);
                }
                else if (!current.IsGrappling(time) && current.IsGrappling(lastTime))
                {
                    grappleScript.Detach();
                }
            }

            lastTime = time;
        }
    }
Ejemplo n.º 2
0
    void KillPlayer(GameObject player)
    {
        if (TutorialCamera.Enabled())
        {
            GameRecorder.StopPlayback();
            if (explode)
            {
                player.SendMessage("Explode");
                SoundManager.Play("crash");

                player.SendMessage("Reload");
                IncrementCrashCount(true);
            }

            return;
        }

        if (!LevelState.Dead)
        {
            MainGUI.Play("RestartLevel");

            // Disable text
            GUIController.DisableTexts();

            // Update drone count
            if (SaveManager.save != null)
            {
                if (explode)
                {
                    IncrementCrashCount(false);
                }
                SaveManager.save.droneCount++;
                SaveManager.Write();

                // Display drone coun
                if (false)
                {
                    GameObject thingy = Tutorial.ShowText("DroneText", "Drones lost: " + SaveManager.save.droneCount, 0, TextAlignment.Center, TextAnchor.MiddleCenter, 0.5f, 0.5f);
                    Mover      mover  = thingy.AddComponent <Mover>();
                    mover.direction = Vector3.up;
                    mover.speed     = 0.2f;
                    TextFader fader = thingy.AddComponent <TextFader>();
                    fader.fadeRate = 1.0f;
                    fader.FadeOut();
                }
            }

            // Update level state
            GUIController.LevelStarted = false;
            LevelStart.started         = false;
            LevelState.Dead            = true;

            if (explode)
            {
                // Create explosion effect
                player.SendMessage("Explode");

                // Crash sound
                SoundManager.Play("crash");

                // Disable renderers if exploding
                player.GetComponent <Renderer>().enabled = false;
                player.transform.Find("Shield").GetComponent <Renderer>().enabled = false;
            }

            // Disable default camera controller until level restarts
            ThirdPersonCamera cameraController = Camera.main.GetComponent <ThirdPersonCamera>();
            if (cameraController != null)
            {
                cameraController.enabled = false;
            }

            // Detach grappling hook so we don't keep swinging
            grapplingHook.Detach();

            // I don't really remember why
            ControlManager.DisabledFrame = true;

            // Pause and then restart the level
            StartCoroutine(PauseBeforeReset());
        }
    }