Пример #1
0
        private void DisplayTactics(TtaBoard board)
        {
            TacticFrame.MyTactic = board.Tactic;
            TacticFrame.Refresh();

            TacticOnBoardFrame.GetComponent <TextMesh>().text = board.Tactic == null ? "" : board.Tactic.CardName;
        }
Пример #2
0
        private void DisplayColony(TtaBoard board)
        {
            var colonyPrefab = Resources.Load <GameObject>("Dynamic-PC/Colony");

            foreach (Transform child in ColonyFrame.transform)
            {
                Destroy(child.gameObject);
            }

            for (int i = 0; i < board.Colonies.Count; i++)
            {
                var colonyCard = board.Colonies[i];

                GameObject cardGo = Instantiate(colonyPrefab);
                var        sp     = UnityResources.GetSprite(colonyCard.SpecialImage);
                if (sp != null)
                {
                    cardGo.GetComponent <SpriteRenderer>().sprite = sp;
                }

                cardGo.transform.SetParent(ColonyFrame.transform);
                cardGo.transform.localPosition = new Vector3(0, -0.205f * i);

                cardGo.GetComponent <PCBoardCardDisplayBehaviour>().Bind(colonyCard);
            }
        }
        private void Refresh(TtaBoard board)
        {
            var unknownCardPrefab = Resources.Load <GameObject>("Dynamic-PC/PCBoardCard-Small");

            foreach (Transform child in HandCardFrame.transform)
            {
                Destroy(child.gameObject);
            }

            float incr = 0.7f;

            List <CardInfo> cards = HandType == "HandCivilCard" ? board.CivilCards : board.MilitaryCards;

            if (cards.Count > 5)
            {
                incr = 0.7f * 4 / (cards.Count - 1);
            }

            for (int i = 0; i < cards.Count; i++)
            {
                var mSp             = Instantiate(unknownCardPrefab);
                var childController = mSp.AddComponent <HandCardChildController>();
                childController.ParentController = this;
                childController.Card             = cards[i];

                mSp.GetComponent <PCBoardCardDisplayBehaviour>()
                .Bind(cards[i], HandCardFrame.transform, new Vector3(i * incr, 0, -0.1f * i));
            }
        }
Пример #4
0
        private void DisplayWorkerPool(TtaBoard board)
        {
            var happyPrefab   = Resources.Load <GameObject>("Dynamic-PC/HappyWorker");
            var unhappyPrefab = Resources.Load <GameObject>("Dynamic-PC/UnhappyWorker");

            foreach (Transform child in WorkerPoolFrame.transform)
            {
                Destroy(child.gameObject);
            }

            float incr = board.Resource[ResourceType.WorkerPool] > 1
                ? (0.66f / (board.Resource[ResourceType.WorkerPool] - 1))
                : 0f;

            for (int i = 0; i < board.Resource[ResourceType.WorkerPool]; i++)
            {
                GameObject mSp;
                if (i < board.DisorderValue)
                {
                    mSp = Instantiate(unhappyPrefab);
                }
                else
                {
                    mSp = Instantiate(happyPrefab);
                }

                mSp.transform.SetParent(WorkerPoolFrame.transform);
                mSp.transform.localPosition = new Vector3(incr * i, 0);
            }
        }
        private void Update()
        {
            if (!SceneTransporter.IsCurrentGameRefreshed())
            {
                return;
            }

            if (SceneTransporter.CurrentGame.Boards.Count <= PlayerNo)
            {
                return;
            }

            TtaBoard board = SceneTransporter.CurrentGame.Boards[PlayerNo];


            PlayerNameTextMesh.GetComponent <TextMesh>().text = board.PlayerName;

            CultureTotalTextMesh.GetComponent <TextMesh>().text       = board.Resource[ResourceType.Culture].ToString();
            CultureIncrementalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.CultureIncrement].ToString();

            ScienceTotalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.Science].ToString() +
                (board.Resource[ResourceType.ScienceForMilitary] == 0
                    ? ""
                    : "<color=#ffa500ff>" +
                 (board.Resource[ResourceType.ScienceForMilitary] > 0 ? "+" : "")
                 + board.Resource[ResourceType.ScienceForMilitary].ToString() + "</color>");
            ScienceIncrementalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.ScienceIncrement].ToString();

            MilitaryStrengthTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.MilitaryForce].ToString();
            ExplorationTextMesh.GetComponent <TextMesh>().text = board.Resource[ResourceType.Exploration].ToString();

            ResourceTotalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.Resource].ToString() +
                (board.Resource[ResourceType.ResourceForMilitary] == 0
                    ? ""
                    : "<color=#ffa500ff>" +
                 (board.Resource[ResourceType.ResourceForMilitary] > 0 ? "+" : "")
                 + board.Resource[ResourceType.ResourceForMilitary].ToString() + "</color>");
            ResourceIncrementalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.ResourceIncrement].ToString();

            FoodTotalTextMesh.GetComponent <TextMesh>().text       = board.Resource[ResourceType.Food].ToString();
            FoodIncrementalTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.FoodIncrement].ToString();

            WhiteMarkerTextMesh.GetComponent <TextMesh>().text =
                board.Resource[ResourceType.WhiteMarker] + "/" + board.Resource[ResourceType.WhiteMarkerMax];

            RedMarkerTextMesh.GetComponent <TextMesh>().text = board.Resource[ResourceType.RedMarker] + "/" +
                                                               board.Resource[ResourceType.RedMarkerMax];
        }
