示例#1
0
    protected override object AdapterTipData(object data)
    {
        PackageProxy m_PackageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        if (data is LogDataVO)
        {
            return(m_PackageProxy.CreateItem(0, (data as LogDataVO).Tid, 0, 0, 0, 0, 0, 0));
        }
        if (data is ShopWindowVO)
        {
            return(m_PackageProxy.CreateItem(0, (data as ShopWindowVO).Tid, 0, 0, 0, 0, 0, 0));
        }
        if (data is ShopSellBackVO)
        {
            return(m_PackageProxy.CreateItem(0, (uint)(data as ShopSellBackVO).Tid, 0, 0, 0, 0, 0, 0));
        }
        if (data is ProduceInfoVO)
        {
            return(m_PackageProxy.CreateItem(0, (uint)(data as ProduceInfoVO).TID, 0, 0, 0, 0, 0, 0));
        }
        if (data is IShip)
        {
            return(m_PackageProxy.GetItem <ItemWarShipVO>((data as IShip).GetUID()));
        }
        if (data is IMod)
        {
            return(m_PackageProxy.GetItem <ItemModVO>((data as IMod).GetUID()));
        }
        if (data is IWeapon)
        {
            return(m_PackageProxy.GetItem <ItemWeaponVO>((data as IWeapon).GetUID()));
        }
        return(base.AdapterTipData(data));
    }
示例#2
0
        public IPackage Build()
        {
            var proxy = new PackageProxy
            {
                Author                = this.Author,
                Name                  = this.Name,
                Version               = this.LatestVersion,
                AvailableVersions     = this.AvailableVersions,
                Description           = this.Description,
                Homepages             = this.Homepages,
                PublishDateTimeString = this.PublishDateTimeString,
                RequestedVersionRange = this.RequestedVersionRange,
                Flags                 = this.Flags,
                Keywords              = this._keywords
            };

            var modules = new NodeModulesProxy();

            foreach (var dep in this.Dependencies)
            {
                modules.AddModule(dep);
            }
            proxy.Modules = modules;
            return(proxy);
        }
示例#3
0
    /// <summary>
    /// 是否材料和钱充足可以
    /// </summary>
    /// <param name="tid"></param>
    /// <returns></returns>
    public bool BeCanProduce(int tid)
    {
        Produce produce = GetProduceByKey(tid);

        EffectElement?[] cost = GetEffectElementsByKey(produce.Cost);
        uint             itmeId;

        if (m_PackageProxy == null)
        {
            m_PackageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        }
        //消耗物品
        for (int i = 0; i < cost.Length; i++)
        {
            itmeId = (uint)cost[i].Value.ItemId;
            long hasCout  = m_PackageProxy.GetItemCountByTID(itmeId);
            long needCout = (long)cost[i].Value.Value;
            if (hasCout < needCout)
            {
                SetGirdDataInfo(tid, ProduceState.CanNotProduce, 0);//默认true
                return(false);
            }
        }
        SetGirdDataInfo(tid, ProduceState.CanProduce, 0);
        return(true);
    }
示例#4
0
    /// <summary>
    /// 获取当前任命出战船
    /// </summary>
    /// <returns></returns>
    public IShip GetAppointWarShip()
    {
        PackageProxy m_PackageProxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        m_HeroItem = m_PackageProxy.GetHeroItem();
        if (m_HeroItem != null && m_HeroItem.Items != null && m_HeroItem.Items.Count > 0)
        {
            ItemWarShipVO itemWarShip = null;
            foreach (ItemBase item in m_HeroItem.Items.Values)
            {
                if (item is ItemWarShipVO)
                {
                    if (m_CurrentWarShip == null || m_CurrentWarShip.GetUID() != item.UID)
                    {
                        if (!m_ShipPackage.TryGetValue(item.UID, out m_CurrentWarShip))
                        {
                            itemWarShip      = item as ItemWarShipVO;
                            m_CurrentWarShip = WarShipDataFactory.BuildShipData(itemWarShip);
                            m_ShipPackage[m_CurrentWarShip.GetUID()] = m_CurrentWarShip;
                        }
                    }
                    return(m_CurrentWarShip);
                }
            }
        }
        m_CurrentWarShip = null;
        return(null);
    }
示例#5
0
    private void OnItemUse(HotkeyCallback callback)
    {
        if (callback.performed)
        {
            if (OwnerView.State.GetTipData() == null)
            {
                return;
            }
            if (m_CurrentSelectedItemData != null)
            {
                if (m_CurrentItemData?.GetReference() == m_CurrentSelectedItemData.UID)                //拆
                {
                    NetworkManager.Instance.GetPackageController().ReqestMove(
                        m_CurrentItemData.GetUID(),
                        PackageProxy.GetPackage(m_Category).UID,
                        Parent.Data.CurrentShip.GetUID());

                    PlayerSound(isAdd: false, m_Category == Category.Equipment ? (m_CurrentSelectedItemData as ItemEquipmentVO).EquipmentType : 0);
                }
                else                //装
                {
                    NetworkManager.Instance.GetPackageController().ReqestMove(
                        m_CurrentSelectedItemData.UID,
                        m_ContainerUID,
                        m_ContainerPOS,
                        Parent.Data.CurrentShip.GetUID());

                    PlayerSound(isAdd: true, m_Category == Category.Equipment ? (m_CurrentSelectedItemData as ItemEquipmentVO).EquipmentType : 0);
                }
            }
        }
    }
示例#6
0
    /// <summary>
    /// 初始化所有船数据
    /// </summary>
    /// <returns></returns>
    public void InitShipPackage()
    {
        PackageProxy m_PackageProxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        ItemContainer[] m_ShipByType = m_PackageProxy.GetItemList <ItemContainer>(Category.WarehousePackage, Category.Package);
        m_ShipPackage.Clear();
        if (m_ShipByType != null)
        {
            foreach (ItemContainer package in m_ShipByType)
            {
                if (package.Items != null)
                {
                    foreach (var item in package.Items.Values)
                    {
                        IShip m_WarShip = WarShipDataFactory.BuildShipData((ItemWarShipVO)item);
                        m_ShipPackage.Add(m_WarShip.GetUID(), m_WarShip);
                    }
                }
            }
        }
        IShip m_CurWarShip = GetAppointWarShip();

        if (!m_ShipPackage.ContainsKey(m_CurWarShip.GetUID()))
        {
            m_ShipPackage.Add(m_CurWarShip.GetUID(), m_CurWarShip);
        }
    }
示例#7
0
 private PackageProxy GetPackageProxy()
 {
     if (m_PackageProxy == null)
     {
         m_PackageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
     }
     return(m_PackageProxy);
 }
