Esempio n. 1
0
    public static string GetTextById(uint text_id)
    {
        string text = "";

        table.LangTextDataBase langtextDb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(text_id);
        if (langtextDb != null)
        {
            text = langtextDb.strText;
        }
        else
        {
            Engine.Utility.Log.Error("Not Found LangTextDataBase id {0}", text_id);
        }
        return(text);
    }
Esempio n. 2
0
    public void SetTalkingBossID(uint bossID)
    {
        IEntity en = RoleStateBarManager.GetEntityByUserID <INPC>(bossID);

        if (en != null)
        {
            m_uTalkingBossID = (uint)en.GetProp((int)EntityProp.BaseID);
        }
        else
        {
            m_uTalkingBossID = 0;
        }
        if (m_uTalkingBossID != 0)
        {
            table.BossTalkDataBase db = GameTableManager.Instance.GetTableItem <table.BossTalkDataBase>((uint)m_uTalkingBossID);
            if (db != null)
            {
                table.LangTextDataBase ldb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(db.textID);
                if (ldb != null)
                {
                    if (!string.IsNullOrEmpty(ldb.talkVoice))
                    {
                        List <uint> idList = StringUtil.GetSplitStringList <uint>(ldb.talkVoice);
                        if (idList != null && idList.Count > 0)
                        {
                            uint audioID = idList[0];
                            if (audioID != 0)
                            {
                                DataManager.Manager <PetDataManager>().PlayCreateAudio(audioID);
                            }
                        }
                    }
                }
                if (TimerAxis.Instance().IsExist(m_uBossTalkTimerID, this))
                {
                    TimerAxis.Instance().KillTimer(m_uBossTalkTimerID, this);
                }
                TimerAxis.Instance().SetTimer(m_uBossTalkTimerID, db.aliveTime * 1000, this, 1);
                TimerAxis.Instance().SetTimer(m_uRefreshStatusTimerID, 1000, this, 1);
            }
        }
        RefreshAllRoleBarHeadStatus(HeadStatusType.BossSay);
    }
Esempio n. 3
0
    void InitAnswerStateUI(AnswerManager.eAnswerState answerState)
    {
        //还未开始答题, > 活动开启10s
        if (answerState == AnswerManager.eAnswerState.BeforeAnswerRule)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(true);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            table.LangTextDataBase langtextDb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(160002);
            m_label_AnswerRuleDesc.text = langtextDb.strText;

            int leftTime = (int)this.m_answerManager.GetPreStartLeftTime();
            if (leftTime > 0)
            {
                m_label_AnswerRuleLeftTime.gameObject.SetActive(true);
                m_label_AnswerRuleLeftTime.text = string.Format("距本轮活动开始 {0:D2}:{1:D2}", leftTime / 60, leftTime % 60);
            }
            else
            {
                m_label_AnswerRuleLeftTime.gameObject.SetActive(false);
            }
        }

        else if (answerState == AnswerManager.eAnswerState.BeforeAnswerDesc)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(true);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(false);
        }

        else if (answerState == AnswerManager.eAnswerState.BeforeAnswerDescCD)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(true);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            if (this.m_answerManager.QuestionIndex == 0)
            {
                m_label_AnswerReadyCDTitle.text = "即将开始答题";
                float PreStartleftTime = this.m_answerManager.PreStartTime;
                m_label_AnswerReadyCDNum.text = ((int)PreStartleftTime).ToString();
            }
            else
            {
                m_label_AnswerReadyCDTitle.text = "即将进入下一题";
                m_label_AnswerReadyCDNum.text   = Mathf.CeilToInt(this.m_answerManager.TrueOrFalseTime).ToString();
            }
        }

        else if (answerState == AnswerManager.eAnswerState.InQuestion)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(true);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            m_sprite_QuestionCD.gameObject.SetActive(true);

            uint   index  = DataManager.Manager <AnswerManager>().QuestionIndex;
            uint   maxNum = DataManager.Manager <AnswerManager>().MaxNum;
            string title  = string.Format("第{0}/{1}题", index, maxNum);
            m_label_QuestionTitle.text = title;

            uint questionId = DataManager.Manager <AnswerManager>().QuestionId;
            table.RightOrWrongDataBase db = GameTableManager.Instance.GetTableItem <table.RightOrWrongDataBase>(questionId);
            if (db != null)
            {
                m_label_QuestionDesc.text = db.answer;
            }


            float questionLeftTime = this.m_answerManager.QuestionTime;

            float fillAmount = questionLeftTime / 20f;
            m_sprite_QuestionCD.fillAmount = fillAmount;
            m_label_QuestionCDLabel.text   = Mathf.CeilToInt(questionLeftTime).ToString();
        }

        else if (answerState == AnswerManager.eAnswerState.InQuestionCD)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(true);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            m_sprite_QuestionCD.gameObject.SetActive(false);

            //中间弹出5、4、3、2、1
        }

        else if (answerState == AnswerManager.eAnswerState.AnswerAnswer)//答案  o  x
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(true);

            bool trueOrFalse = DataManager.Manager <AnswerManager>().AnswerTrueOrFalse;
            m_sprite_True.gameObject.SetActive(false);
            m_sprite_False.gameObject.SetActive(false);

            //添加特效
            m_widget_answerEffectRoot.gameObject.SetActive(true);
            AddTrueOrFalseEffect(trueOrFalse);
        }

        else if (answerState == AnswerManager.eAnswerState.AnswerNextCD)
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(false);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(true);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            m_label_AnswerReadyCDTitle.text = "即将进入下一题";
            m_label_AnswerReadyCDNum.text   = Mathf.CeilToInt(this.m_answerManager.TrueOrFalseTime).ToString();//3、2、1
        }

        else
        {
            m_trans_AnswerRuleRoot.gameObject.SetActive(true);
            m_label_AnswerReady.gameObject.SetActive(false);
            m_trans_AnswerReadyCD.gameObject.SetActive(false);
            m_trans_AnswerQuestion.gameObject.SetActive(false);
            m_trans_AnswerAnswer.gameObject.SetActive(false);

            table.LangTextDataBase langtextDb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(160002);
            m_label_AnswerRuleDesc.text = langtextDb.strText;
        }
    }