Пример #6
0
        private void DisplayWhiteRedMarkers(TtaBoard board)
        {
            //framename是指ActionPoint的frame
            var missingPrefab = Resources.Load <GameObject>("Dynamic-PC/MissingMarker");
            var whitePrefab   = Resources.Load <GameObject>("Dynamic-PC/WhiteMarker");
            var redPrefab     = Resources.Load <GameObject>("Dynamic-PC/RedMarker");

            DisplayActionPoint(WhiteMarkerFrame,
                               board.Resource[ResourceType.WhiteMarkerMax] - board.Resource[ResourceType.WhiteMarker],
                               board.Resource[ResourceType.WhiteMarker], whitePrefab, missingPrefab);

            DisplayActionPoint(RedMarkerFrame,
                               board.Resource[ResourceType.RedMarkerMax] - board.Resource[ResourceType.RedMarker],
                               board.Resource[ResourceType.RedMarker], redPrefab, missingPrefab);
        }
Пример #7
0
 private void DisplayLeader(TtaBoard board)
 {
     if (board.Leader == null)
     {
         LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(null);
         LeaderFrame.GetComponent <SpriteRenderer>().sprite = UnityResources.GetSprite("leader_image_no_leader");
     }
     else
     {
         var sprite = UnityResources.GetSprite(board.Leader.SpecialImage) ??
                      UnityResources.GetSprite("leader_unknown");
         LeaderFrame.GetComponent <SpriteRenderer>().sprite = sprite;
         LeaderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.Leader);
     }
 }
        public void DisplayPlayerEvents(TtaBoard player, GameObject frame)
        {
            frame.FindObject("PlayerName").GetComponent <TextMesh>().text =
                player.PlayerName + ":";


            float start = 1.032f;

            var hidFrame = frame.FindObject("HiddenEvents");

            foreach (Transform child in hidFrame.transform)
            {
                Destroy(child.gameObject);
            }

            foreach (var eventCard in player.CurrentEventPlayed)
            {
                GameObject mSp = Instantiate(_hiddenEventsPrefeb);
                mSp.transform.SetParent(hidFrame.transform);
                mSp.transform.localPosition = new Vector3(start, -0.07f);
                mSp.transform.localScale    = new Vector3(1f, 1f, 1f);

                mSp.FindObject("AgeText").GetComponent <TextMesh>().text = eventCard.CardAge.ToString();

                start += 0.4f;
            }

            if (player.FutureEventPlayed.Count + player.CurrentEventPlayed.Count > 0)
            {
                GameObject sep = Instantiate(_hiddenEventsSeperatorPrefeb);
                sep.transform.SetParent(hidFrame.transform);
                sep.transform.localPosition = new Vector3(start - 0.16f, -0.07f);
                sep.transform.localScale    = new Vector3(1f, 1f, 1f);
                start += 0.22f - 0.16f;
            }

            foreach (var eventCard in player.FutureEventPlayed)
            {
                GameObject mSp = Instantiate(_hiddenEventsPrefeb);
                mSp.transform.SetParent(hidFrame.transform);
                mSp.transform.localPosition = new Vector3(start, -0.07f);
                mSp.transform.localScale    = new Vector3(1f, 1f, 1f);

                mSp.FindObject("AgeText").GetComponent <TextMesh>().text = eventCard.CardAge.ToString();

                start += 0.4f;
            }
        }
        private void Refresh(TtaBoard board)
        {
            var buildingPrefab = Resources.Load <GameObject>("Dynamic-PC/BuildingColumn");

            BuildingType[] buildingArray =
            {
                BuildingType.Farm,      BuildingType.Mine,    BuildingType.Arena,  BuildingType.Lab,
                BuildingType.Library,   BuildingType.Theater, BuildingType.Temple, BuildingType.AirForce,
                BuildingType.Artillery, BuildingType.Cavalry, BuildingType.Infantry
            };

            foreach (Transform child in BuildingCellFrame.transform)
            {
                Destroy(child.gameObject);
            }

            float incr = 0.7f;

            if (board.Buildings.Count() > 9)
            {
                incr = 0.7f * 8 / (board.Buildings.Count() - 1);
            }

            Age[] ages = { Age.A, Age.I, Age.II, Age.III };

            int i = 0;

            foreach (var t in buildingArray)
            {
                if (!board.Buildings.ContainsKey(t))
                {
                    continue;
                }

                var buildings = board.Buildings[t];

                GameObject cellGo = Instantiate(buildingPrefab);

                BuildingChildController bds = cellGo.GetComponent <BuildingChildController>();
                bds.Cells   = buildings;
                bds.Manager = this.Manager;

                cellGo.transform.SetParent(BuildingCellFrame.transform);
                cellGo.transform.localPosition = new Vector3(-3.926f + incr * i, 0.726f, -1f + 0.1f * i);

                i++;
            }
        }
        public void DisplayMyEvents(TtaBoard player)
        {
            float start = 0f;

            foreach (Transform child in MyEventsFrame.transform)
            {
                Destroy(child.gameObject);
            }

            foreach (var eventCard in player.CurrentEventPlayed)
            {
                GameObject mSp = Instantiate(_smallCardPrefeb);
                mSp.transform.SetParent(MyEventsFrame.transform);
                mSp.transform.localPosition = new Vector3(start, 0f);
                mSp.transform.localScale    = new Vector3(1f, 1f, 1f);

                mSp.GetComponent <PCBoardCardDisplayBehaviour>().Bind(eventCard);

                start += 0.7f;
            }

            if (player.FutureEventPlayed.Count + player.CurrentEventPlayed.Count > 0)
            {
                GameObject sep = Instantiate(_hiddenEventsSeperatorPrefeb);
                sep.transform.SetParent(MyEventsFrame.transform);
                sep.transform.localPosition = new Vector3(start - 1.13f, 0f);
                sep.transform.localScale    = new Vector3(1f, 1f, 1f);
                start += 0.16f;
            }

            foreach (var eventCard in player.FutureEventPlayed)
            {
                GameObject mSp = Instantiate(_smallCardPrefeb);
                mSp.transform.SetParent(MyEventsFrame.transform);
                mSp.transform.localPosition = new Vector3(start, 0f);
                mSp.transform.localScale    = new Vector3(1f, 1f, 1f);

                mSp.GetComponent <PCBoardCardDisplayBehaviour>().Bind(eventCard);

                start += 0.7f;
            }
        }
        private void Refresh(TtaBoard board)
        {
            var warningPrefab = Resources.Load <GameObject>("Dynamic-PC/Warning");

            foreach (Transform child in WarningFrame.transform)
            {
                Destroy(child.gameObject);
            }

            for (int i = 0; i < board.Warnings.Count; i++)
            {
                var warning = board.Warnings[i];

                GameObject cardGo = Instantiate(warningPrefab);

                cardGo.transform.SetParent(WarningFrame.transform);
                cardGo.transform.localPosition = new Vector3(0.26f * i, 0);

                cardGo.GetComponent <WarningDisplayBehaviour>().DisplayWarning(warning, WarningPopupFrame);
            }
        }
