void Update()
    {
        int KeyboardSize = Andre.GetKeyboardSize();

        if (currentEventSystem.currentSelectedGameObject != null && KeyboardSize != 0)
        {
            // print ("InputField Name: " + currentEventSystem.currentSelectedGameObject.name + " keyboard: " + Andre.GetKeyboardSize ());
            if (currentEventSystem.currentSelectedGameObject.GetComponent <InputField> () != null && !viewWasResized)
            {
                InputField    iF = currentEventSystem.currentSelectedGameObject.GetComponent <InputField> ();
                RectTransform rT = iF.GetComponent <RectTransform> ();

                float iFBasePoint = iF.transform.position.y - (rT.rect.size.y / 2) - keyboardOffset;
                Andre.Log("Offset: " + iFBasePoint);

                if (iFBasePoint < KeyboardSize)
                {
                    float offset = KeyboardSize - iFBasePoint + keyboardOffset;
                    // Debug.Log ("Should resize view");
                    viewWasResized = true;
                    lastIF         = iF;

                    ScrollRect[] scrolls = FindObjectsOfType(typeof(ScrollRect)) as ScrollRect[];
                    foreach (ScrollRect s in scrolls)
                    {
                        s.enabled = false;
                    }

                    Transform p = iF.transform.parent;
                    lastPPos = p.position;
                    StartCoroutine(moveTo(p, new Vector3(p.position.x, p.position.y + offset, p.position.z)));
                }
                else if (KeyboardSize == 0)
                {
                    // Debug.Log("Not visible but keyboard not shown");
                    Transform p = lastIF.transform.parent;
                    p.position     = lastPPos;
                    viewWasResized = false;
                }
                else
                {
                    // Debug.Log ("Input field is visible");
                }
            }
        }
        else if (viewWasResized)
        {
            ScrollRect[] scrolls = FindObjectsOfType(typeof(ScrollRect)) as ScrollRect[];
            foreach (ScrollRect s in scrolls)
            {
                s.enabled = true;
            }
            Transform p = lastIF.transform.parent;
            StartCoroutine(moveTo(p, lastPPos));
            viewWasResized = false;
        }
    }
Beispiel #2
0
    private IEnumerator corout_GetEncuesta()
    {
        Dictionary <string, string> headers = new Dictionary <string, string> ();

        headers.Add("Content-Type", "application/json");
        headers.Add("Cookie", "Interceramic");
        headers.Add("Authorization", "Bearer " + token.Token);
        headers.Add("pClaveApp", claveApp);

        WWW www = new WWW(GetEncuestaURL, null, headers);

        yield return(www);

        Andre.Log("Encuesta resp: " + www.text);

        encuesta     = JsonUtility.FromJson <EncuestaJ> (www.text);
        PreguntasRef = new List <GameObject> ();

        foreach (Pregunta p in encuesta.PREGUNTAS)
        {
            switch (p.TIPO)
            {
            case "CO": {
                GameObject pregunta = GameObject.Instantiate(ComentarioPrefab);
                pregunta.GetComponent <Comentario> ().Pregunta.text = p.PREGUNTA;
                pregunta.GetComponent <Comentario> ().Id            = p.PREG_ID;
                pregunta.GetComponent <Comentario> ().detopcion_id  = p.RESPUESTAS[0].DETOPCION_ID;
                pregunta.transform.SetParent(Content.transform, false);

                PreguntasRef.Add(pregunta);
                break;
            }

            case "OM": {
                GameObject pregunta = GameObject.Instantiate(OpcionMultiplePrefab);
                pregunta.GetComponent <OpcionMultiple> ().Pregunta.text = p.PREGUNTA;
                pregunta.GetComponent <OpcionMultiple> ().Id            = p.PREG_ID;

                int i = 0;
                foreach (Respuesta r in p.RESPUESTAS)
                {
                    pregunta.GetComponent <OpcionMultiple> ().RespsIds [i++] = r.DETOPCION_ID;
                }
                pregunta.transform.SetParent(Content.transform, false);

                PreguntasRef.Add(pregunta);
                break;
            }
            }
        }

        MainCanvas.hidePopUp(2);
        MainCanvas.popUps [2].GetComponent <LoadingManager> ().stopSpinning();
    }
