Exemple #1
0
        /// <summary>
        /// Adds a new player to the player list if it not yet exists.
        /// </summary>
        /// <returns>The player number.</returns>
        /// <param name="acDeviceId">AirConsole device identifier.</param>
        protected int AddPlayer(int acDeviceId)
        {
            if (acDeviceId < 1)
            {
                return(-1);
            }

            // Get index of this player
            int index = GetPlayerId(acDeviceId);

            // Player does not exist yet
            if (index == -1)
            {
                AllocateCustomStateArrays(acDeviceId);

                // Create new player and subscribe state change event for updating custom device state
                VPlayer newPlayer = new VPlayer(acDeviceId);

                Action <bool> updateState = delegate(bool active) {
                    VolplaneAgent.CustomState.Active[acDeviceId] = active;
                    VolplaneController.AirConsole.SetCustomDeviceState(VolplaneAgent.CustomState.ToJSON());
                };
                newPlayer.OnStateChange += updateState;

                // Invoke 'updateState' delegate for initialization
                updateState(newPlayer.State == VPlayer.PlayerState.Active);

                // Add player to player list
                index = VolplaneAgent.Players.Count;
                VolplaneAgent.Players.Add(newPlayer);

                if (Config.DebugLog == (int)DebugState.All)
                {
                    VDebug.LogFormat("[Volplane] Registered new device with id: {0:D}. Added as player with id: {1:D}.", acDeviceId, index);
                }
            }

            return(index);
        }
 /// <summary>
 /// Vibrate the controller of a player for a specified amount of time.
 /// Maximum time is 10 seconds.
 /// </summary>
 /// <param name="player">Player object.</param>
 /// <param name="time">Time in seconds.</param>
 public void VibrateController(VPlayer player, float time)
 {
     VolplaneController.Main.VibrateController(player, time);
 }
Exemple #3
0
 /// <summary>
 /// Gets the player identifier.
 /// </summary>
 /// <returns>The player identifier.</returns>
 /// <param name="player">Player object.</param>
 public int GetPlayerId(VPlayer player)
 {
     return(VolplaneAgent.Players.FindIndex(vp => vp.DeviceId == player.DeviceId));
 }
 /// <summary>
 /// Resets the controller view of a player to its initial state.
 /// </summary>
 /// <param name="player">Player object.</param>
 /// <param name="viewName">View name.</param>
 public void ResetView(VPlayer player, string viewName)
 {
     VolplaneController.Main.ResetView(player, viewName);
 }
 /// <summary>
 /// Enable or disable the tracking of physical motion data of the controller from a
 /// player (acceleration and rotation).
 /// Calling this method has no effect if the 'Track Device Motion' flag is not set for
 /// specified players controller.
 /// </summary>
 /// <param name="player">Player object.</param>
 /// <param name="value">If set to <c>true</c> motion data will be tracked.</param>
 public void TrackingControllerMotion(VPlayer player, bool value)
 {
     VolplaneController.Main.TrackingControllerMotion(player, value);
 }
 /// <summary>
 /// Changes the controller view of a specific player.
 /// </summary>
 /// <param name="player">Player object.</param>
 /// <param name="viewName">View name.</param>
 public void ChangeView(VPlayer player, string viewName)
 {
     VolplaneController.Main.ChangeView(player, viewName);
 }
 /// <summary>
 /// Gets the current view name of a specific controller.
 /// </summary>
 /// <returns>The current view.</returns>
 /// <param name="player">Player object.</param>
 public string GetCurrentView(VPlayer player)
 {
     return(VolplaneController.Main.GetCurrentView(player));
 }
 /// <summary>
 /// Save user data. This method tries to persistently store the data on the AirConsole servers.
 /// When complete, <see cref="Volplane.VolplaneBehaviour.OnUserDataSaved"/> fires for this player.
 /// </summary>
 /// <param name="player">Player object.</param>
 /// <param name="data">JSON data.</param>
 public void SaveUserData(VPlayer player, JObject data)
 {
     VolplaneController.Main.SaveUserData(player, data);
 }
 /// <summary>
 /// Sets a player active or inactive.
 /// You will not receive any input from inactive players.
 /// </summary>
 /// <remarks>If the player lost connection or is waiting for an advertisement to complete, the state change will
 /// be delayed.</remarks>
 /// <param name="player">Player object.</param>
 /// <param name="value">Activate (<c>true</c>) or deactivate (<c>false</c>) a player.</param>
 public void SetActive(VPlayer player, bool value)
 {
     VolplaneController.Main.SetActive(player, value);
 }
 /// <summary>
 /// Gets the player identifier.
 /// </summary>
 /// <returns>The player identifier.</returns>
 /// <param name="player">Player object.</param>
 public int GetPlayerId(VPlayer player)
 {
     return(VolplaneController.Main.GetPlayerId(player));
 }