Esempio n. 4
0
    public static LangTalkData GetDataByCmd(GameCmd.stTalkDataScriptUserCmd_S cmd)
    {
        table.LangTextDataBase langtextDb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(cmd.txt_id);
        LangTalkData           data       = new LangTalkData();

        data.strStep = cmd.step;
        if (langtextDb != null)
        {
            data.nTextID = langtextDb.dwID;

            uint npcId;
            if (GetNpcIdForDaliyRingTask(out npcId))
            {
                data.nNpcId = npcId;
            }
            else
            {
                data.nNpcId = langtextDb.npcID;
            }

            data.npcType = (NpcType)langtextDb.npcType;
            data.nTaskId = langtextDb.taskID;

            if (!string.IsNullOrEmpty(langtextDb.talkVoice))
            {
                string[] voices = langtextDb.talkVoice.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                data.talkVoice = new uint[voices.Length];
                for (int i = 0; i < voices.Length; i++)
                {
                    data.talkVoice[i] = uint.Parse(voices[i]);
                }
            }

            for (int i = 0; i < cmd.buttons.Count; ++i)
            {
                table.LangTextDataBase btnDb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(cmd.buttons[i]);
                if (btnDb != null)
                {
                    LangTalkData.Button btn = new LangTalkData.Button();
                    btn.taskId     = btnDb.taskID;
                    btn.nindex     = (uint)i + 1;
                    btn.strBtnName = btnDb.strText;
                    data.buttons.Add(btn);
                }
            }

            IEnumerable <XNode> nodes = XDocument.Parse("<root>" + langtextDb.strText + "</root>").Root.Nodes();
            if (nodes != null)
            {
                foreach (var n in nodes)
                {
                    var e = n as XElement;
                    if (e != null)
                    {
                        switch (e.Name.ToString())
                        {
                        case "talk":
                            LangTalkData.Talk talk = new LangTalkData.Talk();
                            if (e.Attribute("type") != null)
                            {
                                var type = int.Parse(e.AttributeValue("type"));
                                talk.bUser = type == 2;
                            }
                            if (e.Attribute("text") != null)
                            {
                                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                                string text       = e.AttributeValue("text");
                                string strColor   = "";
                                bool   starttoken = false;
                                for (int i = 0; i < text.Length; i++)
                                {
                                    if (starttoken)
                                    {
                                        if (text[i] == '0' || text[i] == '1' || text[i] == '2' || text[i] == '3' ||
                                            text[i] == '4' || text[i] == '5' || text[i] == '6' || text[i] == '7' ||
                                            text[i] == '8' || text[i] == '9' || text[i] == 'a' || text[i] == 'b' ||
                                            text[i] == 'c' || text[i] == 'd' || text[i] == 'e' || text[i] == 'f' ||
                                            text[i] == 'A' || text[i] == 'B' || text[i] == 'C' || text[i] == 'D' ||
                                            text[i] == 'E' || text[i] == 'F' || text[i] == '-')
                                        {
                                            strColor += text[i];
                                        }
                                        else if (text[i] == ']')
                                        {
                                            starttoken = false;
                                            strColor  += ']';
                                            if (strColor.Length == 8)
                                            {
                                                strColor = strColor.Replace("[", "<color value=\"#");
                                                strColor = strColor.Replace("]", "\">");
                                                stringBuilder.Append(strColor);
                                            }
                                            else if (strColor.Length == 3)
                                            {
                                                strColor = strColor.Replace("[-]", "</color>");
                                                stringBuilder.Append(strColor);
                                            }
                                            else
                                            {
                                                stringBuilder.Append(strColor);
                                            }
                                            strColor = "";
                                        }
                                        else
                                        {
                                            starttoken = false;
                                            strColor  += text[i];
                                            stringBuilder.Append(strColor);
                                        }
                                    }
                                    else if (text[i] == '[')
                                    {
                                        strColor   = "[";
                                        starttoken = true;
                                    }
                                    else
                                    {
                                        starttoken = false;
                                        stringBuilder.Append(text[i]);
                                    }
                                }
                                talk.strText = stringBuilder.ToString();
                            }
                            data.lstTalks.Add(talk);
                            break;
                        }
                        continue;
                    }
                }
            }
        }
        else
        {
            Engine.Utility.Log.Error("Not Found LangTextDataBase id {0}", cmd.txt_id);
        }

        return(data);
    }
