Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.0 KiB

  1. namespace Oculus.Platform.Samples.VrHoops
  2. {
  3. using UnityEngine;
  4. using System.Collections;
  5. // This class listens for Input events to shoot a ball, and also notifies the P2PManager when
  6. // ball or scores needs to be synchronized to remote players.
  7. public class LocalPlayer : Player {
  8. public override uint Score
  9. {
  10. set
  11. {
  12. base.Score = value;
  13. if (PlatformManager.CurrentState == PlatformManager.State.PLAYING_A_NETWORKED_MATCH)
  14. {
  15. PlatformManager.P2P.SendScoreUpdate(base.Score);
  16. }
  17. }
  18. }
  19. void Update ()
  20. {
  21. GameObject newball = null;
  22. // if the player is holding a ball
  23. if (HasBall)
  24. {
  25. // check to see if the User is hitting the shoot button
  26. if (Input.GetButton("Fire1") || Input.GetKey(KeyCode.Space))
  27. {
  28. newball = ShootBall();
  29. }
  30. }
  31. // spawn a new held ball if we can
  32. else
  33. {
  34. newball = CheckSpawnBall();
  35. }
  36. if (newball && PlatformManager.CurrentState == PlatformManager.State.PLAYING_A_NETWORKED_MATCH)
  37. {
  38. PlatformManager.P2P.AddNetworkBall(newball);
  39. }
  40. }
  41. }
  42. }