private BarrageItem GetNormalBarrageItem(ControversyBarrageConfig barrageConfig)
        {
            BarrageItem item = new BarrageItem()
            {
                ID = barrageConfig.ID, IsSpecial = false
            };

            item.Items        = ProcessBarrageText(item, barrageConfig.text);
            item.CorrectIndex = barrageConfig.correctIndex;
            item.BornTime     = barrageConfig.bornTime;
            return(item);
        }
        private BarrageItem GetSpecialBarrageItem(int specialBarrageID)
        {
            BarrageItem item = new BarrageItem()
            {
                ID = specialBarrageID, IsSpecial = true
            };
            var specialBarrageConfig = ControversySpecialBarrageConfig.GetConfigByKey(specialBarrageID);

            item.Items        = ProcessBarrageText(item, specialBarrageConfig.text);
            item.CorrectIndex = specialBarrageConfig.correctIndex;
            item.BornTime     = specialBarrageConfig.bornTime;
            return(item);
        }
 private void SlashBarrage(BarrageItem barrage)
 {
     NormalBarrageInfos.Remove(barrage);
     Debug.LogError("SlashBarrage ");
     m_heavyAttackColdTime -= m_heavyAttackRecover;
     m_slashedBarrageAmount++;
     CheckCharge();
     m_slashedBarrageLst.Add(barrage.ID);
     if (CurStage != EnumControversyStage.StageTwo)
     {
         CheckStage();
     }
 }
        public bool BarragePassed(BarrageItem barrage)
        {
            if (IsSlashed(barrage.ID))
            {
                if (!NormalBarrageInfos.Contains(barrage))
                {
                    return(false);
                }
                Debug.LogError($"BarragePassed IsSlashed but in normalBarrage {barrage.ID}");
            }
            else
            {
                m_slashedBarrageLst.Add(barrage.ID);
            }

            if (barrage.IsSpecial)
            {
                Debug.LogError("BarragePassed IsSpecial");

                ChangeStage(EnumControversyStage.MissSpecial);
            }
            else
            {
                m_missBarrageCount++;
                NormalBarrageInfos.Remove(barrage);
                if (NormalBarrageInfos.Count == 0)
                {
                    Debug.LogError("NormalBarrageInfos == 0 CheckStage");
                    CheckStage();
                }
                else
                {
                    Debug.LogError("NormalBarrageInfos != 0 CheckStage");

                    if (CurStage == EnumControversyStage.StageTwo)
                    {
                        if (IsStageClear() == false)
                        {
                            ChangeStage(EnumControversyStage.StageTwoLose);
                        }
                    }
                }
            }

            return(true);
        }
        private List <BarrageTextItem> ProcessBarrageText(BarrageItem barrageItem, string text)
        {
            List <BarrageTextItem> items = new List <BarrageTextItem>();
            bool isBeginWithHighlight    = text.StartsWith("HightLight_{");

            string[] strs  = text.Split(new string[] { "HightLight_{" }, StringSplitOptions.RemoveEmptyEntries);
            int      index = 1;

            for (int i = 0; i < strs.Length; i++)
            {
                if (i == 0 && !isBeginWithHighlight)
                {
                    items.Add(new BarrageTextItem()
                    {
                        ID = barrageItem.ID, Index = 0, IsHighLight = false, Text = strs[i], BarrageInfo = barrageItem
                    });
                    continue;
                }
                var specialStr = strs[i].Substring(0, strs[i].IndexOf('}'));
                items.Add(new BarrageTextItem()
                {
                    ID = barrageItem.ID, Index = index++, IsHighLight = true, Text = specialStr, BarrageInfo = barrageItem
                });

                var normalStr = strs[i].Substring(strs[i].IndexOf('}') + 1);
                if (normalStr.Length > 0)
                {
                    items.Add(new BarrageTextItem()
                    {
                        ID = barrageItem.ID, Index = 0, IsHighLight = false, Text = normalStr, BarrageInfo = barrageItem
                    });
                }
            }

            return(items);
        }
        public void SendBarrage(BarrageItem itemInfo)
        {
            if (m_freeSubViews.Count > 0)
            {
                var subview = m_freeSubViews.Dequeue();
                SendBarrage(subview, itemInfo);
            }
            else
            {
                PrefabManager.Instance.InstantiateAsync <UI_Judgment_ControversyBarrage_Item_SubView>(
                    UI_Judgment_ControversyBarrage_Item_SubView.VIEW_NAME,
                    (result) =>
                {
                    if (result.status == RequestStatus.FAIL)
                    {
                        return;
                    }

                    var subview = result.result as UI_Judgment_ControversyBarrage_Item_SubView;
                    subview.Init(subview.GetComponent <RectTransform>());
                    SendBarrage(subview, itemInfo);
                });
            }
        }
        private void SendBarrage(UI_Judgment_ControversyBarrage_Item_SubView subView, BarrageItem itemInfo)
        {
            Transform parent;
            int       track;

            if (itemInfo.IsSpecial)
            {
                track = ControversySpecialBarrageConfig.GetConfigByKey(itemInfo.ID).track;
            }
            else
            {
                track = ControversyBarrageConfig.GetConfigByKey(itemInfo.ID).track;
            }

            switch (track)
            {
            case 1:
                parent = m_go_beginLine1;
                break;

            case 2:
                parent = m_go_beginLine2;
                break;

            case 3:
                parent = m_go_beginLine3;
                break;

            case 4:
                parent = m_go_beginLine4;
                break;

            default:
                parent = m_go_beginLine1;
                break;
            }
            subView.transform.SetParent(parent);
            subView.transform.localScale    = Vector3.one;
            subView.transform.localPosition = Vector3.zero;
            subView.SetInfo(itemInfo, m_dictance);
            if (!m_barrageSubViews.ContainsKey(itemInfo.ID))
            {
                m_barrageSubViews.Add(itemInfo.ID, subView);
            }
        }