Exemple #1
0
    protected override void OnReceive(MultiValue values)
    {
        if (isPositionSync) {
            syncStartPos_ = transform.position;
            syncEndPos_   = values.Pop().value.AsVector3();
            if (isFirst_) transform.position = syncEndPos_;
        }

        if (isRotationSync) {
            syncStartRot_ = transform.rotation;
            syncEndRot_   = values.Pop().value.AsQuaternion();
            if (isFirst_) transform.rotation = syncEndRot_;
        }

        if (isScaleSync) {
            syncStartScale_ = transform.localScale;
            syncEndScale_   = values.Pop().value.AsVector3();
            if (isFirst_) transform.localScale = syncEndScale_;
        }

        syncStartTime_ = Time.time;
        syncEndTime_   = syncStartTime_ + sendCycle;

        if (isFirst_) isFirst_ = false;
    }
Exemple #2
0
 public static MultiValue AsMultiValue(this string value)
 {
     var mValue = new MultiValue();
     var values = new List<MultiValue.Value>();
     foreach (var val in value.Split(MultiValue.Delimiter, System.StringSplitOptions.None)) {
     values.Add(val.AsValue());
     }
     mValue.values = values;
     return mValue;
 }
Exemple #3
0
    protected override void OnSend()
    {
        var values = new MultiValue();

        if (isPositionSync) values.Push(transform.position);
        if (isRotationSync) values.Push(transform.rotation);
        if (isScaleSync)    values.Push(transform.localScale);

        Send(values);
    }
Exemple #4
0
        public static MultiValue AsMultiValue(this string value)
        {
            var mValue = new MultiValue();
            var values = new List <MultiValue.Value>();

            foreach (var val in value.Split(MultiValue.Delimiter, System.StringSplitOptions.None))
            {
                values.Add(val.AsValue());
            }
            mValue.values = values;
            return(mValue);
        }
Exemple #5
0
 protected override void OnReceive(MultiValue data)
 {
     while (data.values.Count > 0) {
         var name  = data.Pop().value;
         var param = data.Pop();
         switch (param.type) {
             case "bool":
                 animator.SetBool(name, param.value.AsBool());
                 break;
             case "int":
                 animator.SetInteger(name, param.value.AsInt());
                 break;
             case "float":
                 animator.SetFloat(name, param.value.AsFloat());
                 break;
         }
     }
 }
Exemple #6
0
    protected override void OnSend()
    {
        var data = new MultiValue();

        foreach (var param in animator.parameters) {
            data.Push(param.name);
            switch (param.type) {
                case AnimatorControllerParameterType.Bool:
                    data.Push(animator.GetBool(param.name));
                    break;
                case AnimatorControllerParameterType.Int:
                    data.Push(animator.GetInteger(param.name));
                    break;
                case AnimatorControllerParameterType.Float:
                    data.Push(animator.GetFloat(param.name));
                    break;
            }
        }

        Send(data);
    }
Exemple #7
0
 protected virtual void OnReceive(MultiValue value)
 {
     Debug.Log("receive multi value: " + value.AsString());
 }
Exemple #8
0
 protected void Send(MultiValue value)
 {
     Send(value.AsString(), "multi");
 }
 protected void Send(MultiValue value)
 {
     Send(value.AsString(), "multi");
 }
 protected virtual void OnReceive(MultiValue value)
 {
     Debug.Log("receive multi value: " + value.AsString());
 }
Exemple #11
0
 public static string AsString(this MultiValue value)
 {
     return(string.Join(
                MultiValue.DelimiterString,
                value.values.Select(val => val.AsString()).ToArray()));
 }