private void makeNewAvatar(TcpClient pClient)
    {
        int avatarID = lastAvatarID++;

        float randomAngle    = rand.Next(minSpawnAngle, maxSpawnAngle) * (float)(Math.PI / 180);
        float randomDistance = rand.Next(0, (int)spawnDistance);

        AvatarObject avatar = new AvatarObject(avatarID, rand.Next(0, 1000), (float)Math.Cos(randomAngle) * randomDistance, 0f, (float)Math.Sin(randomAngle) * randomDistance);

        clientDict.Add(pClient, avatar);
        Console.WriteLine($"{DateTime.Now.ToString("hh:mm:ss")} Added new client to dictionary");

        allAvatars.Add(avatar);

        GetAvatars getAvatars = new GetAvatars();

        getAvatars.AvatarList = allAvatars;

        Console.WriteLine($"{DateTime.Now.ToString("hh:mm:ss")} Generated values for new avatar");
        Console.WriteLine($"	ID: {avatar.id}, skinID: {avatar.skindID}, xPos: {avatar.xPos}, yPos: {avatar.yPos}, zPos: {avatar.zPos}");

        foreach (KeyValuePair <TcpClient, AvatarObject> targetClient in clientDict)
        {
            sendObject(targetClient.Key, getAvatars, targetClient.Value.id);
        }
        Console.WriteLine($"{DateTime.Now.ToString("hh:mm:ss")} Send new avatar to all clients");
    }
    private void ReadAllavatars(JsonData data)
    {
        for (int i = 0; i < data["getData"].Count; i++)
        {
            GetAvatars getAvatars = new GetAvatars();

            getAvatars.avatarID  = int.Parse(data["getData"][i]["avatarID"].ToString());
            getAvatars.avatarURL = data["getData"][i]["avatarURL"].ToString();
            //     getAvatars.Status = data["getData"][i]["Status"].ToString();
            GameObject av = Instantiate(AvatarGO, avatarPrefebs.transform);
            av.GetComponent <SelectAvatar>().urlImage = getAvatars.avatarURL;
            av.GetComponent <SelectAvatar>().avtarid  = getAvatars.avatarID;
        }
    }
Exemple #3
0
 private void handleNewAvatar(GetAvatars pGetAvatars)
 {
     foreach (AvatarObject avatar in pGetAvatars.AvatarList)
     {
         if (_avatarAreaManager.HasAvatarView(avatar.id))
         {
             continue;
         }
         else
         {
             AvatarView avatarView = _avatarAreaManager.AddAvatarView(avatar.id);
             avatarView.transform.localPosition = new Vector3(avatar.xPos, avatar.yPos, avatar.zPos);
             avatarView.SetSkin(avatar.skindID);
             continue;
         }
     }
 }