Beispiel #3
0
    private IEnumerator corout_SendEncuesta()
    {
        Dictionary <string, string> headers = new Dictionary <string, string> ();

        headers.Add("Content-Type", "application/json");
        headers.Add("Cookie", "Interceramic");
        headers.Add("Authorization", "Bearer " + token.Token);
        headers.Add("pClaveApp", claveApp);

        RespuestaJ resp = new RespuestaJ();

        resp.contacto_id    = PlayerPrefs.GetInt("UserId");
        resp.claveApp       = claveApp;
        resp.detencuesta_id = encuesta.DETENCUESTA_ID;
        RespuestasArrJ[] respuestas = new RespuestasArrJ[PreguntasRef.Count];
        for (int i = 0; i < PreguntasRef.Count; i++)
        {
            respuestas[i] = new RespuestasArrJ();
            if (PreguntasRef[i].GetComponent <Comentario> () != null)
            {
                respuestas[i].preg_id      = PreguntasRef[i].GetComponent <Comentario> ().Id;
                respuestas[i].detopcion_id = PreguntasRef[i].GetComponent <Comentario> ().detopcion_id;
                respuestas[i].comentario   = PreguntasRef[i].GetComponent <Comentario> ().comentario;
            }
            else
            {
                respuestas[i].preg_id      = PreguntasRef[i].GetComponent <OpcionMultiple> ().Id;
                respuestas[i].detopcion_id = PreguntasRef[i].GetComponent <OpcionMultiple> ().detopcion_id;
            }
        }
        resp.respuestas = respuestas;

        string SData = JsonUtility.ToJson(resp);

        byte[] JData = Encoding.ASCII.GetBytes(SData.ToCharArray());

        WWW www = new WWW(SendEncuestaURL, JData, headers);

        yield return(www);

        Andre.Log("Encuesta resp: " + www.text);

        MainCanvas.hidePopUp(2);
        MainCanvas.popUps [2].GetComponent <LoadingManager> ().stopSpinning();

        MainCanvas.GetComponent <LogIn> ().logInNotSuccess("Agradecemos tus comentarios");
        MainCanvas.GetComponent <ViewsManager> ().esconderEncuesta();
    }
Beispiel #4
0
    public IEnumerator RutinaConsultar()
    {
        WWWForm form = new WWWForm();

        foreach (ListaElementos listelem in Elementos)
        {
            form.AddField(listelem.NombreCampo,
                          (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Float)) ?
                          listelem.Flotante.ToString() : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.InputField)) ?
                          listelem.CadenaEntrada.text : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Int)) ?
                          listelem.Entero.ToString() : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.String)) ?
                          listelem.Cadena : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Toggle)) ?
                          ((listelem.Togleador.isOn) ? "1" : "0") : listelem.TextoFijo.text
                          );

            Andre.Log("Agregando campo " + listelem.NombreCampo);
        }

        WWW www = new WWW(DireccionAPI);

        yield return(www);


        if (www.error == null)
        {
            Andre.Log(www.text);

            Resultado = www.text;


            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError [i]))
                {
                    CasoDeError = i;
                    EventoError.Invoke();
                    yield return(null);
                }
            }


            for (int i = 0; i < CasosVacio.Length; i++)
            {
                if (www.text.Contains(CasosVacio [i]))
                {
                    EventoVacio.Invoke();
                    break;
                }
            }



            if (CasosExito.Length == 0)
            {
                EventoExito.Invoke();
            }
            else
            {
                for (int i = 0; i < CasosExito.Length; i++)
                {
                    if (www.text.Contains(CasosExito [i]))
                    {
                        EventoExito.Invoke();
                        break;
                    }
                }
            }
        }
        else
        {
            Andre.Log(www.error);
            Resultado = www.error;
            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError [i]))
                {
                    EventoError.Invoke();
                    break;
                }
            }
        }
    }