示例#8
0
        public List <FixedPricePackageEx> SyncPackage(FixedPriceProductEx prod)
        {
            List <FixedPricePackageEx> pkgs = new List <FixedPricePackageEx>();

            // 登入者的語系
            var locale = _httpContextAccessor.HttpContext.User.FindFirst("Locale").Value;

            var KKdayPackages = PackageProxy.GetProdPackages(prod.COMPANY_XID, locale, prod.CURRENCY, prod.PROD_NO, prod.STATE);

            int _pkg_seq = 1;

            KKdayPackages.ForEach(p =>
            {
                var prices = new List <FixedPricePackageDtl>();

                prices.Add(new FixedPricePackageDtlEx()
                {
                    PKG_SEQ_NO = _pkg_seq,
                    PRICE_COND = "price1",
                    PRICE      = p.price1
                });

                prices.Add(new FixedPricePackageDtlEx()
                {
                    PKG_SEQ_NO = _pkg_seq,
                    PRICE_COND = "price2",
                    PRICE      = p.price2
                });

                prices.Add(new FixedPricePackageDtlEx()
                {
                    PKG_SEQ_NO = _pkg_seq,
                    PRICE_COND = "price3",
                    PRICE      = p.price3
                });

                prices.Add(new FixedPricePackageDtlEx()
                {
                    PKG_SEQ_NO = _pkg_seq,
                    PRICE_COND = "price4",
                    PRICE      = p.price4
                });

                pkgs.Add(new FixedPricePackageEx()
                {
                    SEQ_NO   = _pkg_seq,
                    PKG_NO   = p.pkg_no,
                    PKG_NAME = p.pkg_name,
                    PROD_XID = prod.XID,
                    Prices   = prices
                });

                _pkg_seq++;
            });

            return(pkgs);
        }
示例#9
0
    /// <summary>
    /// 设置热键刷新
    /// </summary>
    public void SetHotKey()
    {
        PackageProxy proxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        SetHotKeyEnabled("l", proxy.GetItemCountByTID(ITEM_L) > 0);
        SetHotKeyEnabled("b", proxy.GetItemCountByTID(ITEM_B) > 0);
        SetHotKeyEnabled("r", proxy.GetItemCountByTID(ITEM_R) > 0);
        SetHotKeyEnabled("t", proxy.GetItemCountByTID(ITEM_T) > 0);
    }
示例#10
0
    /// <summary>
    /// 视图打开时调用
    /// </summary>
    /// <param name="owner">父视图</param>
    public override void OnShow(object msg)
    {
        base.OnShow(msg);
        m_FoundryProxy     = GameFacade.Instance.RetrieveProxy(ProxyName.FoundryProxy) as FoundryProxy;
        m_PackageProxy     = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        m_CfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        m_ServerListProxy  = GameFacade.Instance.RetrieveProxy(ProxyName.ServerListProxy) as ServerListProxy;
        m_ShipProxy        = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        HOLD_TIME          = State.GetAction(UIAction.Product_Accelerate).StateList[0].Time;
        m_ExpendNumber     = m_CfgEternityProxy.GetGamingConfig(1).Value.Produce.Value.FinishExpenseRate;
        m_ProduceView      = OwnerView as ProduceView;
        m_FoundryProxy.GetAllDataByTable();
        m_PartProduceList = m_FoundryProxy.GetDataByMainType(BlueprintL1.Material);//零件
        NetworkManager.Instance.GetFoundryController().SendGetFoundryInfo();
        MsgOpenProduce msgOpenProduce = (MsgOpenProduce)msg;

        m_CurrentType = msgOpenProduce.CurrentProduceType;
        m_Grad        = (int)msgOpenProduce.MProduceDialogType;
        m_GradOld     = m_Grad;

        State.OnSelectionChanged -= OnSelectionDataChanged;
        State.OnSelectionChanged += OnSelectionDataChanged;
        State.GetAction(UIAction.Product_Accelerate).Callback        += OnProduce;
        State.GetAction(UIAction.Product_Cancel).Callback            += OnCanelProduce;
        State.GetAction(UIAction.Product_ProduceAndCollect).Callback += OnRevecie;
        State.GetAction(UIAction.Product_Accelerate).Visible          = false;
        switch (m_CurrentType)
        {
        case ProduceType.HeavyWeapon:
            m_CurrentBlueprintType = BlueprintL1.Weapon;
            break;

        case ProduceType.Reformer:
            m_CurrentBlueprintType = BlueprintL1.Reformer;
            break;

        case ProduceType.Chip:
            m_CurrentBlueprintType = BlueprintL1.EquipmentMod;
            break;

        case ProduceType.Device:
            m_CurrentBlueprintType = BlueprintL1.Equipment;
            break;

        case ProduceType.Ship:
            m_CurrentBlueprintType = BlueprintL1.Warship;
            m_FoundryProxy.InitShipPackage();
            break;

        default:
            break;
        }
    }
示例#11
0
        /// <summary>
        /// Gets the package sale date.
        /// </summary>
        /// <returns>The package sale date.</returns>
        /// <param name="rq">Rq.</param>
        //取得套餐可售日期
        public static PkgSaleDateModel GetPkgSaleDate(QueryProductModel rq)
        {
            PkgSaleDateModel pkgSdt = new PkgSaleDateModel();
            List <SaleDt>    dt     = new List <SaleDt>();

            try
            {
                JObject obj = PackageProxy.getSaleDate(rq);

                if (obj["content"]["result"].ToString() != "0000")
                {
                    pkgSdt.result     = obj["content"]["result"].ToString();
                    pkgSdt.result_msg = $"kkday saleDate api response msg is not correct! {obj["content"]["msg"].ToString()}";
                    throw new Exception($"kkday saleDate api response msg is not correct! {obj["content"]["msg"].ToString()}");
                }

                #region --1.取回傳資料是否成功的訊息--

                pkgSdt.result     = obj["content"]["result"].ToString();
                pkgSdt.result_msg = obj["content"]["msg"].ToString();

                #endregion

                #region --2.從傑森物件取『套餐可售日期列表』--

                if (pkgSdt.result.ToString() == "0000")
                {
                    JArray jDt = (JArray)obj["content"]["saleDt"];

                    for (int i = 0; i < jDt.Count; i++)
                    {
                        var model = new SaleDt();

                        model.pkg_no   = jDt[i]["pkgOidObj"].ToString();
                        model.sale_day = jDt[i]["day"].ToString();
                        dt.Add(model);
                    }

                    pkgSdt.saleDt = dt;
                }


                #endregion
            }
            catch (Exception ex)
            {
                pkgSdt.result     = "10001";
                pkgSdt.result_msg = $"SaleDate ERROR :{ex.Message},{ex.StackTrace}";
                Website.Instance.logger.FatalFormat($"SaleDate ERROR :{ex.Message},{ex.StackTrace}");
            }

            return(pkgSdt);
        }
示例#12
0
    /// <summary>
    /// 修改船数据包
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    public void ChangeShipPackage(ulong id)
    {
        PackageProxy  m_PackageProxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        ItemWarShipVO itemWarShipVO  = m_PackageProxy.GetItem <ItemWarShipVO>(id);
        IShip         m_Ship         = null;

        m_Ship = WarShipDataFactory.BuildShipData(itemWarShipVO);
        m_ShipPackage.Add(m_Ship.GetUID(), m_Ship);
        IShip m_CurWarShip = GetAppointWarShip();

        if (!m_ShipPackage.ContainsKey(m_CurWarShip.GetUID()))
        {
            m_ShipPackage.Add(m_CurWarShip.GetUID(), m_CurWarShip);
        }
    }