Пример #12
0
        private void DisplayYellowBlueBank(TtaBoard board)
        {
            //蓝点
            int blueMarkerOwn = board.Resource[ResourceType.BlueMarker];

            for (int blueMarkerDisplay = 15;
                 blueMarkerOwn >= 0 || blueMarkerDisplay >= 0;
                 blueMarkerDisplay--, blueMarkerOwn--)
            {
                if (blueMarkerDisplay >= 0)
                {
                    var bankGo = BlueBankMarkers[15 - blueMarkerDisplay];
                    bankGo.SetActive(blueMarkerOwn > 0);
                }
                else
                {
                    //Marker比上限还多
                    //添加几个新的
                }
            }

            //黄点
            int yellowMarkerOwn = board.Resource[ResourceType.YellowMarker];

            for (int yellowMarkerDisplay = 17;
                 yellowMarkerOwn >= 0 || yellowMarkerDisplay >= 0;
                 yellowMarkerDisplay--, yellowMarkerOwn--)
            {
                if (yellowMarkerDisplay >= 0)
                {
                    var bankGo = YellowBankMarkers[17 - yellowMarkerDisplay];
                    bankGo.SetActive(yellowMarkerOwn > 0);
                }
                else
                {
                    //Marker比上限还多
                    //添加几个新的
                }
            }
        }
Пример #13
0
        private void DisplayMilitaryHandCard(TtaBoard board)
        {
            var unknownCardPrefab = Resources.Load <GameObject>("Dynamic-PC/PCBoardCard-Small");

            foreach (Transform child in MilitaryHandCardFrame.transform)
            {
                Destroy(child.gameObject);
            }

            float incr = 0.7f;

            if (board.MilitaryCards.Count > 5)
            {
                incr = 0.7f * 4 / (board.MilitaryCards.Count - 1);
            }

            for (int i = 0; i < board.MilitaryCards.Count; i++)
            {
                Instantiate(unknownCardPrefab).GetComponent <PCBoardCardDisplayBehaviour>()
                .Bind(board.MilitaryCards[i], MilitaryHandCardFrame.transform, new Vector3(i * incr, 0, -0.1f * i));
            }
        }
