Example #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;
    }
Example #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;
 }
Example #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);
    }
Example #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);
        }
Example #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;
         }
     }
 }
Example #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);
    }
Example #7
0
 protected virtual void OnReceive(MultiValue value)
 {
     Debug.Log("receive multi value: " + value.AsString());
 }
Example #8
0
 protected void Send(MultiValue value)
 {
     Send(value.AsString(), "multi");
 }
Example #9
0
 protected void Send(MultiValue value)
 {
     Send(value.AsString(), "multi");
 }
Example #10
0
 protected virtual void OnReceive(MultiValue value)
 {
     Debug.Log("receive multi value: " + value.AsString());
 }
Example #11
0
 public static string AsString(this MultiValue value)
 {
     return(string.Join(
                MultiValue.DelimiterString,
                value.values.Select(val => val.AsString()).ToArray()));
 }