Beispiel #1
0
    JsonCharacter CreateJsonCharacter()
    {
        JsonCharacter jsonCharacter = new JsonCharacter
        {
            IdPersonaje = (JsonContainer.instance.Pcharacter.IdPersonaje == "") ? "0" : JsonContainer.instance.Pcharacter.IdPersonaje,
            IdUsuaio    = (JsonContainer.instance.Pid.IdUsuaio != "") ? JsonContainer.instance.Pid.IdUsuaio : JsonContainer.instance.Pcharacter.IdUsuaio,
            Genero      = (sexElection.sexo == 0) ? "1" : "0",
            Cabello     = (sexElection.sexo == 1) ? selectionFemeleC.NumeroPeloM.ToString() : selectionCharacter.NumeroPelo.ToString(),
            Cara        = (sexElection.sexo == 1) ? selectionFemeleC.NumeroCaraM.ToString() : selectionCharacter.NumeroCara.ToString(),
            Accesorios  = (sexElection.sexo == 1) ? selectionFemeleC.NumeroAccesorioM.ToString() : selectionCharacter.NumeroAccesorio.ToString(),
            Camisa      = (sexElection.sexo == 1) ? selectionFemeleC.NumeroCamisaM.ToString() : selectionCharacter.NumeroCamisa.ToString(),
            Pantalon    = (sexElection.sexo == 1) ? selectionFemeleC.NumeroPantalonM.ToString() : selectionCharacter.NumeroPantalon.ToString(),
            Zapatos     = (sexElection.sexo == 1) ? selectionFemeleC.NumeroZapatoM.ToString() : selectionCharacter.NumeroZapato.ToString(),
            Semillas    = (JsonContainer.instance.Pid.IdUsuaio != "") ? "0" : JsonContainer.instance.Pcharacter.Semillas,
            Old         = JsonContainer.instance.Pcharacter.Old
        };

        Texture2D texture = new Texture2D(512, 512, TextureFormat.RGB24, false);

        RenderTexture.active = photo.PrenderTexture;

        texture.ReadPixels(new Rect(0, 0, photo.PrenderTexture.width, photo.PrenderTexture.height), 0, 0);

        texture.Apply();

        jsonCharacter.FotoPerfil = Convert.ToBase64String(texture.EncodeToPNG());

        return(jsonCharacter);
    }
        public listCharacters()
        {
            this.Name = "listCharacters";

            this.Idle = new UIIdleList()
            {
                Float           = Float.TOP_CENTER,
                Width           = Styles.Width_Page,
                Height          = Styles.Height_Page,
                BackgroundColor = Media.colorGreyExtraLight,
                MaxItems        = 50,
                FurtherAccess   = true
            };

            this.OnPopulate = (index, item) =>
            {
                if (item.type == "heading")
                {
                    return(Item_Heading(index, item));
                }

                if (item.type == "character")
                {
                    return(Item_Character(index, item));
                }

                return(null);
            };

            this.OnTouchInitialization = (list) =>
            {
                return(new List <OnTouchListener>()
                {
                    new OnTouchListener()
                    {
                        Owner = list.Name,
                        Target = "%imgAvatar",
                        Enabled = true,
                        Released = true,
                        OnRelease = (go) =>
                        {
                            new Suspender()
                            {
                                Suspension = 0.05f,
                                OnFinish = () =>
                                {
                                    if (list.ScrollingDown || list.ScrollingUp)
                                    {
                                        return;
                                    }

                                    Directives.Sense_Touch = false;

                                    int index = int.Parse(go.name.Split('_')[1]);
                                    listCharactersItem item = list.Data[index];

                                    JsonCharacter avatar = null;

                                    if (go.name.Contains("Left"))
                                    {
                                        avatar = item.character;
                                    }
                                    else if (go.name.Contains("Right"))
                                    {
                                        avatar = item.character2;
                                    }

                                    new StateBroadcaster()
                                    {
                                        Material = new StateBroadcasterMaterial()
                                        {
                                            State = "Tick_Hide"
                                        },
                                        OnFinish = () =>
                                        {
                                            UIText txtAvatarsNext = Variables.UI["txtAvatarsNext"] as UIText;

                                            if (Variables.Current_Mojo.soundtrack == null)
                                            {
                                                txtAvatarsNext.Element.text = "OK, let's select sound...";
                                            }
                                            else
                                            {
                                                txtAvatarsNext.Element.text = "OK, let's leave a message...";
                                            }

                                            new StateBroadcaster()
                                            {
                                                Material = new StateBroadcasterMaterial()
                                                {
                                                    State = "Tick_Show_" + index + "_" + avatar.pk
                                                },
                                                OnFinish = () =>
                                                {
                                                    Variables.Current_Mojo.character = avatar;

                                                    if (Variables.Current_Mojo.soundtrack == null)
                                                    {
                                                        new UIPageRenderer <listSoundtracksItem>()
                                                        {
                                                            Material = new UIPageRendererMaterial <listSoundtracksItem>()
                                                            {
                                                                Page = new pageSoundtracks(UIDirection.FROM_RIGHT, UIPageHeight.TALL),
                                                                List = "listSoundtracks",
                                                                ListUrl = Config.URLs.Soundtracks_Page,
                                                                OnConversion = Conversions.Soundtracks,
                                                                FromCache = true
                                                            }
                                                        }
                                                        .Render();
                                                    }
                                                    else
                                                    {
                                                        new UIPageRenderer <listItem>()
                                                        {
                                                            Material = new UIPageRendererMaterial <listItem>()
                                                            {
                                                                Page = new pageMessage(UIDirection.FROM_RIGHT, UIPageHeight.TALL)
                                                            }
                                                        }
                                                        .Render();
                                                    }
                                                }
                                            }
                                            .Broadcast();
                                        }
                                    }
                                    .Broadcast();
                                }
                            }
                            .Suspend();
                        }
                    }
                });
            };
        }
        public listMain()
        {
            this.Name = "listMain";

            this.Idle = new UIIdleList()
            {
                Float           = Float.TOP_CENTER,
                Width           = Styles.Width_Page,
                Height          = Styles.Height_Page,
                BackgroundColor = Media.colorGreyExtraLight,
                MaxItems        = 50,
                FurtherAccess   = true
            };

            this.OnPopulate = (index, item) =>
            {
                if (item.type == "heading")
                {
                    return(Item_Heading(index, item));
                }

                if (item.type == "character")
                {
                    return(Item_Character(index, item));
                }

                if (item.type == "soundtrack")
                {
                    return(Item_Soundtrack(index, item));
                }

                return(null);
            };

            this.OnTouchInitialization = (list) =>
            {
                return(new List <OnTouchListener>()
                {
                    new OnTouchListener()
                    {
                        Owner = list.Name,
                        Target = "%clckHeadingRight_",
                        Enabled = true,
                        Released = true,
                        OnRelease = (go) =>
                        {
                            new Suspender()
                            {
                                Suspension = 0.05f,
                                OnFinish = () =>
                                {
                                    if (list.ScrollingDown || list.ScrollingUp)
                                    {
                                        return;
                                    }

                                    Directives.Sense_Touch = false;

                                    int index = int.Parse(go.name.Split('_')[1]);

                                    Variables.Current_Mojo = new JsonMojo()
                                    {
                                        message = ""
                                    };

                                    if (index == 0)
                                    {
                                        Events.OnTouch_Listeners.FirstOrDefault(e => e.Target == "%clckBottom_").Enabled = false;

                                        new UIPageRenderer <listCharactersItem>()
                                        {
                                            Material = new UIPageRendererMaterial <listCharactersItem>()
                                            {
                                                Page = new pageCharacters(UIDirection.FROM_RIGHT, UIPageHeight.TALL),
                                                List = "listCharacters",
                                                ListUrl = Config.URLs.Characters_Page,
                                                ListFields = new Dictionary <string, string>()
                                                {
                                                    { "soundtrackFk", "0" }
                                                },
                                                OnConversion = Conversions.Characters,
                                                FromCache = true
                                            }
                                        }
                                        .Render();
                                    }
                                    else
                                    {
                                        Events.OnTouch_Listeners.FirstOrDefault(e => e.Target == "%clckBottom_").Enabled = false;

                                        new UIPageRenderer <listSoundtracksItem>()
                                        {
                                            Material = new UIPageRendererMaterial <listSoundtracksItem>()
                                            {
                                                Page = new pageSoundtracks(UIDirection.FROM_RIGHT, UIPageHeight.TALL),
                                                List = "listSoundtracks",
                                                ListUrl = Config.URLs.Soundtracks_Page,
                                                ListFields = new Dictionary <string, string>()
                                                {
                                                    { "characterFk", "0" }
                                                },
                                                OnConversion = Conversions.Soundtracks,
                                                FromCache = true
                                            }
                                        }
                                        .Render();
                                    }
                                }
                            }
                            .Suspend();
                        }
                    },
                    new OnTouchListener()
                    {
                        Owner = list.Name,
                        Target = "%imgMainAvatar",
                        Enabled = true,
                        Released = true,
                        OnRelease = (go) =>
                        {
                            new Suspender()
                            {
                                Suspension = 0.05f,
                                OnFinish = () =>
                                {
                                    if (list.ScrollingDown || list.ScrollingUp)
                                    {
                                        return;
                                    }

                                    Directives.Sense_Touch = false;

                                    int index = int.Parse(go.name.Split('_')[1]);
                                    listMainItem item = list.Data[index];

                                    JsonCharacter character = null;

                                    if (go.name.Contains("Left"))
                                    {
                                        character = item.character;
                                    }
                                    else if (go.name.Contains("Right"))
                                    {
                                        character = item.character2;
                                    }

                                    Variables.Current_Mojo = new JsonMojo()
                                    {
                                        character = character, message = ""
                                    };

                                    new UIPageRenderer <listSoundtracksItem>()
                                    {
                                        Material = new UIPageRendererMaterial <listSoundtracksItem>()
                                        {
                                            Page = new pageSoundtracks(UIDirection.FROM_RIGHT, UIPageHeight.TALL),
                                            List = "listSoundtracks",
                                            ListUrl = Config.URLs.Soundtracks_Page,
                                            ListFields = new Dictionary <string, string>()
                                            {
                                                { "characterFk", character.pk.ToString() }
                                            },
                                            OnConversion = Conversions.Soundtracks,
                                            FromCache = true
                                        }
                                    }
                                    .Render();
                                }
                            }
                            .Suspend();
                        }
                    },
                    new OnTouchListener()
                    {
                        Owner = list.Name,
                        Target = "%listMainItem_",
                        Enabled = true,
                        Released = true,
                        OnRelease = (go) =>
                        {
                            new Suspender()
                            {
                                Suspension = 0.05f,
                                OnFinish = () =>
                                {
                                    if (list.ScrollingDown || list.ScrollingUp)
                                    {
                                        return;
                                    }

                                    Directives.Sense_Touch = false;

                                    int index = int.Parse(go.name.Split('_')[1]);

                                    if (index <= 3)
                                    {
                                        return;
                                    }

                                    listMainItem item = list.Data[index];

                                    Variables.Current_Mojo = new JsonMojo()
                                    {
                                        soundtrack = item.soundtrack, message = ""
                                    };

                                    new UIPageRenderer <listCharactersItem>()
                                    {
                                        Material = new UIPageRendererMaterial <listCharactersItem>()
                                        {
                                            Page = new pageCharacters(UIDirection.FROM_RIGHT, UIPageHeight.TALL),
                                            List = "listCharacters",
                                            ListUrl = Config.URLs.Characters_Page,
                                            ListFields = new Dictionary <string, string>()
                                            {
                                                { "soundtrackFk", item.soundtrack.pk.ToString() }
                                            },
                                            OnConversion = Conversions.Characters,
                                            FromCache = true
                                        }
                                    }
                                    .Render();
                                }
                            }
                            .Suspend();
                        }
                    }
                });
            };
        }