private void DeleteNetworkProc() { if (SelectedNetworkModel == null) { MessageBox.Show("Please select a network."); } if (SelectedNetworkModel != null) { try { var x = MessageBox.Show("Are you sure to delete " + SelectedNetworkModel.Model.Name + "? Doing so, will delete all its dependencies as well", "Delete", MessageBoxButton.OKCancel); if (x == MessageBoxResult.OK && SelectedNetworkModel.Model != null) { _repository.Networks.Remove(SelectedNetworkModel.Model); NetworkList.Remove(SelectedNetworkModel); count++; TextSync = count + " unsynced item(s)"; } } catch (Exception e) { MessageBox.Show("Unable to delete " + SelectedNetworkModel.Model.Name + "."); } } }
//-------------------------------------------------------------------------------------- // DropItem: Function for what happens when an equipable item is dropped. // // Param: // ulObjectNetworkID: ulong value for ID of the spawned network object. //-------------------------------------------------------------------------------------- public void DropItem(ulong ulObjectNetworkID) { // Loop through the list of equipable item IDs for (int i = 0; i < mn_aulEquipableItemIDs.Count; i++) { // Find the ID that matches the pass in object network ID if (mn_aulEquipableItemIDs[i] == ulObjectNetworkID) { // Remove this network ID from the array mn_aulEquipableItemIDs.Remove(ulObjectNetworkID); // Break for loop and continue break; } } // Run server function to destroy/despawn the equipable items scene object DropItemServerRpc(ulObjectNetworkID); }
private void AssignPlayerColorServerRpc(ulong ulClientID) { // Get the clients network object, return if not valid. if (!NetworkManager.Singleton.ConnectedClients.TryGetValue(ulClientID, out NetworkClient ncClient)) { return; } // Get the clients player object, return if not valid if (!ncClient.PlayerObject.TryGetComponent <Player>(out Player oPlayer)) { return; } // new color variable for assigning random color Color cRandomColor = Color.white; // if mn_acAvailablePlayerColors count is at least 2 if (mn_acAvailablePlayerColors.Count > 1) { // Get a random color and assign to color variable cRandomColor = mn_acAvailablePlayerColors[Random.Range(0, mn_acAvailablePlayerColors.Count)]; // loop through mn_acAvailablePlayerColors array for (int i = 0; i < mn_acAvailablePlayerColors.Count; i++) { // if the random color is in the array remove it if (mn_acAvailablePlayerColors[i] == cRandomColor) { mn_acAvailablePlayerColors.RemoveAt(i); } } } // if only one value is left in mn_acAvailablePlayerColors else if (mn_acAvailablePlayerColors.Count == 1) { // Assign last color in array to the color variable cRandomColor = mn_acAvailablePlayerColors[0]; // Remove the final value from the array, making it empty mn_acAvailablePlayerColors.Remove(cRandomColor); // Loop through all colors and re-initialize mn_acAvailablePlayerColors array for (int i = 0; i < m_acAllPlayerColors.Count; i++) { mn_acAvailablePlayerColors.Add(m_acAllPlayerColors[i]); } } // else if the mn_acAvailablePlayerColors count is 0 else { // Print error message, change color of player to black to make it clear there is a problem Debug.Log("Error: mn_acAvailablePlayerColors is Empty?"); cRandomColor = Color.black; } // Send color to player object oPlayer.SetBodyColorServerRpc(cRandomColor); }