private void CmdSyncronizeAnimation(string name, VariableType type, string value) {
            SetAnimationRequest req = new SetAnimationRequest();
            req.entityId = this.identity.GetNetworkID();
            req.entityType = this.identity.GetEntityType();
            req.variableName = name;
            req.variableType = type;
            req.variableValue = value;

            NetworkManager.instance.GetSocket().Emit("Packet::SetAnimation", JSONObject.Create(JsonUtility.ToJson(req)));
        }
        public void SetAnimation(SetAnimationRequest req) {
            switch(req.variableType) {
                case VariableType.BOOL:
                    this.animator.SetBool(req.variableName, bool.Parse(req.variableValue));
                    break; 
                case VariableType.FLOAT:
                    if(req.variableValue != "") 
                        this.animator.SetFloat(req.variableName, float.Parse(req.variableValue));
                    break;
                case VariableType.TRIGGER:
                    this.animator.SetTrigger(req.variableName);
                    break;
                case VariableType.INT:
                    this.animator.SetInteger(req.variableName, int.Parse(req.variableValue));
                    break;
            }

            if(this.identity.IsMine() && !req.isSameThan(this.previousAnimationRequest)) {
                this.CmdSyncronizeAnimation(req.variableName, req.variableType, req.variableValue);
                this.previousAnimationRequest = req;
            }
        }
 public bool isSameThan(SetAnimationRequest req) {
     return req != null && this.variableName == req.variableName && this.variableType == req.variableType && this.variableValue == req.variableValue;
 }
Example #4
0
 public void EntityDoAnimation(SetAnimationRequest req)
 {
     this.networkAnimators[req.entityId].SetAnimation(req);
 }
Example #5
0
        private void EntityDoAnimation(SocketIOEvent e)
        {
            SetAnimationRequest req = JsonUtility.FromJson <SetAnimationRequest>(e.data.ToString());

            GameManager.instance.EntityDoAnimation(req);
        }