예제 #1
0
    public void Show(ulong PlayerID, List <uint> QuestionIDLst, Action CloseCallback = null)
    {
        GameApp.Instance.FightUI.CurEventTypeIsQandA = true;

        IsChallenger = (GameApp.Instance.CurRoomPlayerLst[GetMyselfIndex()].id == PlayerID);
        if (IsChallenger)
        {
            ChallengerName.text = "";
            for (int i = 0; i < AnswerBtn.Length; i++)
            {
                AnswerBtn[i].isEnabled = true;
            }
            CountdownLab.gameObject.SetActive(true);
        }
        else
        {
            for (int i = 0; i < GameApp.Instance.CurRoomPlayerLst.Count; i++)
            {
                if (GameApp.Instance.CurRoomPlayerLst[i].id == PlayerID)
                {
                    CurChallengerName   = GameApp.Instance.CurRoomPlayerLst[i].name;
                    ChallengerName.text = StringBuilderTool.ToInfoString(CurChallengerName, "正在挑战魔王...");
                    break;
                }
            }
            for (int i = 0; i < AnswerBtn.Length; i++)
            {
                AnswerBtn[i].isEnabled = false;
            }
            CountdownLab.gameObject.SetActive(false);
        }

        UpdateScore();

        BossQuestionIDLst = QuestionIDLst;

        for (int i = 0; i < StateArrays.Length; i++)
        {
            for (int j = 0; j < StateArrays[i].Length; j++)
            {
                StateArrays[i][j].spriteName = "i-shalou";
            }
        }

        for (int k = 0; k < Items.Length; k++)
        {
            Items[k].SetIsEnabled(true);
        }

        CurType  = ELibraryType.eBoss;
        RightNum = 0;
        ErrorNum = 0;

        isRight = false;
        IsRobotAnsweredFinished = false;
        AnswerPlayerNum         = 0;
        CloseQAUINum            = 0;
        CurBossQuestionIndex    = 0;

        CurQuestionCfg = null;

        BattleBgFrame.spriteName = "bg_daan_pt";

        BattleBg.mainTexture = Resources.Load("BigUITexture/fight-changjing02") as Texture;

        CountdownNum = GameApp.Instance.GetParameter("BossQandACD");

        if (!CsvConfigTables.Instance.QuestionCsvDic.TryGetValue((int)BossQuestionIDLst[CurBossQuestionIndex], out CurQuestionCfg))
        {
            GameApp.Instance.CommonMsgDlg.OpenSimpleMsgBox(StringBuilderTool.ToString("题库中未找到ID为", BossQuestionIDLst[CurBossQuestionIndex], "的题目!"));
            return;
        }

        CsvConfigTables.Instance.MonsterCsvDic.TryGetValue(4, out MonsterCfg);

        int MyselfIndex = GetMyselfIndex();

        for (int i = 0; i < StateArrays.Length; i++)
        {
            if (i != MyselfIndex)
            {
                for (int j = 0; j < StateArrays[i].Length; j++)
                {
                    StateArrays[i][j].spriteName = "i-yanjing";
                }
            }
        }

        CreatefFightVisualize(CloseCallback);
    }
