private void SetBonusGroup(BonusGroup bonusGroup) { if (CurEdit_Bonus != null) { CurEdit_Bonus.IsEdit = false; CurEdit_Bonus = null; } Cur_BonusGroup = bonusGroup; foreach (Bonus bonus in Cur_BonusGroup.Bonuses) { if (bonus is Bonus_UnlockCardByID) { Cur_BonusGroup.IsSingleton = true; } } SetBonusGroupIsAlways(Cur_BonusGroup.IsAlways.ToString(), false); SetBonusGroupProbability(Cur_BonusGroup.Probability.ToString(), false); SetBonusGroupIsSingleton(Cur_BonusGroup.IsSingleton.ToString(), false); foreach (Bonus bonus in Cur_BonusGroup.Bonuses) { GenerateNewBonus(bonus); } UIManager.Instance.GetBaseUIForm <LevelEditorPanel>().StartCoroutine(Co_refresh); }
private static int getCategoryCount(bool hasStemen, BonusGroup currentBonusGroup) { #region Data int categoryCount; #endregion #region Logic categoryCount = currentBonusGroup.count; if (hasStemen) { categoryCount += 1; } #endregion return(categoryCount); }
public void Initialize(BonusGroup bonusGroup, UnityAction onClickAction, HashSet <int> exceptionCardIDs, List <Bonus_BudgetLifeEnergyMixed.BudgetLifeEnergyComb> exceptionBudgetLifeEnergyComb) { Reset(); BonusGroup = bonusGroup; if (BonusGroup.IsAlways) { Button.interactable = false; Button.enabled = false; Button.onClick.RemoveAllListeners(); } else { Button.interactable = true; Button.enabled = true; Button.onClick.RemoveAllListeners(); Button.onClick.AddListener(delegate { onClickAction(); AudioManager.Instance.SoundPlay("sfx/OnStoryButtonClick"); }); } List <int> newBonusCardIDs = new List <int>(); List <Bonus> removeBonuses = new List <Bonus>(); List <Bonus> addBonuses = new List <Bonus>(); foreach (Bonus bonus in BonusGroup.Bonuses) { if (bonus is Bonus_UnlockCardByID b_id) { if (exceptionCardIDs.Contains(b_id.CardID)) { removeBonuses.Add(bonus); } else { exceptionCardIDs.Add(b_id.CardID); } } } foreach (Bonus bonus in BonusGroup.Bonuses) { if (bonus is Bonus_UnlockCardByLevelNum b_level) { CardInfo_Base ci = AllCards.GetRandomCardInfoByLevelNum(b_level.LevelNum, exceptionCardIDs); removeBonuses.Add(bonus); if (ci != null) { exceptionCardIDs.Add(ci.CardID); newBonusCardIDs.Add(ci.CardID); } } if (bonus is Bonus_BudgetLifeEnergyMixed b_mixed) { Bonus_BudgetLifeEnergyMixed.BudgetLifeEnergyComb comb = b_mixed.GetBudgetLifeEnergyComb(exceptionBudgetLifeEnergyComb); removeBonuses.Add(bonus); if (comb != null) { exceptionBudgetLifeEnergyComb.Add(comb); addBonuses.AddRange(comb.GenerateBonuses()); } } } foreach (Bonus b in addBonuses) { BonusGroup.Bonuses.Add(b); } foreach (int newBonusCardID in newBonusCardIDs) { exceptionCardIDs.Add(newBonusCardID); BonusGroup.Bonuses.Add(new Bonus_UnlockCardByID(newBonusCardID)); } foreach (Bonus removeBonus in removeBonuses) { BonusGroup.Bonuses.Remove(removeBonus); } foreach (Bonus bonus in BonusGroup.Bonuses) { BonusItem_Base bi = BonusItem_Base.InstantiateBonusItem(bonus, Container); M_BonusItems.Add(bi); } if (M_BonusItems.Count == 1 && M_BonusItems[0] is BigBonusItem) { BigBonusItem bigBonusItem = (BigBonusItem)M_BonusItems[0]; card = bigBonusItem.CurrentCard; card.BeDimColor(); card.ShowCardBloom(false); BG_Image.gameObject.SetActive(false); BorderSelected.gameObject.SetActive(false); Border.gameObject.SetActive(false); } }
public static Level GetLevelFromXML(XmlNode node_levelInfo, out bool needRefresh) { needRefresh = false; string Name_zh = node_levelInfo.Attributes["name_zh"].Value; string Name_en = node_levelInfo.Attributes["name_en"].Value; SortedDictionary <string, string> names = new SortedDictionary <string, string> { { "zh", Name_zh }, { "en", Name_en } }; int picID = int.Parse(node_levelInfo.Attributes["picID"].Value); LevelTypes levelType = (LevelTypes)Enum.Parse(typeof(LevelTypes), node_levelInfo.Attributes["levelType"].Value); int difficultyLevel = int.Parse(node_levelInfo.Attributes["difficultyLevel"].Value); switch (levelType) { case LevelTypes.Enemy: { XmlNode node_EnemyInfo = node_levelInfo.FirstChild; EnemyType enemyType = (EnemyType)Enum.Parse(typeof(EnemyType), node_EnemyInfo.Attributes["enemyType"].Value); BuildInfo bi = BuildInfo.GetBuildInfoFromXML(node_EnemyInfo.FirstChild, out bool _needRefresh_build, BuildCards.DefaultCardLimitNumTypes.BasedOnCardBaseInfoLimitNum); needRefresh |= _needRefresh_build; XmlNode node_BonusGroupInfos = node_EnemyInfo.ChildNodes.Item(1); List <BonusGroup> BonusGroups = new List <BonusGroup>(); for (int i = 0; i < node_BonusGroupInfos.ChildNodes.Count; i++) { XmlNode bonusGroupInfo = node_BonusGroupInfos.ChildNodes.Item(i); BonusGroup bg = BonusGroup.GenerateBonusGroupFromXML(bonusGroupInfo, out bool _needRefresh_bonus); needRefresh |= _needRefresh_bonus; BonusGroups.Add(bg); } XmlNode node_CardPriorityInfos = node_EnemyInfo.ChildNodes.Item(2); CardPriority CardPriority = CardPriority.GenerateCardPriorityFromXML(node_CardPriorityInfos, out bool _needRefresh_priority); XmlNode node_ComboListInfos = node_EnemyInfo.ChildNodes.Item(3); List <CardCombo> ComboList = new List <CardCombo>(); for (int i = 0; i < node_ComboListInfos.ChildNodes.Count; i++) { XmlNode comboInfo = node_ComboListInfos.ChildNodes.Item(i); CardCombo cc = CardCombo.GenerateCardComboFromXML(comboInfo, out bool _needRefresh_combo); needRefresh |= _needRefresh_combo; ComboList.Add(cc); } Enemy enemy = new Enemy(picID, names, difficultyLevel, bi, enemyType, BonusGroups, ComboList, CardPriority); return(enemy); } case LevelTypes.Shop: { XmlNode node_ShopInfo = node_levelInfo.FirstChild; List <ShopItem> shopItems = new List <ShopItem>(); for (int i = 0; i < node_ShopInfo.ChildNodes.Count; i++) { XmlNode node_ShopItem = node_ShopInfo.ChildNodes.Item(i); ShopItem si = ShopItem.GenerateShopItemFromXML(node_ShopItem, out bool _needRefresh_shop); needRefresh |= _needRefresh_shop; if (si != null) { shopItems.Add(si); } } int shopItemCardCount = int.Parse(node_ShopInfo.Attributes["shopItemCardCount"].Value); int shopItemOthersCount = int.Parse(node_ShopInfo.Attributes["shopItemOthersCount"].Value); Shop shop = new Shop(picID, names, difficultyLevel, shopItems, shopItemCardCount, shopItemOthersCount); return(shop); } } return(null); }
public static Level BaseDeserialize(DataStream reader) { LevelTypes levelType = (LevelTypes)reader.ReadSInt32(); int levelID = reader.ReadSInt32(); int levelPicID = reader.ReadSInt32(); int levelNameCount = reader.ReadSInt32(); SortedDictionary <string, string> LevelNames = new SortedDictionary <string, string>(); for (int i = 0; i < levelNameCount; i++) { string ls = reader.ReadString8(); string value = reader.ReadString8(); LevelNames[ls] = value; } int difficultyLevel = reader.ReadSInt32(); Level res = null; switch (levelType) { case LevelTypes.Enemy: { BuildInfo BuildInfo = BuildInfo.Deserialize(reader); EnemyType EnemyType = (EnemyType)(reader.ReadSInt32()); int bonusCount = reader.ReadSInt32(); List <BonusGroup> BonusGroups = new List <BonusGroup>(); for (int i = 0; i < bonusCount; i++) { BonusGroups.Add(BonusGroup.Deserialize(reader)); } CardPriority cp = CardPriority.Deserialize(reader); int cardComboCount = reader.ReadSInt32(); List <CardCombo> cardComboList = new List <CardCombo>(); for (int i = 0; i < cardComboCount; i++) { cardComboList.Add(CardCombo.Deserialize(reader)); } res = new Enemy(levelPicID, LevelNames, difficultyLevel, BuildInfo, EnemyType, BonusGroups, cardComboList, cp); break; } case LevelTypes.Shop: { int count = reader.ReadSInt32(); List <ShopItem> shopItems = new List <ShopItem>(); for (int i = 0; i < count; i++) { ShopItem si = ShopItem.Deserialize(reader); shopItems.Add(si); } int shopItemCardCount = reader.ReadSInt32(); int shopItemOthersCount = reader.ReadSInt32(); res = new Shop(levelPicID, LevelNames, difficultyLevel, shopItems, shopItemCardCount, shopItemOthersCount); break; } } res.LevelID = levelID; return(res); }
public void Initialize(BonusGroup bonusGroup, IEnumerator co_refresh, UnityAction deleteAction, UnityAction clearAction, UnityAction onEditAction, UnityAction <bool, int, int, LevelEditorPanel.SelectCardContents> onStartSelectCard) { Clear(); Co_refresh = co_refresh; DeleteButton.onClick.RemoveAllListeners(); DeleteButton.onClick.AddListener(deleteAction); ClearButton.onClick.RemoveAllListeners(); ClearButton.onClick.AddListener(clearAction); OnEditAction = onEditAction; OnStartSelectCard = onStartSelectCard; AddButton.onClick.RemoveAllListeners(); AddButton.onClick.AddListener(delegate { LevelPropertyForm_BonusTypeDropdown btd = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.LevelPropertyForm_BonusTypeDropdown].AllocateGameObject <LevelPropertyForm_BonusTypeDropdown>(BonusContainer); btd.Initialize(onDeleteButtonClick: delegate { My_BonusGroupPropertyForm_BonusTypeDropdown.Remove(btd); btd.PoolRecycle(); Refresh(); }, onAddBonusType : delegate(Bonus.BonusTypes type) { My_BonusGroupPropertyForm_BonusTypeDropdown.Remove(btd); btd.PoolRecycle(); Bonus bonus = null; switch (type) { case Bonus.BonusTypes.UnlockCardByID: { bonus = new Bonus_UnlockCardByID((int)AllCards.EmptyCardTypes.EmptyCard); break; } case Bonus.BonusTypes.UnlockCardByLevelNum: { bonus = new Bonus_UnlockCardByLevelNum(1); break; } case Bonus.BonusTypes.Budget: { bonus = new Bonus_Budget(25); break; } case Bonus.BonusTypes.BudgetLifeEnergyMixed: { bonus = new Bonus_BudgetLifeEnergyMixed(150); break; } case Bonus.BonusTypes.LifeUpperLimit: { bonus = new Bonus_LifeUpperLimit(2); break; } case Bonus.BonusTypes.EnergyUpperLimit: { bonus = new Bonus_EnergyUpperLimit(2); break; } } Cur_BonusGroup.Bonuses.Add(bonus); Refresh(); }); My_BonusGroupPropertyForm_BonusTypeDropdown.Add(btd); }); SetBonusGroup(bonusGroup); }
private static int getCategoryCount(int stemenCount, BonusGroup currentBonusGroup) => currentBonusGroup.count + stemenCount;
public BonusGroupRequest(int clientId, BonusGroup bonusGroup) : base(clientId) { BonusGroup = bonusGroup; }
public override void Deserialize(DataStream reader) { base.Deserialize(reader); BonusGroup = BonusGroup.Deserialize(reader); }