Exemplo n.º 1
0
    private void DeserializeDataDiscretly(PhotonStream stream)
    {
        for (int i = 0; i < this.m_SynchronizeLayers.Count; ++i)
        {
            if (this.m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Discrete)
            {
                this.m_Animator.SetLayerWeight(this.m_SynchronizeLayers[i].LayerIndex, (float)stream.ReceiveNext());
            }
        }

        for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
        {
            SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

            if (parameter.SynchronizeType == SynchronizeType.Discrete)
            {
                switch (parameter.Type)
                {
                case ParameterType.Bool:
                    if (stream.PeekNext() is bool == false)
                    {
                        return;
                    }
                    this.m_Animator.SetBool(parameter.Name, (bool)stream.ReceiveNext());
                    break;

                case ParameterType.Float:
                    if (stream.PeekNext() is float == false)
                    {
                        return;
                    }

                    this.m_Animator.SetFloat(parameter.Name, (float)stream.ReceiveNext());
                    break;

                case ParameterType.Int:
                    if (stream.PeekNext() is int == false)
                    {
                        return;
                    }

                    this.m_Animator.SetInteger(parameter.Name, (int)stream.ReceiveNext());
                    break;

                case ParameterType.Trigger:
                    if (stream.PeekNext() is bool == false)
                    {
                        return;
                    }

                    if ((bool)stream.ReceiveNext())
                    {
                        this.m_Animator.SetTrigger(parameter.Name);
                    }
                    break;
                }
            }
        }
    }
