Esempio n. 1
0
        public bool HasSmiley(Smiley smiley)
        {
            var pack = BlockServices.GetPackage(smiley);
            if (pack == null) return true;

            return this._itemCounts.ContainsKey(pack);
        }
Esempio n. 2
0
        public string GetSmileyImageFor(Smiley smiley)
        {
            string image = SmileyOption.GetImageForSmiley(smiley);

            if (this.ChosenSmiley == smiley)
            {
                return image;
            }

            return image.Insert(image.IndexOf("."), "_g");
        }
Esempio n. 3
0
 public static string GetTextForSmiley(Smiley smiley)
 {
     switch (smiley)
     {
         case Smiley.None:
             return "Geen gezichtje";
         case Smiley.VeryGood:
             return "Zeer goed";
         case Smiley.Good:
             return "Goed";
         case Smiley.Sufficient:
             return "Voldoende";
         case Smiley.Insufficient:
             return "Onvoldoende";
         case Smiley.Weak:
             return "Zwak";
         default:
             return "Ongeldige waarde";
     }
 }
Esempio n. 4
0
 public static string GetImageForSmiley(Smiley smiley)
 {
     switch (smiley)
     {
         case Smiley.None:
             return "smiley_none.png";
         case Smiley.VeryGood:
             return "smiley_verygood.png";
         case Smiley.Good:
             return "smiley_good.png";
         case Smiley.Sufficient:
             return "smiley_sufficient.png";
         case Smiley.Insufficient:
             return "smiley_insufficient.png";
         case Smiley.Weak:
             return "smiley_weak.png";
         default:
             return "smiley_none.png";
     }
 }
