Пример #1
0
 public void CreateMahjong(int value, bool immediate)
 {
     _item = App.GetGameManager <Mahjong2DGameManager>().GetNextMahjong().GetComponent <MahjongItem>();
     _item.transform.localScale   = new Vector3(ScaleX, ScaleY);
     _item.SelfData.ShowDirection = EnumShowDirection.Self;
     _item.SelfData.Direction     = EnumMahJongDirection.Vertical;
     _item.Value = value;
     _showValue  = value;
     if (immediate)
     {
         _item.SelfData.Action = EnumMahJongAction.Lie;
         SetFanImmediate();
     }
     else
     {
         _laiZiLabel.TrySetComponentValue(false);
         if (_fromBg)
         {
             _fromBg.gameObject.SetActive(true);
         }
         _item.SelfData.Action = EnumMahJongAction.Push;
         GameTools.AddChild(_fromTrans, _item.transform);
         Invoke("ShowLaiZiValue", ShowLaiziWait);
     }
 }
Пример #2
0
    private void CreateItem(int index)
    {
        UIMultiScrollIndex itemBase;

        if (_unUsedQueue.Count > 0)
        {
            itemBase = _unUsedQueue.Dequeue();
            itemBase.gameObject.SetActive(true);
        }
        else
        {
            itemBase           = GameTools.AddChild(_content, itemPrefab).GetComponent <UIMultiScrollIndex>();
            itemBase.RealIndex = index;
        }

        itemBase.Scroller = this;
        itemBase.Index    = index;
        _itemList.Add(itemBase);

        if (onUpdateItem != null)
        {
            onUpdateItem(index, itemBase.RealIndex, itemBase.gameObject);
        }
        else
        {
            Debug.Log("CreateItem:" + index + "," + itemBase.RealIndex);
        }
    }
Пример #3
0
        public void ShowInfo(List <int> data)
        {
            Show(true);
            data = GameTools.SortCardWithOutLaiZi(data, App.GetGameManager <Mahjong2DGameManager>().LaiZiNum);
            int ChildLenth = _grid.transform.childCount;

            while (ChildLenth > 0)
            {
                DestroyImmediate(_grid.transform.GetChild(0).gameObject);
                ChildLenth--;
            }
            for (int i = 0, lenth = data.Count; i < lenth; i++)
            {
                MahjongItem item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>();
                GameTools.DestroyDragObject(item);
                item.SelfData.Action        = EnumMahJongAction.StandWith;
                item.SelfData.Direction     = EnumMahJongDirection.Vertical;
                item.SelfData.ShowDirection = EnumShowDirection.Self;
                item.SelfData.MahjongLayer  = ConstantData.ShowItemLayler;
                UIEventListener.Get(item.gameObject).onClick = OnClickItem;
                GameTools.AddChild(_grid.transform, item.transform);
                BoxCollider box = item.gameObject.AddComponent <BoxCollider>();
                box.size = new Vector3(item.BGSprite.width, item.BGSprite.height);
            }
            _grid.repositionNow = true;
            _paiBg.width        = (int)(_grid.GetChildList().Count *_grid.cellWidth);
        }
Пример #4
0
        private void CreatMahjongData(List <int> data)
        {
            var obj    = new GameObject();
            var item   = new MahjongItem();
            var parent = obj.AddComponent <UIGrid>();

            for (int i = 0, lenth = data.Count; i < lenth; i++)
            {
                item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>();
                GameTools.DestroyDragObject(item);
                item.SelfData.Action        = EnumMahJongAction.StandWith;
                item.SelfData.Direction     = EnumMahJongDirection.Vertical;
                item.SelfData.ShowDirection = EnumShowDirection.Self;
                item.SelfData.MahjongLayer  = ConstantData.ShowItemLayler;
                GameTools.AddChild(parent.transform, item.transform);
            }
            UIEventListener.Get(parent.gameObject).onClick = OnClickSpecialGangItem;
            var box = parent.gameObject.AddComponent <BoxCollider>();

            box.size             = new Vector3(parent.GetChildList().Count *item.BGSprite.width, item.BGSprite.height);
            box.center           = new Vector3(110, 0, 0);
            parent.cellWidth     = 72;
            parent.repositionNow = true;
            GameTools.AddChild(_grid.transform, parent.transform);
        }
Пример #5
0
    public override void Enter(GUIManager Entity)
    {
        Object     panel     = ResourceMgr.Instance().LoadRes(ConstValue.RES_GUI_PATH, ConstValue.GUI_OVER);
        GameObject overPanel = GameTools.AddChild(Entity.UIRoot, panel);

        m_panelOver = overPanel.GetComponent <PanelOver>();
        m_panelOver.Init();
    }
