Пример #1
0
    public void DeleteButtonOnClickListener()
    {
        parentList.RemoveRow(this);
        StickerData stickerData = new StickerData();

        stickerData.DeleteSticker(sticker);
    }
Пример #2
0
    public void OnSaveButtonClick()
    {
        //Get stickers from the contentScroll
        Sticker[] stickers = new Sticker[contentScroll.GetContentComponents().Length];
        for (int i = 0; i < contentScroll.GetContentComponents().Length; i++)
        {
            Sticker sticker = contentScroll.GetContentComponents()[i].GetComponent <QROption>().GetSticker();
            if (sticker != null)
            {
                stickers[i] = sticker;
            }
        }

        //Add stickers to JSON file
        StickerData stickerData = new StickerData();

        foreach (Sticker sticker in stickers)
        {
            stickerData.AddSticker(sticker);
        }

        savedPopup.DisplayPopup(3);
        LoadStickersFromFile();
        OnDetailsChanged();
    }
        private List <StickerData> getStickerData()
        {
            List <StickerData> result = new List <StickerData>();

            if (checkBoxTestMode.Checked)
            {
                result = generateTestData();
            }
            else
            {
                DataGridViewRowCollection datagridRows = datagridView.Rows;
                for (int i = 0; i < datagridRows.Count; i++)
                {
                    DataGridViewRow            datagridRow = datagridRows[i];
                    DataGridViewCellCollection cells       = datagridRow.Cells;
                    if (isEmptyCells(cells))
                    {
                        Debug.WriteLine("ROW " + i + " HAS EMPTY CELLS");
                        continue;
                    }
                    StickerData stickerData = new StickerData
                    {
                        itemName    = cells[0].Value.ToString(),
                        date        = cells[1].Value.ToString(),
                        code        = cells[2].Value.ToString(),
                        institution = institution
                    };
                    result.Add(stickerData);
                }
            }
            return(result);
        }
Пример #4
0
    public void OpenEditStickerPanel(Sticker loadSticker)
    {
        this.gameObject.SetActive(true);
        StickerData stickerData = new StickerData();

        contentScroll.RemoveContentComponents();

        LoadStickersFromFile();
        //Create a QROption for each sticker in the JSON file
        int i = 0;

        foreach (Sticker sticker in stickerData.GetAllStickers())
        {
            QROption newOption = Instantiate(qrOptionPrefab, contentScroll.content.transform);
            newOption.SetSticker(sticker);
            newOption.transform.localPosition = new Vector3(575 + (i * 150), newOption.transform.localPosition.y);
            i++;
        }

        //Set size of content box
        RectTransform rectTransform = contentScroll.content.GetComponent <RectTransform>();

        rectTransform.sizeDelta = new Vector2(1500 + (i * 100), 0);

        //Initialize scroll variables
        contentScroll.InitializeVariables();

        //Scroll to selected sticker
        List <Sticker> stickers = stickerData.GetAllStickers();
        int            index    = stickers.FindIndex(x => x.stickerName == loadSticker.stickerName);

        contentScroll.ScrollToContent(index);
        UpdateDetailsPanel();
        OnDetailsChanged();
    }
Пример #5
0
 private XElement StickerToXml(StickerData sticker) =>
 new XElement(
     "Sticker",
     new XElement("Emoji", sticker.Emoji),
     new XElement("Title", sticker.Title),
     new XElement("MemePictureUrl", sticker.MemePictureUrl)
     );
 public void OpenSaveToFavoritesPopup(Sticker sticker)
 {
     this.sticker = sticker;
     stickerData  = new StickerData();
     popupPanel.SetActive(true);
     this.gameObject.SetActive(true);
     OnNameChangeActionListener();
 }
Пример #7
0
    public string GetComboString(StickerData top, StickerData bottom)
    {
        string text = "" + bonusText;

        text = text.Replace("$a", top.GetPrefix());
        text = text.Replace("$b", bottom.GetSuffix());
        text = text.ToUpper();
        text = "x" + multiplier + " " + text;
        return(text);
    }