示例#13
0
        /// <summary>
        /// Gets the package events.
        /// </summary>
        /// <returns>The package events.</returns>
        /// <param name="rq">Rq.</param>
        //取得套餐場次
        public static PkgEventsModel GetPkgEvents(QueryProductModel rq)
        {
            PkgEventsModel pkgEvnt = new PkgEventsModel();
            List <Event>   et      = new List <Event>();

            try {
                JObject obj = PackageProxy.getEvents(rq);

                if (obj["content"]["result"].ToString() != "0000")
                {
                    pkgEvnt.result     = obj["content"]["result"].ToString();
                    pkgEvnt.result_msg = $"kkday event api response msg is not correct! {obj["content"]["msg"].ToString()}";
                    throw new Exception($"kkday event api response msg is not correct! {obj["content"]["msg"].ToString()}");
                }

                #region --1.取回傳資料是否成功的訊息--

                pkgEvnt.result     = obj["content"]["result"].ToString();
                pkgEvnt.result_msg = obj["content"]["msg"].ToString();
                pkgEvnt.pkg_no     = (int)obj["content"]["eventData"][0]["pkgOid"];
                pkgEvnt.is_hl      = obj["content"]["eventData"][0]["isBackup"].ToString();

                #endregion

                #region --2.從傑森物件取『套餐場次列表』--
                JArray jEt = (JArray)obj["content"]["eventData"][0]["events"];

                for (int i = 0; i < jEt.Count; i++)
                {
                    var model = new Event();

                    model.day         = jEt[i]["day"].ToString();
                    model.event_times = jEt[i]["eventTimes"].ToString();
                    et.Add(model);
                }

                pkgEvnt.events = et;

                #endregion
            } catch (Exception ex) {
                pkgEvnt.result     = "10001";
                pkgEvnt.result_msg = $"Events ERROR :{ex.Message},{ex.StackTrace}";
                Website.Instance.logger.FatalFormat($"Events ERROR:{ex.Message},{ex.StackTrace}");
            }

            return(pkgEvnt);
        }
示例#14
0
    /// <summary>
    /// 获取船类型包
    /// </summary>
    /// <param name="warshipL1"></param>
    /// <returns></returns>
    public ItemContainer GetShipContainer(WarshipL1 warshipL1)
    {
        PackageProxy m_PackageProxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        switch (warshipL1)
        {
        case WarshipL1.MiningShip:
            return(m_PackageProxy.GetItemList <ItemContainer>(Category.WarehousePackage, Category.Package)[2]);

        case WarshipL1.FightWarship:
            return(m_PackageProxy.GetItemList <ItemContainer>(Category.WarehousePackage, Category.Package)[1]);

        case WarshipL1.SurveillanceShip:
            return(m_PackageProxy.GetItemList <ItemContainer>(Category.WarehousePackage, Category.Package)[0]);
        }
        return(null);
    }
示例#15
0
 public override void Initialize()
 {
     m_MinNum           = FindComponent <TMP_Text>("Content/Label_Min");
     m_MaxNum           = FindComponent <TMP_Text>("Content/Label_Max");
     m_Tips             = FindComponent <TMP_Text>("Content/Label_Tips");
     m_GoodName         = FindComponent <TMP_Text>("Content/Label_Item_Name");
     m_InputBox         = FindComponent <TMP_InputField>("Content/Input");
     m_TotalPrice       = FindComponent <TMP_Text>("Content/Money/Coin1/Label_Coin");
     m_MoneyRoot        = FindComponent <Transform>("Content/Money");
     m_MoneyIcon        = FindComponent <Image>("Content/Money/Coin1/Image_Icon");
     m_BtnLeft          = FindComponent <Transform>("Content/Btn_Left");
     m_BtnRight         = FindComponent <Transform>("Content/Btn_Right");
     m_HotKeyRoot       = FindComponent <Transform>("Control/Footer/ContentHotKey");
     m_PackageProxy     = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
     m_CfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
     m_ShopProxy        = GameFacade.Instance.RetrieveProxy(ProxyName.ShopProxy) as ShopProxy;
     m_ShipProxy        = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
 }
示例#16
0
    /// <summary>
    /// 更新背包大小
    /// </summary>
    private void UpdatePackSize()
    {
        int pageIndex = State.GetPageIndex();

        PackageProxy pack = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        ItemContainer m_Container = null;

        PackagePageType packType = (PackagePageType)pageIndex;

        switch (packType)
        {
        case PackagePageType.Consumables:
            m_Container = pack.GetPackage(Category.Expendable);
            break;

        case PackagePageType.Material:
            m_Container = pack.GetPackage(Category.Material);
            break;

        case PackagePageType.Weapons:
            m_Container = pack.GetPackage(Category.Weapon);
            break;

        case PackagePageType.Converters:
            m_Container = pack.GetPackage(Category.Reformer);
            break;

        case PackagePageType.Devices:
            m_Container = pack.GetPackage(Category.Equipment);
            break;

        case PackagePageType.Chips:
            m_Container = pack.GetPackage(Category.EquipmentMod);
            break;
        }

        int m_Count    = m_Container != null && m_Container.Items != null ? m_Container.Items.Count : 0;
        int m_MaxCount = m_Container != null ? (int)m_Container.CurrentSizeMax : 100;

        State.SetPageLabel(State.GetPageIndex(), string.Format(GetLocalization("package_title_1008"), m_Count, m_MaxCount));
    }
示例#17
0
    public override void OnShow(object msg)
    {
        base.OnShow(msg);
        if (m_ShipProxy == null)
        {
            m_ShipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        }
        if (m_PackageProxy == null)
        {
            m_PackageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        }
        if (msg != null)
        {
            m_LastPanelShip = (IShip)msg;
        }
        m_Parent.OnEscClick = OnEscClick;

        State.GetAction(UIAction.Hangar_Assemble).Callback -= OnAssembleShip;
        State.GetAction(UIAction.Hangar_Assemble).Callback += OnAssembleShip;
        State.GetAction(UIAction.Hangar_Appoint).Callback  -= OnAppointShip;
        State.GetAction(UIAction.Hangar_Appoint).Callback  += OnAppointShip;
    }
示例#18
0
    public void InitShipItemsByByRespond(S2C_SYNC_FIGHTSHIP_VISIBLE_ITEM_LIST respond)
    {
        PackageProxy packageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        ulong        uid          = respond.uid;

        Dictionary <ulong, ItemContainer> items = new Dictionary <ulong, ItemContainer>();

        foreach (var item in respond.item_list)
        {
            ItemContainer itemcon = packageProxy.CreateItem(item.uid, item.tid, item.parent, item.pos, 0, 0, 0, 0);
            itemcon.Lv = item.lv;
            items.Add(item.uid, itemcon);
        }
        RelationData(items);
        // 用最新的
        if (m_ShipItems.ContainsKey(uid))
        {
            RemoveShipItems(uid);
        }

        m_ShipItems.Add(uid, items);
    }
示例#19
0
    public override void OnShow(object msg)
    {
        base.OnShow(msg);
        m_ShopId = (int)msg;
        if (m_ShopProxy == null)
        {
            m_ShopProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShopProxy) as ShopProxy;
        }
        if (m_PackageProxy == null)
        {
            m_PackageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        }

        State.GetAction(UIAction.Shop_Buy).Callback -= OnHotKeyCallBack;
        State.GetAction(UIAction.Shop_Buy).Callback += OnHotKeyCallBack;

        State.GetAction(UIAction.Shop_Sell).Callback -= OnHotKeyCallBack;
        State.GetAction(UIAction.Shop_Sell).Callback += OnHotKeyCallBack;

        NetworkManager.Instance.GetShopController().RequestShopWindowInfo((uint)m_ShopId);
        NetworkManager.Instance.GetShopController().RequestShopSellBackInfo((uint)m_ShopId);
        State.OnSelectionChanged += OnSelectionChanged;
    }