Пример #6
0
 public void SetNewItem(MahjongItem item, int value, EnumMahJongAction action)
 {
     item.Value           = value;
     item.SelfData.Action = action;
     item.SetColor(Color.white);
     GameTools.AddChild(transform, item.transform);
     ItemList.Add(item);
 }
Пример #7
0
 public void AddItem(Transform trans, bool auto = false, float offsetScaleX = 1, float offsetScaleY = 1)
 {
     GameTools.AddChild(transform, trans, offsetScaleX, offsetScaleY);
     if (OnAddItem != null)
     {
         OnAddItem(trans);
     }
     ResetPositionNow = auto;
 }
Пример #8
0
 /// <summary>
 /// 设置一张麻将作为新抓手牌
 /// </summary>
 /// <param name="item"></param>
 public void SetMahjongAsNewGetIn(MahjongItem item)
 {
     if (item)
     {
         NewCard.GetIn = item;
         GameTools.AddChild(NewCard.transform, item.transform, ItemScaleX, ItemScaleY);
         item.SelfData.MahjongLayer = BaseLayer;
         Layout.ResetPositionNow    = true;
     }
 }
Пример #9
0
    public override void Enter(GUIManager Entity)
    {
        Object panel = ResourceMgr.Instance().LoadRes(ConstValue.RES_GUI_PATH, ConstValue.GUI_LOAD);

        m_panel = GameTools.AddChild(Entity.UIRoot, panel);

        if (m_load != null)
        {
            m_load.Load(Entity);
        }
    }
Пример #10
0
    public override void Enter(GUIManager Entity)
    {
        Messenger.AddListener <GameDoneState>(ConstValue.MSG_GAME_DONE, GameDone);
        Messenger.AddListener <GamePropsId>(ConstValue.MSG_USE_PROP_SUC, UsePropSuc);
        GameStaticData.Combo = 0;

        Object     panel     = ResourceMgr.Instance().LoadRes(ConstValue.RES_GUI_PATH, ConstValue.GUI_PLAYING);
        GameObject gamePanel = GameTools.AddChild(Entity.UIRoot, panel);

        m_panelPlaying = gamePanel.GetComponent <PanelPlaying>();
        m_panelPlaying.Init();
    }
Пример #11
0
    public override void Enter(GUIManager Entity)
    {
        if (ConstValue.level == PlayerPrefs.GetInt(ConstValue.PRE_CUR_LEVEL, 1))
        {
            PlayerPrefs.SetInt(ConstValue.PRE_CUR_LEVEL, ConstValue.level + 1);
        }
        Object     panel    = ResourceMgr.Instance().LoadRes(ConstValue.RES_GUI_PATH, ConstValue.GUI_WIN);
        GameObject winPanel = GameTools.AddChild(Entity.UIRoot, panel);

        m_panelWin = winPanel.GetComponent <PanelWin>();
        m_panelWin.Init();
    }
Пример #12
0
 /// <summary>
 /// 根据长度和角度开始画线
 /// </summary>
 /// <param name="length">长度</param>
 /// <param name="angle">角度</param>
 public void DrawLine(float length, float angle)
 {
     int count = Mathf.FloorToInt((length - 120) / 16);
     int i = 0;
     for (i = 0; i < count; i++)
     {
         GameObject go = GameTools.AddChild(transform, square);
         go.transform.localPosition = new Vector3(i * 16 + 60, 0, 0);
     }
     GameObject tri = GameTools.AddChild(transform, triangle);
     tri.transform.localPosition = new Vector3(i * 16 + 60, 0, 0);
     transform.rotation = Quaternion.Euler(0, 0, angle);
 }
Пример #13
0
 private void SetFanImmediate()
 {
     CancelInvoke("SetFanImmediate");
     if (_toTrans)
     {
         if (_toTrans.childCount > 0)
         {
             _toTrans.DestroyChildren();
         }
         GameTools.AddChild(_toTrans, _item.transform, _laiZiScale, _laiZiScale);
         _item.SelfData.MahjongLayer = _laiZiLayer;
         _laiZiLabel.TrySetComponentValue(true);
     }
 }
Пример #14
0
 public void ThrowOutCard(MahjongItem item, float time)
 {
     _throw.ThrowCard            = item;
     item.SelfData.Action        = EnumMahJongAction.StandWith;
     item.SelfData.Direction     = EnumMahJongDirection.Vertical;
     item.SelfData.ShowDirection = EnumShowDirection.Self;
     GameTools.AddChild(_throw.transform, _throw.ThrowCard.transform, 1, 1, false);
     item.gameObject.SetActive(false);
     item.gameObject.SetActive(true);
     pos   = TweenPosition.Begin(item.gameObject, time, _throw.transform.position);
     scale = TweenScale.Begin(item.gameObject, time, new Vector3(OutCardScaleX, OutCardScaleY, 0));
     App.GetGameManager <Lyzz2DGameManager>().OnSomeOneThrowCard += OutCardFinish;
     App.GetGameManager <Lyzz2DGameManager>().OnSomeOneNeedCard  += OnThrowOutShow;
     Invoke("OnThrowOutShow", time);
 }