Beispiel #5
0
    public IEnumerator RutinaConsultaImagenHeaders()
    {
        WWWForm form = new WWWForm();

        byte[] Datos;


        if (Elementos.Count > 0)
        {
            string CadenaConsulta = "{\n";

            foreach (ListaElementos listelem in Elementos)
            {
                string Campo = (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Float)) ?
                               listelem.Flotante.ToString() : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.InputField)) ?
                               listelem.CadenaEntrada.text : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Int)) ?
                               listelem.Entero.ToString() : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.String)) ?
                               listelem.Cadena : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Toggle)) ?
                               ((listelem.Togleador.isOn) ? "1" : "0") : listelem.TextoFijo.text;

                form.AddField(listelem.NombreCampo, Campo);
            }

            Datos = form.data;
        }
        else
        {
            Datos = null;
        }


        Dictionary <string, string> headers = new Dictionary <string, string>();

        for (int i = 0; i < Cabeceras.Count; i++)
        {
            headers.Add(Cabeceras[i], Valores[i]);
        }

        WWW www = new WWW(DireccionAPI, Datos, headers);

        yield return(www);

        if (www.error == null)
        {
            //Andre.Log(this.name + www.text);

            Resultado = www.text;

            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError [i]))
                {
                    CasoDeError = i;
                    EventoError.Invoke();
                    goto salida;
                }
            }

            for (int i = 0; i < CasosVacio.Length; i++)
            {
                if (www.text.Contains(CasosVacio [i]))
                {
                    Andre.Log(this.name + " esta vacio porque tiene " + CasosVacio[i]);
                    EventoVacio.Invoke();
                    goto salida;
                }
            }



            if (CasosExito.Length == 0)
            {
                //EventoExito.Invoke();
            }
            else
            {
                for (int i = 0; i < CasosExito.Length; i++)
                {
                    if (www.text.Contains(CasosExito [i]))
                    {
                        //EventoExito.Invoke();
                        break;
                    }
                }
            }
        }
        else
        {
            Andre.Log(this.name + www.error);
            Resultado = www.error;

            EventoError.Invoke();
        }


        if (texturaResultado == null)
        {
            texturaResultado = new Texture2D(1, 1);
        }

        texturaResultado = www.texture;
        texturaResultado.Apply();
        yield return(new WaitForEndOfFrame());

        EventoExito.Invoke();

salida:
        Andre.Log("");
    }
Beispiel #6
0
    public IEnumerator RutinaConsultaHeadersPostRaw(string rawParameter)
    {
        WWWForm form = new WWWForm();


        Dictionary <string, string> headers = new Dictionary <string, string>();

        for (int i = 0; i < Cabeceras.Count; i++)
        {
            headers.Add(Cabeceras[i], Valores[i]);
        }

        Debug.Log(rawParameter);

        var DatosPars = System.Text.Encoding.UTF8.GetBytes(rawParameter);

        WWW www = new WWW(DireccionAPI, DatosPars, headers);

        yield return(www);

        if (www.error == null)
        {
            Andre.Log("<color=white>" + this.name + www.text + "</color>");

            Resultado = www.text;

            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError[i]))
                {
                    CasoDeError = i;
                    EventoError.Invoke();
                    //yield return null;
                    goto salida;
                }
            }

            for (int i = 0; i < CasosVacio.Length; i++)
            {
                if (www.text.Contains(CasosVacio[i]))
                {
                    EventoVacio.Invoke();
                    goto salida;
                }
            }


            if (CasosExito.Length == 0)
            {
                EventoExito.Invoke();
            }
            else
            {
                for (int i = 0; i < CasosExito.Length; i++)
                {
                    if (www.text.Contains(CasosExito[i]))
                    {
                        EventoExito.Invoke();
                        break;
                    }
                }
            }
        }
        else
        {
            Andre.Log(this.name + www.error);
            Resultado = www.error;

            EventoError.Invoke();
        }

salida:
        Andre.Log("Salio de la funcion");
    }
