Пример #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;
                    }
                }
            }
        }
Пример #2
0
        public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (this.m_Animator == null)
            {
                return;
            }

            if (stream.IsWriting == true)
            {
                if (this.m_WasSynchronizeTypeChanged == true)
                {
                    this.m_StreamQueue.Reset();
                    this.SerializeSynchronizationTypeState(stream);

                    this.m_WasSynchronizeTypeChanged = false;
                }

                this.m_StreamQueue.Serialize(stream);
                this.SerializeDataDiscretly(stream);
            }
            else
            {
                #if PHOTON_DEVELOP
                if (ReceivingSender != null)
                {
                    ReceivingSender.OnPhotonSerializeView(stream, info);
                }
                else
                #endif
                {
                    if (stream.PeekNext() is byte[])
                    {
                        this.DeserializeSynchronizationTypeState(stream);
                    }

                    this.m_StreamQueue.Deserialize(stream);
                    this.DeserializeDataDiscretly(stream);
                }
            }
        }