Example #1
0
    public static void Load()
    {
        if (!loaded)
        {
            Clear();
        }
        if (Match.self.activeEvent == null)
        {
            return;
        }
        if (self != null)
        {
            foreach (Player p in Match.self.activeEvent.Players)
            {
                self.Add(p);
            }
            loaded = true;
        }

        // clear the ones who left
        bool exists = false;

        foreach (Player i in players)
        {
            exists = false;
            foreach (Player j in Match.self.activeEvent.Players)
            {
                // TODO make it with hashed ID
                if (i.PlayerName == j.PlayerName)
                {
                    exists = true;

                    // update the player's character
                    foreach (GameObject po in objects)
                    {
                        UIPlayer uip = po.GetComponent <UIPlayer>();
                        if (uip.player.PlayerName == j.PlayerName)
                        {
                            uip.Set(j);
                            break;
                        }
                    }

                    break;
                }
            }
            if (!exists)
            {
                self.Delete(i);
            }
        }
    }