Ejemplo n.º 1
0
        /// <summary>
        /// 读取CardResultInfo信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static CardResultInfo[] CreateCardResultInfoArrayWithExcel(string filePath)
        {
            int col = 0, row = 0;
            DataRowCollection collect = ReadExcel(filePath, ref col, ref row);

            CardResultInfo[] array = new CardResultInfo[row - 2];
            for (int i = 2; i < row; i++)
            {
                CardResultInfo info = new CardResultInfo();
                info.levelID        = int.Parse(collect[i][0].ToString());
                info.leftCardID     = int.Parse(collect[i][1].ToString());
                info.rightCardID    = int.Parse(collect[i][2].ToString());
                info.rightFirst     = int.Parse(collect[i][3].ToString()) == 1 ? true : false;
                info.Score          = int.Parse(collect[i][4].ToString());
                info.resultString   = collect[i][5].ToString();
                info.SpecialEndID   = int.Parse(collect[i][6].ToString());
                info.SpecialEndName = collect[i][7].ToString();
                array[i - 2]        = info;
            }
            return(array);
        }
Ejemplo n.º 2
0
    public void nextLine()
    {
        if (this.isFail)
        {
            return;
        }
        if (this.EndID != -1)   //进入结局界面
        {
            Game.Instance.gameResultID = this.EndID;
            SceneManager.LoadScene("ResultScene");
            return;
        }

        this.lineNum -= 1;
        if (this.lineNum < 0 || this.lineNum > 3)
        {
            return;
        }
        if (this.resultNum < 0 || this.resultNum >= this.slots.Count)
        {
            return;
        }

        string         line       = "";
        GameObject     slot       = slots[resultNum];
        CardInfo       leftCard   = slot.transform.Find("LeftCard").GetComponent <SlotCardInstance>().thisCard.GetComponent <CardSingle>().cardInfo;
        CardInfo       rightCard  = slot.transform.Find("RightCard").GetComponent <SlotCardInstance>().thisCard.GetComponent <CardSingle>().cardInfo;
        CardResultInfo cardResult = cardResultInfo.Find(x => x.leftCardID == leftCard.cardID && x.rightCardID == rightCard.cardID);

        if (cardResult == null)
        {
            cardResult                = new CardResultInfo();
            cardResult.Score          = 0;
            cardResult.resultString   = "什么都没有发生……";
            cardResult.SpecialEndName = null;
            cardResult.rightFirst     = false;
            cardResult.SpecialEndID   = -1;
        }

        switch (this.lineNum)
        {
        case 3:
            ShowCardResult(cardResult.rightFirst);
            line = "卡牌属性为“" + CardTypeName[(int)leftCard.type] + "”和“" + CardTypeName[(int)rightCard.type] + "”;\n";
            if (leftCard.type == rightCard.type)
            {
                line += "匹配成功;\n";
                canvas.transform.Find("TextCardType/Click").gameObject.SetActive(true);
            }
            else
            {
                line        += "匹配失败;\n";
                this.lineNum = 0;
                isFail       = true;
                setButtons(this.resultNum > 0 ? ButtonState.LastPage : ButtonState.None, ButtonState.None, ButtonState.ReturnToSelect);
            }
            canvas.transform.Find("TextCardType").GetComponent <Text>().text = line;
            if (isMarked[this.resultNum])
            {
                nextLine();
            }
            break;

        case 2:
            if (cardResult.rightFirst)
            {
                line  = rightRole.roleName + ":" + rightCard.context.Replace("-", "") + "\n";
                line += leftRole.roleName + ":" + leftCard.context.Replace("-", "") + "\n";
            }
            else
            {
                line  = leftRole.roleName + ":" + leftCard.context.Replace("-", "") + "\n";
                line += rightRole.roleName + ":" + rightCard.context.Replace("-", "") + "\n";
            }
            line += "\n";
            canvas.transform.Find("TextCardContext").GetComponent <Text>().text = line;
            canvas.transform.Find("TextCardContext/Click").GetComponent <RectTransform>().anchoredPosition = new Vector3((line.Split('\n')[1].Length + 1) * 25 - 485, 0, 0);
            canvas.transform.Find("TextCardContext/Click").gameObject.SetActive(true);
            if (cardResult.Score == -1)
            {
                this.EndID = cardResult.SpecialEndID;
            }
            if (isMarked[this.resultNum])
            {
                nextLine();
            }
            break;

        case 1:
            line  = cardResult.resultString.Replace('-', '\n');
            line += "\n";
            canvas.transform.Find("TextResult").GetComponent <Text>().text = line;
            canvas.transform.Find("TextResult/Click").GetComponent <RectTransform>().anchoredPosition = new Vector3((line.Split('\n')[line.Split('\n').Length - 2].Length + 1) * 25 - 485, 32 - (line.Split('\n').Length - 2) * 32, 0);
            canvas.transform.Find("TextResult/Click").gameObject.SetActive(true);
            if (isMarked[this.resultNum])
            {
                nextLine();
            }
            break;

        case 0:
            line = "心动值增加:" + cardResult.Score + "\n";

            if (!this.isMarked[resultNum])
            {
                this.isMarked[resultNum] = true;
                //触发特殊结局
                if (cardResult.Score != -1)
                {
                    HeartValue += cardResult.Score;
                }
                else
                {
                    this.EndID = cardResult.SpecialEndID;
                }
            }

            //显示Button
            Debug.Log("关卡信息:" + levelResultInfo.levelID + "/" + levelResultInfo.successEndID);
            if (this.resultNum < this.slots.Count - 1)
            {
                setButtons(this.resultNum > 0 ? ButtonState.LastPage : ButtonState.None, ButtonState.None, ButtonState.NextPage);
            }
            else if (levelResultInfo.successEndID == -1)
            {
                if (this.HeartValue >= levelResultInfo.passScore)
                {
                    setButtons(this.resultNum > 0 ? ButtonState.LastPage : ButtonState.None, ButtonState.None, ButtonState.NextLevel);
                    line += "心动值达标,解锁下一阶段。\n";
                }
                else
                {
                    setButtons(this.resultNum > 0 ? ButtonState.LastPage : ButtonState.None, ButtonState.None, ButtonState.ReturnToSelect);
                    line += "心动值未达标,配对失败。\n";
                }
            }
            else
            {
                if (this.HeartValue >= levelResultInfo.passScore)
                {
                    this.EndID = levelResultInfo.successEndID;
                    Game.Instance.addCP(leftRole.roleID, rightRole.roleID);
                }
                else
                {
                    line      += "心动值未达标,配对失败。\n";
                    this.EndID = levelResultInfo.failEndID;
                }
            }

            canvas.transform.Find("TextHeartValue").GetComponent <Text>().text = line;

            break;

        default: break;
        }
        Debug.Log(line);
    }