Пример #8
0
    public void SaveCube()
    {
        List <StickerData> serializableStickers = new List <StickerData>();

        foreach (var sticker in stickers)
        {
            Axis        axis = sticker.GetNormalAxis();
            StickerData serializableSticker = new StickerData(axis, sticker.GetCubeCoordinates(), sticker.StickerColor);
            serializableStickers.Add(serializableSticker);
        }
        fileManager.Save(fullPath, serializableStickers);
    }
Пример #9
0
    void UpdatePageData()
    {
        List <StickerData> stickerData = new List <StickerData>();

        foreach (GameObject g in stickers)
        {
            StickerData sD = new StickerData();
            sD.position = g.transform.position;
            sD.sprite   = g.name;
            stickerData.Add(sD);
        }
        pageData.stickers = stickerData;
    }
Пример #10
0
 public FaceStickersPage()
 {
     this.InitializeComponent();
     this.DataContext = StickerData.GetStickerData();
     stickerList.Add(new StickerData()
     {
         imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg", imageName = "1001"
     });
     //stickerList.Add(new StickerData() { imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg" });
     //stickerList.Add(new StickerData() { imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg" });
     //stickerList.Add(new StickerData() { imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg" });
     //stickerList.Add(new StickerData() { imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg" });
     //stickerList.Add(new StickerData() { imagePath = "ms-appx:///Assets/Stickers/EyeStickers/sticker1.jpg" });
 }
Пример #11
0
    public void OnSearchInputFieldChangeListener()
    {
        if (searchInputField.text != "")
        {
            StickerData    stickerData = new StickerData();
            List <Sticker> stickers    = stickerData.GetAllStickers();

            //Filter list based on sticker name
            List <Sticker> filteredList = stickers.FindAll(x => x.stickerName.ToLower().Contains(searchInputField.text.ToLower()));
            LoadFavoriteStickerList(filteredList);
        }
        else
        {
            LoadFavoriteStickerListFromFile();
        }
    }
        private List <StickerData> generateTestData()
        {
            List <StickerData> result = new List <StickerData>();

            for (int i = 1; i <= 27; i++)
            {
                StickerData data = new StickerData
                {
                    itemName    = "Test " + i,
                    date        = DateTime.Now.ToString(),
                    code        = "CODE" + i,
                    institution = institution
                };
                result.Add(data);
            }
            return(result);
        }
Пример #13
0
//    private static StickerGroup mStickerGroup;

    private void AddStickerData(StickerData data)
    {
        StickerItem item;

        if (!stickerDatas.TryGetValue(data.texture, out item))
        {
            item             = new StickerItem();
            item.stickerName = data.texture;
            item.prefab      = data.prefab;
            item.material    = data.material;
            stickerDatas.Add(item.stickerName, item);

            string[] strs = data.blockModels.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            item.models = strs.ToList();
        }
        else
        {
            Debug.LogError("has multiple >>>>>>>" + data.texture);
        }

//        item.prefab.Add(data.prefab);
//        item.material.Add(data.material);
    }
Пример #14
0
        public IEnumerable <GameObject> Create(StickerData data, GameObject parent)
        {
            var parentTransform = parent.transform;

            var stickers = new List <GameObject>();

            if (data.X != FaceColor.None)
            {
                stickers.Add(Create(Vector3.right, data.Directions.x, data.X, parentTransform));
            }

            if (data.Y != FaceColor.None)
            {
                stickers.Add(Create(Vector3.up, data.Directions.y, data.Y, parentTransform));
            }

            if (data.Z != FaceColor.None)
            {
                stickers.Add(Create(Vector3.forward, data.Directions.z, data.Z, parentTransform));
            }

            return(stickers);
        }
Пример #15
0
    private void SavePlacedStickers()
    {
        List <GameObject>  placed = GetPlacedStickerList();
        List <StickerData> data   = new List <StickerData>();

        for (int i = placed.Count - 1; i >= 0; i--)
        {
            if (placed[i])
            {
                StickerData s = new StickerData();
                s.name     = placed[i].GetComponent <PlacedSticker>().stickerInformation.name.ToString();
                s.scale    = placed[i].GetComponent <RectTransform>().localScale.x;
                s.rotation = placed[i].GetComponent <RectTransform>().localEulerAngles.z;
                s.xCoord   = placed[i].GetComponent <RectTransform>().localPosition.x;
                s.yCoord   = placed[i].GetComponent <RectTransform>().localPosition.y;
                data.Add(s);
            }
            if (data.Count == 30)
            {
                break;
            }
        }
        GameController.Instance.SavePlacedStickers(data);
    }