Пример #15
0
 void Awake()
 {
     _middleIndex = (_num - 1) / 2;
     _btnList     = new List <FrogItem>();
     for (var i = 0; i < _num; i++)
     {
         GameObject go = GameTools.AddChild(transform, Resources.Load <GameObject>("FrogItem"));
         go.name = "FrogItem" + i;
         FrogItem item = go.GetComponent <FrogItem>();
         item.SetInfo(i <_middleIndex?FrogType.Left : i> _middleIndex ? FrogType.Right : FrogType.Center);
         go.transform.localPosition = new Vector3(i * 102 - _middleIndex * 102, 0, 0);
         item.onClick.AddListener(OnFrogClick);
         _btnList.Add(item);
     }
 }
Пример #16
0
        public void SetGetCardItem(int value)
        {
            var findItem = Layout.GetChildList().Find(item => item.GetComponent <MahjongItem>().Value.Equals(value));

            if (findItem != null)
            {
                GameTools.AddChild(NewCard.transform, findItem.transform, ItemScaleX, ItemScaleY);
                NewCard.GetIn           = findItem.GetComponent <MahjongItem>();
                Layout.ResetPositionNow = true;
            }
            else
            {
                YxDebug.LogError("There is not exist such value in handcards,value is :" + value);
            }
        }
Пример #17
0
    private void CreateItem(int index)
    {
        UIMultiScrollIndex item;

        if (_unUsedQueue.Count > 0)
        {
            item = _unUsedQueue.Dequeue();
        }
        else
        {
            item = GameTools.AddChild(_content, itemPrefab).GetComponent <UIMultiScrollIndex>();
        }
        item.Scroller = this;
        item.Index    = index;
        _itemList.Add(item);
    }
Пример #18
0
 public void ThrowOutCard(MahjongItem item, float time, AsyncCallback showFinishCall = null)
 {
     if (showFinishCall != null)
     {
         _showFinishCall = showFinishCall;
     }
     _throw.ThrowCard            = item;
     item.SelfData.Action        = DirectLie ? EnumMahJongAction.Lie: EnumMahJongAction.StandWith;
     item.SelfData.Direction     = EnumMahJongDirection.Vertical;
     item.SelfData.ShowDirection = EnumShowDirection.Self;
     GameTools.AddChild(_throw.transform, _throw.ThrowCard.transform, 1, 1, false);
     GameTools.RefreshTrans(item.transform);
     _pos   = TweenPosition.Begin(item.gameObject, time, _throw.transform.position);
     _scale = TweenScale.Begin(item.gameObject, time, new Vector3(OutCardScaleX, OutCardScaleY, 0));
     App.GetGameManager <Mahjong2DGameManager>().OnSomeOneNeedCard = OnThrowOutShow;
     Invoke("OnThrowOutShow", time);
 }
Пример #19
0
    /// <summary>
    /// 实例化一整页的Item
    /// </summary>
    /// <param name="offset">偏移[-300:前一页][0:当前][300:后一页]</param>
    private void CreateItemGrid(int offset)
    {
        _newItemList.Clear();
        int index = 0;

        for (int i = 0; i < 6; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                GameObject go = GameTools.AddChild(itemPanel, itemPrefab);
                go.name = "item " + (index < 10 ? "0" + index : index.ToString());
                go.transform.localPosition = new Vector3(j * 60 - 120 + offset, 150 - i * 60, 0);
                _newItemList.Add(go.GetComponent <BagItem>());
                index++;
            }
        }
    }
Пример #20
0
    private UIScrollIndex CreateItem(int index)
    {
        UIScrollIndex itemBase;

        if (_unUsedQueue.Count > 0)
        {
            itemBase = _unUsedQueue.Dequeue();
        }
        else
        {
            itemBase = GameTools.AddChild(_content, itemPrefab).GetComponent <UIScrollIndex>();
        }

        itemBase.Scroller = this;
        itemBase.Index    = index;
        _itemList.Add(itemBase);

        return(itemBase);
    }
