コード例 #1
0
    public override void Initialize()
    {
        base.Initialize();
        if (lightOriginalFallOffExponent <= 0)
        {
            lightOriginalFallOffExponent = light2D.falloffExponent;
        }
        if (historyAgent == null)
        {
            historyAgent = GetComponent <HistoryAgent>();
        }


        light2D.gameObject.layer = ToLayer(GameManager.teamData[historyAgent.historyAgentStats.teamIndex].teamLightLayer);

        if (light2DCamera != null)
        {
            light2DCamera.detectLayers = new LayerMask[0];
            light2DCamera.detectLayers = GameManager.teamData[historyAgent.historyAgentStats.teamIndex].teamCamDetectLightLayers;
        }

        Color _curColor = spriteRenderer.color;

        light2D.angleFalloffExponent = 0;
        light2D.falloffExponent      = lightOriginalFallOffExponent;
        Debug.Log(lightOriginalFallOffExponent);
        lightMeshRenderer.enabled = true;
        _curColor.a          = 1;
        spriteRenderer.color = _curColor;
    }
コード例 #2
0
    public IEnumerator Playback(int _teamIndex, int _recordingIndex, bool _loop)
    {
        float _playbackStartTime = Time.time;
        int   _sampleIndex       = 0;

        List <InstanceData> _playbackRecordingData = teamHistoryData[_teamIndex].recordings[_recordingIndex];

        InstanceData _curInstanceData  = _playbackRecordingData[0];
        InstanceData _nextInstanceData = _playbackRecordingData[1];
        int          _samplesCount     = _playbackRecordingData.Count;

        Debug.Log("Recording Samples: " + _samplesCount);
        float _progress            = 0;
        float _prematureDeathDelay = 0;// so dying early do not start next loop earlier. (due to time take for death animation)

        HistoryAgent _shadow = HistoryAgent.GetFromPool(shadowGO);

        _shadow.Initialize(_teamIndex, _recordingIndex, _curInstanceData.position, _curInstanceData.rotation);

        while (_sampleIndex < _samplesCount)
        {
            _progress = (Time.time - _playbackStartTime - _prematureDeathDelay - _curInstanceData.timecode) / (_nextInstanceData.timecode - _curInstanceData.timecode);

            if (_shadow.isAlive)
            {
                if (_shadow.historyAgentStats.currentHitPoints <= 0)
                {
                    _shadow.isAlive      = false;
                    _prematureDeathDelay = Time.time;
                    yield return(StartCoroutine(_shadow.animator.DieAnim()));

                    _prematureDeathDelay = Time.time - _prematureDeathDelay;
                }
                else
                {
                    _shadow.MoveTo(Vector3.Lerp(_curInstanceData.position, _nextInstanceData.position, _progress),
                                   Mathf.Lerp(_curInstanceData.rotation, _nextInstanceData.rotation, _progress), Time.fixedDeltaTime);
                }
            }
            yield return(new WaitForFixedUpdate());

            if (_progress >= 1)
            {
                _sampleIndex++;
                if (_sampleIndex + 1 >= _samplesCount)
                {
                    //DIE ANIMATION AND RELATED HERE
                    if (_shadow.isAlive)
                    {
                        _shadow.isAlive = false;
                        yield return(StartCoroutine(_shadow.animator.DieAnim()));
                    }
                    _shadow.Pool();
                    if (_loop)
                    {
                        StartCoroutine(Playback(_teamIndex, _recordingIndex, _loop));
                    }
                    yield break;
                }
                _curInstanceData  = _playbackRecordingData[_sampleIndex];
                _nextInstanceData = _playbackRecordingData[_sampleIndex + 1];
            }
        }
    }