Пример #16
0
 public void Setup(StickerData data)
 {
     image.sprite = data.sprite;
     text.text    = data.name;
 }
    public static void CreateStickerPrefab(string prefabName)
    {
        List <StickerData> datas = PBDataBaseManager.Instance.GetStickerDatas();


        StickerData data = datas.FirstOrDefault(s => s.prefab == prefabName);

        if (data == null)
        {
            Debug.LogError("failed:CreateStickerPrefab>>>" + prefabName);
            return;
        }

        try
        {
            GameObject fbx =
                AssetDatabase.LoadAssetAtPath <GameObject>(Path.Combine(BlockPath.Sticker_Fbx_Dir,
                                                                        data.model + ".fbx"));


            string   matPath = Path.Combine(BlockPath.Sticker_Material_Dir, data.prefab + ".mat");
            Material mat     = AssetDatabase.LoadAssetAtPath <Material>(matPath);
            if (mat == null)
            {
                mat = AssetDatabase.LoadAssetAtPath <Material>(Path.Combine(BlockPath.Sticker_Material_Dir,
                                                                            data.material + ".mat"));


                AssetDatabase.CreateAsset(GameObject.Instantiate(mat), matPath);
                mat = AssetDatabase.LoadAssetAtPath <Material>(matPath);
            }

            Texture2D tex =
                AssetDatabase.LoadAssetAtPath <Texture2D>(Path.Combine(BlockPath.Sticker_Texture_Dir,
                                                                       data.texture + ".png"));


            mat.mainTexture = tex;

            GameObject go = GameObject.Instantiate(fbx);
            go.name = data.prefab;

            Animator animator = go.GetComponent <Animator>();
            if (animator != null)
            {
                GameObject.DestroyImmediate(animator);
            }

            Renderer render = go.GetComponent <Renderer>();
            render.receiveShadows    = false;
            render.shadowCastingMode = ShadowCastingMode.Off;
            render.sharedMaterials   = new[] { mat };

            if (!Directory.Exists(BlockPath.Sticker_Prefab_Dir))
            {
                Directory.CreateDirectory(BlockPath.Sticker_Prefab_Dir);
            }

            PrefabUtility.CreatePrefab(BlockPath.Sticker_Prefab_Dir + "/" + data.prefab + ".prefab", go,
                                       ReplacePrefabOptions.ReplaceNameBased);
            GameObject.DestroyImmediate(go);
        }
        finally
        {
//				EditorUtility.ClearProgressBar();
            AssetDatabase.Refresh();
        }
    }
