hch
2025-12-10 ab6febff1dbce17e318a6d687b8d3e5077b85f01
363 【活动内容】开服庆典
8个文件已修改
14个文件已添加
935 ■■■■■ 已修改文件
Main/Config/PartialConfigs/SuccessConfig.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Achievement/AchievementManager.cs 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/HomeWin.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSActivityManager.cs 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaBaseWin.cs 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaBaseWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaChangeCell.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaChangeCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaChangeWin.cs 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaChangeWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaGiftCell.cs 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaGiftCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaGiftWin.cs 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaGiftWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaMissionCell.cs 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaMissionCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaMissionWin.cs 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/OSActivity/OSGalaMissionWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Redpoint/MainRedDot.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Store/StoreModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Utility/EnumHelper.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Utility/UIHelper.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Config/PartialConfigs/SuccessConfig.cs
@@ -20,7 +20,7 @@
        return null;
    }
    //获得成就条件,默认一个类型只有一种条件
    //获得成就条件,只适用于只有1种条件的情况获取
    public static string GetConditionString(int type)
    {
        if (typeToIDsDict.ContainsKey(type))
Main/System/Achievement/AchievementManager.cs
@@ -60,11 +60,14 @@
        UpdateRedpoint(types);
    }
    public int GetAchievementProgress(int type)
    public int GetAchievementProgress(int type, string condKey = "")
    {
        if (achivementDict.ContainsKey(type))
        {
            var condKey = SuccessConfig.GetConditionString(type);
            if (condKey.IsNullOrEmpty())
            {
                condKey = SuccessConfig.GetConditionString(type);
            }
            if (achivementDict[type].ContainsKey(condKey))
            {
                return achivementDict[type][condKey];
@@ -113,10 +116,10 @@
    }
    //获取成就状态  0: 未领取 1: 未达成 2: 已领取
    public int GetAchievementState(int id)
    public int GetAchievementState(int id, string condKey = "")
    {
        var config = SuccessConfig.Get(id);
        var process = GetAchievementProgress(config.Type);
        var process = GetAchievementProgress(config.Type, condKey);
        if (process < config.NeedCnt)
        {
            return 1;
@@ -131,10 +134,33 @@
    //主线章节
    Redpoint mainLevelRedpoint = new Redpoint(MainRedDot.RedPoint_DailyKey, MainRedDot.RedPoint_MainMissionKey);
    //庆典成就
    const int osGalaRepointSuccessID = MainRedDot.RedPoint_OSGala * 10 + 1;
    Redpoint osGalaRedpoint = new Redpoint(MainRedDot.RedPoint_OSGala, osGalaRepointSuccessID);
    //类型:红点id
    Dictionary<int, int> redpointDict = new Dictionary<int, int>()
    {
        {1, MainRedDot.RedPoint_MainMissionKey}
        {1, MainRedDot.RedPoint_MainMissionKey},
        {2, osGalaRepointSuccessID},
        {3, osGalaRepointSuccessID},
        {4, osGalaRepointSuccessID},
        {5, osGalaRepointSuccessID},
        {6, osGalaRepointSuccessID},
        {7, osGalaRepointSuccessID},
        {8, osGalaRepointSuccessID},
        {9, osGalaRepointSuccessID},
        {10, osGalaRepointSuccessID},
        {11, osGalaRepointSuccessID},
        {12, osGalaRepointSuccessID},
        {13, osGalaRepointSuccessID},
        {14, osGalaRepointSuccessID},
        {15, osGalaRepointSuccessID},
        {16, osGalaRepointSuccessID},
        {17, osGalaRepointSuccessID},
        {18, osGalaRepointSuccessID},
        {19, osGalaRepointSuccessID},
    };
    void UpdateRedpoint(List<int> _types)
@@ -144,9 +170,15 @@
            _types = redpointDict.Keys.ToList();
        }
        bool isGalaRed = false;
        foreach (var type in _types)
        {
            if (!redpointDict.ContainsKey(type))
            {
                continue;
            }
            if (isGalaRed && type >= 2 && type <= 19)
            {
                continue;
            }
@@ -162,11 +194,19 @@
            foreach (var id in allAchivement)
            {
                var config = SuccessConfig.Get(id);
                if (type == 6)
                {
                    process = GetAchievementProgress(type, config.Condition[0].ToString());
                }
                if (config.NeedCnt <= process)
                {
                    if (!IsAchievementAwarded(id))
                    {
                        redpoint.state = RedPointState.Simple;
                        if (type >= 2 && type <= 19)
                        {
                            isGalaRed = true;
                        }
                        break;
                    }
                }
@@ -185,6 +225,10 @@
                return true;
            }
        }
        else if (type >= 2 && type <= 19)
        {
            return OSActivityManager.Instance.IsOpenedOSGala();
        }
        return false;
    }
@@ -198,8 +242,14 @@
    int CmpIds(int a, int b)
    {
        var stateA = GetAchievementState(a);
        var stateB = GetAchievementState(b);
        var configA = SuccessConfig.Get(a);
        var configB = SuccessConfig.Get(b);
        var condA = configA.Condition.IsNullOrEmpty() ? "" : configA.Condition[0].ToString();
        var condB = configB.Condition.IsNullOrEmpty() ? "" : configB.Condition[0].ToString();
        var stateA = GetAchievementState(a, condA);
        var stateB = GetAchievementState(b, condB);
        if (stateA != stateB)
        {
@@ -209,6 +259,27 @@
        return a - b;
    }
    public List<int> GetAchievementIDsByTypes(int[] types)
    {
        List<int> allIds = new List<int>();
        foreach (var type in types)
        {
            var ids = SuccessConfig.GetTypeToIDDict(type);
            if (!ids.IsNullOrEmpty())
            {
                //合并
                allIds.AddRange(SuccessConfig.GetTypeToIDDict(type));
            }
            // else
            // {
            //     Debug.LogError($"{type}");
            // }
        }
        allIds.Sort(CmpIds);
        return allIds;
    }
    public void SendGetAward(int id)
    {
        var config = SuccessConfig.Get(id);
Main/System/Main/HomeWin.cs
@@ -63,6 +63,7 @@
    [SerializeField] Button FirstChargeBtn;
    [SerializeField] Button osMainLevelBtn;
    [SerializeField] Button osHeroCallBtn;
    [SerializeField] Button osGalaBtn;
    //坐骑
    [SerializeField] Image horseBGImg;
@@ -197,6 +198,10 @@
        osHeroCallBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<OSHeroCallBaseWin>();
        });
        osGalaBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<OSGalaBaseWin>();
        });
    }
