Exemple #1
0
    void confirmRefresh(object para)
    {
        PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (pdm == null)
        {
            return;
        }

        //if (ShopModule.SECRET_REFRESH_COST > pdm.GetProceeds(ShopModule.SECRET_REFRESH_PROC_TYPE))
        ProceedsType pt = ShopModule.GetSecretShopRefreshPoceType();

        if (ShopModule.GetSecretShopRefreshCost() > pdm.GetProceeds(pt))
        {
            //PromptUIManager.Instance.AddNewPrompt(ShopModule.GetBuyMoneyNotEnougthStr(pt));
            PopTipManager.Instance.AddNewTip(StringHelper.GetString("refresh_no_money", FontColor.Red));
            return;
        }

        ShopRefreshAction param = new ShopRefreshAction();

        param.OpType = (int)ShopOpType.Refresh;

        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_SHOP, param);
    }
Exemple #2
0
 void OnItemClick(int itemID)
 {
     if (itemID > 0)
     {
         ShopModule.ShowItemPreviewUIHandler(itemID);
     }
 }
Exemple #3
0
    void OnBuyBtnClick()
    {
        //判断是否还在打折;
        //TODO::
        bool discount = ShopModule.IsShopItemInDiscount(shopT);

        if (discount != isDiscount)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble7"), transform);
            return;
        }

        //判断是否已经下架;
        //TODO::
        bool isSale = ShopModule.IsShopItemInSaling(shopT);

        if (!isSale)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), transform);
            return;
        }
        //购买商品接口;
        ShopModule.BuyItem(shopT.getId(), 1, isDiscount);

        CloseUI();
    }
Exemple #4
0
    void UpdateShopItemsMoneyWithoutSecret()
    {
        BetterList <int> ids = ShopModule.GetEffectShopIdsWithoutSecret();

        if (ids == null)
        {
            return;
        }

        foreach (int id in ids)
        {
            if (!mAllItemsLists.ContainsKey(id))
            {
                continue;
            }

            MallItemUI itemUI = mAllItemsLists[id] as MallItemUI;

            if (itemUI == null)
            {
                continue;
            }

            itemUI.UpdateMoneyShow();
        }
    }
    /// <summary>
    /// 最大购买次数;
    /// </summary>
    /// <returns></returns>
    public int GetMaxCount()
    {
        ////-----根据人物当前资源最大购买次数--------
        //int countByMoney = -1;
        //long count = -1;
        //if(ObjectSelf.GetInstance().TryGetResourceCountById(ShopT.getCostType(), ref count))
        //{
        //    countByMoney = (int)(count / perPrice);
        //}

        //int vipLv = ObjectSelf.GetInstance().VipLevel;
        //Shopbuy sb = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(ShopT.getId());
        ////-----根据人物当前vip每日限购最大购买次数--
        //int countByDaily = -1;
        ////-----根据人物当前vip总限购最大购买次数----
        //int countByTotal = -1;
        //if(DataTemplate.GetInstance().IsShopBuyLimited(ShopT))
        //{
        //    countByDaily = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(ShopT, vipLv) - sb.todaynum;
        //    countByTotal = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(ShopT, vipLv) - sb.buyallnum;
        //}

        //int[] times = new int[3];
        //times[0] = countByMoney;
        //times[1] = countByDaily;
        //times[0] = countByTotal;

        //return Mathf.Max(0, Mathf.Min(times));

        return(ShopModule.GetMaxBuyCount(ShopT.getId(), perPrice));
    }
Exemple #6
0
 void Awake()
 {
     m_sm = ModuleManager.Instance.Get <ShopModule>();
     if (string.IsNullOrEmpty(m_strGUID))
     {
         guid = Guid.NewGuid().ToString();
     }
 }
        protected void OnAeraClick()
        {
            if (m_OnClickCallback != null)
            {
                m_OnClickCallback();
            }

            ShopModule.ShowItemPreviewUIHandler(m_ItemId);
        }
