少年修仙传客户端代码仓库
client_linchunjie
2018-09-14 a0ede150686a218c92b901b1f20aef12a9913890
System/Activity/ActivityNotifyBehaviour.cs
@@ -1,169 +1,189 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using System;
using TableConfig;
namespace Snxxz.UI
{
    public class ActivityNotifyBehaviour : MonoBehaviour
    {
        int m_NotifyType;
        [SerializeField] Button CloseBtn;
        [SerializeField] Text title;
        [SerializeField] Image icon;
        [SerializeField] Button confirmBtn;
        [SerializeField] Text confirmBtnText;
        DailyQuestModel m_DailyQuestModel;
        DailyQuestModel dailyQuestModel
        {
            get
            {
                return m_DailyQuestModel ?? (m_DailyQuestModel = ModelCenter.Instance.GetModel<DailyQuestModel>());
            }
        }
        DungeonModel m_DungeonModel;
        DungeonModel dungeonModel
        {
            get
            {
                return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel<DungeonModel>());
            }
        }
        ActivityNotifyWin m_NotifyWin;
        ActivityModel m_ActivityModel
        {
            get
            {
                return ModelCenter.Instance.GetModel<ActivityModel>();
            }
        }
        private void Awake()
        {
            CloseBtn.onClick.AddListener(OnClose);
            confirmBtn.onClick.AddListener(OnConfirmClick);
        }
        private void OnConfirmClick()
        {
            if((DailyQuestType)m_NotifyType != DailyQuestType.WyTaiChi)
            {
                if (PlayerDatas.Instance.extersion.pkState == 1)
                {
                    SysNotifyMgr.Instance.ShowTip("PK_Leave");
                    return;
                }
                if (PlayerDatas.Instance.extersion.bossState == 1)
                {
                    SysNotifyMgr.Instance.ShowTip("Boss_Leave");
                    return;
                }
            }
            var config = ConfigManager.Instance.GetTemplate<DailyQuestConfig>((int)m_NotifyType);
            if (config != null)
            {
                switch ((DailyQuestType)m_NotifyType)
                {
                    case DailyQuestType.FairyLand:
                    case DailyQuestType.IceCrystal:
                    case DailyQuestType.Demon:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.GuardSky:
                        if (ModelCenter.Instance.GetModel<FairyModel>().completeGuardSky)
                        {
                            SysNotifyMgr.Instance.ShowTip("TheEmperor1");
                            break;
                        }
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.Kirin:
                        {
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<MultipleDifficultyDungeonWin>();
                        }
                        break;
                    case DailyQuestType.FairyFeast:
                        dungeonModel.SingleChallengeDungeon(config.RelatedID);
                        break;
                    case DailyQuestType.Trial:
                        {
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<TrialDungeonSelectWin>();
                        }
                        break;
                    case DailyQuestType.AncientBattleGround:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, dungeonModel.GetBelongToLine(config.ID));
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.HeavenBattle:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, dungeonModel.GetBelongToLine(config.ID));
                        WindowCenter.Instance.Open<HeavenBattleWin>();
                        break;
                    case DailyQuestType.WyTaiChi:
                        if (!VersionConfig.Get().isBanShu)
                        {
                            dailyQuestModel.currentDailyQuest = config.ID;
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<TaiChilDungeonEntranceWin>();
                        }
                        break;
                    case DailyQuestType.FairyLeague:
                        WindowCenter.Instance.Open<UnionPanel>(false, 4);
                        break;
                }
            }
            else
            {
                switch ((ActivityModel.SpecialActivity)m_NotifyType)
                {
                    case ActivityModel.SpecialActivity.FairyBoss:
                        WindowCenter.Instance.Open<FairyBoss>();
                        break;
                }
            }
            OnClose();
        }
        public void Init(int type, ActivityNotifyWin _notifyWin)
        {
            m_NotifyWin = _notifyWin;
            m_NotifyType = type;
            DailyQuestConfig cfg = ConfigManager.Instance.GetTemplate<DailyQuestConfig>((int)type);
            confirmBtnText.text = Language.Get("Z1074");
            if (cfg != null)
            {
                title.text = cfg.Title;
                icon.SetSprite(cfg.Icon);
            }
            else
            {
                var _index = type - (int)ActivityModel.SpecialActivity.None;
                ActivityModel.SpecialActivityData _data;
                if (m_ActivityModel.TryGetSpecialActivityData(_index,out _data))
                {
                    title.text = Language.Get(_data.Title);
                    icon.SetSprite(_data.Icon);
                }
            }
        }
        private void OnClose()
        {
            m_NotifyWin.Release(m_NotifyType);
        }
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using System;
using TableConfig;
namespace Snxxz.UI
{
    public class ActivityNotifyBehaviour : MonoBehaviour
    {
        int m_NotifyType;
        [SerializeField] Button CloseBtn;
        [SerializeField] Text title;
        [SerializeField] Image icon;
        [SerializeField] Button confirmBtn;
        [SerializeField] Text confirmBtnText;
        DailyQuestModel m_DailyQuestModel;
        DailyQuestModel dailyQuestModel
        {
            get
            {
                return m_DailyQuestModel ?? (m_DailyQuestModel = ModelCenter.Instance.GetModel<DailyQuestModel>());
            }
        }
        DungeonModel m_DungeonModel;
        DungeonModel dungeonModel
        {
            get
            {
                return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel<DungeonModel>());
            }
        }
        ActivityNotifyWin m_NotifyWin;
        ActivityModel m_ActivityModel
        {
            get
            {
                return ModelCenter.Instance.GetModel<ActivityModel>();
            }
        }
        private void Awake()
        {
            CloseBtn.onClick.AddListener(OnClose);
            confirmBtn.onClick.AddListener(OnConfirmClick);
        }
        private void OnConfirmClick()
        {
            switch ((DailyQuestType)m_NotifyType)
            {
                case DailyQuestType.FairyGrabBoss:
                case DailyQuestType.WyTaiChi:
                    break;
                default:
                    if (PlayerDatas.Instance.extersion.pkState == 1)
                    {
                        SysNotifyMgr.Instance.ShowTip("PK_Leave");
                        return;
                    }
                    if (PlayerDatas.Instance.extersion.bossState == 1)
                    {
                        SysNotifyMgr.Instance.ShowTip("Boss_Leave");
                        return;
                    }
                    break;
            }
            var config = Config.Instance.Get<DailyQuestConfig>((int)m_NotifyType);
            if (config != null)
            {
                switch ((DailyQuestType)m_NotifyType)
                {
                    case DailyQuestType.FairyLand:
                    case DailyQuestType.IceCrystal:
                    case DailyQuestType.Demon:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.GuardSky:
                        var fairyData = PlayerDatas.Instance.fairyData;
                        if (!fairyData.HasFairy)
                        {
                            break;
                        }
                        var fairyModel = ModelCenter.Instance.GetModel<FairyModel>();
                        if (fairyData.fairy == null
                            || fairyData.fairy.FamilyLV < fairyModel.guardSkyOpenFairyLv)
                        {
                            SysNotifyMgr.Instance.ShowTip("GuardSkyOpenLvError", fairyModel.guardSkyOpenFairyLv);
                            break;
                        }
                        if (fairyModel.completeGuardSky)
                        {
                            SysNotifyMgr.Instance.ShowTip("TheEmperor1");
                            break;
                        }
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.Kirin:
                        {
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<MultipleDifficultyDungeonWin>();
                        }
                        break;
                    case DailyQuestType.FairyFeast:
                        dungeonModel.SingleChallenge(config.RelatedID);
                        break;
                    case DailyQuestType.Trial:
                        {
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<TrialDungeonSelectWin>();
                        }
                        break;
                    case DailyQuestType.AncientBattleGround:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, dungeonModel.GetBelongToLine(config.ID));
                        WindowCenter.Instance.Open<NormalDungeonEntranceWin>();
                        break;
                    case DailyQuestType.HeavenBattle:
                        dungeonModel.currentDungeon = new Dungeon(config.RelatedID, dungeonModel.GetBelongToLine(config.ID));
                        WindowCenter.Instance.Open<HeavenBattleWin>();
                        break;
                    case DailyQuestType.WyTaiChi:
                        if (!VersionConfig.Get().isBanShu)
                        {
                            dailyQuestModel.currentDailyQuest = config.ID;
                            dungeonModel.currentDungeon = new Dungeon(config.RelatedID, 0);
                            WindowCenter.Instance.Open<TaiChilDungeonEntranceWin>();
                        }
                        break;
                    case DailyQuestType.FairyLeague:
                        WindowCenter.Instance.Open<UnionPanel>(false, 4);
                        break;
                    case DailyQuestType.FairyGrabBoss:
                        WindowCenter.Instance.Open<LootPreciousFrameWin>(false, 1);
                        break;
                }
            }
            else
            {
                switch ((ActivityModel.SpecialActivity)m_NotifyType)
                {
                    case ActivityModel.SpecialActivity.FairyBoss:
                        WindowCenter.Instance.Open<FairyBoss>();
                        break;
                }
            }
            OnClose();
        }
        public void Init(int type, ActivityNotifyWin _notifyWin)
        {
            m_NotifyWin = _notifyWin;
            m_NotifyType = type;
            DailyQuestConfig cfg = Config.Instance.Get<DailyQuestConfig>((int)type);
            confirmBtnText.text = Language.Get("Z1074");
            if (cfg != null)
            {
                title.text = cfg.Title;
                icon.SetSprite(cfg.Icon);
            }
            else
            {
                var _index = type - (int)ActivityModel.SpecialActivity.None;
                ActivityModel.SpecialActivityData _data;
                if (m_ActivityModel.TryGetSpecialActivityData(_index,out _data))
                {
                    title.text = Language.Get(_data.Title);
                    icon.SetSprite(_data.Icon);
                }
            }
        }
        private void OnClose()
        {
            m_NotifyWin.Release(m_NotifyType);
        }
    }
}