@@ -632,7 +637,8 @@
        {
            DisplayHorse();
        }
        else if (funcId == (int)FuncOpenEnum.OSMainLevl || funcId == (int)FuncOpenEnum.OSHeroCall)
        else if (funcId == (int)FuncOpenEnum.OSMainLevl || funcId == (int)FuncOpenEnum.OSHeroCall
        || funcId == (int)FuncOpenEnum.OSGala)
        {
            DisplayOSActivity();
        }
@@ -683,6 +689,7 @@
    {
        osMainLevelBtn.SetActive(OSActivityManager.Instance.IsOpened(3));
        osHeroCallBtn.SetActive(OSActivityManager.Instance.IsOpened(4));
        osGalaBtn.SetActive(OSActivityManager.Instance.IsOpenedOSGala());
    }
    void OnDayEvent()
Main/System/OSActivity/OSActivityManager.cs
@@ -65,9 +65,7 @@
            osHeroCallGiftSortList.Add(_list[i] + 100000000);
        }
        config = FuncConfigConfig.Get("OSACelebration");
        osGalaOpenDays = int.Parse(config.Numerical1);
        osGalaScoreAwards = ConfigParse.ParseIntArray2Dict(config.Numerical2);
        ParseOSGalaConfig();
    }
    // 开服排行活动是否开启