Beispiel #7
0
    public IEnumerator RutinaConsultaHeadersPost()
    {
        WWWForm form = new WWWForm();


        Dictionary <string, string> headers = new Dictionary <string, string>();

        for (int i = 0; i < Cabeceras.Count; i++)
        {
            headers.Add(Cabeceras[i], Valores[i]);
        }

        string CadenaConsulta = ""; // "{\n";

        if (Elementos.Count > 0)
        {
            foreach (ListaElementos listelem in Elementos)
            {
                string Campo = (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Float)) ?
                               listelem.Flotante.ToString() : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.InputField)) ?
                               "\"" + listelem.CadenaEntrada.text + "\"": (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Int)) ?
                               ((listelem.Entero < 0) ? "null" : listelem.Entero.ToString()): (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.String)) ?
                               "\"" + listelem.Cadena + "\"" : (listelem.TiposComparacion.Equals(ListaElementos.FormasComparacion.Toggle)) ?
                               ((listelem.Togleador.isOn) ? "1" : "0") : "\"" + listelem.TextoFijo.text + "\"";

                form.AddField(listelem.NombreCampo, Campo);
                CadenaConsulta = CadenaConsulta + "\t\"" + listelem.NombreCampo + "\"\t: " + Campo + ",\n";

                form.AddField("xml", listelem.Cadena);
            }

            CadenaConsulta = CadenaConsulta + "}";
            CadenaConsulta = CadenaConsulta.Replace(",\n}", "\n}");
            Andre.Log(this.name + CadenaConsulta);
        }



        var DatosPars = form.data; // System.Text.Encoding.UTF8.GetBytes(CadenaConsulta);

        WWW www = new WWW(DireccionAPI, DatosPars, headers);

        yield return(www);

        if (www.error == null)
        {
            Andre.Log("<color=blue>" + this.name + www.text + "</color>");

            Resultado = www.text;

            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError [i]))
                {
                    CasoDeError = i;
                    EventoError.Invoke();
                    //yield return null;
                    goto salida;
                }
            }

            for (int i = 0; i < CasosVacio.Length; i++)
            {
                if (www.text.Contains(CasosVacio [i]))
                {
                    EventoVacio.Invoke();
                    goto salida;
                }
            }


            if (CasosExito.Length == 0)
            {
                EventoExito.Invoke();
            }
            else
            {
                for (int i = 0; i < CasosExito.Length; i++)
                {
                    if (www.text.Contains(CasosExito [i]))
                    {
                        EventoExito.Invoke();
                        break;
                    }
                }
            }
        }
        else
        {
            Andre.Log(this.name + www.error);
            Resultado = www.error;

            EventoError.Invoke();
        }

salida:
        Andre.Log("Salio de la funcion");
    }
