예제 #1
0
        public void Update()
        {
            if (networkIdentity.IsControlling())
            {
                AnimatorStateInfo asi = animator.GetCurrentAnimatorStateInfo(0);
                float             x   = animator.GetFloat("x");
                float             y   = animator.GetFloat("y");
                //Debug.LogFormat("{0},{1}", x, y);
                NetworkAnimatorDirection nad = getDirection((int)x, (int)y);
                NetworkAnimatorState     nas = NetworkAnimatorState.Walking;

                if (asi.fullPathHash == attacking)
                {
                    nas = NetworkAnimatorState.Attacking;
                }

                if (animatorDirection != nad || animatorState != nas)
                {
                    animatorDirection      = nad;
                    animatorState          = nas;
                    animatorData.state     = (int)animatorState;
                    animatorData.direction = (int)animatorDirection;
                    networkIdentity.GetSocket().Emit(NetworkTags.ANIMATOR_STATE, new JSONObject(JsonUtility.ToJson(animatorData)));
                    //Debug.LogFormat("Sending: ({0},{1})", (int)x, (int)y);
                }
            }
        }
예제 #2
0
        public void Start()
        {
            animatorState     = NetworkAnimatorState.Walking;
            animatorDirection = NetworkAnimatorDirection.Down;
            networkIdentity   = GetComponent <NetworkIdentity>();
            animator          = GetComponent <Animator>();
            animatorData      = new AnimatorData();

            NetworkClient.OnAnimationUpdate += onAnimationUpdate;
        }
예제 #3
0
        private void onAnimationUpdate(SocketIOEvent E)
        {
            string id = E.data["id"].ToString();

            if (id == networkIdentity.GetID())
            {
                animatorState     = (NetworkAnimatorState)((int)E.data["state"].f);
                animatorDirection = (NetworkAnimatorDirection)((int)E.data["direction"].f);
                Vector2Int vect = getValues(animatorDirection);
                Debug.LogFormat("Received: ({0},{1})", vect.x, vect.y);
                animator.SetFloat("x", vect.x);
                animator.SetFloat("y", vect.y);

                if (animatorState == NetworkAnimatorState.Attacking)
                {
                    animator.SetTrigger("isAttacking");
                }
            }
        }
예제 #4
0
 private Vector2Int getValues(NetworkAnimatorDirection Direction)
 {
     return(directionPairs.First(x => x.Key == Direction).Value);
 }