Пример #14
0
        private static void ExtractBuildingBoard(TtaBoard board, string htmlShade)
        {
            board.Buildings = new Dictionary <BuildingType, Dictionary <Age, BuildingCell> >();
            var titleMap = new List <BuildingType>();

            var buildingBoardTableHtml = BgoRegexpCollections.ExtractBuildingBoard.Match(htmlShade).Groups[1].Value;

            var mcsRow = BgoRegexpCollections.ExtractBuildingBoardRow.Matches(buildingBoardTableHtml);

            //分析表头
            var titleRowHtml = mcsRow[0].Groups[1].Value;

            foreach (Match mcTitle in BgoRegexpCollections.FindP.Matches(titleRowHtml))
            {
                BuildingType bType;
                switch (mcTitle.Groups[1].Value)
                {
                case "Air Force":
                    bType = BuildingType.AirForce;
                    break;

                case "&nbsp;":
                    bType = BuildingType.Unknown;
                    break;

                default:
                    bType = (BuildingType)Enum.Parse(typeof(BuildingType), mcTitle.Groups[1].Value);
                    break;
                }

                if (bType != BuildingType.Unknown)
                {
                    titleMap.Add(bType);
                }
            }

            for (int rowIndex = 1; rowIndex < mcsRow.Count; rowIndex++)
            {
                //分析从第二行开始的内容
                var mcsColumn = BgoRegexpCollections.ExtractBuildingBoardCell.Matches(mcsRow[rowIndex].Groups[1].Value);

                //第一格是时代
                var strAge =
                    BgoRegexpCollections.FindP.Match(mcsColumn[0].Groups[1].Value).Groups[1].Value.Replace("Age&nbsp;",
                                                                                                           "");
                var age = (Age)Enum.Parse(typeof(Age), strAge);

                //从第二格开始
                for (int colIndex = 1; colIndex < mcsColumn.Count; colIndex++)
                {
                    if (mcsColumn[colIndex].Groups[1].Value == "&nbsp;")
                    {
                        continue;
                    }

                    BuildingCell cell = new BuildingCell();

                    var cellHtml = mcsColumn[colIndex].Groups[1].Value;

                    var mcsNameAndCount = BgoRegexpCollections.FindP.Matches(cellHtml);
                    var buildingName    = mcsNameAndCount[0].Groups[1].Value;
                    cell.Card = civilopedia.GetCardInfoByName(buildingName);

                    var workerCount = mcsNameAndCount[1].Groups[1].Value == "&nbsp;"
                        ? 0
                        : BgoRegexpCollections.ExtractBuildingBoardBuidingCount.Matches(mcsNameAndCount[1].Groups[1].Value).Count;
                    cell.Worker = workerCount;

                    var mcsResource = BgoRegexpCollections.ExtractBuildingBoardResourceCount.Matches(cellHtml);
                    cell.Storage = mcsResource.Count;

                    if (!board.Buildings.ContainsKey(titleMap[colIndex - 1]))
                    {
                        board.Buildings[titleMap[colIndex - 1]] = new Dictionary <Age, BuildingCell>();
                    }
                    board.Buildings[titleMap[colIndex - 1]].Add(age, cell);
                }
            }
        }