Beispiel #8
0
    public IEnumerator RutinaConsultaHeadesYBodyBytes(byte[] Datos)
    {
        Dictionary <string, string> headers = new Dictionary <string, string>();

        for (int i = 0; i < Cabeceras.Count; i++)
        {
            headers.Add(Cabeceras[i], Valores[i]);
        }



        //form.data = Datos;
        //form.headers = headers;
        WWW www = new WWW(DireccionAPI, Datos, headers);

        yield return(www);

        if (www.error == null)
        {
            Andre.Log(this.name + www.text);

            Resultado = www.text;

            for (int i = 0; i < CasosError.Length; i++)
            {
                if (www.text.Contains(CasosError[i]))
                {
                    CasoDeError = i;
                    EventoError.Invoke();
                    goto salida;
                }
            }

            for (int i = 0; i < CasosVacio.Length; i++)
            {
                if (www.text.Contains(CasosVacio[i]))
                {
                    Andre.Log(this.name + " esta vacio porque tiene " + CasosVacio[i]);
                    EventoVacio.Invoke();
                    yield return(null);
                }
            }



            if (CasosExito.Length == 0)
            {
                EventoExito.Invoke();
            }
            else
            {
                for (int i = 0; i < CasosExito.Length; i++)
                {
                    if (www.text.Contains(CasosExito[i]))
                    {
                        EventoExito.Invoke();
                        break;
                    }
                }
            }
        }
        else
        {
            Andre.Log(this.name + www.error);
            Resultado = www.error;

            EventoError.Invoke();
        }


salida:
        Andre.Log("Salio de la funcion");
    }
        override public void create()
        {
            FlxG.backColor = FlxColor.ToColor("dedbc3");
            base.create();

            _world = new World(new Vector2(0, 98.0f));

            charactersGrp   = new FlxGroup();
            blocksGrp       = new FlxGroup();
            movingBlocksGrp = new FlxGroup();
            doors           = new FlxGroup();
            crates          = new FlxGroup();


            //Dictionary<string,string> levelAttrs = FlxXMLReader.readAttributesFromOelFile("ogmo/level1.oel", "level/grid");
            //FlxTilemap tiles = new FlxTilemap();
            //tiles.useExtraMiddleTiles = false;
            //tiles.auto = FlxTilemap.AUTO;
            //tiles.indexOffset = -1;
            //tiles.loadMap(levelAttrs["grid"], FlxG.Content.Load<Texture2D>("level1_tiles"), 10, 10);
            //tiles.setScrollFactors(0, 0);
            //tiles.boundingBoxOverride = true;

            //blocksGrp.add(tiles);

            List <Dictionary <string, string> > lblocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/grid");

            foreach (Dictionary <string, string> nodes in lblocks)
            {
                FarTileblock t = new FarTileblock(Convert.ToInt32(nodes["x"]) + (Convert.ToInt32(nodes["w"]) / 2), Convert.ToInt32(nodes["y"]) + (Convert.ToInt32(nodes["h"]) / 2), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]), _world);
                t.auto = FlxTilemap.AUTO;
                t.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t);
                t._body.BodyType = BodyType.Static;


                FlxTileblock t2 = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]));
                t2.auto = FlxTilemap.AUTO;
                t2.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t2);
            }

            List <Dictionary <string, string> > blocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/tileblocks");

            foreach (Dictionary <string, string> nodes in blocks)
            {
                if (nodes["Name"] == "elevator")
                {
                    MovingBlock block = new MovingBlock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]));
                    block.loadGraphic("level1_specialBlock", false, true, 40, 20);
                    movingBlocksGrp.add(block);

                    FlxPath xpath = new FlxPath(null);
                    xpath.add(Convert.ToInt32(nodes["x"]) + 20, Convert.ToInt32(nodes["y"]) + 10);
                    xpath.addPointsUsingStrings(nodes["pathNodesX"], nodes["pathNodesY"], 20, 10);
                    block.followPath(xpath, 80, FlxObject.PATH_FORWARD, false);
                }
                if (nodes["Name"] == "door")
                {
                    Door door = new Door(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]) - 100);
                    doors.add(door);
                }
                //foreach (var item in nodes)
                //{
                //    Console.WriteLine("{0} {1}", item.Key, item.Value);
                //}
            }
            //bat = new Bat(x, y);
            //actors.add(bat);
            //Console.WriteLine("Building a bat {0} {1} {2} {3}", x, y, PathNodesX, PathNodesY);

            //if (PathNodesX != "" && PathNodesY != "")
            //{
            //    Console.WriteLine("Building a path {0} {1} {2}", PathNodesX, PathNodesY, PathCornering);

            //    FlxPath xpath = new FlxPath(null);
            //    xpath.add(x, y);
            //    xpath.addPointsUsingStrings(PathNodesX, PathNodesY);
            //    bat.followPath(xpath, PathSpeed, PathType, false);
            //    bat.pathCornering = PathCornering;


            //}



            Andre andre = new Andre(0, 0);

            charactersGrp.add(andre);

            Liselot liselot = new Liselot(40, 40);

            charactersGrp.add(liselot);

            Army army = new Army(30, 20);

            charactersGrp.add(army);

            Inspector inspector = new Inspector(50, 50);

            charactersGrp.add(inspector);

            Worker worker = new Worker(60, 60);

            charactersGrp.add(worker);

            Chef chef = new Chef(100, 30);

            charactersGrp.add(chef);


            FlxTileblock bg = new FlxTileblock(0, 0, 240, 800);

            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            bg      = new FlxTileblock(640, 0, 240, 800);
            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            for (int i = 0; i < 5; i++)
            {
                SmallCrate c = new SmallCrate((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(c);
            }

            for (int i = 0; i < 5; i++)
            {
                Bottle b = new Bottle((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(b);
            }
            for (int i = 0; i < 55; i++)
            {
                Fruit f = new Fruit((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100), _world);
                f._body.ApplyLinearImpulse(new Vector2(20, 2120));


                crates.add(f);
            }


            add(doors);
            add(charactersGrp);
            add(blocksGrp);
            add(movingBlocksGrp);
            add(crates);

            FlxG.showHud();
            FlxG.setHudTextPosition(1, FlxG.width / 2, 10);
            FlxG.setHudTextScale(1, 3);
        }