Exemplo n.º 2
0
        private void SerializeDataContinuously()
        {
            if (this.m_Animator == null)
            {
                return;
            }

            for (int i = 0; i < this.m_SynchronizeLayers.Count; ++i)
            {
                if (this.m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Continuous)
                {
                    this.m_StreamQueue.SendNext(this.m_Animator.GetLayerWeight(this.m_SynchronizeLayers[i].LayerIndex));
                }
            }

            for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
            {
                SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

                if (parameter.SynchronizeType == SynchronizeType.Continuous)
                {
                    switch (parameter.Type)
                    {
                    case ParameterType.Bool:
                        this.m_StreamQueue.SendNext(this.m_Animator.GetBool(parameter.Name));
                        break;

                    case ParameterType.Float:
                        this.m_StreamQueue.SendNext(this.m_Animator.GetFloat(parameter.Name));
                        break;

                    case ParameterType.Int:
                        this.m_StreamQueue.SendNext(this.m_Animator.GetInteger(parameter.Name));
                        break;

                    case ParameterType.Trigger:
                        if (!TriggerUsageWarningDone)
                        {
                            TriggerUsageWarningDone = true;
                            Debug.Log(
                                "PhotonAnimatorView: When using triggers, make sure this component is last in the stack.\n" +
                                "If you still experience issues, implement triggers as a regular RPC \n" +
                                "or in custom IPunObservable component instead", this);
                        }

                        this.m_StreamQueue.SendNext(this.m_Animator.GetBool(parameter.Name));
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void SerializeDataDiscretly(PhotonStream stream)
        {
            for (int i = 0; i < this.m_SynchronizeLayers.Count; ++i)
            {
                if (this.m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Discrete)
                {
                    stream.SendNext(this.m_Animator.GetLayerWeight(this.m_SynchronizeLayers[i].LayerIndex));
                }
            }

            for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
            {
                SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

                if (parameter.SynchronizeType == SynchronizeType.Discrete)
                {
                    switch (parameter.Type)
                    {
                    case ParameterType.Bool:
                        stream.SendNext(this.m_Animator.GetBool(parameter.Name));
                        break;

                    case ParameterType.Float:
                        stream.SendNext(this.m_Animator.GetFloat(parameter.Name));
                        break;

                    case ParameterType.Int:

                        //HACK: 'direction' has to be set as float (used in blend tree) but
                        //photon animator sends it as an integer
                        if (parameter.Name == "direction")
                        {
                            stream.SendNext(this.m_Animator.GetFloat(parameter.Name));
                        }
                        else
                        {
                            stream.SendNext(this.m_Animator.GetInteger(parameter.Name));
                        }
                        break;

                    case ParameterType.Trigger:
                        // here we can't rely on the current real state of the trigger, we might have missed its raise
                        stream.SendNext(this.m_raisedDiscreteTriggersCache.Contains(parameter.Name));
                        break;
                    }
                }
            }

            // reset the cache, we've synchronized.
            this.m_raisedDiscreteTriggersCache.Clear();
        }
Exemplo n.º 4
0
        private void SerializeDataDiscretly(PhotonStream stream)
        {
            for (int i = 0; i < this.m_SynchronizeLayers.Count; ++i)
            {
                if (this.m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Discrete)
                {
                    stream.SendNext(this.m_Animator.GetLayerWeight(this.m_SynchronizeLayers[i].LayerIndex));
                }
            }

            for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
            {
                SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

                if (parameter.SynchronizeType == SynchronizeType.Discrete)
                {
                    switch (parameter.Type)
                    {
                    case ParameterType.Bool:
                        stream.SendNext(this.m_Animator.GetBool(parameter.Name));
                        break;

                    case ParameterType.Float:
                        stream.SendNext(this.m_Animator.GetFloat(parameter.Name));
                        break;

                    case ParameterType.Int:
                        stream.SendNext(this.m_Animator.GetInteger(parameter.Name));
                        break;

                    case ParameterType.Trigger:
                        if (!TriggerUsageWarningDone)
                        {
                            TriggerUsageWarningDone = true;
                            Debug.Log(
                                "PhotonAnimatorView: When using triggers, make sure this component is last in the stack.\n" +
                                "If you still experience issues, implement triggers as a regular RPC \n" +
                                "or in custom IPunObservable component instead", this);
                        }

                        // here we can't rely on the current real state of the trigger, we might have missed its raise
                        stream.SendNext(this.m_raisedDiscreteTriggersCache.Contains(parameter.Name));
                        break;
                    }
                }
            }

            // reset the cache, we've synchronized.
            this.m_raisedDiscreteTriggersCache.Clear();
        }
Exemplo n.º 5
0
    /// <summary>
    /// Caches the discrete triggers values for keeping track of raised triggers, and will be reseted after the sync routine got performed
    /// </summary>
    public void CacheDiscreteTriggers()
    {
        for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
        {
            SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

            if (parameter.SynchronizeType == SynchronizeType.Discrete && parameter.Type == ParameterType.Trigger && this.m_Animator.GetBool(parameter.Name))
            {
                if (parameter.Type == ParameterType.Trigger)
                {
                    this.m_raisedDiscreteTriggersCache.Add(parameter.Name);
                    break;
                }
            }
        }
    }
Exemplo n.º 6
0
        private void DeserializeDataContinuously()
        {
            if (this.m_StreamQueue.HasQueuedObjects() == false)
            {
                return;
            }

            for (int i = 0; i < this.m_SynchronizeLayers.Count; ++i)
            {
                if (this.m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Continuous)
                {
                    this.m_Animator.SetLayerWeight(this.m_SynchronizeLayers[i].LayerIndex,
                                                   (float)this.m_StreamQueue.ReceiveNext());
                }
            }

            for (int i = 0; i < this.m_SynchronizeParameters.Count; ++i)
            {
                SynchronizedParameter parameter = this.m_SynchronizeParameters[i];

                if (parameter.SynchronizeType == SynchronizeType.Continuous)
                {
                    switch (parameter.Type)
                    {
                    case ParameterType.Bool:
                        this.m_Animator.SetBool(parameter.Name, (bool)this.m_StreamQueue.ReceiveNext());
                        break;

                    case ParameterType.Float:
                        this.m_Animator.SetFloat(parameter.Name, (float)this.m_StreamQueue.ReceiveNext());
                        break;

                    case ParameterType.Int:
                        this.m_Animator.SetInteger(parameter.Name, (int)this.m_StreamQueue.ReceiveNext());
                        break;

                    case ParameterType.Trigger:
                        this.m_Animator.SetBool(parameter.Name, (bool)this.m_StreamQueue.ReceiveNext());
                        break;
                    }
                }
            }
        }
Exemplo n.º 7
0
    void SerializeDataContinuously()
    {
        if (m_Animator == null)
        {
            return;
        }

        for (int i = 0; i < m_SynchronizeLayers.Count; ++i)
        {
            if (m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Continuous)
            {
                m_StreamQueue.SendNext(m_Animator.GetLayerWeight(m_SynchronizeLayers[i].LayerIndex));
            }
        }

        for (int i = 0; i < m_SynchronizeParameters.Count; ++i)
        {
            SynchronizedParameter parameter = m_SynchronizeParameters[i];

            if (parameter.SynchronizeType == SynchronizeType.Continuous)
            {
                switch (parameter.Type)
                {
                case ParameterType.Bool:
                    m_StreamQueue.SendNext(m_Animator.GetBool(parameter.Name));
                    break;

                case ParameterType.Float:
                    m_StreamQueue.SendNext(m_Animator.GetFloat(parameter.Name));
                    break;

                case ParameterType.Int:
                    m_StreamQueue.SendNext(m_Animator.GetInteger(parameter.Name));
                    break;

                case ParameterType.Trigger:

                    break;
                }
            }
        }
    }
Exemplo n.º 8
0
    void SerializeDataDiscretly(PhotonStream stream)
    {
        for (int i = 0; i < m_SynchronizeLayers.Count; ++i)
        {
            if (m_SynchronizeLayers[i].SynchronizeType == SynchronizeType.Discrete)
            {
                stream.SendNext(m_Animator.GetLayerWeight(m_SynchronizeLayers[i].LayerIndex));
            }
        }

        for (int i = 0; i < m_SynchronizeParameters.Count; ++i)
        {
            SynchronizedParameter parameter = m_SynchronizeParameters[i];

            if (parameter.SynchronizeType == SynchronizeType.Discrete)
            {
                switch (parameter.Type)
                {
                case ParameterType.Bool:
                    stream.SendNext(m_Animator.GetBool(parameter.Name));
                    break;

                case ParameterType.Float:
                    stream.SendNext(m_Animator.GetFloat(parameter.Name));
                    break;

                case ParameterType.Int:
                    stream.SendNext(m_Animator.GetInteger(parameter.Name));
                    break;

                case ParameterType.Trigger:

                    break;
                }
            }
        }
    }