Пример #15
0
        // ReSharper disable once FunctionComplexityOverflow
        private static void FillPlayerBoard(TtaBoard board, String htmlShade)
        {
            #region 分析建筑面板

            ExtractBuildingBoard(board, htmlShade);

            #endregion

            //蓝点
            var blueMarkerHtml = BgoRegexpCollections.ExtractBlueMarker.Match(htmlShade).Groups[1].Value;
            board.Resource[ResourceType.BlueMarker] = BgoRegexpCollections.ExtractBlueMarkerCounter.Matches(blueMarkerHtml).Count;

            //黄点
            var yellowMarkerHtml = BgoRegexpCollections.ExtractYellowMarker.Match(htmlShade).Groups[1].Value;
            board.Resource[ResourceType.YellowMarker] = BgoRegexpCollections.ExtractYellowMarkerCounter.Matches(yellowMarkerHtml).Count;

            //红白点
            var matchCivilMilitaryActions = BgoRegexpCollections.ExtractGovenrmentAndActionPoints.Match(htmlShade);
            board.Government = civilopedia.GetCardInfoByName(matchCivilMilitaryActions.Groups[1].Value);

            int markerCount = BgoRegexpCollections.ExtractGovenrmentAndActionPointsCama.Matches(
                matchCivilMilitaryActions.Groups[2].Value).Count;
            int missingCount = BgoRegexpCollections.ExtractGovenrmentAndActionPointsMissing.Matches(
                matchCivilMilitaryActions.Groups[2].Value).Count;
            board.Resource[ResourceType.WhiteMarker]    = markerCount;
            board.Resource[ResourceType.WhiteMarkerMax] = markerCount + missingCount;

            //board.Resource[ResourceType.ExtraWhiteMarker] = 0;
            //board.ResourceFluctuation[ResourceType.ExtraWhiteMarker] = 0;

            markerCount =
                BgoRegexpCollections.ExtractGovenrmentAndActionPointsCama.Matches(
                    matchCivilMilitaryActions.Groups[3].Value).Count;
            missingCount =
                BgoRegexpCollections.ExtractGovenrmentAndActionPointsMissing.Matches(
                    matchCivilMilitaryActions.Groups[3].Value).Count;
            board.Resource[ResourceType.RedMarker]    = markerCount;
            board.Resource[ResourceType.RedMarkerMax] = markerCount + missingCount;

            //领袖
            var matchLeader = BgoRegexpCollections.ExtractLeader.Match(htmlShade);
            board.Leader = matchLeader.Success ? civilopedia.GetCardInfoByName(matchLeader.Groups[1].Value) : null;

            //闲置工人
            var matchWorkerPool = BgoRegexpCollections.ExtractWorkerPool.Match(htmlShade);
            board.Resource[ResourceType.WorkerPool] =
                BgoRegexpCollections.ExtractPlayerNameAndResourceHappy.Matches(matchWorkerPool.Groups[1].Value).Count
                +
                BgoRegexpCollections.ExtractPlayerNameAndResourceUnhappy.Matches(matchWorkerPool.Groups[1].Value).Count;

            //奇迹
            var matchWonder = BgoRegexpCollections.ExtractWonder.Match(htmlShade);
            board.CompletedWonders = new List <CardInfo>();
            foreach (Match m in BgoRegexpCollections.ExtractWondeName.Matches(matchWonder.Groups[1].Value))
            {
                if (m.Groups[3].Value != "")
                {
                    board.CompletedWonders.Add(civilopedia.GetCardInfoByName(m.Groups[3].Value));
                }
                else
                {
                    board.ConstructingWonder      = civilopedia.GetCardInfoByName(m.Groups[5].Value);
                    board.ConstructingWonderSteps = new List <string>();
                    foreach (Match mBuild in BgoRegexpCollections.ExtractWondeBuildStatus.Matches(m.Groups[6].Value))
                    {
                        board.ConstructingWonderSteps.Add(mBuild.Groups[1].Value.Length > 4
                            ? "X"
                            : mBuild.Groups[1].Value);
                    }
                }
            }

            //殖民地
            var colonyMatch = BgoRegexpCollections.ExtractColonyBox.Match(htmlShade);
            board.Colonies = new List <CardInfo>();
            foreach (Match m in BgoRegexpCollections.FindCardInfoFromUnorderedList.Matches(colonyMatch.Groups[1].Value))
            {
                var card = civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value), m.Groups[2].Value);
                board.Colonies.Add(card);
            }

            //特殊科技
            var    matchSpecialTech   = BgoRegexpCollections.ExtractSpecialTech.Match(htmlShade);
            String tech               = matchSpecialTech.Groups[1].Value;
            var    matchesSpecialTech = BgoRegexpCollections.ExtractSpecialTechName.Matches(tech);
            board.SpecialTechs = new List <CardInfo>();
            foreach (Match match in matchesSpecialTech)
            {
                CardInfo info = civilopedia.GetCardInfoByName(match.Groups[1].Value);
                board.SpecialTechs.Add(info);
            }

            //手牌
            var matchHandCivilCard = BgoRegexpCollections.ExtractHandCivilCard.Match(htmlShade);
            board.CivilCards = new List <CardInfo>();
            foreach (Match m in BgoRegexpCollections.ExtractHandCardName.Matches(matchHandCivilCard.Groups[1].Value))
            {
                board.CivilCards.Add(civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value), m.Groups[2].Value));
            }

            var matchHandMilitaryCard = BgoRegexpCollections.ExtractHandMilitaryCard.Match(htmlShade);
            board.MilitaryCards = new List <CardInfo>();
            foreach (Match m in BgoRegexpCollections.ExtractHandCardName.Matches(matchHandMilitaryCard.Groups[1].Value))
            {
                board.MilitaryCards.Add(civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value), m.Groups[2].Value));
            }

            //警告
            var warningMatch = BgoRegexpCollections.ExtractWarning.Match(htmlShade);
            board.Warnings = new List <Warning>();
            int corruptionValue = 0;
            foreach (Match m in BgoRegexpCollections.ExtractWarningItem.Matches(warningMatch.Groups[1].Value))
            {
                var playerColors = new[] { "Unknown", "Orange", "Purple", "Green", "Grey" };
                var warningStr   = m.Groups[1].Value;
                if (warningStr.StartsWith("War"))
                {
                    //War over Territory against Purple
                    var         warName = "WarOver" + warningStr.CutBetween("over ", " against");
                    WarningType t       = (WarningType)Enum.Parse(typeof(WarningType), warName);
                    Warning     w       = new Warning
                    {
                        Type = t,
                        Data = Array.IndexOf(playerColors, warningStr.CutAfter("against ")).ToString()
                    };
                    board.Warnings.Add(w);
                }
                else if (warningStr.StartsWith("Corruption"))
                {
                    corruptionValue++;
                }
                else if (warningStr.StartsWith("Famine"))
                {
                    Warning w = new Warning
                    {
                        Type = WarningType.Famine,
                    };
                    board.Warnings.Add(w);
                }
                else if (warningStr.StartsWith("Civil disorder"))
                {
                    Warning w = new Warning
                    {
                        Type = WarningType.CivilDisorder,
                    };
                    board.Warnings.Add(w);
                }
            }
            if (corruptionValue > 0)
            {
                Warning w = new Warning
                {
                    Type = WarningType.Corruption,
                    Data = corruptionValue.ToString()
                };
                board.Warnings.Add(w);
            }

            //阵型
            var matchTactic = BgoRegexpCollections.ExtractTactics.Match(htmlShade);
            board.Tactic = matchTactic.Success
                ? civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), matchTactic.Groups[1].Value),
                                                matchTactic.Groups[2].Value)
                : null;

            board.CurrentEventPlayed = new List <CardInfo>();
            board.FutureEventPlayed  = new List <CardInfo>();

            //已打出的事件(未知内容),success就表示有,那么就肯定没有已知内容
            var matchPlayedEvents = BgoRegexpCollections.ExtractPlayedEvents.Match(htmlShade);
            if (matchPlayedEvents.Success)
            {
                string eventStr   = matchPlayedEvents.Groups[1].Value;
                var    collection = board.CurrentEventPlayed;
                foreach (Match m in BgoRegexpCollections.ExtractPlayedEventsItem.Matches(eventStr))
                {
                    var ageStr = m.Groups[3].Value;
                    if (ageStr == "")
                    {
                        collection = board.FutureEventPlayed;
                        continue;
                    }
                    var unknownCard = CardInfo.UnknownMilitaryCard((Age)Enum.Parse(typeof(Age), ageStr));
                    collection.Add(unknownCard);
                }
            }
            else if (
                (matchPlayedEvents = BgoRegexpCollections.ExtractPlayedEventsVisible.Match(htmlShade)).Success)
            //已打出的事件(已知内容),success就表示有
            {
                string currentEventStr = matchPlayedEvents.Groups[1].Value;
                string futureEventStr  = matchPlayedEvents.Groups[2].Value;

                foreach (Match m in BgoRegexpCollections.FindCardInfoFromUnorderedList.Matches(currentEventStr))
                {
                    var card =
                        civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value), m.Groups[2].Value);
                    board.CurrentEventPlayed.Add(card);
                }

                foreach (Match m in BgoRegexpCollections.FindCardInfoFromUnorderedList.Matches(futureEventStr))
                {
                    var card =
                        civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value),
                                                      m.Groups[2].Value);
                    board.FutureEventPlayed.Add(card);
                }
            }
        }
