Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using Photon.Pun;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4.  
  5. public class Player : MonoBehaviourPun, IPunObservable
  6. {
  7. [SerializeField] float speed = 100f;
  8. [SerializeField] float jumpeSpeed = 800f;
  9. [SerializeField] GameObject cam;
  10. [SerializeField] Text nameText;
  11. int actorNumber;
  12.  
  13. void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
  14. {
  15. }
  16.  
  17. public void SetUp(int actorNumber, string name, bool fromSceneLoad)
  18. {
  19. Debug.Log(gameObject.name + " is local: " + photonView.IsMine);
  20.  
  21. if (!photonView.IsMine && fromSceneLoad)
  22. Destroy(gameObject);
  23.  
  24. if (photonView.IsMine)
  25. GetComponent<SpriteRenderer>().color = Color.green;
  26.  
  27. this.actorNumber = actorNumber;
  28. nameText.text = name;
  29.  
  30. if (photonView.IsMine)
  31. GameManager.getInstance.UpdateSceneCam(false);
  32.  
  33. gameObject.name = name;
  34. }
  35.  
  36. void Update()
  37. {
  38. if (photonView.IsMine)
  39. checkInput();
  40. }
  41.  
  42. void checkInput()
  43. {
  44. Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0);
  45. transform.position += movement * speed * Time.deltaTime;
  46. }
  47.  
  48. public int getActorNumber() { return actorNumber; }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement