Exemplo n.º 1
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)                                 //Текущий игрок
     {
         stream.SendNext(transform.position);              //Положение
         stream.SendNext(transform.rotation);              //Поворот
         stream.SendNext(pl.dir);                          //Поворт рук
         stream.SendNext(dir);                             //Направление
         stream.SendNext(anim.GetFloat("Speed"));          //Скорость для анимации
         stream.SendNext(pl.jump);                         //Прыжок дл анимации
         stream.SendNext(hp.hp);                           //хп
     }
     if (stream.isReading)                                 //Мультиплеерный игрок
     {
         realPosition  = (Vector3)stream.ReceiveNext();    //
         realRotation  = (Quaternion)stream.ReceiveNext(); //
         realLookAngle = (Vector3)stream.ReceiveNext();    //
         dir           = (float)stream.ReceiveNext();      //
         Vector3 localScale = transform.localScale;
         localScale.x         = dir;
         transform.localScale = localScale;
         if (anim == null)
         {
             anim = GetComponent <Animator>();
         }
         anim.SetFloat("Speed", (float)stream.ReceiveNext());                //
         bool j = (bool)stream.ReceiveNext();                                //
         anim.SetBool("Jump", j);
         if (hp == null)
         {
             hp = GetComponent <hitpoints>();                                        //
         }
         hp.hp = (float)stream.ReceiveNext();                                        //
     }
 }
Exemplo n.º 2
0
 void Awake()
 {
     // Setting up references.
     groundCheck = transform.Find("groundCheck");
     anim        = GetComponent <Animator> ();
     anim.SetBool("Jump", false);
     anim.SetBool("Stunned", false);
     Hp          = transform.GetComponent <hitpoints> ();
     healthText  = GameObject.Find("healthText").GetComponent <Text> ();
     healthBar   = GameObject.Find("healthBar").GetComponent <Image> ();
     MainMessage = GameObject.Find("MainMessage").GetComponent <Text> ();
     UseBarBg    = GameObject.Find("UseBar_bg").GetComponent <Image> ();
     UseBar      = GameObject.Find("UseBar").GetComponent <Image> ();
 }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     hp = gameObject.GetComponent <hitpoints> ();
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     pl   = transform.GetComponent <PlayerControl> ();
     anim = GetComponent <Animator>();
     hp   = GetComponent <hitpoints>();
 }