Пример #21
0
        public virtual Transform AddCard(int value, bool isSingle, bool changeNumber = true)
        {
            var newMahJong = GameTools.CreateMahjong(value, changeNumber);

            ParseItemToThis(newMahJong);
            if (isSingle)
            {
                var item = newMahJong.GetComponent <MahjongItem>();
                ParseItemToThis(item);
                NewCard.GetIn = item;
                GameTools.AddChild(NewCard.transform, item.transform, ItemScaleX, ItemScaleY);
            }
            else
            {
                AddItem(newMahJong);
            }
            newMahJong.GetComponent <MahjongItem>().JudgeHunTag(App.GetGameManager <Lyzz2DGameManager>().LaiZiNum);
            return(newMahJong);
        }
Пример #22
0
    void Start()
    {
        int i = 0, j = 0;
        //物品数量应该由外部传入,这里我用随机数代替,Random.Range包前不包后,也就是随机值为1~15
        int itemCount = Random.Range(1, 16);
        //横向的数量
        int horizontalCount = Mathf.Min(itemCount, 5);
        //纵向的数量
        int verticalCount = Mathf.Min(Mathf.CeilToInt(itemCount / 5f), 3);

        for (int k = 0; k < itemCount; k++)
        {
            //计算X轴的偏移
            int valueX = (i * (cellWidth + Spacing)) - (horizontalCount - 1) * (cellWidth + Spacing) / 2;
            //计算Y轴的偏移
            int valueY = (j * (cellHeight + Spacing)) - (verticalCount - 1) * (cellHeight + Spacing) / 2;
            //实例化对象并设置名称和坐标
            GameObject go = GameTools.AddChild(transform, _prefab);
            go.name = "Item" + k;
            //下面的Y值取反,是因为顺着Y轴方向向下,数值减小
            go.transform.localPosition = new Vector3(valueX, -valueY, 0);
            //这里主要判断当一行图标排满5个时,使其换行
            if (++i == 5)
            {
                i = 0; j++;
            }

            //下面的这几句跟布局无关,就是做缓动效果的

            //缓动 透明度
            CanvasGroup icon = go.GetComponent <CanvasGroup>();
            icon.alpha = 0;
            icon.DOFade(1, _time).SetDelay(k * 0.1f);
            //缓动 缩放
            icon.transform.localScale = Vector3.one * 0.5f;
            icon.transform.DOScale(1, _time).SetDelay(k * 0.1f);
        }
        //动态改变背景框的大小
        _border.sizeDelta = new Vector2(horizontalCount * cellWidth + 20, verticalCount * cellHeight + 20);
    }
Пример #23
0
    private void RandomPosition()
    {
        //这里为了看出各种效果,所以采用随机点的方式,各位根据实际情况来确定点的位置
        Vector3 pos1 = RandomVector();
        Vector3 pos2 = RandomVector();
        //两点之间的距离
        float length = Vector3.Distance(pos1, pos2);

        //为了不要让随机出的点挨得太近(当然 实际项目中也不可能),所以这里加个限制,当两点距离过小时,重新随机pos2
        while (length < 120)
        {
            pos2   = RandomVector();
            length = Vector3.Distance(pos1, pos2);
        }
        _icon1Trans.localPosition = pos1;
        _icon2Trans.localPosition = pos2;

        //两点的角度
        float      angle = Mathf.Atan2(pos2.y - pos1.y, pos2.x - pos1.x) * 180 / Mathf.PI;
        GameObject go    = GameTools.AddChild(_icon1Trans.transform, linePrefab);
        Line       line  = go.GetComponent <Line>();

        line.DrawLine(length, angle);
    }
Пример #24
0
 /// <summary>
 /// 添加一张牌到牌堆
 /// </summary>
 /// <param name="item"></param>
 /// <param name="downTime"></param>
 public void AddCardToPiles(MahjongItem item, float downTime)
 {
     if (item != null)
     {
         _controlItem = item;
         if (_direct)
         {
             GameTools.AddChild(Layout.transform, _controlItem.transform, OutCardScaleX, OutCardScaleY, false, false);
             OnMoveDownFinished();
         }
         else
         {
             Vector3 nextPos = GetNextCardPosition();
             GameTools.AddChild(Layout.transform, _controlItem.transform, OutCardScaleX, OutCardScaleY, false, false);
             _downPos = TweenPosition.Begin(_controlItem.gameObject, downTime, nextPos);
             TweenScale.Begin(item.gameObject, downTime, new Vector3(ItemScaleX, ItemScaleY));
             Invoke("OnMoveDownFinished", downTime);
         }
     }
     else
     {
         Debug.LogError("打出的那张牌竟然空了,额........................");
     }
 }
Пример #25
0
 private void SetFanImmediate()
 {
     CancelInvoke("SetFanImmediate");
     GameTools.AddChild(_toTrans, _item.transform);
     _laiZiLabel.SetActive(true);
 }