Exemplo n.º 1
0
    public void Update()
    {
        float horizontal, vertical;
        bool  jump;

        ReadPlayerInput(out horizontal, out vertical, out jump);
        actor.PerformActions(horizontal, vertical, jump);

        if (recorder.IsRecording())
        {
            recorder.RecordFrameAction(horizontal, vertical, Mathf.Atan2(transform.forward.x, transform.forward.z), jump);
        }
    }
Exemplo n.º 2
0
    void FixedUpdate()
    {
        if (isPlaying)
        {
            if (frameCount < recordedFrames.Length)
            {
                Vector3 v           = new Vector3(recordedFrames[frameCount].mHorizontal, 0.0f, recordedFrames[frameCount].mVertical);
                float   spaceAngle  = Mathf.Atan2(coordinateSpace.transform.forward.x, coordinateSpace.transform.forward.z);
                float   recordAngle = recordedFrames[0].mOffset;
                float   a           = spaceAngle - recordAngle;
                Vector3 t           = Quaternion.AngleAxis(a * Mathf.Rad2Deg, Vector3.up) * v;
                actor.PerformActions(t.x, t.z, recordedFrames[frameCount].mJump);

                frameCount++;
            }
            else
            {
                if (mode == PlaybackMode.RunOnce)
                {
                    StopPlayback();
                }
                else if (mode == PlaybackMode.Loop)
                {
                    frameCount = 0;
                }
            }

            Vector3 worldPos  = new Vector3(transform.position.x, transform.position.y + healthPanelOffset, transform.position.z);
            Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos);
            healthSlider.transform.position = new Vector3(screenPos.x, screenPos.y, screenPos.z);
            healthSlider.value = 1.0f - ((float)frameCount / (float)recordedFrames.Length);

            Color current = r.materials[0].color;
            current.a            = 1.0f - ((float)frameCount / (float)recordedFrames.Length);
            r.materials[0].color = current;
        }
    }