// Update is called once per frame
    void Update()
    {
        if (timer >= 2.0f)
        {
            PartialPlayer partialPlayer = new PartialPlayer();
            partialPlayer._id        = playerAttributes.ID;
            partialPlayer.name       = playerAttributes.Name;
            partialPlayer.score      = playerAttributes.Score;
            partialPlayer.attributes = new Attributes();
            partialPlayer.attributes.amountOfBlobs       = playerAttributes.Blobs;
            partialPlayer.attributes.anticlockwiseTorque = (int)playerAttributes.AnticlockwiseTorque;
            partialPlayer.attributes.clockwiseTorque     = (int)playerAttributes.ClockwiseTorque;
            partialPlayer.attributes.downwardThrust      = (int)playerAttributes.DownwardThrust;
            partialPlayer.attributes.leftThrust          = (int)playerAttributes.LeftThrust;
            partialPlayer.attributes.rightThrust         = (int)playerAttributes.RightThrust;
            partialPlayer.attributes.upwardThrust        = (int)playerAttributes.UpwardThrust;
            partialPlayer.attributes.timeStamp           = System.DateTime.Now;

            string json   = JsonUtility.ToJson(partialPlayer);
            byte[] myData = System.Text.Encoding.UTF8.GetBytes(json);

            //Dictionary<string, string> headers = new Dictionary<string, string>();
            //headers.Add("Content-Type", "application/json");
            //headers.Add("X-HTTP-Method-Override", "PUT");
            //WWW www = new WWW(uri, myData, headers);
            StartCoroutine(putRequest(uri, myData));
            timer = 0.0f;
        }
        else
        {
            timer += Time.deltaTime;
        }
    }
    private PlayerGraphics CreatePlayerGraphics(PartialPlayer player)
    {
        var playerModelClone = Instantiate(PlayerModelPrefab);
        var playerGraphics   = playerModelClone.GetComponent <PlayerGraphics>();

        playerGraphics.CTModel = Instantiate(CTPlayerPrefab);
        playerGraphics.TModel  = Instantiate(TPlayerPrefab);

        playerGraphics.CTModel.transform.parent = playerGraphics.TModel.transform.parent = playerModelClone.transform;

        if (player.Team == Team.CounterTerrorist)
        {
            playerGraphics.TModel.SetActive(false);
        }
        else
        {
            playerGraphics.CTModel.SetActive(false);
        }

        playerModelClone.name = "Player " + player.SteamID;

        playerGraphics.Tickrate = GraphicsManager.Instance.Tickrate;
        playerGraphics.NameTag.GetComponent <TextMesh>().text = player.Name;

        return(playerGraphics);
    }
Exemplo n.º 3
0
        public void AddPlayer(PartialPlayer player)
        {
            var playerInfoPanel = Instantiate(_playerInfoPanelPrefab, transform).GetComponent <PlayerInfoPanel>();

            playerInfoPanel.Initialize(player, transform);

            _playerPanels.Add(playerInfoPanel);
        }
Exemplo n.º 4
0
        public void AddPlayer(PartialPlayer player)
        {
            if (player.IsBot || player.Team == Team.Spectate)
            {
                return;
            }

            var teamPanel = _teamPanels.First(t => t.CurrentFaction == player.Team);

            teamPanel.AddPlayer(player);
        }
Exemplo n.º 5
0
        public List <PartialPlayer> PlayerSearch(string query)
        {
            var stored     = (bool?)System.Web.HttpContext.Current.Cache["PlayerListStored"] ?? false;
            var playerList = new List <PartialPlayer>();

            if (stored)
            {
                playerList = (List <PartialPlayer>)System.Web.HttpContext.Current.Cache["SearchPlayerList"];
            }
            else
            {
                string physialpath = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "Scripts", "static", "players.json");
                var    url         = new Uri(physialpath);
                string playersList;
                using (var wc = new WebClient())
                {
                    playersList = wc.DownloadString(url);
                }
                var json = JArray.Parse(playersList);
                foreach (var e in json)
                {
                    var partialPlayer = new PartialPlayer(e.Value <string>("id"),
                                                          e.Value <int>("Overall"),
                                                          e.Value <string>("FirstName"),
                                                          e.Value <string>("LastName"),
                                                          e.Value <string>("Position"),
                                                          e.Value <int>("TradeValue"),
                                                          e.Value <double>("Potential"),
                                                          e.Value <string>("PotentialColorString"),
                                                          e.Value <int>("PotentialColor"));
                    playerList.Add(partialPlayer);
                }

                System.Web.HttpContext.Current.Cache.Insert("SearchPlayerList", playerList);
                System.Web.HttpContext.Current.Cache.Insert("PlayerListStored", true);
            }

            query = query.ToUpper();
            return(playerList.Where(p => p.LastName.ToUpper().StartsWith(query) ||
                                    p.FirstName.ToUpper().StartsWith(query))
                   .OrderBy(k => k.Overall)
                   .Reverse()
                   .Take(10)
                   .ToList());
        }
    // Use this for initialization
    void Start()
    {
        playerAttributes = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAttributes>();

        WWWForm form = new WWWForm();

        form.AddField("score", 0);

        WWW www = new WWW(uri, form);

        while (!www.isDone)
        {
        }
        PartialPlayer partialPlayer = JsonUtility.FromJson <PartialPlayer>(www.text);

        playerAttributes.ID   = partialPlayer._id;
        playerAttributes.Name = partialPlayer.name;
    }
 public void EnsureCorrectPlayerModel(PartialPlayer player)
 {
     if (player.Team == Team.CounterTerrorist)
     {
         CTModel.SetActive(true);
         TModel.SetActive(false);
         if (_ctGraphicsSource == null)
         {
             _ctGraphicsSource = CTModel.GetComponent <PlayerGraphicsSource>();
         }
         _currentPlayerGraphicsSource = _ctGraphicsSource;
     }
     else
     {
         CTModel.SetActive(false);
         TModel.SetActive(true);
         if (_tGraphicsSource == null)
         {
             _tGraphicsSource = TModel.GetComponent <PlayerGraphicsSource>();
         }
         _currentPlayerGraphicsSource = _tGraphicsSource;
     }
 }
 public void Initialize(PartialPlayer player, Transform parentPanel)
 {
     _steamId      = player.SteamID;
     NameText.text = player.Name;
 }
 private void UpdateHealth(PartialPlayer player)
 {
     HealthText.text      = player.Health.ToString();
     Background.sizeDelta = new Vector2((float)player.Health / 100 * _startWidth, Background.sizeDelta.y);
 }