Exemple #8
0
    public void SetShowData(ShopTemplate shopT)
    {
        nameTxt.text   = GameUtils.getString(shopT.getCommodityName());
        iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getResourceName());

        //判断当前时间是否打折期间---与购买商品时候是否打折进行比对,如果不同,购买失败,让玩家从新购买;
        isDiscount = ShopModule.IsShopItemInDiscount(shopT);

        UpdateMoneyInfo();
    }
    void OnBuyBtnClick()
    {
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopTemplate);

        //string errStr = "";
        //if(!ShopModule.BuyItem(mShopTemplate.getId(), 1, isDiscount, out errStr))
        //{
        //    InterfaceControler.GetInst().AddMsgBox(errStr, transform);
        //}
        ShopModule.BuyItem(mShopTemplate.getId(), 1, isDiscount);
    }
    public override void InitUIView()
    {
        base.InitUIView();

        if (data != null)
        {
            _shopT = DataTemplate.GetInstance().GetShopTemplateByID(data.shopId);

            iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + ShopT.getResourceName());
            //iconImg.SetNativeSize();
            nameTxt.text        = GameUtils.getString(ShopT.getCommodityName());
            oneCostImg.sprite   = GameUtils.GetSpriteByResourceType(ShopT.getCostType());
            totalCostImg.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType());

            //判断当前时间是否打折期间---与购买商品时候是否打折进行比对,如果不同,购买失败,让玩家从新购买;
            isDiscount = ShopModule.IsShopItemInDiscount(ShopT);

            if (isDiscount)
            {
                perPrice = ShopT.getDiscountCost()[0];
            }
            else
            {
                perPrice = ShopT.getCost()[0];
            }
            oneCostTxt.text   = perPrice.ToString();
            totalCostTxt.text = (ItemCount * perPrice).ToString();

            maxCount = GetMaxCount();

            ItemCount = Mathf.Min(1, maxCount);

            moneyIcon.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType());
            switch (ShopT.getCostType())
            {
            case (int)EM_RESOURCE_TYPE.Gold:
                GameEventDispatcher.Inst.addEventListener(GameEventID.G_Gold_Update, UpdateTotalGoldInfo);
                UpdateTotalGoldInfo();
                break;

            case (int)EM_RESOURCE_TYPE.Money:
                GameEventDispatcher.Inst.addEventListener(GameEventID.G_Money_Update, UpdateTotalMoneyInfo);
                UpdateTotalMoneyInfo();
                break;
            }

            int curCount = -1;
            if (ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, Convert.ToInt32(_shopT.getPara()), ref curCount))
            {
                curCountTxt.text = curCount + "";
            }
        }
    }
Exemple #11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            NinjectModule shopModule    = new ShopModule();
            NinjectModule serviceModule = new ServiceModule("DefaultConnection");
            var           kernel        = new StandardKernel(shopModule, serviceModule);

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
Exemple #12
0
    void UpdateData(int ProceedsTypeIdx, int count, bool isBuy)
    {
        if (mitem == null)
        {
            GameDebug.LogError("请先初始化在进行刷新操作");
            return;
        }

        if (ProceedsTypeIdx < 0 || ProceedsTypeIdx > 2)
        {
            GameDebug.LogError("商店数据错误");
            return;
        }

        int proceedsType = ShopModule.GetShopItemProceedsType(mitem, ProceedsTypeIdx);
        int perPrice     = ShopModule.GetShopItemPerPrice(mitem, ProceedsTypeIdx);

        mPt = (ProceedsType)proceedsType;

        SetMoneyType(mPt);
        int itemNumber = (int)(count * mitem.multiple);

        countLb.text = "x" + itemNumber;

        mCost = (uint)(perPrice * itemNumber);

        if (isBuy)
        {
            moneyLb.text = "已售罄";
        }
        else
        {
            PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
            if (pdm == null)
            {
                return;
            }

            if (pdm.GetProceeds(mPt) >= mCost)
            {
                moneyLb.text = mCost + "";
            }
            else
            {
                moneyLb.text = StringHelper.StringWithColor(FontColor.Red, mCost.ToString());
            }
        }
        huiSp.gameObject.SetActive(isBuy);
        isScretItemBuyDone = isBuy;
    }
    void OnItemClick()
    {
        //判断VIP等级是否足够;
        if (mShopT.getVipLimit() > ObjectSelf.GetInstance().VipLevel)
        {
            InterfaceControler.GetInst().AddMsgBox(string.Format(GameUtils.getString("shop_bubble3"), mShopT.getVipLimit()), UI_ShopMgr.inst.transform);
            return;
        }

        //当前金钱够不够买一个的;
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopT);

        int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(mShopT.getId()).todaynum;

        int costNum = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, isDiscount);

        long             curCount = -1;
        EM_RESOURCE_TYPE resType  = (EM_RESOURCE_TYPE)mShopT.getCostType();

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resType, ref curCount))
        {
            if (curCount >= costNum)
            {
                if (mShopT.getType() != 51)
                {
                    LogManager.LogError("不是金币类型51的物品,所属标签填写错误!" + mShopT.getId());
                    return;
                }

                //打开金币购买界面;
                UI_GoldBuyMgr.SetData(mShopT);
                UI_HomeControler.Inst.AddUI(UI_GoldBuyMgr.UI_ResPath);
            }
            else
            {
                switch (resType)
                {
                case EM_RESOURCE_TYPE.Gold:
                    //打开魔钻不足提示窗;
                    InterfaceControler.GetInst().ShowGoldNotEnougth(UI_QuikBuyGoldMgr.Inst.transform);
                    break;

                default:
                    InterfaceControler.GetInst().AddMsgBox("除魔钻资源不足时,其他资源不足先不做处理", UI_ShopMgr.inst.transform);
                    break;
                }
            }
        }
    }
