Ejemplo n.º 1
0
 /// <summary>
 /// 判断移动
 /// </summary>
 private void JudgeMove(CookiesAttribute ca)
 {
     _columnDeleteNumList[ca._c]++;
     foreach (KeyValuePair <GameObject, CookiesAttribute> item in _cookiesAttributeDictionary)
     {
         if (item.Value._c == ca._c && item.Value._r < ca._r)
         {
             item.Value._move++;
             if (_moveCookies.IndexOf(item.Value) == -1 && _deleteCookies.IndexOf(item.Value) == -1)
             {
                 _moveCookies.Add(item.Value);
             }
         }
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 鼠标按下饼干
    /// </summary>
    /// <param name="evenData"></param>
    /// <param name="obj"></param>
    private void OnCookiesDown(PointerEventData evenData, GameObject obj, EventTriggerListener etl)
    {
        if (_mouseState != MouseState.弹起)
        {
            return;
        }
        CookiesAttribute ca = _cookiesAttributeDictionary[obj];

        _choseCookiesType = ca._type;
        ShowOther(false);
        _deleteCookies.Add(ca);
        RefreshColumnRow(ca);
        ChoseAnimation(obj);
        _mouseState = MouseState.;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 生成饼干
    /// </summary>
    /// <param name="c">列</param>
    /// <param name="r">行</param>
    public CookiesAttribute CreateCookies(int c, int r)
    {
        GameObject    cookies = Instantiate(_cookiesPrefab);
        RectTransform rtf     = cookies.GetComponent <RectTransform>();

        rtf.SetParent(_content);
        rtf.localPosition = new Vector2(_startX + c * _intervalX, _startY - r * _intervalY);
        //随机图标
        Sprite           sprite = _spritesList[UnityEngine.Random.Range(0, _typeNum)];
        CookiesAttribute ca     = cookies.AddComponent <CookiesAttribute>();

        ca._c            = c;
        ca._r            = r;
        ca._image        = rtf.GetComponent <Image>();
        ca._image.sprite = sprite;
        ca._type         = sprite.name;
        _cookiesAttributeDictionary.Add(cookies, ca);
        EventTriggerListener.Get(cookies)._onDown  = OnCookiesDown;
        EventTriggerListener.Get(cookies)._onEnter = OnCookiesEnter;
        EventTriggerListener.Get(cookies)._onUp    = OnCookiesUp;
        return(ca);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 鼠标经过饼干
    /// </summary>
    /// <param name="evenData"></param>
    /// <param name="obj"></param>
    private void OnCookiesEnter(PointerEventData evenData, GameObject obj, EventTriggerListener etl)
    {
        if (_mouseState != MouseState.)
        {
            return;
        }
        CookiesAttribute ca = _cookiesAttributeDictionary[obj];

        if (_choseCookiesType == ca._type)
        {
            int index = _deleteCookies.IndexOf(ca);
            if (index != -1)
            {
                //已存在数组列表
                if (index == _deleteCookies.Count - 1)
                {
                    return;
                }
                for (int i = _deleteCookies.Count - 1; i > index; i--)
                {
                    DOTween.Kill(_deleteCookies[i].transform);
                    _deleteCookies[i].transform.localScale = new Vector2(1, 1);
                    _deleteCookies.RemoveAt(i);
                    Destroy(_linesList[i - 1]);
                    _linesList.RemoveAt(i - 1);
                }
                RefreshColumnRow(_deleteCookies[_deleteCookies.Count - 1]);
            }
            else if (Math.Abs(ca._c - _prevCookiesColumn) <= 1 && Math.Abs(ca._r - _prevCookiesRow) <= 1)
            {
                _deleteCookies.Add(ca);
                RefreshColumnRow(ca);
                CreateLine();
                ChoseAnimation(obj);
            }
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// 刷新当前行列值
 /// </summary>
 /// <param name="cookiesName"></param>
 private void RefreshColumnRow(CookiesAttribute ca)
 {
     _prevCookiesColumn = ca._c;
     _prevCookiesRow    = ca._r;
 }