Esempio n. 5
0
    /// <summary>
    /// 更新顶部栏状态
    /// </summary>
    public void UpdateHeadStatus(HeadStatusType type, bool adjustPos = true)
    {
        RoleStateBarManager mgr    = DataManager.Manager <RoleStateBarManager>();
        IEntity             entity = RoleStateBarManager.GetEntity(UID);

        if (null == entity)
        {
            return;
        }
        Transform widget = GetWidget(type);

        if (null != widget)
        {
            QuestTraceInfo traceInfo = null;
            bool           visible   = false;
            if (type != HeadStatusType.TaskStatus)
            {
                visible = RoleStateBarManager.IsEntityHeadStatusTypeEnable(entity, type);
            }
            else
            {
                if (RoleStateBarManager.TryGetNPCTraceInfo(entity, out traceInfo))
                {
                    visible = true;
                }
            }
            if (widget.gameObject.activeSelf != visible)
            {
                widget.gameObject.SetActive(visible);
            }
            if (type == HeadStatusType.Title &&
                null != m_particleWidget)
            {
                m_particleWidget.ReleaseParticle();
            }
            if (visible)
            {
                switch (type)
                {
                case HeadStatusType.Hp:
                    if (null != m_hpSlider && null != m_spHpbg && null != m_spHpForg)
                    {
                        float          hpPer = entity.GetProp((int)CreatureProp.Hp) / (float)entity.GetProp((int)CreatureProp.MaxHp);
                        EntityHpSprite hpSp  = RoleStateBarManager.GetEntityHpSpData(entity);
                        if (hpSp != null)
                        {
                            m_spHpbg.spriteName = hpSp.bgSpriteName;
                            m_spHpbg.MakePixelPerfect();
                            m_spHpForg.spriteName = hpSp.spriteName;
                            m_spHpForg.MakePixelPerfect();
                            m_hpSlider.gameObject.SetActive(hpSp.bShow);
                            m_hpSlider.value = hpPer;
                        }
                    }
                    break;

                case HeadStatusType.Name:
                    if (null != m_labName)
                    {
                        m_labName.text = ColorManager.GetColorString(mgr.GetNameColor(entity), entity.GetName());
                    }
                    break;

                case HeadStatusType.Clan:
                    if (null != m_labClanName)
                    {
                        Action <string, int> clanNameDlg = (clanName, getNameSeed) =>
                        {
                            if (getNameSeed >= m_iGetNameSeed)
                            {
                                //保证先后
                                //string name = DataManager.Manager<TextManager>().GetLocalFormatText(LocalTextType.Clan_Commond_shizumingzi, clanName);
                                //labelClan.fontSize = data.m_nFontSize;
                                m_labClanName.text = ColorManager.GetColorString(RoleStateBarManager.GetClanNameColor(entity), clanName);
                            }
                        };
                        RoleStateBarManager.GetRoleBarClanName(entity, clanNameDlg, ++m_iGetNameSeed);
                    }
                    break;

                case HeadStatusType.Title:
                    if (null != m_labTitle)
                    {
                        table.TitleDataBase titleDb = RoleStateBarManager.GetTitleText(entity);
                        if (null != titleDb)
                        {
                            bool visibleTxt = (titleDb.UIState == 0);
                            if (null != m_labTitle)
                            {
                                if (m_labTitle.gameObject.activeSelf != visibleTxt)
                                {
                                    m_labTitle.gameObject.SetActive(visibleTxt);
                                }
                                m_labTitle.text = titleDb.SceneTextUI;
                            }

                            if (null != m_particleWidget)
                            {
                                if (m_particleWidget.gameObject.activeSelf == visibleTxt)
                                {
                                    m_particleWidget.gameObject.SetActive(!visibleTxt);
                                }

                                m_particleWidget.AddParticle(titleDb.FxUI, m_particleRelativeWidget);
                            }
                        }
                    }
                    break;

                case HeadStatusType.Collect:
                    if (null != m_labCollectTips)
                    {
                        m_labCollectTips.color = ColorManager.GetColor32OfType(ColorType.JSXT_CaiJiWu);
                    }
                    break;

                case HeadStatusType.HeadMaskIcon:
                    if (null != m_spHeadMask)
                    {
                        table.NpcHeadMaskDataBase npcmaskDB = RoleStateBarManager.GetNPCHeadMaskDB(entity);
                        string iconName = (null != npcmaskDB) ? npcmaskDB.headMaskIcon : "";
                        UIManager.GetAtlasAsyn(iconName, ref m_headCASD, () =>
                        {
                            if (null != m_spHeadMask)
                            {
                                m_spHeadMask.atlas = null;
                            }
                        }, m_spHeadMask);
                    }
                    break;

                case HeadStatusType.TaskStatus:
                    if (null != m_spTaskStatus && null != traceInfo)
                    {
                        long   uid  = 0;
                        string icon = "";
                        if (RoleStateBarManager.TryGetQuestStatusIcon(traceInfo, out uid, out icon) &&
                            uid == UID)
                        {
                            UIManager.GetAtlasAsyn(icon, ref m_taskCASD, () =>
                            {
                                if (null != m_spTaskStatus)
                                {
                                    m_spTaskStatus.atlas = null;
                                }
                            }, m_spTaskStatus);
                        }
                        else
                        {
                            widget.gameObject.SetActive(false);
                        }
                    }
                    break;

                case HeadStatusType.CampMask:
                {
                    bool isGod = true;
                    int  camp  = entity.GetProp((int)Client.CreatureProp.Camp);
                    if (camp == (int)GameCmd.eCamp.CF_Red)
                    {
                        isGod = false;
                    }
                    if (null != m_tsDemonMask && m_tsDemonMask.gameObject.activeSelf == isGod)
                    {
                        m_tsDemonMask.gameObject.SetActive(!isGod);
                    }

                    if (null != m_tsGodMask && m_tsGodMask.gameObject.activeSelf != isGod)
                    {
                        m_tsGodMask.gameObject.SetActive(isGod);
                    }
                }
                break;

                case HeadStatusType.BossSay:
                {
                    uint npcID = DataManager.Manager <RoleStateBarManager>().GetTalkingBossID();

                    table.BossTalkDataBase db = GameTableManager.Instance.GetTableItem <table.BossTalkDataBase>(npcID);
                    if (db != null)
                    {
                        uint textID = db.textID;
                        table.LangTextDataBase ldb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(textID);
                        if (ldb != null)
                        {
                            m_bossText.text = ldb.strText;
                        }
                        m_bossTalk.gameObject.SetActive(visible);
                    }
                    else
                    {
                        m_bossTalk.gameObject.SetActive(false);
                    }
                }
                break;
                }
            }

            if (adjustPos)
            {
                AdjustStatusPos();
            }
        }
    }