Example #1
0
        private void ProcessTreaty(
            XmlElement element,
            DiplomacyActionWeights.DiplomacyActionWeight weight)
        {
            string attribute = element.GetAttribute("type");

            if (attribute.Contains("Limitation"))
            {
                LimitationTreatyType limitationTreatyType = (LimitationTreatyType)Enum.Parse(typeof(LimitationTreatyType), attribute.Replace("Limitation", ""));
                weight.Type = (object)limitationTreatyType;
            }
            else
            {
                int num = (int)Enum.Parse(typeof(TreatyType), attribute);
            }
        }
Example #2
0
        private void SyncLimitationGroup(LimitationTreatyType ltt)
        {
            this._app.UI.ClearItems("lstLimitationGroup");
            switch (ltt)
            {
            case LimitationTreatyType.ShipClass:
                using (Dictionary <ShipClass, string> .Enumerator enumerator = TreatyEditDialog.ShipClassLimitationGroups.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <ShipClass, string> current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value));
                    }
                    break;
                }

            case LimitationTreatyType.Weapon:
                using (IEnumerator <LogicalWeapon> enumerator = this._app.AssetDatabase.Weapons.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        LogicalWeapon current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, current.UniqueWeaponID, current.WeaponName);
                    }
                    break;
                }

            case LimitationTreatyType.ResearchTree:
                int userItemId = 0;
                using (List <TechFamily> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.TechFamilies.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TechFamily current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, userItemId, current.Name);
                        ++userItemId;
                    }
                    break;
                }

            case LimitationTreatyType.ResearchTech:
                using (List <Tech> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.Technologies.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Tech           current         = enumerator.Current;
                        int            techId          = this._app.GameDatabase.GetTechID(current.Id);
                        PlayerTechInfo playerTechInfo1 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.InitiatingPlayerId, techId);
                        PlayerTechInfo playerTechInfo2 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.ReceivingPlayerId, techId);
                        if (playerTechInfo1 != null && playerTechInfo1.State != TechStates.Researched && (playerTechInfo1.State != TechStates.Researching && playerTechInfo2 != null) && (playerTechInfo2.State != TechStates.Researched && playerTechInfo2.State != TechStates.Researching))
                        {
                            this._app.UI.AddItem("lstLimitationGroup", string.Empty, techId, current.Name);
                        }
                    }
                    break;
                }

            case LimitationTreatyType.StationType:
                using (Dictionary <StationType, string> .Enumerator enumerator = TreatyEditDialog.StationTypeLimitationGroups.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <StationType, string> current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value));
                    }
                    break;
                }
            }
        }