예제 #1
0
 protected override void ResetGame()
 {
     InputBridgeBase.ToggleMovement(false);
     CustomPlayerProperties.ResetProps(PhotonNetwork.LocalPlayer);
     if (PhotonNetwork.IsMasterClient)
     {
         CustomRoomProperties.InitializeRoom(PhotonNetwork.CurrentRoom, PhotonNetwork.CurrentRoom.PlayerCount);
     }
 }
예제 #2
0
 protected virtual void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #3
0
 private void RPCRespawn()
 {
     if (!view.IsMine)
     {
         //StartCoroutine(EnableAvatar());
         avatar.SetActive(true);
     }
     else
     {
         InputBridgeBase.ToggleMovement(true);
     }
 }
예제 #4
0
 private void RPCDespawn()
 {
     if (!view.IsMine)
     {
         avatar.SetActive(false);
         thisTransform.localPosition = Vector3.zero;
         //thisObject.SetActive(false);
     }
     else
     {
         InputBridgeBase.ToggleMovement(false);
         thisTransform.localPosition = Vector3.zero;
         respawnEvent.Raise();
     }
 }
예제 #5
0
    public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
    {
        // this will update when the game state changes
        if (propertiesThatChanged.ContainsKey(CustomRoomProperties.game))
        {
            int newstate = (int)propertiesThatChanged[CustomRoomProperties.game];
            if (newstate == 1 && PhotonNetwork.IsMasterClient)
            {
                GameMode.instance.SetupAvatars();
                GameMode.instance.StartGame();
            }
            else if (newstate == 2)
            {
                InputBridgeBase.ToggleMovement(true);
                uiMessage.Value = "Start!";
            }
            else if (newstate == 3)
            {
                InputBridgeBase.ToggleMovement(false);
                GameMode.instance.EndGame();
            }
        }

        // this will update when a player scores
        if (propertiesThatChanged.ContainsKey(CustomRoomProperties.scores) && GameMode.instance.IsGameActive)
        {
            GameMode.instance.CheckGame();
        }

        // this will update when the interest in a team is updated
        // ie when a team wins
        if (propertiesThatChanged.ContainsKey(CustomRoomProperties.interest) && GameMode.instance.IsGameActive)
        {
            if (!GameMode.instance.IsGameActive)
            {
                return;
            }
            var index = (int)propertiesThatChanged[CustomRoomProperties.interest];
            if (index == -1)
            {
                return;
            }
            var team = GameMode.instance.Teams[index].teamName;
            uiMessage.Value = $"{team} won!";
        }
    }