Esempio n. 5
0
 // Fills map with jewels
 void FillMap()
 {
     for (int i = 0; i < rows; i++)
     {
         for (int j = 0; j < columns; j++)
         {
             if (smileys[i, j] == null)
             {
                 Vector2 smileyPos = new Vector2(1 + i + gap + i * gap, -3 + j + gap + j * gap);
                 for (int x = 0; x < smileyPool.Count; x++)
                 {
                     GameObject o = smileyPool[x];
                     if (!o.activeSelf)
                     {
                         o.transform.position = smileyPos;
                         o.SetActive(true);
                         smileys[i, j] = new Smiley(o, o.name);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 public void ChangeFace(Smiley newSmiley)
 {
     this.Events.Raise(new ChangeFaceSendEvent(newSmiley));
 }
Esempio n. 7
0
 public ChangeFaceSendEvent(Smiley face)
 {
     this.Face = face;
 }
Esempio n. 8
0
        private static async Task <Editor> Fetch(EditorPackage package)
        {
            if (string.IsNullOrEmpty(package.PostUriForm))
            {
                return(null);
            }
            var html = await HttpClientHelper.Get(package.PostUriForm);

            HtmlNode.ElementsFlags.Remove("form");

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            HtmlNode formNode = htmlDoc.DocumentNode.Descendants("form").First(x => (string)x.GetAttributeValue("id", "") == "hop");

            //Submit URL
            string submitUrl = formNode.GetAttributeValue("action", "");

            //All inputs/select data
            Dictionary <string, string> formInputs = new Dictionary <string, string>();

            foreach (HtmlNode node in formNode.Descendants("input"))
            {
                if (node.GetAttributeValue("value", "") != "" && node.GetAttributeValue("name", "") != "")
                {
                    if (node.GetAttributeValue("name", "") == "MsgIcon")
                    {
                        // Message' icon - Only if checked
                        if (node.GetAttributeValue("checked", "") == "checked")
                        {
                            formInputs.Add(node.GetAttributeValue("name", ""), node.GetAttributeValue("value", ""));
                        }
                    }
                    else if (node.GetAttributeValue("type", "") == "checkbox")
                    {
                        // Checkboxes
                        formInputs.Add(node.GetAttributeValue("name", ""), node.GetAttributeValue("checked", "") == "checked" ? "1" : "0");
                    }
                    else
                    {
                        try
                        {
                            formInputs.Add(node.GetAttributeValue("name", ""), node.GetAttributeValue("value", ""));
                        }
                        catch (Exception)
                        {
                            Debug.WriteLine("ext0 =" + node.GetAttributeValue("name", "") + "," + node.GetAttributeValue("value", ""));
                            throw;
                        }
                    }
                }
            }

            foreach (HtmlNode node in formNode.Descendants("select"))
            {
                if (node.GetAttributeValue("name", "") == "subcat")
                {
#warning "Categories list used to select/change FP category not implemented"
                }

                // add Selected category (on edit), or first one if none selected.
                HtmlNode selectedNode = node
                                        .Descendants("option")
                                        .FirstOrDefault(x => (string)x.GetAttributeValue("selected", "") == "selected");

                if (selectedNode != null)
                {
                    formInputs.Add(node.GetAttributeValue("name", ""), selectedNode.GetAttributeValue("value", ""));
                }
                else
                {
                    formInputs.Add(node.GetAttributeValue("name", ""), node.Descendants("option").First().GetAttributeValue("value", " "));
                }
            }

            foreach (HtmlNode node in formNode.Descendants("textarea"))
            {
                formInputs.Add(node.GetAttributeValue("name", ""), WebUtility.HtmlDecode(node.InnerText) + Environment.NewLine);
            }

            var smileys = new List <Smiley>();
            foreach (HtmlNode node in formNode.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "smiley" || x.GetAttributeValue("class", "") == "dynamic_smilies")?.Descendants("img"))
            {
                var url = node.GetAttributeValue("src", "");
                var tag = node.GetAttributeValue("title", "");
                if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(tag))
                {
                    var smiley = new Smiley(url, tag);
                    smileys.Add(smiley);
                }
            }


            //Debug.WriteLine("Parsing OK");

            //foreach (KeyValuePair<string, string> entry in formInputs)
            //{
            //    Debug.WriteLine("inputs = " + entry.Key + " " + entry.Value);
            //}

            // Populate with multi quote temporary content if found and that content_form is empty
            var content = "";
            if (formInputs.TryGetValue("content_form", out content))
            {
                if (string.IsNullOrEmpty(content.CleanFromWeb()))
                {
                    if (!string.IsNullOrEmpty(Loc.Editor.MultiQuoteTemporaryContent))
                    {
                        formInputs["content_form"]            = Loc.Editor.MultiQuoteTemporaryContent;
                        Loc.Editor.MultiQuoteTemporaryContent = null;
                    }
                }
            }

            return(new Editor
            {
                FromUrl = package.PostUriForm,
                SubmitUrl = submitUrl,
                Data = formInputs,
                idxTopic = 0,
                Intent = package.Intent,
                Smileys = smileys
            });
        }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        if (smiley1 && Input.GetMouseButtonDown(0))
        {
            //Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            lastClick = Input.mousePosition;
            //Debug.DrawRay (ray.origin, ray.direction, Color.green);
            //RaycastHit2D hit = Physics2D.GetRayIntersection(ray, 1000);
            RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero);
            Debug.Log("Worldpoint:" + worldPoint);
            if (hit)
            {
                if (hit.collider == null)
                {
                    return;
                }
                GameObject collidedGO = hit.collider.gameObject;
                if (hit && collidedGO && collidedGO != smiley1 && collidedGO.tag == "Smiley")
                {
                    smiley2 = collidedGO;
                    smiley1.transform.localScale -= new Vector3(expandSmiley, expandSmiley, 0);
                    Vector2 tempPos = smiley1.transform.position;
                    // string tempName = smiley1.name;
                    smiley1.transform.position = smiley2.transform.position;
                    // smiley1.name = smiley2.name;
                    smiley2.transform.position = tempPos;
                    // smiley2.name = tempName;

                    //finding which smileys[r, c] has smiley1 (and then smiley2) to change it in the matrix
                    //it's a terrible code, I know, but it was 2a.m. and I was really sleepy
                    int r1 = 0, c1 = 0;
                    for (int r = 0; r < rows; r++)
                    {
                        for (int c = 0; c < columns; c++)
                        {
                            if (smileys[r, c] != null && smileys[r, c].gameObject == smiley1)
                            {
                                r1 = r;
                                c1 = c;
                            }
                        }
                    }

                    for (int r = 0; r < rows; r++)
                    {
                        for (int c = 0; c < columns; c++)
                        {
                            if (smileys[r, c] != null && smileys[r, c].gameObject == smiley2)
                            {
                                Smiley s = smileys[r1, c1];
                                smileys[r1, c1] = smileys[r, c];
                                smileys[r, c]   = s;
                            }
                        }
                    }


                    smiley1 = null;
                    smiley2 = null;

                    CheckCollision();
                }
                else if (hit && hit.collider.gameObject)
                {   //same smiley
                    smiley1.transform.localScale -= new Vector3(expandSmiley, expandSmiley, 0);
                    smiley1 = null;
                }
            }
        }
        else if (Input.GetMouseButtonDown(0))
        {
            //Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            lastClick = Input.mousePosition;
            //Debug.DrawRay (ray.origin, ray.direction, Color.green);
            //RaycastHit2D hit = Physics2D.GetRayIntersection(ray, 1000);
            RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero);
//			canvas.GetComponent<HintCreator> ().createText ("HUEHUEHUEHUE", Color.blue, Input.mousePosition);
//			Debug.Log ("Worldpoint:" + worldPoint);
//			Debug.Log ("Viewport:" + Camera.main.ScreenToViewportPoint(Input.mousePosition));
//			Debug.Log ("MousePosition:" + Input.mousePosition);
//			Debug.Log ("Raypos:" + Camera.main.ScreenPointToRay(Input.mousePosition));
//				Debug.Log ("WorldtoScreenpoint:" + Camera.main.WorldToScreenPoint(worldPoint));
            if (hit)
            {
                GameObject collidedGO = hit.collider.gameObject;
                if (collidedGO && collidedGO.tag == "Smiley")
                {
                    smiley1 = hit.collider.gameObject;
                    smiley1.transform.localScale += new Vector3(expandSmiley, expandSmiley, 0);
                }
            }
        }
    }
Esempio n. 10
0
    void MoveSmileys()
    {
        bool anyMoved = false;

        ShufflePool();

        // for (int r = 0; r < rows; r++)
        //  for (int c = 0 ; c < columns; c++)
        //      if (smileys[c, r] == null){
        //          Vector2 smileyPos = new Vector2(r + gap + r * gap, c + gap + c * gap);
        //          for (int n = 0; n < smileyPool.Count; n++){
        //              GameObject o = smileyPool[n];
        //              if (!o.activeSelf){
        //                  o.transform.position = smileyPos;
        //                  o.SetActive(true);
        //                  smileys[r, c] = new Smiley(o, o.name);
        //              }
        //          }
        //      }

        // FillMap();

        for (int r = 1; r < rows; r++)
        {
            for (int c = 0; c < columns; c++)
            {
                if (smileys[c, r] != null && smileys[c, r - 1] == null)
                {
                    smileys[c, r - 1] = smileys[c, r];
                    smileys[c, r - 1].gameObject.transform.position = new Vector3(1 + c + gap + c * gap, -3 + r - 1 + gap + (r - 1) * gap, 0);
                    smileys[c, r] = null;
                    anyMoved      = true;
                }
                if (r == rows - 1 && smileys[c, r] == null)
                {
                    anyMoved = true;
                    Vector2 smileyPos = new Vector2(1 + c + gap + c * gap, -3 + r + gap + r * gap);
                    for (int n = 0; n < smileyPool.Count; n++)
                    {
                        GameObject o = smileyPool[n];
                        if (!o.activeSelf)
                        {
                            o.transform.position = smileyPos;
                            o.SetActive(true);
                            smileys[c, r] = new Smiley(o, o.name);
                            break;
                        }
                    }
                }
            }
        }

        if (anyMoved)
        {
            Invoke("MoveSmileys", 0.5f);
        }
        else
        {
            CheckCollision();
        }
    }
Esempio n. 11
0
    void CheckCollision()
    {
        bool hasCollision = false;

        //checking rows
        for (int r = 0; r < rows; r++)
        {
            int counter = 1;
            for (int c = 1; c < columns; c++)
            {
                Smiley s1 = smileys[r, c], s2 = smileys[r, c - 1];
                if (s1 != null && s2 != null && s1.name == s2.name)
                {
                    counter++;
                }
                else
                {
                    counter = 1;
                }

                if (counter >= 3)
                {
                    hasCollision = true;
                    s1.gameObject.SetActive(false);
                    s2.gameObject.SetActive(false);
                    smileys[r, c - 2].gameObject.SetActive(false);
                    UpdatePower(counter);
                }
            }
        }

        //checking columns
        for (int c = 0; c < columns; c++)
        {
            int counter = 1;
            for (int r = 1; r < rows; r++)
            {
                Smiley s1 = smileys[r, c], s2 = smileys[r - 1, c];
                if (s1 != null && s2 != null && s1.name == s2.name)
                {
                    counter++;
                }
                else
                {
                    counter = 1;
                }

                if (counter >= 3)
                {
                    hasCollision = true;
                    s1.gameObject.SetActive(false);
                    s2.gameObject.SetActive(false);
                    smileys[r - 2, c].gameObject.SetActive(false);
                    UpdatePower(counter);
                }
            }
        }

        //moving all non active smileys to the puta que pariu
        for (int r = 0; r < rows; r++)
        {
            for (int c = 0; c < columns; c++)
            {
                if (smileys[r, c] != null && !smileys[r, c].gameObject.activeSelf)
                {
                    smileys[r, c].gameObject.transform.position = new Vector3(-10, -10, 0);
                    smileys[r, c] = null;
                }
            }
        }

        if (hasCollision)
        {
            Invoke("MoveSmileys", 0.5f);
        }
    }