示例#20
0
    /// <summary>
    /// 好友信息解析
    /// </summary>
    /// <param name="respond"></param>
    public void InitShipItemsByByRespond(S2C_SYNC_PLAYERINFO respond)
    {
        PackageProxy packageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        ulong        uid          = respond.uid;

        Debug.Log("收到并解析玩家数据" + uid);
        Dictionary <ulong, ItemContainer> items = new Dictionary <ulong, ItemContainer>();

        foreach (var item in respond.item_list)
        {
            ItemContainer itemcon = packageProxy.CreateItem(item.uid, item.tid, item.parent, item.pos, 0, 0, 0, 0);
            itemcon.Lv = item.lv;
            items.Add(item.uid, itemcon);
        }
        RelationData(items);
        // 用最新的
        if (m_ShipItems.ContainsKey(uid))
        {
            RemoveShipItems(uid);
        }

        m_ShipItems.Add(uid, items);
        GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_SHIPDATA_CHANGE, uid);
    }
示例#21
0
        public void Validate()
        {
            // Wire up the node label parents.

            foreach (var node in NodeDefinitions.Values)
            {
                if (node.Labels != null)
                {
                    node.Labels.Node = node;
                }
            }

            // Validate the properties.

            Provisioner = Provisioner ?? defaultProvisioner;
            Kubernetes  = Kubernetes ?? new KubernetesOptions();
            Docker      = Docker ?? new DockerOptions();
            Ceph        = Ceph ?? new CephOptions()
            {
                Enabled = false
            };
            Mon = Mon ?? new MonOptions()
            {
                Enabled = false
            };
            Prometheus = Prometheus ?? new PrometheusOptions()
            {
                Enabled = false
            };
            DrivePrefix = DrivePrefix ?? defaultDrivePrefix;
            Setup       = Setup ?? new SetupOptions();
            Hosting     = Hosting ?? new HostingOptions();
            NodeOptions = NodeOptions ?? new NodeOptions();
            Network     = Network ?? new NetworkOptions();

            Kubernetes.Validate(this);
            Docker.Validate(this);
            Ceph.Validate(this);
            Mon.Validate(this);
            Prometheus.Validate(this);
            Setup.Validate(this);
            Network.Validate(this);
            Hosting.Validate(this);
            NodeOptions.Validate(this);
            Network.Validate(this);

            new HostingManagerFactory().Validate(this);

            if (TimeSources == null || TimeSources.Length == 0 || TimeSources.Count(ts => string.IsNullOrWhiteSpace(ts)) > 0)
            {
                TimeSources = new string[] { "pool.ntp.org" };
            }

            if (NodeDefinitions == null || NodeDefinitions.Count == 0)
            {
                throw new ClusterDefinitionException("At least one cluster node must be defined.");
            }

            foreach (var node in NodeDefinitions.Values)
            {
                node.Validate(this);
            }

            if (Name == null)
            {
                throw new ClusterDefinitionException($"The [{nameof(ClusterDefinition)}.{nameof(Name)}] property is required.");
            }

            if (!IsValidName(Name))
            {
                throw new ClusterDefinitionException($"The [{nameof(ClusterDefinition)}.{nameof(Name)}={Name}] property is not valid.  Only letters, numbers, periods, dashes, and underscores are allowed.");
            }

            if (Datacenter == null)
            {
                throw new ClusterDefinitionException($"The [{nameof(ClusterDefinition)}.{nameof(Datacenter)}] property is required.");
            }

            if (!IsValidName(Datacenter))
            {
                throw new ClusterDefinitionException($"The [{nameof(ClusterDefinition)}.{nameof(Datacenter)}={Datacenter}] property is not valid.  Only letters, numbers, periods, dashes, and underscores are allowed.");
            }

            var masterNodeCount = Masters.Count();

            if (masterNodeCount == 0)
            {
                throw new ClusterDefinitionException("Clusters must have at least one master node.");
            }
            else if (masterNodeCount > 5)
            {
                throw new ClusterDefinitionException("Clusters may not have more than [5] master nodes.");
            }
            else if (!NeonHelper.IsOdd(masterNodeCount))
            {
                throw new ClusterDefinitionException($"[{masterNodeCount}] master nodes is not allowed.  Only an off number of master nodes is allowed: [1, 3, or 5]");
            }

            if (!string.IsNullOrEmpty(PackageProxy))
            {
                // Ensure that this is set to zero or more network endpoints
                // formatted like:
                //
                //      HOSTNAME:PORT
                //      ADDRESS:PORT

                foreach (var endpoint in PackageProxy.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var fields = endpoint.Split(':');

                    if (!IPAddress.TryParse(fields[0], out var address) && !NetHelper.IsValidHost(fields[0]))
                    {
                        throw new ClusterDefinitionException($"Invalid IP address or HOSTNAME [{fields[0]}] in [{nameof(ClusterDefinition)}.{nameof(PackageProxy)}={PackageProxy}].");
                    }

                    if (!int.TryParse(fields[1], out var port) || !NetHelper.IsValidPort(port))
                    {
                        throw new ClusterDefinitionException($"Invalid port [{fields[1]}] in [{nameof(ClusterDefinition)}.{nameof(PackageProxy)}={PackageProxy}].");
                    }
                }
            }

            // Ensure that each node has a valid unique or NULL IP address.

            NetworkCidr nodesSubnet = null;

            if (Network.NodeSubnet != null)
            {
                nodesSubnet = NetworkCidr.Parse(Network.NodeSubnet);
            }

            var addressToNode = new Dictionary <string, NodeDefinition>();

            foreach (var node in SortedNodes)
            {
                if (node.PrivateAddress != null)
                {
                    NodeDefinition conflictNode;

                    if (addressToNode.TryGetValue(node.PrivateAddress, out conflictNode))
                    {
                        throw new ClusterDefinitionException($"Node [name={node.Name}] has invalid private IP address [{node.PrivateAddress}] that conflicts with node [name={conflictNode.Name}].");
                    }
                }
            }

            foreach (var node in SortedNodes)
            {
                if (node.PrivateAddress != null)
                {
                    if (!IPAddress.TryParse(node.PrivateAddress, out var address))
                    {
                        throw new ClusterDefinitionException($"Node [name={node.Name}] has invalid private IP address [{node.PrivateAddress}].");
                    }

                    if (nodesSubnet != null && !nodesSubnet.Contains(address))
                    {
                        throw new ClusterDefinitionException($"Node [name={node.Name}] has private IP address [{node.PrivateAddress}] that is not within the hosting [{nameof(Network.NodeSubnet)}={Network.NodeSubnet}].");
                    }
                }
                else if (!Hosting.IsCloudProvider)
                {
                    throw new ClusterDefinitionException($"Node [name={node.Name}] is not assigned a private IP address.  This is required when deploying to a [{nameof(Environment)}={Environment}] hosting environment.");
                }
            }
        }