예제 #2
0
    public void Show(bool isShow, uint QuestionID = 0, ELibraryType type = ELibraryType.eNormal, Action CloseCallback = null)
    {
        if (isShow)
        {
            GameApp.Instance.FightUI.CurEventTypeIsQandA = true;
            //GameApp.Instance.UICurrency.Show(true);

            UpdateScore();

            if (QuestionID == 0)
            {
                if (NormalQLLst.Count == 0)
                {
                    foreach (KeyValuePair <int, QuestionConfig> pair in CsvConfigTables.Instance.QuestionCsvDic)
                    {
                        if (pair.Value.LibraryType == 0 && pair.Value.SystemID == GameApp.Instance.CurFightStageCfg.GroupID % 100)
                        {
                            NormalQLLst.Add(pair.Key);
                        }
                    }
                }
                if (BossQLLst.Count == 0)
                {
                    foreach (KeyValuePair <int, QuestionConfig> pair in CsvConfigTables.Instance.QuestionCsvDic)
                    {
                        if (pair.Value.LibraryType == 1 && pair.Value.SystemID == GameApp.Instance.CurFightStageCfg.GroupID % 100)
                        {
                            BossQLLst.Add(pair.Key);
                        }
                    }
                }
            }

            for (int i = 0; i < StateArrays.Length; i++)
            {
                for (int j = 0; j < StateArrays[i].Length; j++)
                {
                    StateArrays[i][j].spriteName = "i-shalou";
                }
            }

            for (int k = 0; k < Items.Length; k++)
            {
                Items[k].SetIsEnabled(true);
            }

            //CourageState.SetActive(false);
            //for (int h = 0; h < CourageItems.Length; h++)
            //    CourageItems[h].gameObject.SetActive(false);

            CurType  = type;
            RightNum = 0;
            ErrorNum = 0;

            isRight = false;
            IsRobotAnsweredFinished = false;
            AnswerPlayerNum         = 0;
            CloseQAUINum            = 0;

            //isEarningsHalved = false;

            CurQuestionCfg = null;

            BattleBgFrame.spriteName = "bg_daan_pt";

            ChallengerName.text = "";
            for (int i = 0; i < AnswerBtn.Length; i++)
            {
                AnswerBtn[i].isEnabled = true;
            }
            CountdownLab.gameObject.SetActive(true);

            switch (CurType)
            {
            case ELibraryType.eNormal:
            {
                BattleBg.mainTexture = Resources.Load("BigUITexture/fight-changjing01") as Texture;

                CountdownNum = GameApp.Instance.GetParameter("NormalQandACD");

                if (QuestionID == 0)
                {
                    int r = UnityEngine.Random.Range(0, NormalQLLst.Count);
                    if (CsvConfigTables.Instance.QuestionCsvDic.TryGetValue(NormalQLLst[r], out CurQuestionCfg))
                    {
                        NormalQLLst.RemoveAt(r);
                    }
                }
                else
                {
                    if (!CsvConfigTables.Instance.QuestionCsvDic.TryGetValue((int)QuestionID, out CurQuestionCfg))
                    {
                        GameApp.Instance.CommonMsgDlg.OpenSimpleMsgBox(StringBuilderTool.ToString("题库中未找到ID为", QuestionID, "的题目!"));
                        return;
                    }
                }

                CsvConfigTables.Instance.MonsterCsvDic.TryGetValue(3 /*UnityEngine.Random.Range(1, 3)*/, out MonsterCfg);

                //MonsterMagicPower.transform.parent.gameObject.SetActive(true);

                if (GameApp.Instance.PlayerData == null || GameApp.Instance.IsFightingRobot)
                {
                    RobotRespondence();
                }
            }
            break;

            case ELibraryType.eBoss:
            {
                BattleBg.mainTexture = Resources.Load("BigUITexture/fight-changjing02") as Texture;

                CountdownNum = GameApp.Instance.GetParameter("BossQandACD");

                if (QuestionID == 0)
                {
                    int r = UnityEngine.Random.Range(0, BossQLLst.Count);
                    if (CsvConfigTables.Instance.QuestionCsvDic.TryGetValue(BossQLLst[r], out CurQuestionCfg))
                    {
                        BossQLLst.RemoveAt(r);
                    }
                }
                else
                {
                    if (!CsvConfigTables.Instance.QuestionCsvDic.TryGetValue((int)QuestionID, out CurQuestionCfg))
                    {
                        GameApp.Instance.CommonMsgDlg.OpenSimpleMsgBox(StringBuilderTool.ToString("题库中未找到ID为", QuestionID, "的题目!"));
                        return;
                    }
                }

                CsvConfigTables.Instance.MonsterCsvDic.TryGetValue(4, out MonsterCfg);

                //MonsterMagicPower.transform.parent.gameObject.SetActive(false);

                int MyselfIndex = GetMyselfIndex();
                for (int i = 0; i < StateArrays.Length; i++)
                {
                    if (i != MyselfIndex)
                    {
                        for (int j = 0; j < StateArrays[i].Length; j++)
                        {
                            StateArrays[i][j].spriteName = "i-yanjing";
                        }
                    }
                }
            }
            break;
            }

            CreatefFightVisualize(CloseCallback);
        }
        else
        {
            GameApp.Instance.SoundInstance.StopSe(CurQuestionCfg.Voice);
            GameApp.Instance.SoundInstance.StopSe(CurQuestionCfg.WrongVoice);

            //GameApp.Instance.UICurrency.Show(false);

            StopCoroutine("Countdown");
            StopCoroutine("_AutoCloseCountdown");

            TweenControl.Instance.TweenScaleEffect(Settlement, 0.2f, 1, 0);

            Destroy(MainPlayer);
            Destroy(Monster);

            if (gameObject.activeSelf)
            {
                AppearEffect.Close(AppearType.Popup, () =>
                {
                    for (int j = 0; j < AnswerBtn.Length; j++)
                    {
                        AnswerBtn[j].isEnabled = true;
                        //OptionBgColor[j].spriteName = OptionBgColorSpriteName[j];

                        ResultSpr[j].gameObject.SetActive(false);
                    }

                    if (IsRunCloseCB)
                    {
                        if (CloseCB != null)
                        {
                            CloseCB();
                            CloseCB = null;
                        }
                    }

                    gameObject.SetActive(false);
                });
            }
            else
            {
                if (GameApp.Instance.PlayerData != null && !GameApp.Instance.IsFightingRobot)
                {
                    GameApp.Instance.FightUI.EnableNextPlayerThrowDice();
                }
            }

            if (GameApp.Instance.PlayerData != null && !GameApp.Instance.IsFightingRobot)
            {
                GameApp.SendMsg.AnswerQuestion((uint)CurQuestionCfg.QuestionID + 1000, false);
            }
        }
    }