Ejemplo n.º 1
0
        public CardInfo GetCardInfoByName(String name)
        {
            var translatedName = TtaTranslation.GetTranslatedText(name);
            var cardInfo       =
                cardInfos.FirstOrDefault(info => info.Value.CardName == name || info.Value.CardName == translatedName)
                .Value;

            if (cardInfo == null)
            {
                Assets.CSharpCode.UI.Util.LogRecorder.Log("Unknown name:" + translatedName);
                cardInfo = new CardInfo
                {
                    CardName =
                        TtaTranslation.GetTranslatedText(name).Trim(),
                    InternalId = CardInfo.UnknownInternalId,
                    CardType   = CardType.Unknown,
                    CardAge    = Age.A
                };
            }
            else
            {
                cardInfo = cardInfo.Clone();
            }

            return(cardInfo);
        }
        protected override void Refresh()
        {
            this.gameObject.SetActive(_display);
            var prefab = Resources.Load <GameObject>("Dynamic-PC/Dialog/DialogOption");

            //每一个Action都生成一个文本选项
            foreach (Transform t in OptionsFrame.transform)
            {
                Destroy(t.gameObject);
            }

            CardInfo card    = null;
            var      actions =
                Manager.CurrentGame.PossibleActions.Where(a => a.ActionType == PlayerActionType.ResolveEventOption)
                .ToList();

            for (var index = 0; index < actions.Count; index++)
            {
                var action     = actions[index];
                var optionText = TtaTranslation.GetTranslatedText(action.Data[1] as String);
                card = action.Data[0] as CardInfo;

                var mSp = Instantiate(prefab);

                var buttonController = mSp.GetComponent <DialogButtonController>();
                buttonController.Manager    = this.Manager;
                buttonController.ButtonName = "ResolveEventDialog.Option.";
                buttonController.Data       = action.Data[1];

                mSp.transform.parent        = OptionsFrame.transform;
                mSp.transform.localPosition = new Vector3(0f, -0.6f * index, -0.01f);
                mSp.FindObject("OptionText").GetComponent <TextMesh>().text = optionText;
            }

            EventCardFrame.Bind(card);
        }
Ejemplo n.º 3
0
        public static void LoadCiviloPedia()
        {
            if (Civilopedias != null)
            {
                return;
            }

            TextAsset textAsset = Resources.Load <TextAsset>("Civilopedia/BGO.2.0");

            var dictStr = textAsset.text;

            Civilopedias = new Dictionary <string, TtaCivilopedia>();

            var civilopedia = new TtaCivilopedia();

            civilopedia.cardInfos = new Dictionary <string, CardInfo>();

            var rows = dictStr.Split("\n".ToCharArray());

            foreach (var row in rows)
            {
                var csvRow = CsvUtil.SplitRow(row.Trim());
                if (csvRow.Count != 20)
                {
                    continue;
                }

                try
                {
                    CardInfo info = new CardInfo
                    {
                        InternalId  = csvRow[0],
                        CardName    = TtaTranslation.GetTranslatedText(csvRow[1]).Trim(),
                        CardType    = (CardType)Convert.ToInt32(csvRow[2]),
                        CardAge     = (Age)Convert.ToInt32(csvRow[3]),
                        Description = csvRow[4],
                        NormalImage = "SpriteTile/Cards/" + csvRow[5].Replace(".png", "")
                    };

                    info.SmallImage = info.NormalImage + "_small";
                    UnityResources.LazyLoadSprite(info.SmallImage,
                                                  () => UnityResources.ZoomSprite(info.NormalImage, new Vector2(0.5f, 0.5f), 70f / 297f));

                    info.SpecialImage = "SpriteTile/Cards/" + csvRow[6].Replace(".png", "");

                    info.Package = csvRow[7];

                    info.ResearchCost  = ToIntList(csvRow[8], "/");
                    info.BuildCost     = ToIntList(csvRow[9], ",");
                    info.RedMarkerCost = ToIntList(csvRow[10], "|");

                    info.ImmediateEffects = new List <CardEffect>();
                    info.ImmediateEffects.AddRange(CreateEffects(csvRow[11])); //使用效果(ActionCard专用)
                    info.ImmediateEffects.AddRange(CreateEffects(csvRow[12])); //一次性效果(ColonyCard专用)

                    info.SustainedEffects = CreateEffects(csvRow[13]);         //持续效果

                    info.AffectedTrget = ToIntList(csvRow[14], ",");           //6月6日新加:影响对象

                    info.WinnerEffects = CreateEffects(csvRow[15]);
                    info.LoserEffects  = CreateEffects(csvRow[16]);

                    info.TacticComposition = ToIntList(csvRow[17], ",");
                    info.TacticValue       = string.IsNullOrEmpty(csvRow[18])
                        ? new List <int>()
                        : csvRow[18].Split("/".ToCharArray())
                                             .Select(a => Convert.ToInt32(a.Split(",".ToCharArray())[2]))
                                             .ToList();

                    info.ImmediateEffects.AddRange(CreateEffects(csvRow[19])); //领袖技能主动使用效果(LeaderCard专用)

                    civilopedia.cardInfos[info.InternalId] = info;
                }
                catch (Exception e)
                {
                    LogRecorder.Log(e.Message + " " + row);
                }
            }

            Civilopedias.Add("2.0", civilopedia);
        }