Пример #16
0
        /// <summary>
        /// 填充面板的帮助方法
        /// </summary>
        /// <param name="html"></param>
        /// <param name="game"></param>
        // ReSharper disable once FunctionComplexityOverflow
        internal static void FillGameBoard(String html, BgoGame game)
        {
            //分析用户面板

            game.PossibleActions = new List <PlayerAction>();

            //解出卡牌列
            var matches = BgoRegexpCollections.ExtractCardRow.Matches(html);

            game.CardRow = new List <CardRowCardInfo>();

            foreach (Match mc in matches)
            {
                var card = civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), mc.Groups[5].Value),
                                                         mc.Groups[6].Value);

                BgoCardRowCardInfo cardRowCardInfo = new BgoCardRowCardInfo
                {
                    Card            = card,
                    CanPutBack      = mc.Groups[4].Value.Contains("carteEnMain"),
                    CanTake         = mc.Groups[2].Value != "" && (!mc.Groups[4].Value.Contains("carteEnMain")),
                    CivilActionCost =
                        BgoRegexpCollections.ExtractGovenrmentAndActionPointsMissing.Matches(mc.Groups[8].Value).Count
                };

                //LogRecorder.Log(card.CardName + mc.Groups[2].Value);

                BgoPlayerAction pa = new BgoPlayerAction
                {
                    ActionType = PlayerActionType.TakeCardFromCardRow
                };
                pa.Data[0] = cardRowCardInfo;
                pa.Data[1] = game.CardRow.Count; //Card Row Pos
                pa.Data[2] = mc.Groups[3].Value; //idNote
                pa.Data[3] = mc.Groups[2].Value; //PostUrl

                //能拿能放回去,才能有Action
                if (cardRowCardInfo.CanPutBack || cardRowCardInfo.CanTake)
                {
                    game.PossibleActions.Add(pa);
                }

                game.CardRow.Add(cardRowCardInfo);
            }

            //当前事件
            var matchCurrentEvent = BgoRegexpCollections.ExtractCurrentEvent.Match(html);

            if (matchCurrentEvent.Groups[3].Value == "")
            {
                game.CurrentEventAge  = (Age)Enum.Parse(typeof(Age), matchCurrentEvent.Groups[5].Value);
                game.CurrentEventCard =
                    civilopedia.GetCardInfoByName(game.CurrentEventAge, matchCurrentEvent.Groups[6].Value);
                game.CurrentEventCount = matchCurrentEvent.Groups[7].Value;
            }
            else
            {
                game.CurrentEventAge   = (Age)Enum.Parse(typeof(Age), matchCurrentEvent.Groups[3].Value);
                game.CurrentEventCard  = null;
                game.CurrentEventCount = matchCurrentEvent.Groups[7].Value;
            }

            //未来事件
            var matchFutureEvent = BgoRegexpCollections.ExtractFutureEvent.Match(html);

            if (matchFutureEvent.Groups[1].Value.Length > 4)
            {
                game.FutureEventAge   = Age.A;
                game.FutureEventCount = "0";
            }
            else
            {
                game.FutureEventAge   = (Age)Enum.Parse(typeof(Age), matchFutureEvent.Groups[1].Value);
                game.FutureEventCount = matchFutureEvent.Groups[2].Value;
            }

            //卡牌剩余
            var matchCivilRemain = BgoRegexpCollections.ExtractCivilCardRemains.Match(html);

            game.CivilCardsRemain = Convert.ToInt32(matchCivilRemain.Groups[2].Value);
            var matchMilitaryRemain = BgoRegexpCollections.ExtractMilitryCardRemains.Match(html);

            game.MilitaryCardsRemain = Convert.ToInt32(matchMilitaryRemain.Groups[2].Value);

            //当前阶段
            var matchPhase = BgoRegexpCollections.ExtractGamePhase.Match(html);
            var phase      = matchPhase.Groups[1].Value;

            switch (phase.Trim())
            {
            case "Political Phase":
                game.CurrentPhase = TtaPhase.PoliticalPhase;
                break;

            case "Action Phase":
                game.CurrentPhase = TtaPhase.ActionPhase;
                break;

            case "Event Resolution":
                game.CurrentPhase = TtaPhase.EventResolution;
                break;

            case "Discard Phase":
                game.CurrentPhase = TtaPhase.DiscardPhase;
                break;

            default:
                game.CurrentPhase = TtaPhase.OtherPhase;
                break;
            }

            //时代和回合
            var matchAgeAndRound = BgoRegexpCollections.ExtractAgeAndRound.Match(html);

            game.CurrentAge   = (Age)Enum.Parse(typeof(Age), matchAgeAndRound.Groups[1].Value);
            game.CurrentRound = Convert.ToInt32(matchAgeAndRound.Groups[2].Value);

            //可抄袭阵型
            var sharedTacticsMatch = BgoRegexpCollections.ExtractSharedTactics.Match(html);

            game.SharedTactics = new List <CardInfo>();
            foreach (Match m in BgoRegexpCollections.ExtractSharedTacticsItem.Matches(sharedTacticsMatch.Groups[1].Value))
            {
                if (m.Groups[1].Value == "&nbsp;")
                {
                    continue;
                }
                game.SharedTactics.Add(civilopedia.GetCardInfoByName((Age)Enum.Parse(typeof(Age), m.Groups[1].Value),
                                                                     m.Groups[2].Value));
            }

            //拆开玩家面板

            matches     = BgoRegexpCollections.ExtractPlayerPlate.Matches(html);
            game.Boards = new List <TtaBoard>();

            int plateStart = -1;

            foreach (Match mc in matches)
            {
                if (plateStart != -1)
                {
                    String plate = html.Substring(plateStart, mc.Index - plateStart);

                    TtaBoard board = new TtaBoard();
                    game.Boards.Add(board);

                    FillPlayerBoard(board, plate);
                }

                plateStart = mc.Index;


                if (mc.Groups[2].Value != "")
                {
                    break;
                }
            }

            #region 校准名字和资源

            ExtractPlayerNameAndResource(html, game);

            #endregion


            //可用行动
            var subDropdown = BgoRegexpCollections.ExtractSubDropDown("action").Match(html);
            if (subDropdown.Success)
            {
                matches = BgoRegexpCollections.ExtractActions.Matches(subDropdown.Groups[1].Value);
                foreach (Match mc in matches)
                {
                    BgoPlayerAction pa = new BgoPlayerAction {
                        ActionType = PlayerActionType.Unknown
                    };
                    pa.Data[0] = mc.Groups[2].Value;
                    pa.Data[1] = mc.Groups[1].Value;

                    game.PossibleActions.Add(pa);
                }

                Match mSubmitForm = BgoRegexpCollections.ExtractSubmitForm.Match(html);
                game.ActionForm = new Dictionary <string, string>();

                if (mSubmitForm.Success)
                {
                    game.ActionFormSubmitUrl = mSubmitForm.Groups[1].Value;
                    matches = BgoRegexpCollections.ExtractSubmitFormDetail.Matches(mSubmitForm.Groups[2].Value);
                    foreach (Match mc in matches)
                    {
                        if (mc.Groups[2].Value != "")
                        {
                            game.ActionForm[mc.Groups[2].Value] = "";
                        }
                        else
                        {
                            game.ActionForm[mc.Groups[4].Value] = mc.Groups[5].Value;
                        }
                    }
                }
            }

            BgoActionFormater.Format((BgoGame)game, html);
        }