Exemple #14
0
 public void Destory()
 {
     this.m_BuilderModule             = null;
     this.m_BuildingModule            = null;
     this.m_PlayerModule              = null;
     this.m_ArmyModule                = null;
     this.m_ItemModule                = null;
     this.m_ShopModule                = null;
     this.m_RemovableModule           = null;
     this.m_TaskModule                = null;
     this.m_PropsModule               = null;
     this.m_DefenseModule             = null;
     this.m_AchievementBuildingModule = null;
     this.m_CurrentFriend             = null;
 }
Exemple #15
0
    /// <summary>
    /// 刷新下次免费刷新时间Label;
    /// </summary>
    void updateNextRefreshTimeLb()
    {
        PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (pdm == null)
        {
            return;
        }

        int index = pdm.GetPlayerShopData().Buncket;

        List <int> times = ShopModule.GetRefreshTimes();

        sRefreshTimeLb.text = string.Format(StringHelper.GetString("shop_refresh_time"), times[index]);
        //return null;
    }
Exemple #16
0
 public InternalModules(InternalAccessors accessors, InternalAdditionalLogics additionalLogics, LogicData data, IServerAPI api)
 {
     AchievementModule      = AchievementModule.CreateClient(accessors.AchievementAccessor, additionalLogics.ScorersLogic, additionalLogics.DropLogic, accessors.FormulaController, additionalLogics.ImpactController);
     ActivationModule       = ActivationModule.CreateClient(accessors.FormulaController, additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, accessors.PlayerAccessor, accessors.UnitsAccessor, additionalLogics.ApplyChangeLogic);
     AutowinModule          = AutowinModule.CreateClient(additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, additionalLogics.FormulaLogic, additionalLogics.ExplorerLogic);
     BattleModule           = BattleModule.CreateClient(accessors.BattleAccessor, accessors.ExplorerAccessor, accessors.UnitsAccessor, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.TriggerLogic, additionalLogics.BattleLogic, additionalLogics.BuffLogic);
     CheatModule            = CheatModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, additionalLogics.ExplorerLogic, additionalLogics.BattleLogic, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.DropLogic, additionalLogics.ScorersLogic);
     CutSceneModule         = CutSceneModule.CreateClient(accessors.CutSceneAccessor, additionalLogics.ImpactController, additionalLogics.ApplyChangeLogic);
     EquipmentModule        = EquipmentModule.CreateClient(accessors.InventoryAccessor, accessors.ScorersAccessor, accessors.UnitsAccessor, additionalLogics.ImpactController, additionalLogics.FormulaLogic);
     ExplorerProgressModule = ExplorerProgressModule.CreateClient(accessors.ExplorerAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.SettingsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.ExplorerLogic, additionalLogics.FormulaLogic, additionalLogics.ImpactController);
     GachaModule            = GachaModule.CreateClient(additionalLogics.ImpactController, accessors.ScorersAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.ExplorerAccessor, additionalLogics.DropLogic, accessors.ConditionController, additionalLogics.FormulaLogic);
     SettingsModule         = SettingsModule.CreateClient(accessors.SettingsAccessor, accessors.ScorersAccessor, additionalLogics.ImpactController);
     ShopModule             = ShopModule.CreateClient(accessors.ScorersAccessor, accessors.ShopAccessor, additionalLogics.FormulaLogic, additionalLogics.ImpactController, additionalLogics.ShopLogic, additionalLogics.DropLogic);
     StartSessionModule     = StartSessionModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, accessors.ShopAccessor, accessors.LogAccessor, accessors.AchievementAccessor, additionalLogics.BattleLogic, additionalLogics.ShopLogic, additionalLogics.ExplorerLogic, accessors.FormulaController, additionalLogics.ImpactController);
     StorageModule          = StorageModule.CreateClient(accessors.ScorersAccessor, accessors.InventoryAccessor);
     UnitProgressModule     = UnitProgressModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.FormulaLogic, accessors.PlayerAccessor, additionalLogics.ImpactController);
 }
    public void MakeShopModule(Transform moduleParent, Vector3 spawnPosit)
    {
        GameObject shopModuleObj = Resources.Load <GameObject>("Prefabs/Maps/ETC/ShopModule");

        if (shopModuleObj != null)
        {
            ShopModule shopModule = GameObject.Instantiate(shopModuleObj, spawnPosit, Quaternion.identity, moduleParent).GetComponent <ShopModule>();
            shopModule.AddToMapManager(mapManager);
            shopModule.GetMyTiles();

            List <Tile> shopWallList = shopModule.GetWallList();
            for (int i = 0; i < shopWallList.Count; i++)
            {
                everyWallList.Add(shopWallList[i]);
            }
        }
    }