示例#22
0
    /// <summary>
    /// 重置所有动画状态
    /// </summary>
    private void ResetAnimators(Animator selected, HotkeyPhase phase, bool forceUpdate = false)
    {
        if (forceUpdate || m_CurrentButton != selected)
        {
            m_CurrentButton = selected;

            m_ButtonL.ResetTrigger("Normal");
            m_ButtonL.ResetTrigger("IsOn");
            m_ButtonL.ResetTrigger("Disabled");

            m_ButtonB.ResetTrigger("Normal");
            m_ButtonB.ResetTrigger("IsOn");
            m_ButtonB.ResetTrigger("Disabled");

            m_ButtonR.ResetTrigger("Normal");
            m_ButtonR.ResetTrigger("IsOn");
            m_ButtonR.ResetTrigger("Disabled");

            m_ButtonT.ResetTrigger("Normal");
            m_ButtonT.ResetTrigger("IsOn");
            m_ButtonT.ResetTrigger("Disabled");

            PackageProxy proxy = Facade.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

            long countL = proxy.GetItemCountByTID(ITEM_L);
            long countB = proxy.GetItemCountByTID(ITEM_B);
            long countR = proxy.GetItemCountByTID(ITEM_R);
            long countT = proxy.GetItemCountByTID(ITEM_T);

            if (m_CurrentButton == m_ButtonL && countL <= 0)
            {
                return;
            }
            if (m_CurrentButton == m_ButtonT && countT <= 0)
            {
                return;
            }
            if (m_CurrentButton == m_ButtonR && countR <= 0)
            {
                return;
            }
            if (m_CurrentButton == m_ButtonB && countB <= 0)
            {
                return;
            }

            m_ButtonL.SetTrigger(m_CurrentButton == m_ButtonL && countL > 0 ? "IsOn" : (m_CurrentButton == null && countL > 0 ? "Normal" : "Disabled"));
            m_ButtonT.SetTrigger(m_CurrentButton == m_ButtonT && countT > 0 ? "IsOn" : (m_CurrentButton == null && countT > 0 ? "Normal" : "Disabled"));
            m_ButtonR.SetTrigger(m_CurrentButton == m_ButtonR && countR > 0 ? "IsOn" : (m_CurrentButton == null && countR > 0 ? "Normal" : "Disabled"));
            m_ButtonB.SetTrigger(m_CurrentButton == m_ButtonB && countB > 0 ? "IsOn" : (m_CurrentButton == null && countB > 0 ? "Normal" : "Disabled"));

            m_LabelL.text = countL.ToString();
            m_LabelB.text = countB.ToString();
            m_LabelR.text = countR.ToString();
            m_LabelT.text = countT.ToString();

            if (phase == HotkeyPhase.Performed)
            {
                //AnimationRoot("FinishAndClose");
            }
        }
    }
示例#23
0
    /// <summary>
    /// 布局蓝图的材料部分
    /// </summary>
    /// <param name="tid">蓝图的TID</param>
    /// <param name="materialNode">材料节点</param>

    private void LayoutBlueprintMaterial(uint tid, Transform materialNode)
    {
        CfgEternityProxy cfg  = GetConfig();
        PackageProxy     pack = GetPackage();

        Produce produce = cfg.GetProduceByKey(tid);

        Transform materialList      = FindComponent <Transform>(materialNode, "Resources");
        TMP_Text  materialTimeField = FindComponent <TMP_Text>(materialNode, "Label_Time");

        materialTimeField.text = TableUtil.GetLanguageString("production_text_1024") + TimeUtil.GetTimeStr(produce.Time);

        int index         = 0;
        int currencyIndex = 0;
        List <EffectElement?> sortedElements = new List <EffectElement?>();

        if (produce.Cost > 0)
        {
            EffectElement?[] elements = cfg.GetEffectElementsByKey((uint)produce.Cost);
            if (elements.Length > 0)
            {
                for (int i = 0; i < elements.Length; i++)
                {
                    EffectElement?element = elements[i];
                    Item          item    = cfg.GetItemByKey((uint)element.Value.ItemId);

                    if (ItemTypeUtil.GetItemType(item.Type).MainType == Category.Currency)
                    {
                        sortedElements.Insert(currencyIndex, element);
                        currencyIndex++;
                    }
                    else
                    {
                        sortedElements.Add(element);
                    }
                }
            }

            for (; index < sortedElements.Count; index++)
            {
                EffectElement?element = sortedElements[index];
                Item          item    = cfg.GetItemByKey((uint)element.Value.ItemId);

                Transform node    = index < materialList.childCount ? materialList.GetChild(index) : UnityEngine.Object.Instantiate(materialList.GetChild(0), materialList);
                Image     icon    = FindComponent <Image>(node, "Icon/Icon");
                Image     quality = FindComponent <Image>(node, "Icon/Quality");
                TMP_Text  name    = FindComponent <TMP_Text>(node, "Label_Name");
                TMP_Text  count   = FindComponent <TMP_Text>(node, "Label_Num");

                node.gameObject.SetActive(true);
                UIUtil.SetIconImageSquare(icon, item.Icon);

                long haveCount = pack.GetItemCountByTID((uint)element.Value.ItemId);
                long needCount = (long)element.Value.Value;

                quality.color = ColorUtil.GetColorByItemQuality(item.Quality);
                name.text     = TableUtil.GetItemName(element.Value.ItemId);
                if (haveCount < needCount)
                {
                    count.text = string.Format("<color=#ff0000>{0}</color>/{1}", haveCount, needCount);
                }
                else
                {
                    count.text = string.Format("<color=#00ff00>{0}</color>/{1}", haveCount, needCount);
                }
            }
        }
        for (; index < materialList.childCount; index++)
        {
            materialList.GetChild(index).gameObject.SetActive(false);
        }
    }
示例#24
0
    protected override void OnViewPartLoaded()
    {
        base.OnViewPartLoaded();
        m_UIScrollRect = FindComponent <UIScrollRect>("Content/Scroller");
        m_UIScrollRect.SetSelection(new Vector2Int(0, 0));
        ClearData();
        m_Items = new List <ItemBase>();
        switch (Parent.Data.State)
        {
        case WarshipPanelState.ListWeapon:
            m_Category        = Category.Weapon;
            m_CurrentItemData = Parent.Data.CurrentWeaponData.Data;
            m_ContainerUID    = Parent.Data.CurrentWeaponData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentWeaponData.ContainerPOS;
            break;

        case WarshipPanelState.ListReformer:
            m_Category        = Category.Reformer;
            m_CurrentItemData = Parent.Data.CurrentReformerData.Data;
            m_ContainerUID    = Parent.Data.CurrentReformerData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentReformerData.ContainerPOS;
            break;

        case WarshipPanelState.ListEquip:
            m_Category        = Category.Equipment;
            m_CurrentItemData = Parent.Data.CurrentEquipmentData.Data;
            m_ContainerUID    = Parent.Data.CurrentEquipmentData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentEquipmentData.ContainerPOS;
            break;

        case WarshipPanelState.ListMod:
            m_Category                  = Category.EquipmentMod;
            m_CurrentWeapon             = Parent.Data.CurrentWeaponData.Data;
            m_CurrentWeaponContainerUID = Parent.Data.CurrentWeaponData.ContainerUID;
            m_CurrentWeaponContainerPOS = Parent.Data.CurrentWeaponData.ContainerPOS;
            m_CurrentItemData           = Parent.Data.CurrentModData.Data;
            m_ContainerUID              = Parent.Data.CurrentModData.ContainerUID;
            m_ContainerPOS              = Parent.Data.CurrentModData.ContainerPOS;
            if (Parent.Data.BeforeState == WarshipPanelState.ModMainShip)
            {
                SendViewerChange(Parent.Data.CurrentShip.GetTID(), true);
            }
            else
            {
                SendViewerChange(m_CurrentWeapon.GetTID(), false);
            }
            break;
        }

        m_ItemsDic = PackageProxy.GetPackage(m_Category).Items;
        if (m_ItemsDic != null && m_ItemsDic.Count > 0)
        {
            foreach (var item in m_ItemsDic)
            {
                switch (m_Category)
                {
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.FightWarship && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting:
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.MiningShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Mining:
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.SurveillanceShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Treasure:
                case Category.Weapon when m_ContainerPOS != 0 && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting:
                case Category.Reformer:
                case Category.Equipment when(item.Value as ItemEquipmentVO).EquipmentType == (EquipmentL1)(m_ContainerPOS + 1):
                case Category.EquipmentMod when(item.Value as ItemModVO).ModType1 == Parent.Data.CurrentModData.ModType1 && (item.Value as ItemModVO).ModType2 == Parent.Data.CurrentModData.ModType2:
                    m_Items.Add(item.Value);

                    break;
                }
            }
        }
        AddDatas(null, m_Items.ToArray());
        ShowCharacter();
    }