Пример #18
0
    public void ScoreSticker(GameObject sticker)
    {
        PolygonCollider2D collider = sticker.GetComponent <PolygonCollider2D>();
        SpriteRenderer    sprite   = sticker.GetComponent <SpriteRenderer>();

        float totalMultiplier = 1;

        Queue <GameObject> bonusTexts = new Queue <GameObject>();

        comboSoundCounter = 0;
        comboSoundIndex   = 0;

        //measure how much of the sticker is off-target
        float onTargetAmount = 0;

        foreach (Vector2 point in collider.points)
        {
            Vector2 stickerPos   = new Vector2(sticker.transform.position.x, sticker.transform.position.y);
            Vector2 stickerScale = new Vector2(sticker.transform.lossyScale.x, sticker.transform.lossyScale.y);
            if (target.OverlapPoint(point * stickerScale + stickerPos))
            {
                onTargetAmount++;
            }
        }
        onTargetAmount = onTargetAmount / collider.points.Length;
        if (onTargetAmount == 1)
        {
            //Nice On!
        }
        else if (onTargetAmount >= .8f)
        {
            totalMultiplier *= .5f;
            bonusTexts.Enqueue(MakeBonusText("x0.5 OFF EDGE", BADCOLOR));
            sprite.color *= new Color(1, 1, 1, 0.9f);
        }
        else
        {
            totalMultiplier *= 0;
            bonusTexts.Enqueue(MakeBonusText("x0 MISS", VERYBADCOLOR));
            sprite.color *= new Color(1, 1, 1, 0.4f);
        }

        Collider2D[]    collOut = new Collider2D[20];
        ContactFilter2D filter  = new ContactFilter2D();

        filter.SetLayerMask(placer.stickerMask);
        filter.useLayerMask = true;
        int collisions = Physics2D.OverlapCollider(collider, filter, collOut);

        //check for combos
        int comboCollisions = 0;
        List <SpriteRenderer> nonComboSprites = new List <SpriteRenderer>();
        StickerData           topData         = sticker.GetComponent <StickerData>();

        for (int i = 0; i < collisions; i++)
        {
            StickerData bottomData = collOut[i].GetComponent <StickerData>();
            bool        comboFound = false;
            foreach (StickerCombo combo in comboList.combos)
            {
                if (combo.CheckCombo(topData.tags, bottomData.tags))
                {
                    totalMultiplier *= combo.multiplier;
                    bonusTexts.Enqueue(MakeBonusText(combo.GetComboString(topData, bottomData), combo.color));
                    comboCollisions++;
                    comboFound = true;
                    comboSoundCounter++;
                }
            }
            if (!comboFound)
            {
                nonComboSprites.Add(collOut[i].GetComponent <SpriteRenderer>());
            }
        }
        foreach (SpriteRenderer s in nonComboSprites)
        {
            s.color *= new Color(1, 1, 1, 0.8f);
        }

        collisions -= comboCollisions;

        //check how many stickers are overlapping.
        if (collisions == 0)
        {
            //Nice placement!
        }
        else if (collisions == 1)
        {
            totalMultiplier *= 0.7f;
            bonusTexts.Enqueue(MakeBonusText("x0.7 SINGLE OVERLAP", BADCOLOR));
        }
        else if (collisions == 2)
        {
            totalMultiplier *= 0.5f;
            bonusTexts.Enqueue(MakeBonusText("x0.5 DOUBLE OVERLAP", BADCOLOR));
        }
        else
        {
            totalMultiplier *= 0;
            bonusTexts.Enqueue(MakeBonusText("x0 MULTI OVERLAP", VERYBADCOLOR));
        }

        float radialOffset = Mathf.PI * .5f;
        float radDir       = 1;

        if (sticker.transform.position.x < 0)
        {
            radDir = -1;
        }
        radialOffset += radDir * Mathf.PI * .3f;
        if (sticker.transform.position.y > 0)
        {
            radialOffset += radDir * Mathf.PI * .3f;
        }
        foreach (GameObject t in bonusTexts)
        {
            t.transform.position = Vector3.Scale(sticker.transform.position, new Vector3(1, 1, 0)) +
                                   new Vector3(Mathf.Cos(radialOffset) * 70, Mathf.Sin(radialOffset) * 70,
                                               t.transform.position.z);
            t.GetComponent <TextFade>().velocity = new Vector3(Mathf.Cos(radialOffset) * 10, Mathf.Sin(radialOffset) * 10, 0);
            radialOffset += radDir * Mathf.PI * .1f;
        }

        Vector3 bounds       = collider.bounds.extents;
        float   stickerScore = bounds.x + bounds.y;

        stickerScore *= totalMultiplier;
        stickerScore  = Mathf.Round(stickerScore);
        ScorePop(stickerScore);

        if (score >= targetScore)
        {
            targetScoreText.color = new Color(.5f, 1, .5f);
        }
    }