Exemple #18
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // dependency injection
            NinjectModule shopModule            = new ShopModule();
            NinjectModule salesConsultantModule = new SalesConsultantModule();
            NinjectModule serviceModule         = new ServiceModule();

            var kernel = new Ninject.StandardKernel(shopModule, salesConsultantModule, serviceModule);

            //you just unbind ninject validator and there should be no collision with default validator.
            kernel.Unbind <ModelValidatorProvider>();
            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
Exemple #19
0
    protected override void OnRespond(respond_shop_op respond, object userdata)
    {
        ShopModule module = ModuleManager.Instance.FindModule <ShopModule>();

        if (module == null)
        {
            GameDebug.LogError("没有找到shopmodule");
            return;
        }

        if (respond.result != (int)Message.ERROR_CODE.ERR_SHOP_OK)
        {
            switch ((Message.ERROR_CODE)respond.result)
            {
            case ERROR_CODE.ERR_SHOP_FAILED:
                break;

            //case ERROR_CODE.ERR_MALL_BUY_NO_TIMES:
            //    break;
            //case ERROR_CODE.ERR_MALL_FAILED:
            //    break;
            default:
                break;
            }
            return;
        }

        if (userdata is ShopBuyItemAction)
        {
            module.BuyShopItem(respond.shopid);
        }

        //改到人物shop物品属性改变后再刷新;
        //if (userdata is ShopRefreshAction)
        //{
        //    module.RefreshShop();
        //}

        //if (userdata is ShopFreeRefreshAction)
        //{
        //    module.RefreshShop();
        //}
    }
Exemple #20
0
    public void Initialize(UserData userData, List <BuildingData> buildingData, List <ArmyData> armyData, List <ItemData> itemData,
                           List <ObjectUpgrade <ArmyType> > armyUpgrade, List <ObjectUpgrade <ItemType> > itemUpgrade, List <RemovableObjectData> removableObjects,
                           List <TaskInformation> tasks, Dictionary <MercenaryIdentity, MercenaryData> mercenaries, Dictionary <int, PropsData> props, List <DefenseObjectData> defenseObjects,
                           int removableObjectStartNo, int propsStartNo, List <AchievementBuildingData> achievementBuildings, int achievementBuildingStartNo)
    {
        this.m_BuilderModule = new BuilderManager();

        this.m_PlayerModule    = new PlayerLogicObject();
        this.m_BuildingModule  = new BuildingModule(this.m_BuilderModule);
        this.m_ArmyModule      = new ArmyModule();
        this.m_ItemModule      = new ItemModule();
        this.m_MercenaryModule = new MercenaryModule();
        this.m_ShopModule      = new ShopModule();
        this.m_RemovableModule = new RemovableObjectModule(this.m_BuilderModule);

        this.m_MercenaryModule.InitializeMercenaries(mercenaries);
        this.m_ItemModule.InitializeItem(itemData, itemUpgrade);
        this.m_ArmyModule.InitializeArmy(armyData, armyUpgrade);
        this.m_PlayerModule.IntializePlayer(userData);
        this.m_BuildingModule.IntializeBuilding(buildingData);
        this.m_RemovableModule.InitialWithData(removableObjects, removableObjectStartNo);

        this.m_BuildingModule.ItemUpgradeFinished += ItemUpgradeFinished;
        this.m_BuildingModule.ArmyUpgradeFinished += ArmyUpgradeFinished;

        this.m_IsNewPlayer = (removableObjects.Count == ClientSystemConstants.INITIAL_REMOVABLE_OBJECT_NUMBER) &&
                             (removableObjects[0].Position == null);


        this.m_TaskModule = new TaskManager();
        foreach (TaskInformation info in tasks)
        {
            TaskProgressFactory.PopulateTaskInformation(info);
        }
        this.m_TaskModule.InitialTask(tasks);

        this.m_PropsModule = new PropsModule();
        this.m_PropsModule.InitializeProps(props, propsStartNo);
        this.m_DefenseModule = new DefenseObjectModule();
        this.m_DefenseModule.InitialDefenseObject(defenseObjects);
        this.m_AchievementBuildingModule = new AchievementBuildingModule();
        this.m_AchievementBuildingModule.InitialAchievementBuilding(achievementBuildings, achievementBuildingStartNo);
    }