示例#25
0
        public void Validate()
        {
            Provisioner = Provisioner ?? defaultProvisioner;
            DrivePrefix = DrivePrefix ?? defaultDrivePrefix;
            Setup       = Setup ?? new SetupOptions();
            Hosting     = Hosting ?? new HostingOptions();
            Vpn         = Vpn ?? new VpnOptions();
            HiveNode    = HiveNode ?? new HiveNodeOptions();
            Docker      = Docker ?? new DockerOptions();
            Image       = Image ?? new ImageOptions();
            Network     = Network ?? new NetworkOptions();
            Consul      = Consul ?? new ConsulOptions();
            Vault       = Vault ?? new VaultOptions();
            Log         = Log ?? new LogOptions();
            Dashboard   = Dashboard ?? new DashboardOptions();
            HiveFS      = HiveFS ?? new HiveFSOptions();
            Proxy       = Proxy ?? new ProxyOptions();
            HiveMQ      = HiveMQ ?? new HiveMQOptions();

            Setup.Validate(this);
            Network.Validate(this);
            Hosting.Validate(this);
            Vpn.Validate(this);
            HiveNode.Validate(this);
            Docker.Validate(this);
            Image.Validate(this);
            Consul.Validate(this);
            Vault.Validate(this);
            Log.Validate(this);
            Dashboard.Validate(this);
            HiveFS.Validate(this);
            Proxy.Validate(this);
            HiveMQ.Validate(this);

            new HostingManagerFactory().Validate(this);

            if (TimeSources == null || TimeSources.Length == 0 || TimeSources.Count(ts => string.IsNullOrWhiteSpace(ts)) > 0)
            {
                TimeSources = new string[] { "pool.ntp.org" };
            }

            if (NodeDefinitions == null || NodeDefinitions.Count == 0)
            {
                throw new HiveDefinitionException("At least one hive node must be defined.");
            }

            foreach (var node in NodeDefinitions.Values)
            {
                node.Validate(this);
            }

            if (Name == null)
            {
                throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(Name)}] property is required.");
            }

            if (!IsValidName(Name))
            {
                throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(Name)}={Name}] property is not valid.  Only letters, numbers, periods, dashes, and underscores are allowed.");
            }

            if (Datacenter == null)
            {
                throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(Datacenter)}] property is required.");
            }

            if (!IsValidName(Datacenter))
            {
                throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(Datacenter)}={Datacenter}] property is not valid.  Only letters, numbers, periods, dashes, and underscores are allowed.");
            }

            if (!string.IsNullOrEmpty(PackageProxy))
            {
                var packageCacheUris = PackageProxy.Split(',');

                for (int i = 0; i < packageCacheUris.Length; i++)
                {
                    packageCacheUris[i] = packageCacheUris[i].Trim();

                    if (!Uri.TryCreate(packageCacheUris[i], UriKind.Absolute, out var aptProxyUri))
                    {
                        throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(PackageProxy)}={PackageProxy}] includes [{packageCacheUris[i]}] which is not a valid URI.");
                    }

                    if (aptProxyUri.Scheme != "http")
                    {
                        throw new HiveDefinitionException($"The [{nameof(HiveDefinition)}.{nameof(PackageProxy)}={PackageProxy}] includes [{packageCacheUris[i]}] which does not have the [http] scheme.");
                    }
                }
            }

            var managementNodeCount = Managers.Count();

            if (managementNodeCount == 0)
            {
                throw new HiveDefinitionException("Hives must have at least one management node.");
            }
            else if (managementNodeCount > 5)
            {
                throw new HiveDefinitionException("Hives may not have more than [5] management nodes.");
            }
            else if (!NeonHelper.IsOdd(managementNodeCount))
            {
                throw new HiveDefinitionException("Hives must have an odd number of management nodes: [1, 3, or 5]");
            }

            // Ensure that each node has a valid unique or NULL IP address.

            NetworkCidr nodesSubnet   = null;
            NetworkCidr vpnPoolSubnet = null;

            if (Network.NodesSubnet != null)
            {
                nodesSubnet = NetworkCidr.Parse(Network.NodesSubnet);
            }

            if (Vpn.Enabled)
            {
                vpnPoolSubnet = NetworkCidr.Parse(Network.VpnPoolSubnet);
            }

            var addressToNode = new Dictionary <string, NodeDefinition>();

            foreach (var node in SortedNodes)
            {
                if (node.PrivateAddress != null)
                {
                    NodeDefinition conflictNode;

                    if (addressToNode.TryGetValue(node.PrivateAddress, out conflictNode))
                    {
                        throw new HiveDefinitionException($"Node [name={node.Name}] has invalid private IP address [{node.PrivateAddress}] that conflicts with node [name={conflictNode.Name}].");
                    }
                }
            }

            foreach (var node in SortedNodes)
            {
                if (node.PrivateAddress != null)
                {
                    if (!IPAddress.TryParse(node.PrivateAddress, out var address))
                    {
                        throw new HiveDefinitionException($"Node [name={node.Name}] has invalid private IP address [{node.PrivateAddress}].");
                    }

                    if (vpnPoolSubnet != null && vpnPoolSubnet.Contains(address))
                    {
                        throw new HiveDefinitionException($"Node [name={node.Name}] has private IP address [{node.PrivateAddress}] within the hosting [{nameof(Network.VpnPoolSubnet)}={Network.VpnPoolSubnet}].");
                    }

                    if (nodesSubnet != null && !nodesSubnet.Contains(address))
                    {
                        throw new HiveDefinitionException($"Node [name={node.Name}] has private IP address [{node.PrivateAddress}] that is not within the hosting [{nameof(Network.NodesSubnet)}={Network.NodesSubnet}].");
                    }
                }
                else if (!Hosting.IsCloudProvider)
                {
                    throw new HiveDefinitionException($"Node [name={node.Name}] is not assigned a private IP address.  This is required when deploying to a [{nameof(Environment)}={Environment}] hosting environment.");
                }
            }

            // Verify that we have nodes identified for persisting log data if logging is enabled.

            if (Log.Enabled)
            {
                if (Nodes.Where(n => n.Labels.LogEsData).Count() == 0)
                {
                    throw new HiveDefinitionException($"At least one node must be configured to store log data by setting [{nameof(NodeDefinition.Labels)}.{nameof(NodeLabels.LogEsData)}=true] when hive logging is enabled.");
                }
            }
        }
