Exemplo n.º 1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     counter += Time.deltaTime;
     if (counter > refreshPos)
     {
         string message = "22/";
         message += gameObject.transform.position.y;
         message += "~";
         serverConnection.SendMessage(message);
         counter = 0;
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 //Sends the players position (x,y), state which depends on animation its doing, and number to know where the player is facing
 //Sent to server to send to other users playing in the same game to update position of their npcs
 void FixedUpdate()
 {
     counter += Time.deltaTime;
     if (counter > refreshPos)
     {
         // 20/x,y,state
         string message = "20/";
         message += gameObject.transform.position.x;
         message += "/";
         message += gameObject.transform.position.y;
         message += "/";
         message += globalData.State.ToString();
         message += "/";
         message += animator.GetFloat("Horizontal");
         message += "~";
         server.SendMessage(message);
         counter = 0;
     }
 }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     t += Time.deltaTime;
     rb.transform.position = new Vector3(rb.transform.position.x, oscillation * Mathf.Sin(t) + InitialY, rb.transform.position.z);
     if (Random.Range(0, 100) > bulletRate)
     {
         if (counter < countMax && !animator.GetBool("shootTongue"))
         {
             animator.SetBool("shootBullet", true);
             counter += Time.deltaTime;
         }
         else
         {
             animator.SetBool("shootTongue", true);
             string message = "23/0/1~";
             serverConnection.SendMessage(message);
             counter = 0;
         }
     }
 }