Exemple #21
0
    void UpdateMoneyInfo()
    {
        int resourceId = mShopTemplate.getCostType();

        moneyIcon.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        moneyIcon.SetNativeSize();
        long count = -1;

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resourceId, ref count))
        {
            moneyTxt.text = count.ToString();
        }

        costImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(mShopTemplate.getId()).todaynum;
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopTemplate);

        costTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopTemplate, buyTimes, isDiscount).ToString();
    }
Exemple #22
0
    void OnItemClick(GameObject go)
    {
        if (go == null)
        {
            return;
        }

        try
        {
            int id = (int)(EventTriggerListener.Get(go).param);
            if (id != -1)
            {
                ShopModule.ShowItemPreviewUIHandler(id);
            }
        }
        catch (Exception e)
        {
            LogManager.LogError(e);
        }
    }
Exemple #23
0
    void InitMallItems()
    {
        //// 神秘商店初始化;
        //BetterList<int> resIds = Module.GetPlayerSecretShopItemIds();

        //if (resIds != null)
        //{
        //    foreach (int id in resIds)
        //    {
        //        ShopTableItem item = DataManager.ShopTable[id] as ShopTableItem;
        //        if (item == null)
        //            continue;

        //        CreateMallItem(item);
        //    }
        //}

        // 其他商店初始化;
        CreateMallItems(ShopModule.GetEffectShopItemsWithoutSecret());
        CreateNullItems();
    }
    /// <sumary>
    ///
    /// </sumary>
    public void UpdatePerSecond()
    {
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopT);

        mCostOldObj.SetActive(isDiscount);
        mCostNewObj.SetActive(isDiscount);

        int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(mShopT.getId()).todaynum;

        if (isDiscount)
        {
            mOldTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, false).ToString();
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, true).ToString();
        }
        else
        {
            //临时这么写;
            mCostNewObj.SetActive(true);
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, true).ToString();
        }
    }
Exemple #25
0
    void UpdateMoneyInfo()
    {
        int resourceId = shopT.getCostType();

        moneyImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        moneyImg.SetNativeSize();
        long count = -1;

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resourceId, ref count))
        {
            moneyTxt.text = count.ToString();
        }

        mOldImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        mNewImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);

        bool isDiscount = ShopModule.IsShopItemInDiscount(shopT);

        mCostOldObj.SetActive(isDiscount);
        mCostNewObj.SetActive(isDiscount);

        int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopT.getId()).todaynum;

        if (isDiscount)
        {
            mOldTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, false).ToString();
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, true).ToString();
        }
        else
        {
            //临时这么写;
            mCostNewObj.SetActive(true);
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, false).ToString();
        }
        //costImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        //int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopT.getId()).todaynum;
        //bool isDiscount = ShopModule.IsShopItemInDiscount(shopT);
        //costTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, isDiscount).ToString();
    }
    void ShowBuyWater(bool isDiscount, int costNum)
    {
        UI_RechargeBox box = UI_HomeControler.Inst.AddUI(UI_RechargeBox.UI_ResPath).GetComponent <UI_RechargeBox>();

        if (box == null)
        {
            LogManager.LogError("提示窗is null");
            return;
        }

        box.SetDescription_text(GameUtils.getString("vigour_buy_title"));
        box.SetIsNeedDescription(true);
        box.SetConsume_Image(GameUtils.GetSpriteByResourceType(shopT.getCostType()));
        box.SetConNum(costNum.ToString());
        box.SetLeftBtn_text(GameUtils.getString("common_button_purchase"));
        box.SetLeftClick(() =>
        {
            ShopModule.BuyItem(shopT.getId(), 1, isDiscount);
            box.OnCloes();
        });

        box.SetRightBtn_text(GameUtils.getString("common_button_close"));
    }
    void OnBuyBtnClick()
    {
        //判断是否还在打折;
        //TODO::
        bool discount = ShopModule.IsShopItemInDiscount(ShopT);

        if (discount != isDiscount)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble7"), selfTransform);
            return;
        }

        //判断是否已经下架;
        //TODO::
        bool isSale = ShopModule.IsShopItemInSaling(ShopT);

        if (!isSale)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), selfTransform);
            return;
        }

        //购买商品接口;
        //string err = "";
        //if(!ShopModule.BuyItem(ShopT.getId(),ItemCount, isDiscount, out err))
        //{
        //    InterfaceControler.GetInst().AddMsgBox(err, selfTransform);
        //}
        //else
        //{
        //    CloseUI();
        //}

        ShopModule.BuyItem(ShopT.getId(), ItemCount, isDiscount);
        CloseUI();
    }
