Beispiel #1
0
    public static Color GetRandomColor(Dictionary <int, AvatarColorDefinition> avatarColors)
    {
        System.Random random = new System.Random();
        int[]         array  = new int[avatarColors.Count];
        avatarColors.Keys.CopyTo(array, 0);
        AvatarColorDefinition avatarColorDefinition = avatarColors[array[random.Next(0, array.Length)]];

        if (!ColorUtility.TryParseHtmlString("#" + avatarColorDefinition.Color, out Color color))
        {
            return(AvatarService.DefaultBodyColor);
        }
        return(color);
    }
Beispiel #2
0
 private void loadColorSwatch(AvatarColorDefinition avatarColorDefinition, GameObject colorSwatchPrefab)
 {
     if (avatarColorDefinition != null && ColorUtility.TryParseHtmlString("#" + avatarColorDefinition.Color, out var color))
     {
         avatarColors[avatarColorDefinition.ColorId] = avatarColorDefinition;
         GameObject gameObject = UnityEngine.Object.Instantiate(colorSwatchPrefab);
         PenguinProfileColorSwatch component = gameObject.GetComponent <PenguinProfileColorSwatch>();
         component.OnClicked = (Action <int>)Delegate.Combine(component.OnClicked, new Action <int>(onColorSwatchClicked));
         component.SetColor(avatarColorDefinition.ColorId, color, avatarColorDefinition.ColorName);
         gameObject.transform.SetParent(ColorGrid, worldPositionStays: false);
     }
     else
     {
         Log.LogError(this, "AvatarColorDefinition did not contain a valid color");
     }
 }
    public override IEnumerator PerformFirstPass()
    {
        AssetRequest <AvatarDefinition> avatarRequest = Content.LoadAsync(AvatarDefinitionKey);

        yield return(avatarRequest);

        AssetRequest <AvatarDefinition> mannequinAvatarRequest = Content.LoadAsync(MannequinAvatarDefinitionKey);

        yield return(mannequinAvatarRequest);

        AvatarColorDefinition defaultColorDefinition = Service.Get <GameData>().Get <Dictionary <int, AvatarColorDefinition> >()[0];

        if (ColorUtility.TryParseHtmlString("#" + defaultColorDefinition.Color, out Color bodyColor))
        {
            avatarRequest.Asset.BodyColor.BodyColor = bodyColor;
        }
        AvatarService avatarService = new AvatarService(new AvatarDefinition[2]
        {
            avatarRequest.Asset,
            mannequinAvatarRequest.Asset
        });

        Service.Set(avatarService);
        AvatarOutfitCombineManager.UseGpuSkinning = UseGpuSkinning;
        AvatarOutfitCombineManager.CombineLocal   = CombineLocal;
        AvatarOutfitCombineManager.CombineRemote  = CombineRemote;
        ManifestContentKey      key          = StaticGameDataUtils.GetManifestContentKey(typeof(TemporaryHeadStatusDefinition));
        AssetRequest <Manifest> assetRequest = Content.LoadAsync(key);

        yield return(assetRequest);

        Manifest manifest = assetRequest.Asset;

        ScriptableObject[] assets = manifest.Assets;
        foreach (ScriptableObject scriptableObject in assets)
        {
            TemporaryHeadStatusDefinition temporaryHeadStatusDefinition = (TemporaryHeadStatusDefinition)scriptableObject;
            HeadStatusView.HeadStatusToDefinition[temporaryHeadStatusDefinition.Type] = temporaryHeadStatusDefinition;
        }
    }