Пример #19
0
    private void LoadStickersFromFile()
    {
        StickerData stickerData = new StickerData();

        stickersFromFile = stickerData.GetAllStickers();
    }
        static void CreateStickerMat()
        {
            List <StickerData> datas = PBDataBaseManager.Instance.GetStickerDatas();

            List <string> fbxErrors = new List <string>();
            List <string> matErrors = new List <string>();
            List <string> texErrors = new List <string>();

            try
            {
                for (int i = 0; i < datas.Count; i++)
                {
                    EditorUtility.DisplayProgressBar("生成贴纸材质", "", (float)i / datas.Count);

                    StickerData data = datas[i];
                    GameObject  fbx  = AssetDatabase.LoadAssetAtPath <GameObject>(Path.Combine(BlockPath.Sticker_Fbx_Dir, data.model + ".fbx"));
                    if (fbx == null)
                    {
                        if (!fbxErrors.Contains(data.model))
                        {
                            fbxErrors.Add(data.model);
                        }
                        continue;
                    }

                    string   matPath = Path.Combine(BlockPath.Sticker_Material_Dir, data.prefab + ".mat");
                    Material mat     = AssetDatabase.LoadAssetAtPath <Material>(matPath);
                    if (mat == null)
                    {
                        mat = AssetDatabase.LoadAssetAtPath <Material>(Path.Combine(BlockPath.Sticker_Material_Dir, data.material + ".mat"));
                        if (mat == null)
                        {
                            if (!matErrors.Contains(data.material))
                            {
                                matErrors.Add(data.material);
                            }
                            continue;
                        }

                        AssetDatabase.CreateAsset(GameObject.Instantiate(mat), matPath);
                        mat = AssetDatabase.LoadAssetAtPath <Material>(matPath);
                    }

                    Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D>(Path.Combine(BlockPath.Sticker_Texture_Dir, data.texture + ".png"));
                    if (tex == null)
                    {
                        if (!texErrors.Contains(data.texture))
                        {
                            texErrors.Add(data.texture);
                        }
                        continue;
                    }

                    mat.mainTexture = tex;
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();

                AssetDatabase.Refresh();

                if (fbxErrors.Count > 0)
                {
                    DisplayErrorDialog("找不到以下fbx\n", fbxErrors);
                }
                if (matErrors.Count > 0)
                {
                    DisplayErrorDialog("找不到以下material\n", matErrors);
                }
                if (texErrors.Count > 0)
                {
                    DisplayErrorDialog("找不到以下textures\n", texErrors);
                }
            }
        }
Пример #21
0
        internal Image generateOneSticker(StickerData stickerData)
        {
            Debug.WriteLine("institution: " + institution);
            Debug.WriteLine("SAVE TO PATH: " + saveToPath);
            try
            {
                string imgName;
                if (institution.Equals(Institution.MTS_ALKAHFI))
                {
                    imgName = "ALKAHFI.png";
                }
                else
                {
                    imgName = "kiis.jpg";
                }
                //get image
                Image Image = Image.FromFile("Resources/" + imgName);
                Debug.WriteLine("ResourceManager result :" + (Image == null ? "TRUE" : "FALSE" + Image.GetType()));

                if (null != Image)
                {
                    //write image
                    PixelFormat pf              = PixelFormat.Format32bppArgb;
                    Bitmap      Canvas          = new Bitmap(STICKER_WIDTH, STICKER_HEIGHT, pf); //This is the Bitmap Image; you have not yet selected a file,
                    Brush       BackgroundBrush = new SolidBrush(Color.White);                   //Bitmap BM = new Bitmap(Image.FromFile(@"D:\Resources\International\Picrofo_Logo.png"), rect.Width, rect.Height);

                    Graphics g = Graphics.FromImage(Canvas);

                    //draw background
                    g.FillRectangle(BackgroundBrush, 0, 0, STICKER_WIDTH, STICKER_HEIGHT);

                    //draw logo
                    g.DrawImage(Image, 3, 2, 60, 60);

                    //draw content
                    //g2d.setColor(Color.BLACK);

                    float stringXIndex = STICKER_HEIGHT + 3;
                    //Institution
                    String institutionAlias = getInstitutionAlias(stickerData.institution);
                    //if (institutionAlias.length() <= 17)
                    //{
                    //    g2d.setFont(new Font("Arial", Font.BOLD, 13));
                    //}
                    //else {
                    //    g2d.setFont(new Font("Arial", Font.BOLD, 10));
                    //}
                    Brush fontBrush = new SolidBrush(Color.Black);
                    Font  Font      = new Font("Arial", 8);
                    Font  TitleFont = new Font("Arial", 8, FontStyle.Bold);

                    int reducer = 12;
                    g.DrawString(institutionAlias, TitleFont, fontBrush, stringXIndex, 15 - reducer);
                    g.DrawString(stickerData.itemName, Font, fontBrush, stringXIndex, 32 - reducer);
                    g.DrawString(stickerData.date, Font, fontBrush, stringXIndex, 47 - reducer);
                    g.DrawString(stickerData.code, Font, fontBrush, stringXIndex, 62 - reducer);

                    //draw borders
                    //GENERAL BORDER
                    Pen outerPen   = new Pen(Color.Black, 4);
                    Pen contentPen = new Pen(Color.Black, 1);

                    g.DrawRectangle(outerPen, 0, 0, STICKER_WIDTH - 1, STICKER_HEIGHT - 1);
                    //contents borders
                    int borderXIndex = STICKER_WIDTH - STICKER_HEIGHT;
                    g.DrawRectangle(contentPen, STICKER_HEIGHT, 0, borderXIndex, 18);  //institution
                    g.DrawRectangle(contentPen, STICKER_HEIGHT, 18, borderXIndex, 16); //name
                    g.DrawRectangle(contentPen, STICKER_HEIGHT, 34, borderXIndex, 16); //date
                    g.DrawRectangle(contentPen, STICKER_HEIGHT, 50, borderXIndex, 16); //code

                    string fullPath = saveToPath + "/" + institution + "-" + stickerData.itemName + "_" + count + ".png";
                    Canvas.Save(fullPath, ImageFormat.Png);

                    Debug.WriteLine("SUCCESS SAVING IMAGE:" + fullPath);
                    count++;
                    return(Canvas);
                }

                //var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                //var logoimage = Path.Combine(outPutDirectory, "Resources\\ALKAHFI.png");
                //string relLogo = new Uri(logoimage).LocalPath;
                //LinkedResource LinkedResource = new LinkedResource(relLogo);
                //Debug.WriteLine("ResourceManager result :" + (LinkedResource == null ? "NULL" : "FOUND"));// + O.GetType()));
                //if(null!= LinkedResource)
                //{
                //     //Image.FromFile(LinkedResource.ContentLink.LocalPath);
                //}
            }
            catch (Exception e)
            {
                Debug.WriteLine("ERROR :" + e.Message);
            }

            return(null);
        }
Пример #22
0
    private void LoadFavoriteStickerListFromFile()
    {
        StickerData stickerData = new StickerData();

        LoadFavoriteStickerList(stickerData.GetAllStickers());
    }
Пример #23
0
    // Update is called once per frame
    void Update()
    {
        /*Vector2 pos = Input.mousePosition;
         * pos.Scale(new Vector2(1f / Screen.width, 1f / Screen.height));
         * pos = new Vector2(Mathf.Clamp01(pos.x), Mathf.Clamp01(pos.y));
         * pos.Scale(PIXELSCALE);
         * pos = pos - (PIXELSCALE * .5f);*/

        if (Input.GetButtonDown("Fire1") || Input.GetButtonDown("Jump"))
        {
            stickerSound.pitch = Random.Range(1, 2.5f);
            stickerSound.Play();
            if (sticker != null)
            {
                scoring.ScoreSticker(sticker.gameObject);
                sticker.position       = new Vector3(sticker.position.x, sticker.position.y, stickerDepth);
                sprite.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
                stickerDepth          -= .1f;
                outline.Color          = Color.white;
                outline.GenerateOutline();
                sticker.SetParent(target);
            }

            if (stickerQueue.Count == 0)
            {
                sticker = null;
                if (!finished)
                {
                    FinishLevel();
                }
            }
            else
            {
                sticker         = MakeSticker(stickerQueue.Dequeue()).transform;
                stickerCollider = sticker.GetComponent <PolygonCollider2D>();
                sprite          = sticker.GetComponent <SpriteRenderer>();
                outline         = sticker.GetComponent <SpriteOutline>();
            }

            remainingStickersText.text = "STICKERS LEFT: " + stickerQueue.Count;
        }

        if (finished && Input.GetButtonDown("Submit"))
        {
            if (win)
            {
                SceneManager.LoadScene(nextLevel);
            }
            else
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }
        }

        if (sticker == null)
        {
            movementSound.Stop();
            return;
        }

        //COLLISION---------------------
        Collider2D[]    collOut = new Collider2D[20];
        ContactFilter2D filter  = new ContactFilter2D();

        filter.SetLayerMask(stickerMask);
        filter.useLayerMask = true;
        int overlapCount = Physics2D.OverlapCollider(stickerCollider, filter, collOut);

        if (overlapCount > 0)
        {
            bool       allCombos = true;
            Collider2D notCombo  = null;
            for (int i = 0; i < overlapCount; i++)
            {
                Collider2D  c          = collOut[i];
                StickerData sticker1   = sticker.GetComponent <StickerData>();
                StickerData sticker2   = c.GetComponent <StickerData>();
                bool        comboFound = false;
                foreach (StickerCombo combo in scoring.comboList.combos)
                {
                    comboFound = comboFound || combo.CheckCombo(sticker1.tags, sticker2.tags);
                }
                if (!comboFound)
                {
                    allCombos = false;
                    notCombo  = c;
                }
            }
            if (!allCombos)
            {
                //collision detected!
                overlapWarning.enabled = true;
                if (releaseTime >= RELEASEWAIT)
                {
                    Vector3 pushOut = stickerCollider.transform.position - notCombo.transform.position;
                    Vector2 pushDir = new Vector2(pushOut.x, pushOut.y).normalized;
                    velocity = pushDir * minSpeed;
                    push     = true;
                }
            }
            else
            {
                overlapWarning.enabled = false;
                push = false;
            }
        }
        else
        {
            overlapWarning.enabled = false;
            push = false;
        }

        //check if the target is overlapped
        bool    withinTarget = true;
        Vector2 stickerPos   = new Vector2(sticker.transform.position.x, sticker.transform.position.y);
        Vector2 stickerScale = new Vector2(sticker.lossyScale.x, sticker.lossyScale.y);

        foreach (Vector2 point in stickerCollider.points)
        {
            withinTarget = withinTarget && targetCollider.OverlapPoint(point * stickerScale + stickerPos);
        }
        if (!withinTarget)
        {
            offEdgeWarning.enabled = true;
            if (releaseTime >= RELEASEWAIT)
            {
                Vector3 pushOut = target.position - sticker.position;
                Vector2 pushDir = new Vector2(pushOut.x, pushOut.y).normalized;
                if (push)
                {
                    velocity += pushDir * minSpeed * 2;
                }
                else
                {
                    velocity = pushDir * minSpeed;
                    push     = true;
                }
            }
        }
        else
        {
            offEdgeWarning.enabled = false;
        }

        //MOVEMENT----------------------
        #region Movement
        Vector2 pos = new Vector2(sticker.transform.position.x, sticker.transform.position.y);

        Vector2 inputVec = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        if (inputVec.magnitude > 1)
        {
            inputVec.Normalize();
        }

        if (inputVec.magnitude == 0)
        {
            movementSound.Stop();
            if (!push || releaseTime < RELEASEWAIT)
            {
                velocity = Vector2.zero;

                /*//friction
                 * if(velocity.magnitude < Time.deltaTime * accel)
                 * {
                 *  velocity = Vector2.zero;
                 * } else
                 * {
                 *  velocity -= velocity.normalized * Time.deltaTime * accel;
                 * }*/
            }
            releaseTime += Time.deltaTime;
        }
        else
        {
            movementSound.pitch = Mathf.Clamp(movementSound.pitch + Time.deltaTime * Random.Range(-1f, 1f) * 2, .75f, 1.5f);
            if (!movementSound.isPlaying)
            {
                movementSound.Play();
            }
            if (releaseTime != 0)
            {
                velocity = inputVec * minSpeed;
            }
            else if (velocity.magnitude < maxSpeed * .95f)
            {
                velocity += accel * inputVec * Time.deltaTime;
            }
            else
            {
                velocity += velocityChange * inputVec * Time.deltaTime;
            }
            releaseTime = 0;
        }
        if (velocity.magnitude > maxSpeed)
        {
            velocity = velocity.normalized * maxSpeed;
        }
        pos += velocity * Time.deltaTime;
        sticker.transform.position = pos;
        warnings.position          = new Vector3(pos.x, pos.y, warnings.position.z);

        #endregion
    }