Пример #17
0
        //用update会导致弹出窗口的OnMouseExit捕捉不到
        public void Refresh()
        {
            if (!SceneTransporter.IsCurrentGameRefreshed())
            {
                //当前游戏不完整,不刷新
                ////此处应该抛出异常
                return;
            }

            if (SceneTransporter.CurrentGame.Boards.Count <= BoardBehavior.CurrentPlayerBoardIndex)
            {
                //当前玩家编号出现错误,不刷新
                //此处应该抛出异常
                return;
            }

            TtaBoard board = SceneTransporter.CurrentGame.Boards[BoardBehavior.CurrentPlayerBoardIndex];

            DisplayCardRow(SceneTransporter.CurrentGame.CardRow);
            DisplayEventsAndCardCounts(SceneTransporter.CurrentGame);

            //如果当前阶段是PoliticalPhase,那么就展示PoliticalPhase
            if (SceneTransporter.CurrentGame.CurrentPhase == TtaPhase.PoliticalPhase)
            {
                //不一定你是当前玩家,因为有可能别人在他的政治行动阶段打你呢
                //或者你正在处理一个事件
                if (SceneTransporter.CurrentGame.PossibleActions.Count > 0)
                {
                    DisplayPoliticalPhaseDialogs(SceneTransporter.CurrentGame);
                }
                else
                {
                    HideAllPoliticalPhaseDialogs();
                }
            }
            else
            {
                HideAllPoliticalPhaseDialogs();
            }

            var backgroundSpriteName = "SpriteTile/PCBoard/pc-board-player-background-" + "orange,purple,green,grey".Split(",".ToCharArray())[BoardBehavior.CurrentPlayerBoardIndex];
            var backgroundsp         = UnityResources.GetSprite(backgroundSpriteName);

            BackgroundSpriteGo.GetComponent <SpriteRenderer>().sprite = backgroundsp;


            JournalFrame.Refresh();

            //展示用代码


            DisplayYellowBlueBank(board);

            DisplayWhiteRedMarkers(board);

            DisplayGovenrment(board);
            DisplayLeader(board);

            DisplayCivilHandCard(board);
            DisplayMilitaryHandCard(board);

            DisplayWonders(board);
            DisplayColony(board);

            DisplayBuildings(board);

            DisplaySpecialTech(board);

            DisplayWarnings(board);

            DisplayTactics(board);

            DisplayWorkerPool(board);
        }
