BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Samples / VrHoops / Scripts / LocalPlayer.cs

LocalPlayer.cs

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