示例#26
0
    /// <summary>
    /// 更新数据
    /// </summary>
    private void UpdateData()
    {
        PackageProxy packageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;

        ClearData();

        UIViewCategory category = State.GetPageCategoryData();

        if (category.ItemType != null)
        {
            if (category.IsAll)
            {
                UIViewPage page = State.GetPage();

                for (int i = 0; i < page.Categorys.Length; i++)
                {
                    if (page.Categorys[i].IsAll)
                    {
                        continue;
                    }

                    category = page.Categorys[i];

                    m_ItemBaseCache.Clear();
                    for (int j = 0; j < category.ItemType.Length; j++)
                    {
                        ItemType itemType = category.ItemType[j];
                        if (itemType == null)
                        {
                            continue;
                        }

                        m_ItemBaseCache.AddRange(packageProxy.FindItemArrayByItemType(itemType, true));
                    }

                    AddDatas(category.Label, m_ItemBaseCache.ToArray());

                    m_ItemBaseCache.Clear();
                }
            }
            else
            {
                m_ItemBaseCache.Clear();

                for (int i = 0; i < category.ItemType.Length; i++)
                {
                    ItemType itemType = category.ItemType[i];
                    if (itemType == null)
                    {
                        continue;
                    }

                    m_ItemBaseCache.AddRange(packageProxy.FindItemArrayByItemType(itemType, true));
                }

                AddDatas(category.Label, m_ItemBaseCache.ToArray());

                m_ItemBaseCache.Clear();
            }
        }

        UpdatePackSize();
    }
示例#27
0
    public override void OnShow(object msg)
    {
        base.OnShow(msg);

        LoadViewPart(ASSET_ADDRESS, OwnerView.ListBox);
        OwnerView.PageBox.gameObject.SetActive(false);
        m_WarshipDialogPanel             = OwnerView as WarshipDialogPanel;
        m_BeforeToggle                   = m_WarshipDialogPanel.BeforeToggle;
        m_CfgEternityProxy               = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        m_ShipProxy                      = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        m_PackageProxy                   = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        m_ServerListProxy                = GameFacade.Instance.RetrieveProxy(ProxyName.ServerListProxy) as ServerListProxy;
        m_SceneShipProxy                 = GameFacade.Instance.RetrieveProxy(ProxyName.SceneShipProxy) as SceneShipProxy;
        m_WarshipDialogPanel.AppointShip = m_ShipProxy.GetAppointWarShip();

        if (m_WarshipDialogPanel.LastShip != null)
        {
            if (m_ShipProxy.GetAppointWarShip().GetTID() != m_WarshipDialogPanel.LastShip.GetTID())
            {
                m_SceneShipProxy.HideShip();
                m_SceneShipProxy.ShowShip();
            }
        }
        m_WarshipDialogPanel.LastShip = m_ShipProxy.GetAppointWarShip();
        if (msg != null)
        {
            m_CurrentShip = msg as IShip;
        }
        else
        {
            m_CurrentShip = m_ShipProxy.GetAppointWarShip();
        }
        m_ShowAppiontIcon = true;
        if (m_WarshipDialogPanel.AppointShip.GetTID() != m_CurrentShip.GetTID())
        {
            m_ShowAppiontIcon = false;
        }
        if (m_CurrentShip == null)
        {
            return;
        }
        if (m_CurrentShip == null)
        {
            Debug.Log("没有战船");
            return;
        }

        m_Weapons = new IWeapon[m_CurrentShip.GetWeaponContainer().GetCurrentSizeMax()];
        IWeapon[] tempWeapons = m_CurrentShip.GetWeaponContainer().GetWeapons();
        if (tempWeapons != null)
        {
            for (int i = 0; i < tempWeapons.Length; i++)
            {
                m_Weapons[tempWeapons[i].GetPos()] = tempWeapons[i];
            }
            tempWeapons = null;
        }

        m_Equipment = new IEquipment[m_CurrentShip.GetEquipmentContainer().GetCurrentSizeMax()];
        IEquipment[] tempEquips = m_CurrentShip.GetEquipmentContainer().GetEquipments();
        if (tempEquips != null)
        {
            for (int i = 0; i < tempEquips.Length; i++)
            {
                m_Equipment[tempEquips[i].GetPos()] = tempEquips[i];
            }
            tempEquips = null;
        }

        m_Reformer = m_CurrentShip.GetReformerContainer().GetReformer();
    }