Пример #18
0
 private void DisplayGovenrment(TtaBoard board)
 {
     GovernmentFrame.FindObject("Name").GetComponent <TextMesh>().text = board.Government.CardName;
     GovernmentFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.Government);
 }
Пример #19
0
        private void DisplaySpecialTech(TtaBoard board)
        {
            SpecialTechFrame.SpecialTechs = board.SpecialTechs;

            SpecialTechFrame.Refresh();
        }
Пример #20
0
        private void DisplayWonders(TtaBoard board)
        {
            //建造中
            if (board.ConstructingWonder != null)
            {
                ConstructingWonderFrame.SetActive(true);
                ConstructingWonderFrame.FindObject("WonderName").GetComponent <TextMesh>().text =
                    board.ConstructingWonder.CardName;
                var stepFrame = ConstructingWonderFrame.FindObject("Steps");

                foreach (Transform child in stepFrame.transform)
                {
                    Destroy(child.gameObject);
                }

                var stepPrefab = Resources.Load <GameObject>("Dynamic-PC/WonderBuildingStage");

                float init = -0.16f * board.ConstructingWonderSteps.Count + 0.16f;
                for (int index = 0; index < board.ConstructingWonderSteps.Count; index++)
                {
                    var str = board.ConstructingWonderSteps[index];

                    var mSp = Instantiate(stepPrefab);
                    if (str == "X")
                    {
                        mSp.FindObject("StepText").SetActive(false);
                    }
                    else
                    {
                        mSp.FindObject("BlueMarker").SetActive(false);
                        mSp.FindObject("StepText").GetComponent <TextMesh>().text = str;
                    }
                    mSp.transform.parent        = stepFrame.transform;
                    mSp.transform.localPosition = new Vector3(init + 0.16f * index, 0, 0);
                }

                ConstructingWonderFrame.GetComponent <PCBoardCardDisplayBehaviour>().Bind(board.ConstructingWonder);
            }
            else
            {
                ConstructingWonderFrame.SetActive(false);
            }

            //建造完成
            var wonderPrefab = Resources.Load <GameObject>("Dynamic-PC/CompletedWonder");

            foreach (Transform child in CompletedWondersFrame.transform)
            {
                Destroy(child.gameObject);
            }

            for (int i = 0; i < board.CompletedWonders.Count; i++)
            {
                var wonderCard = board.CompletedWonders[i];

                GameObject cardGo = Instantiate(wonderPrefab);
                cardGo.FindObject("WonderName").GetComponent <TextMesh>().text = wonderCard.CardName;

                cardGo.transform.SetParent(CompletedWondersFrame.transform);
                cardGo.transform.localPosition = new Vector3(0, -0.27f * i);

                cardGo.FindObject("Mask").GetComponent <PCBoardCardDisplayBehaviour>().Bind(wonderCard);

                var sp = UnityResources.GetSprite(wonderCard.SpecialImage);
                if (sp != null)
                {
                    cardGo.FindObject("Image").GetComponent <SpriteRenderer>().sprite = sp;
                }
            }
        }