Exemple #28
0
    /// <summary>
    /// 点击立刻购买;
    /// </summary>
    void OnMsgBoxYesClick()
    {
        UI_HomeControler.Inst.ReMoveUI(UI_RechargeBox.UI_ResPath);

        int          stoneid = DataTemplate.GetInstance().GetGameConfig().getIdentify_stone_id();
        ShopTemplate shopT   = DataTemplate.GetInstance().GetShopTemplateByID(stoneid);

        if (!ShopModule.IsShopItemInSaling(shopT))
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), transform);
            return;
        }
        int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(stoneid).todaynum;
        bool isdiscount = ShopModule.IsShopItemInDiscount(shopT);

        int haveCount = 0;

        ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, itemId, ref haveCount);

        //获取符文鉴定石对应到商店表的id;
        int shopId = DataTemplate.GetInstance().GetGameConfig().getIdentify_stone_id();

        ShopModule.BuyItem(shopId, itemCount - haveCount, isdiscount);
    }
Exemple #29
0
    private void UpdateVipExp()
    {
        int exp         = objectSelf.VipExp;
        var vipTemplate = (VipTemplate)m_VipReader.getTableData(objectSelf.VipLevel);
        int maxExp      = vipTemplate.getVipExp();

        if (maxExp > 0)
        {
            m_ExpSlider.value = (float)exp / maxExp;
            int money = ShopModule.GetMoneyCountToNextVipLv(objectSelf.VipLevel, exp);
            System.Text.StringBuilder builder = new System.Text.StringBuilder(string.Format(m_TopDescriptionTextTempString, money));
            builder.AppendFormat("<color=#ECAF48>VIP{0}</color>", (objectSelf.VipLevel + 1));
//            builder.Append((objectSelf.VipLevel+1).ToString());
            m_TopDescriptionText.text = builder.ToString();
            m_VipExpText.text         = string.Format("/{0}", maxExp);
            m_CurrentExpText.text     = exp.ToString();
        }
        else
        {
            m_TopDescriptionText.text = GameUtils.getString("VIP_tips1");;
            m_ExpSlider.gameObject.SetActive(false);
            m_VipExpText.gameObject.SetActive(false);
        }
    }
		public static string ShopCodeToHtml(string text,ShopModule module)
		{
			text = text.Trim();

			// build stack of shop codes, look for closure and proper nesting
			Regex openPattern = new Regex(@"\[(?!/)[\w""\?=&/;\+%\*\:~,\.\-\$@#]+\]", RegexOptions.IgnoreCase);
			Regex closePattern = new Regex(@"\[/\w+\]", RegexOptions.IgnoreCase);
			Regex bothPattern = new Regex(@"\[[\w""\?=&/;\+%\*\:~,\.\-\$@#]+\]", RegexOptions.IgnoreCase);
			ArrayList stack = new ArrayList();
			Match allMatches = bothPattern.Match(text);
			int indexAfterLastClosingTag = 0;
			while (allMatches.Success)
			{
				string tag = allMatches.ToString();
				if (openPattern.IsMatch(tag))
				{
					// it's an opening tag, add it to the stack
					stack.Add(tag);
					allMatches = allMatches.NextMatch();
				}
				else
				{
					// if it's a closing URL tag, disregard
					//if (tag == "[/url]") break;
					// this is a closing tag. see if it matches the previous opening tag
					if (stack.Count == 0)
					{
						// there are no more opening tags on the stack, so we'll have to insert one after the last closer
						string newCloser = tag.Replace("[/", "[");
						text = text.Insert(indexAfterLastClosingTag, newCloser);
						allMatches = bothPattern.Match(text, indexAfterLastClosingTag + newCloser.Length);
					}
					else
					{
						// opening tags left on the stack...
						string tempOpen = (string)stack[stack.Count - 1];
						if (tempOpen.StartsWith("[url=")) tempOpen = "[url]";
						if (tag.Replace("[/", "[") == tempOpen)
						{
							// it matches the last opening tag, remove it from the stack
							stack.RemoveAt(stack.Count - 1);
							indexAfterLastClosingTag = allMatches.Index + tag.Length;
							allMatches = allMatches.NextMatch();
						}
						else
						{
							// closer doesn't match last opener
							string previousOpeningTag = (string)stack[stack.Count - 1];
							stack.RemoveAt(stack.Count - 1);
							// put a closing tag before it
							string newCloser = previousOpeningTag.Replace("[", "[/");
							text = text.Insert(allMatches.Index, newCloser);
							indexAfterLastClosingTag = allMatches.Index + newCloser.Length;
							// if there's a future closing tag of the same type, we need an opener after this closer
							MatchCollection futureClosers = closePattern.Matches(text, indexAfterLastClosingTag);
							foreach (Match futureClose in futureClosers)
							{
								if (futureClose.ToString() == previousOpeningTag.Replace("[", "[/"))
								{
									text = text.Insert(indexAfterLastClosingTag + tag.Length, previousOpeningTag);
									break;
								}
							}
							allMatches = bothPattern.Match(text, indexAfterLastClosingTag);
						}
					}
				}
			}

			// convert HTML escapes
			text = Regex.Replace(text, "&", "&amp;", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<", "&lt;", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, ">", "&gt;", RegexOptions.IgnoreCase);

			// identify URL's that don't have url shop code so we can parse them to be links.
			Regex protolcPattern = new Regex(@"(?<theurl>(?<!(\]|""))(((news|(ht|f)tp(s?))\://)[\w\-\*]+(\.[\w\-/~\*]+)*/?)([\w\?=&/;\+%\*\:~,\.\-\$#])*)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
			Regex wwwPattern = new Regex(@"(?<theurl>(?<!(\]|""|//))(?<=\s|^)(w{3}(\.[\w\-/~\*]+)*/?)([\?\w=&;\+%\*\:~,\-\$#])*)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
			Regex emailPattern = new Regex(@"(?<theurl>(?<=\s|\])(?<!(mailto:|""\]))([\w\.\-_']+)@(([\w\-]+\.)+[\w\-]+))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
			text = protolcPattern.Replace(text, "[url=\"${theurl}\"]${theurl}[/url]");
			text = wwwPattern.Replace(text, "[url=\"http://${theurl}\"]${theurl}[/url]");
			text = emailPattern.Replace(text, "[url=\"mailto:${theurl}\"]${theurl}[/url]");

			// replace URL tags
			text = Regex.Replace(text, @"(\[url="")(\S+?)(""\])", "<a href=\"$2\" target=\"_blank\">", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<a href=\""mailto:)(\S+?)(\"" target=\""_blank\"">)", "<a href=\"mailto:$2\">", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"\[/url\]", "</a>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(\[image="")(\S+?)(""\])", "<img src=\"$2\" />", RegexOptions.IgnoreCase);

			// replace basic tags
			IList tFtc = module.GetAllTags();
			if(tFtc != null)
			{
				foreach (ShopTag Item in tFtc)
				{
					text = Regex.Replace(text, Regex.Escape(Item.ShopCodeStart), Item.HtmlCodeStart, RegexOptions.IgnoreCase);
					text = Regex.Replace(text, Regex.Escape(Item.ShopCodeEnd), Item.HtmlCodeEnd, RegexOptions.IgnoreCase);
				}
			}

			IList tEc =  module.GetAllEmoticons();

			if(tEc != null)
			{
				foreach (ShopEmoticon Item in tEc)
				{
					text = Regex.Replace(text, Regex.Escape(Item.TextVersion), "<img src=\"" + module.ThemePath + Item.ImageName + "\" />", RegexOptions.IgnoreCase);
				}
			}

			// replace line breaks, get block elements right
			//if (!text.StartsWith("[quote]")) text = "<p class=shop>" + text;
			//if (!text.EndsWith("[/quote]")) text += "</p>";
			text = Regex.Replace(text, @"\[quote\]", "<blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"\[/quote\]", "</blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(?<!(</blockquote>))\r\n\r\n(?!(<p>|<blockquote>|</blockquote>))", "</p><p>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(?<=(</p>|<blockquote>|</blockquote>|\A))(\r\n)*<blockquote>", "<blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"\r\n\r\n<blockquote>", "</p><blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"<blockquote>\r\n(?!(<p>|<blockquote>|</blockquote>))", "<blockquote><p>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(?<!(</p>|<blockquote>|</blockquote>))\r\n</blockquote>", "</p></blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"</blockquote>\r\n\r\n", "</blockquote><p>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"</blockquote>\r\n</blockquote>", "</blockquote></blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(?<!(</p>|<blockquote>|</blockquote>|\A))<blockquote>", "</p><blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"<blockquote>(?!(<p>|<blockquote>|</blockquote>))", "<blockquote><p>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(?<!(</p>|<blockquote>|</blockquote>))</blockquote>", "</p></blockquote>", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"</blockquote>(\r\n)?(?!(<p>|<blockquote>|</blockquote>|\Z))", "</blockquote><p>", RegexOptions.IgnoreCase);
			text = text.Replace("\r\n", "<br />");

			text = TextParser.Censor(text);

			return text.Trim();
		}
		public static string HtmlToShopCode(string text, ShopModule module)
		{
			text = text.Trim();
			// replace line breaks, get block elements right
			text = text.Replace("\r\n", "");
			text = Regex.Replace(text, @"((?<!(\A|<blockquote>|</blockquote>|</p>))(<blockquote>|<p>))", "</p>$1", RegexOptions.IgnoreCase | RegexOptions.Compiled);
			text = Regex.Replace(text, @"(</blockquote>|</p>)((?!(<p>|<blockquote>|</blockquote>))(.*</p>))", "$1<p>$2", RegexOptions.IgnoreCase | RegexOptions.Compiled);
			text = Regex.Replace(text, "^<p>", "", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "</p>$", "", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<blockquote>", "\r\n[quote]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "</blockquote>", "[/quote]\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<p>", "\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "</p>", "\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<br>", "\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<br/>", "\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "<br />", "\r\n", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"\[quote\](?!(\r\n))", "[quote]\r\n", RegexOptions.IgnoreCase | RegexOptions.Compiled);
			text = Regex.Replace(text, @"(?<!(\r\n))\[/quote\]", "\r\n[/quote]", RegexOptions.IgnoreCase | RegexOptions.Compiled);

			IList tEc = module.GetAllEmoticons();
			if(tEc != null)
			{
				foreach (ShopEmoticon Item in tEc)
				{
					text = Regex.Replace(text, "<img src=\"" + module.ThemePath + Item.ImageName + "\">", Item.TextVersion, RegexOptions.IgnoreCase);
					text = Regex.Replace(text, "<img src=\"" + module.ThemePath + Item.ImageName + "\"/>", Item.TextVersion, RegexOptions.IgnoreCase);
					text = Regex.Replace(text, "<img src=\"" + module.ThemePath + Item.ImageName + "\" />", Item.TextVersion, RegexOptions.IgnoreCase);

				}
			}

			// replace basic tags
			IList tFtc = module.GetAllTags();
			if(tFtc != null)
			{
				foreach (ShopTag Item in tFtc)
				{
					text = Regex.Replace(text, Item.HtmlCodeStart, Item.ShopCodeStart, RegexOptions.IgnoreCase);
					text = Regex.Replace(text, Item.HtmlCodeEnd, Item.ShopCodeEnd, RegexOptions.IgnoreCase);
				}
			}
			text = Regex.Replace(text, @"</a>", "[/url]", RegexOptions.IgnoreCase);

			// replace img and a tags
			text = Regex.Replace(text, @"(<a href="")(\S+)("" target=""_blank"">)", "[url=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<a href="")(\S+)("" target=_blank>)", "[url=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<a href="")(\S+)("">)", "[url=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<a href="")(\S+)("">)", "[url=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<img src="")(\S+)("">)", "[image=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<img src="")(\S+)("" />)", "[image=\"$2\"]", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, @"(<img src="")(\S+)(""/>)", "[image=\"$2\"]", RegexOptions.IgnoreCase);
			
			// catch remaining HTML as invalid
			text = Regex.Replace(text, @"<.*>", "", RegexOptions.IgnoreCase);

			// convert HTML escapes
			text = Regex.Replace(text, "&nbsp;", " ", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "&amp;", "&", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "&lt;", "<", RegexOptions.IgnoreCase);
			text = Regex.Replace(text, "&gt;", ">", RegexOptions.IgnoreCase);

			return text.Trim();
		}
Exemple #32
0
    void BuyMallItem(int resId, int subId)
    {
        MallTableItem item = Module.MallTable[resId] as MallTableItem;

        if (item == null)
        {
            return;
        }

        PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();

        //有钱没;
        MallItemInfo info = item.mallItems[subId];
        ProceedsType pt   = (ProceedsType)item.processType;

        if (pdm.GetProceeds(pt) < info.processNow)
        {
            //PromptUIManager.Instance.AddNewPrompt(ShopModule.GetBuyMoneyNotEnougthStr(pt));
            PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, ShopModule.GetBuyMoneyNotEnougthStr(pt)));
            return;
        }

        //次数够了没;
        switch (mModule.GetLimitTypeByID(resId))
        {
        case MallLimitType.ERROR:
            GameDebug.LogError("数据错误");
            return;

        case MallLimitType.NONE:
            break;

        case MallLimitType.DAY:
        case MallLimitType.FOREVER:
            if (mModule.GetPlayerBuyTimes(resId) >= item.limitTimes)
            {
                //PromptUIManager.Instance.AddNewPrompt(StringHelper.GetString("buy_no_time"));
                PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, StringHelper.GetString("buy_no_time")));
                return;
            }
            break;
        }

        MallBuyItemAction param = new MallBuyItemAction();

        param.ResId  = resId;
        param.SubIdx = subId;

        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_MALL_BUY, param);
    }