示例#28
0
        /// <summary>
        /// Gets the package lst.
        /// </summary>
        /// <returns>The package lst.</returns>
        /// <param name="rq">Rq.</param>
        //取得套餐列表
        public static PackageModel GetPkgLst(QueryProductModel rq)
        {
            PackageModel          pkg    = new PackageModel();
            List <PkgDetailModel> pkgLst = new List <PkgDetailModel>();

            DataModel.Discount.DiscountRuleModel disc = null;
            PkgPriceModel pkg_price = new PkgPriceModel();

            try {
                //商品黑名單過濾
                //抓商品是否為黑名單
                bool isBlack = DiscountRepository.GetProdBlackWhite(rq.prod_no);

                if (isBlack)
                {
                    pkg.result     = "10";
                    pkg.result_msg = $"Bad Request:Product-{rq.prod_no} is not available";
                    return(pkg);
                }


                JObject obj     = PackageProxy.getPkgLst(rq);
                JObject objProd = ProdProxy.getProd(rq);

                if (obj["content"]["result"].ToString() != "0000")
                {
                    pkg.result     = obj["content"]["result"].ToString();
                    pkg.result_msg = $"kkday package api response msg is not correct! {obj["content"]["msg"].ToString()}";
                    throw new Exception($"kkday package api response msg is not correct! {obj["content"]["msg"].ToString()}");
                }

                if (objProd["content"]["result"].ToString() != "0000")
                {
                    pkg.result     = obj["content"]["result"].ToString();
                    pkg.result_msg = $"kkday product api response msg is not correct! {objProd["content"]["msg"].ToString()}";
                    throw new Exception($"kkday product api response msg is not correct! {objProd["content"]["msg"].ToString()}");
                }

                #region --1.取回傳資料是否成功的訊息、一般資訊--

                pkg.result         = obj["content"]["result"].ToString();
                pkg.result_msg     = obj["content"]["msg"].ToString();
                pkg.cost_calc_type = obj["content"]["costCalcMethod"].ToString();

                #endregion

                #region --2.從傑森物件取『套餐列表』--
                JArray jPkglst = (JArray)obj["content"]["packageList"];

                pkg_price.pkgs     = new List <pkgs>(); // 初始化陣列
                pkg_price.currency = rq.current_currency;

                for (int i = 0; i < jPkglst.Count; i++)
                {
                    var model       = new PkgDetailModel();
                    var price_model = new pkgs(); // pkg_price 用

                    model.pkg_no        = jPkglst[i]["productPkg"]["pkgOid"].ToString();
                    model.pkg_name      = jPkglst[i]["productPkg"]["pkgName"].ToString();
                    model.online_s_date = jPkglst[i]["productPkg"]["begValidDt"].ToString();
                    model.online_e_date = jPkglst[i]["productPkg"]["endValidDt"].ToString();
                    model.weekDays      = jPkglst[i]["productPkg"]["weekDays"].ToString();

                    model.is_unit_pirce = jPkglst[i]["productPkg"]["priceType"].ToString();

                    model.price1             = DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price1"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price1_org         = (double?)jPkglst[i]["productPkg"]["price1Org"] ?? 0;
                    model.price1_org_net     = (double?)jPkglst[i]["productPkg"]["price1NetOrg"] ?? 0;
                    model.price1_profit_rate = (double?)jPkglst[i]["productPkg"]["price1GrossRate"] ?? 0;
                    model.price1_comm_rate   = (double?)jPkglst[i]["productPkg"]["price1CommRate"] ?? 0;
                    model.price1_age_range   = jPkglst[i]["productPkg"]["price1BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price1EndOld"].ToString();
                    model.price1_b2c = (double?)jPkglst[i]["productPkg"]["price1Sale"] ?? 0;
                    // model.price1_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price1_list = (double)jPkglst[i]["productPkg"][""];

                    model.price2             = (double?)jPkglst[i]["productPkg"]["price2"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price2"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price2_org         = (double?)jPkglst[i]["productPkg"]["price2Org"] ?? 0;
                    model.price2_org_net     = (double?)jPkglst[i]["productPkg"]["price2NetOrg"] ?? 0;
                    model.price2_profit_rate = (double?)jPkglst[i]["productPkg"]["price2GrossRate"] ?? 0;
                    model.price2_comm_rate   = (double?)jPkglst[i]["productPkg"]["price2CommRate"] ?? 0;
                    model.price2_age_range   = jPkglst[i]["productPkg"]["price2BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price2EndOld"].ToString();
                    model.price2_b2c = (double?)jPkglst[i]["productPkg"]["price2Sale"] ?? 0;
                    // model.price2_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price2_list = (double)jPkglst[i]["productPkg"][""];

                    model.price3             = (double?)jPkglst[i]["productPkg"]["price3"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price3"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price3_org         = (double?)jPkglst[i]["productPkg"]["price3Org"] ?? 0;
                    model.price3_org_net     = (double?)jPkglst[i]["productPkg"]["price3NetOrg"] ?? 0;
                    model.price3_profit_rate = (double?)jPkglst[i]["productPkg"]["price3GrossRate"] ?? 0;
                    model.price3_comm_rate   = (double?)jPkglst[i]["productPkg"]["price3CommRate"] ?? 0;
                    model.price3_age_range   = jPkglst[i]["productPkg"]["price3BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price3EndOld"].ToString();
                    model.price3_b2c = (double?)jPkglst[i]["productPkg"]["price3Sale"] ?? 0;
                    // model.price3_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price3_list = (double)jPkglst[i]["productPkg"][""];

                    model.price4             = (double?)jPkglst[i]["productPkg"]["price4"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price4"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price4_org         = (double?)jPkglst[i]["productPkg"]["price4Org"] ?? 0;
                    model.price4_org_net     = (double?)jPkglst[i]["productPkg"]["price4NetOrg"] ?? 0;
                    model.price4_profit_rate = (double?)jPkglst[i]["productPkg"]["price4GrossRate"] ?? 0;
                    model.price4_comm_rate   = (double?)jPkglst[i]["productPkg"]["price4CommRate"] ?? 0;
                    model.price4_age_range   = jPkglst[i]["productPkg"]["price4BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price4EndOld"].ToString();
                    model.price4_b2c = (double?)jPkglst[i]["productPkg"]["price4Sale"] ?? 0;
                    // model.price4_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price4_list = (double)jPkglst[i]["productPkg"][""];

                    model.status = jPkglst[i]["productPkg"]["status"].ToString();
                    model.norank_min_book_qty = (int)jPkglst[i]["productPkg"]["minOrderNum"];
                    model.norank_max_book_qty = (int)jPkglst[i]["productPkg"]["maxOrderNum"];
                    model.rank_min_book_qty   = (int)jPkglst[i]["productPkg"]["minOrderQty"];
                    model.min_orverage_qty    = (int)jPkglst[i]["productPkg"]["minOrderAdultQty"];
                    model.isMultiple          = jPkglst[i]["productPkg"]["isMultiple"].ToString();
                    model.book_qty            = jPkglst[i]["productPkg"]["orderQty"].ToString();
                    model.unit = jPkglst[i]["productPkg"]["unit"].ToString();

                    model.unit_txt    = jPkglst[i]["productPkg"]["unitTxt"].ToString();
                    model.unit_qty    = (int)jPkglst[i]["productPkg"]["unitQty"];
                    model.pickupTp    = jPkglst[i]["productPkg"]["pickupTp"].ToString();
                    model.pickupTpTxt = jPkglst[i]["productPkg"]["pickupTpTxt"].ToString();
                    model.is_hl       = jPkglst[i]["productPkg"]["isBackUp"].ToString();
                    model.is_event    = jPkglst[i]["productPkg"]["hasEvent"].ToString();

                    var d = jPkglst[i]["productPkg"]["pkgDesc"];
                    if (d.FirstOrDefault() != null)
                    {
                        //取各套餐內的各個敘述
                        List <DescItem> desc = (d["descItems"][0]["content"])
                                               .Select(x => new DescItem {
                            id   = (string)x["id"],
                            desc = (string)x["desc"]
                        }).ToList();
                        model.desc_items = desc;
                    }

                    //組moduleSetting
                    var moduleSet = jPkglst[i]["productPkg"]["moduleSetting"];

                    if (moduleSet.FirstOrDefault() != null)
                    {
                        FlightInfoType fit = new FlightInfoType()
                        {
                            value =
                                moduleSet["flightInfoType"]["value"].ToString()
                        };

                        SendInfoType sit = new SendInfoType()
                        {
                            value =
                                moduleSet["sendInfoType"]["value"].ToString(),
                            country_code =
                                moduleSet["sendInfoType"]["countryCode"].ToString()
                        };

                        VoucherValidInfo vi = new VoucherValidInfo();

                        if (moduleSet["voucherValidInfo"] != null && moduleSet["voucherValidInfo"].Any())
                        {
                            vi.valid_period_type =
                                moduleSet["voucherValidInfo"]["validPeriodType"].ToString();

                            vi.before_specific_date =
                                moduleSet["voucherValidInfo"]["beforeSpecificDate"].ToString();

                            if (moduleSet["voucherValidInfo"]["afterOrderDate"] != null && moduleSet["voucherValidInfo"]["afterOrderDate"].Any())
                            {
                                AfterOrderDate aod = new AfterOrderDate()
                                {
                                    qty  = (int?)moduleSet["voucherValidInfo"]["afterOrderDate"]["qty"],
                                    unit = moduleSet["voucherValidInfo"]["afterOrderDate"]["unit"].ToString()
                                };

                                vi.after_order_date = aod;
                            }
                        }

                        ModuleSetting ms = new ModuleSetting()
                        {
                            flight_info_type   = fit,
                            send_info_type     = sit,
                            voucher_valid_info = vi
                        };

                        model.module_setting = ms;
                    }

                    pkgLst.Add(model);


                    price_model.pkg_no     = model.pkg_no;
                    price_model.price1     = model.price1;
                    price_model.price1_b2c = model.price1_b2c;
                    price_model.price2     = model.price2;
                    price_model.price2_b2c = model.price2_b2c;
                    price_model.price3     = model.price3;
                    price_model.price3_b2c = model.price3_b2c;
                    price_model.price4     = model.price4;
                    price_model.price4_b2c = model.price4_b2c;
                    pkg_price.pkgs.Add(price_model);
                }

                pkg.pkgs          = pkgLst;
                pkg.discount_rule = disc;
                pkg.guid          = Guid.NewGuid().ToString();
                rds.SetProdInfotoRedis(JsonConvert.SerializeObject(pkg_price), "b2d:pkgsPrice:" + pkg.guid, 1440); // 將 pkg_price 存入redis

                //依套餐取回『可售日期』
                pkg.sale_dates = (PkgSaleDateModel)GetPkgSaleDate(rq);;

                #endregion
            } catch (Exception ex) {
                pkg.result     = "10001";
                pkg.result_msg = $"Package ERROR :{ex.Message},{ex.StackTrace}";
                Website.Instance.logger.FatalFormat($"Package ERROR :{ex.Message},{ex.StackTrace}");
            }

            return(pkg);
        }