Comments (3)
Done. This has been implemented and will be part of v0.3.6
release.
from easymultiplayer-invector.
It is not fixed We are testing on the latest release
from easymultiplayer-invector.
using UnityEngine;
using EMI.Utils;
using EMI.Managers;
using UnityEngine.UI;
using System.Collections;
using System.Linq;
namespace EMI.UI
{
/// <summary>
/// A very simple script showing how you can tie into the available callback and populate
/// a list of player names and tie it to their total kill count;
/// </summary>
public class KillCounterPlayerList : MonoBehaviour
{
#region Properties
[SerializeField, Tooltip("The text to update, if not supplied will try to auto populate")] protected Text textComp = null;
#endregion
#region Init
protected virtual void Start()
{
StartCoroutine(InitCallback());
if (textComp == null) textComp = GetComponent<Text>();
}
protected virtual IEnumerator InitCallback()
{
yield return new WaitUntil(() => KillCounterUI.instance != null);
KillCounterUI.instance.OnKillCounterUpdated += KillCountUpdated;
}
#endregion
#region KillCount Updated
/// <summary>
/// This is called every single time the killCounter is updated. //Default Broken
/// </summary>
//protected virtual void KillCountUpdated(Dictionary<int, int> killCounter)
//{
// string playerName;
// string tmpString = "";
// foreach (KeyValuePair<int, int> item in killCounter)
// {
// ClientConnection conn = ClientUtil.GetClientConnection(item.Key);
// playerName = (conn == null || string.IsNullOrEmpty(conn.playerName)) ? item.Key.ToString() : conn.playerName;
// //if((playerName[0])!='-'){
// //}
// //else
// //{
// // tmpString += $"{playerName} : {item.Value}\n";
// //}
// //if((playerName[0])=='-')
// //{
// //}
// //else
// tmpString += $"{playerName} : {item.Value}\n";
// }
// if (textComp) textComp.text = tmpString;
//}
//protected virtual void KillCountUpdated(Dictionary<int, int> killCounter) //Git Hub Broken
//{
// string playerName;
// string tmpString = "";
// Dictionary<string, int> playerNameDictionary = new Dictionary<string, int>();
// foreach (KeyValuePair<int, int> item in killCounter)
// {
// ClientConnection conn = ClientUtil.GetClientConnection(item.Key);
// playerName = (conn == null || string.IsNullOrEmpty(conn.playerName)) ? item.Key.ToString() : conn.playerName;
// playerNameDictionary.Add(playerName, item.Value);
// }
// foreach (KeyValuePair<string, int> item in playerNameDictionary.OrderByDescending(x => x.Key))
// {
// tmpString += $"{item.Key} : {item.Value}\n";
// }
// if (textComp) textComp.text = tmpString;
// Debug.Log(tmpString);
//}
//protected virtual void KillCountUpdated(Dictionary<int, int> killCounter) //Works
//{
// string playerName;
// string tmpString = "";
// foreach (KeyValuePair<int, int> item in killCounter)
// {
// ClientConnection conn = ClientUtil.GetClientConnection(item.Key);
// playerName = (conn == null || string.IsNullOrEmpty(conn.playerName)) ? item.Key.ToString() : conn.playerName;
// tmpString += $"{playerName} : {item.Value}\n";
// }
// if (textComp) textComp.text = tmpString;
//}
protected virtual void KillCountUpdated(Dictionary<int, int> killCounter) //Ammars
{
string playerName;
string tmpString = "";
Dictionary<string, int> playerNameDictionary = new Dictionary<string, int>();
foreach (KeyValuePair<int, int> item in killCounter)
{
ClientConnection conn = ClientUtil.GetClientConnection(item.Key);
playerName = (conn == null || string.IsNullOrEmpty(conn.playerName)) ? item.Key.ToString() : conn.playerName;
playerNameDictionary.Add(playerName, item.Value);
//tmpString += $"{playerName} : {item.Value}\n";
}
foreach (KeyValuePair<string, int> item in playerNameDictionary.OrderByDescending(x => x.Key))
{
tmpString += $"{item.Key} : {item.Value}\n";
}
if (textComp) textComp.text = tmpString;
Debug.Log(tmpString);
}
#endregion
}
}
from easymultiplayer-invector.
Related Issues (20)
- Create Example Scene For Chatbox HOT 1
- Damage indicator / Direction of bullet + Leaderboard HOT 3
- Top Down Shooter Add On Beta HOT 1
- Pause menu would be beautiful as a new feature
- When using chatbox with shooterMelee Template with Dedicated Server, Client is disconnected. HOT 6
- Add Colorblind Support HOT 1
- Clean Import Of TopDown Throws Errors HOT 1
- Error after switch from Host mode on to off, and rebuild HOT 1
- Upgrade To Invector 2.6.2 HOT 2
- Perform Test Results Window Too Slow HOT 1
- First Person Camera HOT 1
- Upgrade to Mirror 67.1.0 HOT 1
- Multiplayer support for vAnimatorEventReceiver and vGenericAnimation HOT 1
- Add Support For Invector 2.6.2a HOT 2
- AI Broken When Rebuild Navmesh HOT 1
- StandBuild run server error HOT 4
- Draw-Hide weapons not synced. HOT 1
- Hold Input Button Bug HOT 4
- Player stays locked on after getting killed HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easymultiplayer-invector.