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");
    }
Beispiel #2
0
 void Start()
 {
     AvatarTools.API_Key    = "AfmJWHbD9khpycyklMR5GSR1j4CSg5Yt";
     AvatarTools.API_Secret = "3Vng4tiwU6zP7Zqetjq0DRdTISQ4CBAO";
     obj = FindObjectOfType <AvatarObject>();
     obj.LoadResultEvent  += (done) => Debug.Log(done ? "加载完成" : "加载失败");
     AvatarDebug.Enable    = true;
     AvatarDebug.LogEvent += (log, stack, type) => Debug.Log(log);
 }