@@ -147,6 +145,7 @@
        return a.CompareTo(b);
    }
    //开服招募榜礼包
    public void RefreshGiftSortList()
    {
        osHeroCallGiftSortList.Sort(CmpGift);
@@ -165,6 +164,7 @@
    {
        osMainLevelRedpoint.state = !DayRemind.Instance.GetDayRemind(DayRemind.OSMainLevel) ? RedPointState.Simple : RedPointState.None;
        osHeroCallRedpoint.state = RedPointState.None;
        osGalaRedpoint3.state = RedPointState.None;
        if (StoreModel.Instance.freeShopDict.Count == 0) return;
@@ -179,6 +179,22 @@
                if (StoreModel.Instance.GetShopLimitBuyCount(shopID) < config.LimitCnt)
                {
                    osHeroCallRedpoint.state = RedPointState.Simple;
                    break;
                }
            }
        }
        if (StoreModel.Instance.freeShopDict.ContainsKey((int)StoreFunc.OSGalaGift))
        {
            var shopList = StoreModel.Instance.freeShopDict[(int)StoreFunc.OSGalaGift];
            for (int i = 0; i < shopList.Count; i++)
            {
                var shopID = shopList[i];
                var config = StoreConfig.Get(shopID);
                if (StoreModel.Instance.GetShopLimitBuyCount(shopID) < config.LimitCnt)
                {
                    osGalaRedpoint3.state = RedPointState.Simple;
                    break;
                }
            }
@@ -199,16 +215,29 @@
    #region 开服庆典
    //开服庆典
    public int osGalaOpenDays = 0; //持续天数
    public Dictionary<int, int[][]> osGalaScoreAwards = new Dictionary<int, int[][]>();  // 开服庆典积分奖励
    public Dictionary<int, int[][]> osGalaScoreAwards = new Dictionary<int, int[][]>();  // 开服庆典积分奖励 积分:奖励
    public Dictionary<int, int> typeToGuideID = new Dictionary<int, int>();
    public List<int> osGalaChangeSortList = new List<int>();    //兑换列表(商店5)
    public List<int> osGalaGiftSortList = new List<int>();    //开服庆典礼包 充值ID + 100000000
    public int osGalaScore = 0; //当前积分 累计的;消耗的是货币55
    public int osGalaAwardState = 0; //按位记录是否领取
    public event Action OnOSGalaDataChangeEvent;
    // 兑换商店
    // Redpoint osGalaRedpoint2 = new Redpoint(MainRedDot.RedPoint_OSGala, MainRedDot.RedPoint_OSGala * 10 + 2);
    // 礼包免费
    Redpoint osGalaRedpoint3 = new Redpoint(MainRedDot.RedPoint_OSGala, MainRedDot.RedPoint_OSGala * 10 + 3);
    // 总奖励
    Redpoint osGalaRedpoint4 = new Redpoint(MainRedDot.RedPoint_OSGala, MainRedDot.RedPoint_OSGala * 10 + 4);
    public void UpdateOSGalaData(HAB05_tagSCOSACelebrationInfo netPack)
    {
        osGalaScore = (int)netPack.PointTotal;
        osGalaAwardState = (int)netPack.PointAward;
        OnOSGalaDataChangeEvent?.Invoke();
        UpdateGalaRedpoint();
    }
    public bool IsOpenedOSGala()
@@ -221,6 +250,83 @@
        return TimeUtility.OpenDay <= osGalaOpenDays;
    }
    // 是否已领取奖励
    public bool IsGotAward(int index)
    {
        return (osGalaAwardState & (1 << index)) != 0;
    }
    // 是否可领取奖励
    public bool CanGetAward(int index, int score)
    {
        if (IsGotAward(index))
        {
            return false;
        }
        if (osGalaScore < score)
        {
            return false;
        }
        return true;
    }
    void ParseOSGalaConfig()
    {
        var config = FuncConfigConfig.Get("OSACelebration");
        osGalaOpenDays = int.Parse(config.Numerical1);
        osGalaScoreAwards = ConfigParse.ParseIntArray2Dict(config.Numerical2);
        config = FuncConfigConfig.Get("Achievement");
        typeToGuideID = ConfigParse.ParseIntDict(config.Numerical1);
        var list = StoreModel.Instance.storeTypeDict[(int)StoreFunc.OSGalaChange];
        for (int i = 0; i < list.Count; i++)
        {
            var item = list[i];
            osGalaChangeSortList.Add(item.shopId);
        }
        var _list1 = StoreModel.Instance.storeTypeDict[(int)StoreFunc.OSGalaGift];
        var _list2 = RechargeManager.Instance.GetCTGIDListByType(19);
        for (int i = 0; i < _list1.Count; i++)
        {
            var item = _list1[i];
            osGalaGiftSortList.Add(item.shopId);
        }
        for (int i = 0; i < _list2.Count; i++)
        {
            osGalaGiftSortList.Add(_list2[i] + 100000000);
        }
    }
    public void RefreshOSGalaGiftSortList()
    {
        osGalaGiftSortList.Sort(CmpGift);
    }
    public void RefreshOSGalaChangeSortList()
    {
        osGalaGiftSortList.Sort(CmpGift);
    }
    void UpdateGalaRedpoint()
    {
        osGalaRedpoint4.state = RedPointState.None;
        var keys = osGalaScoreAwards.Keys.ToList();
        keys.Sort();
        for (int i = 0; i < keys.Count; i++)
        {
            var score = keys[i];
            if (CanGetAward(i, score))
            {
                osGalaRedpoint4.state = RedPointState.Simple;
                return;
            }
        }
    }
    #endregion
}
Main/System/OSActivity/OSGalaBaseWin.cs
New file
@@ -0,0 +1,142 @@
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Tuesday, July 24, 2018
//--------------------------------------------------------
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
////开服盛典
public class OSGalaBaseWin : FunctionsBaseWin
{
    [SerializeField] Image processImg;
    [SerializeField] Text timeText;
    [SerializeField] Text totalScoreText;
    [SerializeField] ItemCell[] itemCells;
    [SerializeField] Image[] gotImgs;
    [SerializeField] Text[] scoreTexts;
    [SerializeField] UIEffectPlayer[] effectPlayers;
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        OSActivityManager.Instance.OnOSGalaDataChangeEvent += OnOSGalaDataChangeEvent;
        GlobalTimeEvent.Instance.secondEvent += ShowTime;
        Display();
    }
    protected override void OnPreClose()
    {
        base.OnPreClose();
        OSActivityManager.Instance.OnOSGalaDataChangeEvent -= OnOSGalaDataChangeEvent;
        GlobalTimeEvent.Instance.secondEvent -= ShowTime;
    }
    protected override void OpenSubUIByTabIndex()
    {
        switch (functionOrder)
        {
            case 0:
                currentSubUI = UIManager.Instance.OpenWindow<OSGalaMissionWin>();
                break;
            case 1:
                currentSubUI = UIManager.Instance.OpenWindow<OSGalaChangeWin>();
                break;
            case 2:
                currentSubUI = UIManager.Instance.OpenWindow<OSGalaGiftWin>();
                break;
        }
    }
    private void OnOSGalaDataChangeEvent()
    {
        Display();
    }
    void Display()
    {
        var keys = OSActivityManager.Instance.osGalaScoreAwards.Keys.ToList();
        keys.Sort();
        // value 分段,按keys中的达标获取
        var addValue = 1.0f / keys.Count;
        var value = 0f;
        for (int i = 0; i < keys.Count; i++)
        {
            var score = keys[i];
            var award = OSActivityManager.Instance.osGalaScoreAwards[score];
            if (OSActivityManager.Instance.osGalaScore >= score)
            {
                value += addValue;
            }
            else
            {
                break;
            }
        }
        processImg.fillAmount = value;
        ShowTime();
        totalScoreText.text = Language.Get("OSActivity11") + OSActivityManager.Instance.osGalaScore.ToString();
        for (int i = 0; i < itemCells.Length; i++)
        {
            if (i < keys.Count)
            {
                itemCells[i].SetActive(true);
                int score = keys[i];
                int index = i;
                int itemID = OSActivityManager.Instance.osGalaScoreAwards[score][0][0];
                itemCells[i].Init(new ItemCellModel(itemID, false, OSActivityManager.Instance.osGalaScoreAwards[score][0][1]));
                itemCells[i].button.AddListener(() =>
                {
                    if (!OSActivityManager.Instance.CanGetAward(index, score))
                    {
                        ItemTipUtility.Show(itemID);
                        return;
                    }
                    var pack = new CA504_tagCMPlayerGetReward();
                    pack.RewardType = 9;
                    pack.DataEx = (uint)score;
                    GameNetSystem.Instance.SendInfo(pack);
                });
                gotImgs[i].SetActive(OSActivityManager.Instance.IsGotAward(i));
                scoreTexts[i].text = keys[i].ToString();
                if (OSActivityManager.Instance.CanGetAward(index, score))
                {
                    effectPlayers[i].Play();
                }
                else
                {
                    effectPlayers[i].Stop();
                }
            }
            else
            {
                itemCells[i].SetActive(false);
            }
        }
    }
    void ShowTime()
    {
        if (TimeUtility.OpenDay >= OSActivityManager.Instance.osGalaOpenDays)
        {
            timeText.text = Language.Get("OSActivity6");
        }
        else
        {
            timeText.text = Language.Get("OSActivity10") + TimeUtility.SecondsToShortDHMS(TimeUtility.GetRemindTimeByOpenDay(OSActivityManager.Instance.osGalaOpenDays));
        }
    }
}
Main/System/OSActivity/OSGalaBaseWin.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 40d472c19a23cf7439b6b4171a3dc689
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaChangeCell.cs
New file
@@ -0,0 +1,66 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class OSGalaChangeCell : CellView
{
    [SerializeField] ItemCell moneyItem;
    [SerializeField] ItemCell[] itemCells;
    [SerializeField] Button buyBtn;
    [SerializeField] Transform saleOutRect;
    [SerializeField] Text buyLimitText;
    public void Display(int index)
    {
        var id = OSActivityManager.Instance.osGalaChangeSortList[index];
        //商店
        var storeConfig = StoreConfig.Get(id);
        int scoreItemID = UIHelper.GetItemIDWithMoneyType(55);
        moneyItem.Init(new ItemCellModel(scoreItemID, false, storeConfig.MoneyNum));
        moneyItem.button.AddListener(() =>
        {
            ItemTipUtility.Show(scoreItemID);
        });
        var awards = StoreModel.Instance.GetShopItemlistEx(storeConfig);
        for (int i = 0; i < itemCells.Length; i++)
        {
            var itemCell = itemCells[i];
            if (i < awards.Count)
            {
                itemCell.SetActive(true);
                int itemID = awards[i][0];
                itemCell.Init(new ItemCellModel(itemID, true, awards[i][1]));
                itemCell.button.SetListener(() => ItemTipUtility.Show(itemID));
            }
            else
            {
                itemCell.SetActive(false);
            }
        }
        var state = StoreModel.Instance.GetShopIDState(id);
        if (state == 1)
        {
            saleOutRect.SetActive(true);
            buyBtn.SetActive(false);
        }
        else
        {
            saleOutRect.SetActive(false);
            buyBtn.SetActive(true);
            buyBtn.SetListener(() =>
            {
                StoreModel.Instance.SendBuyShopItem(storeConfig, 1);
            });
        }
        var buyCnt = StoreModel.Instance.GetShopLimitBuyCount(id);
        buyLimitText.text = Language.Get("storename8", storeConfig.LimitCnt - buyCnt, storeConfig.LimitCnt);
    }
}
Main/System/OSActivity/OSGalaChangeCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67af5ca397064d24387bb5dafc986b69
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaChangeWin.cs
New file
@@ -0,0 +1,64 @@
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Tuesday, July 24, 2018
//--------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
////开服庆典 - 兑换
public class OSGalaChangeWin : UIBase
{
    [SerializeField] ScrollerController scrollerController;
    protected override void OnPreOpen()
    {
        scrollerController.OnRefreshCell += OnRefreshCell;
        StoreModel.Instance.RefreshBuyShopLimitEvent += RefreshStore;
        OSActivityManager.Instance.RefreshOSGalaChangeSortList();
        Display();
    }
    protected override void OnPreClose()
    {
        scrollerController.OnRefreshCell -= OnRefreshCell;
        StoreModel.Instance.RefreshBuyShopLimitEvent -= RefreshStore;
    }
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as OSGalaChangeCell;
        _cell.Display(cell.index);
    }
    void Display()
    {
        scrollerController.Refresh();
        for (int i = 0; i < OSActivityManager.Instance.osGalaChangeSortList.Count; i++)
        {
            scrollerController.AddCell(ScrollerDataType.Header, i);
        }
        scrollerController.Restart();
    }
    void RefreshStore()
    {
        scrollerController.m_Scorller.RefreshActiveCellViews();
    }
}
Main/System/OSActivity/OSGalaChangeWin.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da028c17d189bf4479d73388ae438c28
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaGiftCell.cs
New file
@@ -0,0 +1,120 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class OSGalaGiftCell : CellView
{
    [SerializeField] Text nameText;
    [SerializeField] ItemCell[] itemCells;
    [SerializeField] Button buyBtn;
    [SerializeField] Text moneyText;
    [SerializeField] Image moneyIcon;
    [SerializeField] Transform saleOutRect;
    [SerializeField] Image redImg;
    [SerializeField] Text buyLimitText;
    [SerializeField] Image maskImg;
    public void Display(int index)
    {
        var id = OSActivityManager.Instance.osGalaGiftSortList[index];
        if (id > 100000000)
        {
            //充值
            id -= 100000000;
            var ctgConfig = CTGConfig.Get(id);
            nameText.text = ctgConfig.Title;
            for (int i = 0; i < itemCells.Length; i++)
            {
                var itemCell = itemCells[i];
                if (i < ctgConfig.GainItemList.Length)
                {
                    itemCell.SetActive(true);
                    int itemID = ctgConfig.GainItemList[i][0];
                    itemCell.Init(new ItemCellModel(itemID, true, ctgConfig.GainItemList[i][1]));
                    itemCell.button.SetListener(() => ItemTipUtility.Show(itemID));
                }
                else
                {
                    itemCell.SetActive(false);
                }
            }
            RechargeManager.Instance.TryGetRechargeCount(id, out var rechargeCount);
            var limitCnt = ctgConfig.DailyBuyCount;
            if (rechargeCount.todayCount < limitCnt)
            {
                saleOutRect.SetActive(false);
                maskImg.SetActive(false);
                buyBtn.SetActive(true);
                buyBtn.SetListener(() =>
                {
                    RechargeManager.Instance.CTG(id);
                });
                RechargeManager.Instance.TryGetOrderInfo(id, out var orderInfo);
                moneyText.text = Language.Get("PayMoneyNum", orderInfo.PayRMBNumOnSale);
                moneyIcon.SetActive(false);
            }
            else
            {
                saleOutRect.SetActive(true);
                maskImg.SetActive(true);
                buyBtn.SetActive(false);
            }
            buyLimitText.text = Language.Get("storename6", limitCnt - rechargeCount.todayCount, limitCnt);
            redImg.SetActive(false);
        }
        else
        {
            //商店
            var storeConfig = StoreConfig.Get(id);
            nameText.text = storeConfig.Name;
            var awards = StoreModel.Instance.GetShopItemlistEx(storeConfig);
            for (int i = 0; i < itemCells.Length; i++)
            {
                var itemCell = itemCells[i];
                if (i < awards.Count)
                {
                    itemCell.SetActive(true);
                    int itemID = awards[i][0];
                    itemCell.Init(new ItemCellModel(itemID, true, awards[i][1]));
                    itemCell.button.SetListener(() => ItemTipUtility.Show(itemID));
                }
                else
                {
                    itemCell.SetActive(false);
                }
            }
            var state = StoreModel.Instance.GetShopIDState(id);
            if (state == 1)
            {
                saleOutRect.SetActive(true);
                maskImg.SetActive(true);
                buyBtn.SetActive(false);
                redImg.SetActive(false);
            }
            else
            {
                saleOutRect.SetActive(false);
                maskImg.SetActive(false);
                buyBtn.SetActive(true);
                buyBtn.SetListener(() =>
                {
                    StoreModel.Instance.SendBuyShopItemWithPopCheck(storeConfig, 1);
                });
                moneyText.text = storeConfig.MoneyNum == 0 ? Language.Get("L1127") : storeConfig.MoneyNum.ToString();
                moneyIcon.SetActive(storeConfig.MoneyNum != 0);
                moneyIcon.SetIconWithMoneyType(storeConfig.MoneyType);
                redImg.SetActive(storeConfig.MoneyNum == 0);
            }
            var buyCnt = StoreModel.Instance.GetShopLimitBuyCount(id);
            buyLimitText.text = Language.Get("storename6", storeConfig.LimitCnt - buyCnt, storeConfig.LimitCnt);
        }
    }
}
Main/System/OSActivity/OSGalaGiftCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7390224540c1054c9ba0e96bae8674b
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaGiftWin.cs
New file
@@ -0,0 +1,60 @@
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Tuesday, July 24, 2018
//--------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
////开服庆典 - 礼包
public class OSGalaGiftWin : UIBase
{
    [SerializeField] ScrollerController scrollerController;
    protected override void OnPreOpen()
    {
        scrollerController.OnRefreshCell += OnRefreshCell;
        StoreModel.Instance.RefreshBuyShopLimitEvent += RefreshStore;
        RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent;
        OSActivityManager.Instance.RefreshOSGalaGiftSortList();
        Display();
    }
    protected override void OnPreClose()
    {
        scrollerController.OnRefreshCell -= OnRefreshCell;
        StoreModel.Instance.RefreshBuyShopLimitEvent -= RefreshStore;
        RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent;
    }
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as OSGalaGiftCell;
        _cell.Display(cell.index);
    }
    void Display()
    {
        scrollerController.Refresh();
        for (int i = 0; i < OSActivityManager.Instance.osGalaGiftSortList.Count; i++)
        {
            scrollerController.AddCell(ScrollerDataType.Header, i);
        }
        scrollerController.Restart();
    }
    void RefreshStore()
    {
        scrollerController.m_Scorller.RefreshActiveCellViews();
    }
    void OnRechargeCountEvent(int id)
    {
        scrollerController.m_Scorller.RefreshActiveCellViews();
    }
}
Main/System/OSActivity/OSGalaGiftWin.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ef7df34ebcd38d42ba1ca95b494ba7d
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaMissionCell.cs
New file
@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class OSGalaMissionCell : CellView
{
    [SerializeField] Text nameText;
    [SerializeField] Image processImg;
    [SerializeField] Text processText;
    [SerializeField] ItemCell[] itemCells;
    [SerializeField] Button getBtn;
    [SerializeField] Button gotoBtn;
    [SerializeField] Transform gotRect;
    public void Display(int id)
    {
        var config = SuccessConfig.Get(id);
        int targetValue = 0;
        int curValue = 0;
        var type = config.Type;
        if (type == 2)
        {
            // 主线关卡活动
            nameText.text = Language.Get($"Achievement{type}", config.NeedCnt / 100, config.NeedCnt % 100);
        }
        else if (type == 4)
        {
            nameText.text = Language.Get($"Achievement{type}", UIHelper.AppendColor(OfficialRankManager.Instance.GetOfficialRankColor(config.NeedCnt),
                            RealmConfig.Get(config.NeedCnt).Name));
        }
        else if (type == 6)
        {
            // 装备品质
            nameText.text = Language.Get($"Achievement{type}", config.NeedCnt, UIHelper.GetQualityNameWithColor(config.Condition[0]));
        }
        else if (config.Condition.IsNullOrEmpty())
        {
            nameText.text = Language.Get($"Achievement{type}", config.NeedCnt);
        }
        else
        {
            nameText.text = Language.Get($"Achievement{type}", config.NeedCnt, config.Condition[0]);
        }
        if (type == 2)
        {
            targetValue = MainLevelConfig.GetToTargetLevelIndex(config.NeedCnt) + 1;
            curValue = MainLevelConfig.GetToTargetLevelIndex(AchievementManager.Instance.GetAchievementProgress(type)) + 1;
        }
        else if (type == 6)
        {
            targetValue = config.NeedCnt;
            curValue = AchievementManager.Instance.GetAchievementProgress(type, config.Condition[0].ToString());
        }
        else
        {
            targetValue = config.NeedCnt;
            curValue = AchievementManager.Instance.GetAchievementProgress(type);
        }
        processImg.fillAmount = (float)curValue / targetValue;
        processText.text = Math.Min(targetValue, curValue) + "/" + targetValue;
        var cond = config.Condition.IsNullOrEmpty() ? "" : config.Condition[0].ToString();
        var state = AchievementManager.Instance.GetAchievementState(id, cond);
        for (int i = 0; i < itemCells.Length; i++)
        {
            if (i < config.AwardItemList.Length)
            {
                itemCells[i].SetActive(true);
                int itemID = config.AwardItemList[i][0];
                itemCells[i].Init(new ItemCellModel(itemID, false, config.AwardItemList[i][1]));
                itemCells[i].button.AddListener(() =>
                {
                    ItemTipUtility.Show(itemID);
                });
            }
            else
            {
                itemCells[i].SetActive(false);
            }
        }
        getBtn.SetActive(state == 0);
        gotoBtn.SetActive(state == 1);
        gotRect.SetActive(state == 2);
        getBtn.AddListener(() =>
        {
            AchievementManager.Instance.SendGetAward(id);
        });
        gotoBtn.AddListener(() =>
        {
            UIManager.Instance.CloseWindow<OSGalaBaseWin>();
            int guideID = 0;
            OSActivityManager.Instance.typeToGuideID.TryGetValue(type, out guideID);
            if (guideID > 0)
            {
                NewBieCenter.Instance.StartNewBieGuide(guideID);
            }
        });
    }
}
Main/System/OSActivity/OSGalaMissionCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3eca62a486d2d9a40bea2997c93082fe
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/OSActivity/OSGalaMissionWin.cs
New file
@@ -0,0 +1,70 @@
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Tuesday, July 24, 2018
//--------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
////开服活动-主线关卡活动
public class OSGalaMissionWin : UIBase
{
    [SerializeField] ScrollerController scroller;
    int[] types = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
    List<int> ids = new List<int>();
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        AchievementManager.Instance.OnAchievementUpdateEvent += OnAchievementUpdateEvent;
        CreateScroller();
    }
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
        AchievementManager.Instance.OnAchievementUpdateEvent -= OnAchievementUpdateEvent;
    }
    void OnAchievementUpdateEvent(int type)
    {
        // -1 为所有类型
        if (type >= 2 && type <= 19 || type == -1)
        {
            ids = AchievementManager.Instance.GetAchievementIDsByTypes(types);
            scroller.m_Scorller.RefreshActiveCellViews();
        }
    }
    void CreateScroller()
    {
        ids = AchievementManager.Instance.GetAchievementIDsByTypes(types);
        var count = ids.Count;
        scroller.Refresh();
        for (int i = 0; i < count; i++)
        {
            scroller.AddCell(ScrollerDataType.Header, i);
        }
        scroller.Restart();
    }
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as OSGalaMissionCell;
        _cell.Display(ids[cell.index]);
    }
}
Main/System/OSActivity/OSGalaMissionWin.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 030ec9a086c424f4d92911dac344b8ff
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/Redpoint/MainRedDot.cs
@@ -73,6 +73,7 @@
    public const int RedPoint_OSMainLevel = 111;    //开服榜
    public const int RedPoint_OSHeroCard = 112;
    public const int RedPoint_OSGala = 113; //开服庆典
    Redpoint osGalaRedpoint = new Redpoint(RedPoint_OSGala);
    public const int RedPoint_Download = 116;
Main/System/Store/StoreModel.cs
@@ -570,6 +570,8 @@
    Guild = 2, //2:公会
    Hero = 3, //3:将魂
    OSHeroCall = 4, //4:开服招募礼包
    OSGalaChange = 5, //5:开服庆典兑换
    OSGalaGift = 6, //6:开服庆典礼包
}
Main/Utility/EnumHelper.cs
@@ -711,6 +711,7 @@
    default44,  // 272 武将招募积分
    GoldRush = 285, // 淘金令
    ChallengeVoucher = 286,//挑战凭证
    OSGalaScore = 288, //开服庆典积分
};
Main/Utility/UIHelper.cs
@@ -1004,6 +1004,7 @@
        {43, PlayerDataType.default34},
        {42, PlayerDataType.default33},
        {53, PlayerDataType.ChallengeVoucher},
        {55, PlayerDataType.OSGalaScore},
        {99, PlayerDataType.ExAttr11},
    };
@@ -1152,6 +1153,11 @@
                    //挑战凭证
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ChallengeVoucher);
                }
            case 55:
                {
                    //开服庆典积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.OSGalaScore);
                }
            case 98:
                {
                    //过期型代金券