示例#1
0
    public static Bonus Deserialize(DataStream reader)
    {
        BonusTypes type  = (BonusTypes)reader.ReadSInt32();
        Bonus      bonus = null;

        switch (type)
        {
        case BonusTypes.UnlockCardByID:
        {
            int cardID = reader.ReadSInt32();
            bonus = new Bonus_UnlockCardByID(cardID);
            break;
        }

        case BonusTypes.UnlockCardByLevelNum:
        {
            int levelNum = reader.ReadSInt32();
            bonus = new Bonus_UnlockCardByLevelNum(levelNum);
            break;
        }

        case BonusTypes.LifeUpperLimit:
        {
            int lifeUpperLimit = reader.ReadSInt32();
            bonus = new Bonus_LifeUpperLimit(lifeUpperLimit);
            break;
        }

        case BonusTypes.EnergyUpperLimit:
        {
            int energyUpperLimit = reader.ReadSInt32();
            bonus = new Bonus_EnergyUpperLimit(energyUpperLimit);
            break;
        }

        case BonusTypes.Budget:
        {
            int budget = reader.ReadSInt32();
            bonus = new Bonus_Budget(budget);
            break;
        }

        case BonusTypes.BudgetLifeEnergyMixed:
        {
            int value = reader.ReadSInt32();
            bonus = new Bonus_BudgetLifeEnergyMixed(value);
            break;
        }
        }

        return(bonus);
    }
示例#2
0
    public List <Bonus> GetBonusListFromBonusComb(BudgetLifeEnergyComb comb)
    {
        List <Bonus> res = new List <Bonus>();

        if (comb.Budget != 0)
        {
            Bonus_Budget bb = new Bonus_Budget(comb.Budget);
            res.Add(bb);
        }

        if (comb.LifeUpperLimit != 0)
        {
            Bonus_LifeUpperLimit bl = new Bonus_LifeUpperLimit(comb.LifeUpperLimit);
            res.Add(bl);
        }

        if (comb.EnergyUpperLimit != 0)
        {
            Bonus_EnergyUpperLimit be = new Bonus_EnergyUpperLimit(comb.EnergyUpperLimit);
            res.Add(be);
        }

        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);
    }