コード例 #1
0
    public void POW_AddChargItem(int index, ItemObject item)
    {
        if (item == null)
        {
            return;
        }

        //´íÎó #7042 Crash bug
        if (null == PeCreature.Instance || null == PeCreature.Instance.mainPlayer)
        {
            return;
        }

        PlayerPackageCmpt packageCmpt = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

        if (null == packageCmpt || null == packageCmpt.package || !packageCmpt.package.HasItemObj(item))
        {
            return;
        }

        EquipmentCmpt equipCmpt = PeCreature.Instance.mainPlayer.GetCmpt <EquipmentCmpt>();

        if (null == equipCmpt || null == equipCmpt._ItemList || equipCmpt._ItemList.Contains(item))
        {
            return;
        }

        RPCServer(EPacketType.PT_CL_POW_AddChargItem, index, item.instanceId);
    }
コード例 #2
0
    void OnPlayerItemPackageEvent(object sender, PlayerPackageCmpt.GetItemEventArg e)
    {
//		ItemPackage.EventArg.Op type = e.;


        PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();

        if (pkg == null)
        {
            return;
        }

//		ItemObject io = e.itemObj;
//		if (io == null)
//			return;
        ItemProto item = ItemProto.Mgr.Instance.Get(e.protoId);

        if (item == null)
        {
            return;
        }

        //lz-2018.1.19 获取东西的时候显示背包数量
        string msg = string.Format("{0} X {1} ({2})", item.GetName(), e.count, pkg.GetItemCount(e.protoId));

        new PeTipMsg(msg, item.icon[0], PeTipMsg.EMsgLevel.Norm, PeTipMsg.EMsgType.Misc);
//		PeTipMsg tips = new PeTipMsg(msg, PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
    }
コード例 #3
0
    bool AddItemToPlayer(int id)
    {
        if (m_Datas.ContainsKey(id) &&
            null != MainPlayer.Instance.entity &&
            null != MainPlayer.Instance.entity.packageCmpt)
        {
            PlayerPackageCmpt playerPackage = MainPlayer.Instance.entity.packageCmpt as PlayerPackageCmpt;
            if (null != playerPackage && null != m_Datas[id].itemObj)
            {
                if (m_Datas[id].itemObj.protoData.maxStackNum > 1)
                {
                    if (playerPackage.Add(m_Datas[id].itemObj.protoId, m_Datas[id].itemObj.stackCount))
                    {
                        ItemMgr.Instance.DestroyItem(m_Datas[id].itemObj.instanceId);
                        return(true);
                    }
                }
                else
                {
                    if (playerPackage.Add(m_Datas[id].itemObj, true))
                    {
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
コード例 #4
0
    void UpdatePackageNum()
    {
        if (PeCreature.Instance.mainPlayer != null)
        {
            if (playerPackageCmpt == null || player == null || player != PeCreature.Instance.mainPlayer)
            {
                player            = PeCreature.Instance.mainPlayer;
                playerPackageCmpt = player.GetCmpt <PlayerPackageCmpt>();
            }
            //bool bEnough = true;

            foreach (CSUI_EXchangeItem item in m_EXchangeItem)
            {
                if (item.ProtoId > 0)
                {
                    item.PackageNum = playerPackageCmpt.package.GetCount(item.ProtoId);
                }
            }

            foreach (CSUI_GetItem item in m_GetItem)
            {
                if (item.ProtoId > 0)
                {
                    item.PackageNum = playerPackageCmpt.package.GetCount(item.ProtoId);
                }
            }
        }
    }
コード例 #5
0
    void BtnTakeAllOnClick()
    {
        if (m_RefNpc == null || mInteractionPackage1 == null)
        {
            return;
        }

        if (!m_RefNpc.IsRandomNpc)
        {
            return;
        }

        //lz-2016.09.2 以前没做网络模式
        if (PeGameMgr.IsMulti)
        {
            PlayerNetwork.mainPlayer.RequestGetAllItemFromNpc(m_RefNpc.NPC.Id, 0);
            return;
        }

        PlayerPackageCmpt package  = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
        List <ItemObject> itemList = mInteractionPackage1.ToList();

        if (package.CanAddItemList(itemList))
        {
            package.AddItemList(itemList);
            mInteractionPackage1.Clear();
        }
    }
コード例 #6
0
 void Start()
 {
     hcc      = HoloCameraControl.Instance;
     ppc      = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
     mItemPac = ppc.package._playerPak;
     //ppc.getItemEventor.Subscribe(OnItemAdd);
 }
コード例 #7
0
            public static bool RemoveFromPkg(this PeEntity entity, int prototypeId, int count)
            {
                PlayerPackageCmpt pkg = entity.GetCmpt <PlayerPackageCmpt>();

                if (null == pkg)
                {
                    return(false);
                }

                return(pkg.Destory(prototypeId, count));
            }
コード例 #8
0
            public static int GetCreationItemCount(this PeEntity entity, ECreation type)
            {
                PlayerPackageCmpt pkg = entity.GetCmpt <PlayerPackageCmpt>();

                if (null == pkg)
                {
                    return(0);
                }

                return(pkg.package.GetCreationCount(type));
            }
コード例 #9
0
            public static int GetPkgItemCount(this PeEntity entity, int prototypeId)
            {
                PlayerPackageCmpt pkg = entity.GetCmpt <PlayerPackageCmpt>();

                if (null == pkg)
                {
                    return(0);
                }

                return(pkg.package.GetCount(prototypeId));
            }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        if (m_Assembly == null)
        {
            return;
        }

        UpdateUpgradeTime();

        if (PeCreature.Instance.mainPlayer != null)
        {
            if (playerPackageCmpt == null || player == null || player != PeCreature.Instance.mainPlayer)
            {
                player            = PeCreature.Instance.mainPlayer;
                playerPackageCmpt = player.GetCmpt <PlayerPackageCmpt>();
            }
            bool bEnough = true;

            foreach (CSUI_MaterialGrid mg in m_MatGrids)
            {
                if (mg.ItemID > 0)
                {
                    mg.ItemNum = playerPackageCmpt.package.GetCount(mg.ItemID);
                    if (mg.ItemNum < mg.NeedCnt)
                    {
                        bEnough = false;
                        continue;
                    }
                }
            }

            if (bEnough && !m_Assembly.isUpgrading && !m_Assembly.isDeleting && m_Assembly.Level != m_Assembly.GetMaxLevel())
            {
                m_Upgrade.m_Button.isEnabled = true;
            }
            else
            {
                m_Upgrade.m_Button.isEnabled = false;
            }

            int level = m_Assembly.Level + 1;
            if (m_Assembly.Level == m_Assembly.GetMaxLevel())
            {
                m_Upgrade.m_LevelVal.text = "LV " + level.ToString() + " (MAX)";
            }
            else
            {
                m_Upgrade.m_LevelVal.text = "LV " + level.ToString();
            }
        }
    }
コード例 #11
0
    void OnEquipRightMouseClicked(Grid_N grid)
    {
        if (m_RefNpc == null)
        {
            return;
        }

        if (null == grid.ItemObj)
        {
            return;
        }

        if (GameConfig.IsMultiMode)
        {
            if (NpcEquipment.TryTakeOffEquipment(grid.ItemObj))
            {
                PlayerNetwork.mainPlayer.RequestNpcTakeOffEquip(m_RefNpc.Id, grid.ItemObj.instanceId, -1);
                //lz-2016.08.31 脱下装备成功播放音效
                GameUI.Instance.PlayTakeOffEquipAudio();
            }
        }
        else
        {
            PlayerPackageCmpt playerPackageCmpt = PeCreature.Instance.mainPlayer == null ? null : Pathea.PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
            //lz-2016.07.19 这里应该用添加和移除同步检测和操作的接口
            if (NpcEquipment.TakeOffEquipment(grid.ItemObj, true, playerPackageCmpt))
            {
                GameUI.Instance.mItemPackageCtrl.Show();
                if (GameUI.Instance.mItemPackageCtrl != null)
                {
                    GameUI.Instance.mItemPackageCtrl.ResetItem();
                }
                //lz-2016.08.31 脱下装备成功播放音效
                GameUI.Instance.PlayTakeOffEquipAudio();
            }
            else
            {
                //lz-2016.07.19 玩家包裹可以添加,说明在取下装备的时候失败了
                if (null == playerPackageCmpt || playerPackageCmpt.package.CanAdd(grid.ItemObj))
                {
                    //lz-2016.07.19 提示NPC正在使用此装备
                    CSUI_MainWndCtrl.ShowStatusBar(PELocalization.GetString(8000594));
                }
                else
                {
                    //lz-2016.07.19  提示玩家背包已经满了
                    CSUI_MainWndCtrl.ShowStatusBar(PELocalization.GetString(8000050).Replace("\\n", " "));
                }
            }
        }
    }
コード例 #12
0
ファイル: UIRevive.cs プロジェクト: jvdbout/planetexplorers
 public bool CanRevive()
 {
     if (playerPackage == null)
     {
         if (GameUI.Instance != null && GameUI.Instance.mMainPlayer != null)
         {
             playerPackage = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
         }
         if (playerPackage == null)
         {
             return(false);
         }
     }
     return(playerPackage.ContainsItem(mRevivePrtroId));
 }
コード例 #13
0
    public void OpenWnd(CSRepairObject repMachine)
    {
        Show();
        mRepairMachine = repMachine;
        mMachinePos    = repMachine.GetComponentInParent <PeEntity>().transform.position;

        if (null != PeCreature.Instance && null != PeCreature.Instance.mainPlayer)
        {
            m_PlayerPackageCmpt = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
        }

        if (Pathea.PeGameMgr.IsMulti)
        {
            _net = MapObjNetwork.GetNet(mRepairMachine.m_Entity.ID);
            if (_net != null)
            {
                Net.RequestItemList();
            }
            else
            {
                Debug.LogError("net id is error id = " + mRepairMachine.m_Entity.ID);
            }
            return;
        }
        if (mRepairMachine != null && mRepairMachine.m_Repair != null)
        {
            if (this.mRepairMachine.m_Repair.IsRepairingM)
            {
                if (this.mRepairMachine.m_Repair.onRepairedTimeUp == null)
                {
                    this.mRepairMachine.m_Repair.onRepairedTimeUp = this.RepairComplate;
                }
                if (!mRepairMachine.m_Repair.IsRunning)
                {
                    this.mRepairMachine.m_Repair.CounterToRunning();
                }
            }
            UpdateItem(mRepairMachine.m_Repair.m_Item);
        }
        else
        {
            //lz-2016.08.18 修理机里的东西为空的时候需要更新UI状态
            this.UpdateBtnState();
        }

        TutorialData.AddActiveTutorialID(8);
    }
コード例 #14
0
    public void OnRightMouseCliked_Equip(Grid_N grid)
    {
        if (null == equipmentCmpt)
        {
            return;
        }

        if (grid.ItemObj == null)
        {
            return;
        }

        if (PeGameMgr.IsMulti)
        {
            //lz-2016.10.31 错误 #5316 先尝试脱装备,可以脱的时候再脱,避免复制装备
            if (equipmentCmpt.TryTakeOffEquipment(grid.ItemObj))
            {
                PlayerNetwork.mainPlayer.RequestNpcTakeOffEquip(servant.Id, grid.ItemObj.instanceId, -1);
                //lz-2016.08.31 脱下装备成功播放音效
                GameUI.Instance.PlayTakeOffEquipAudio();
            }
        }
        else
        {
            PlayerPackageCmpt playerPackageCmpt = PeCreature.Instance.mainPlayer == null ? null : Pathea.PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
            if (equipmentCmpt.TakeOffEquipment(grid.ItemObj, true, playerPackageCmpt))
            {
                GameUI.Instance.mItemPackageCtrl.ResetItem();
                //lz-2016.08.30 脱下装备成功播放音效
                GameUI.Instance.PlayTakeOffEquipAudio();
            }
            else
            {
                //lz-2016.07.19 玩家包裹可以添加,说明在取下装备的时候失败了
                if (null == playerPackageCmpt || playerPackageCmpt.package.CanAdd(grid.ItemObj))
                {
                    //lz-2016.07.19 提示NPC正在使用此装备
                    MessageBox_N.ShowOkBox(PELocalization.GetString(8000594));
                }
                else
                {
                    //lz-2016.07.19  提示玩家背包已经满了
                    CSUI_MainWndCtrl.ShowStatusBar(PELocalization.GetString(8000050));
                }
            }
        }
    }
コード例 #15
0
    //log: lz-2016.05.19 是否有复活药
    public bool HasReviveMedicine()
    {
        if (this.m_PlayerPackage == null)
        {
            if (GameUI.Instance != null && GameUI.Instance.mMainPlayer != null)
            {
                this.m_PlayerPackage = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
            }
            if (this.m_PlayerPackage == null)
            {
                return(false);
            }
        }
        int itemCount = this.m_PlayerPackage.GetItemCount(m_RevivePrtroId);

        return(itemCount > 0);
    }
コード例 #16
0
 // Update is called once per frame
 void Update()
 {
     if (m_PPCoal == null)
     {
         return;
     }
     if (PeCreature.Instance.mainPlayer == null)
     {
         return;
     }
     if (playerPackageCmpt == null || player == null || player != PeCreature.Instance.mainPlayer)
     {
         player            = PeCreature.Instance.mainPlayer;
         playerPackageCmpt = player.GetCmpt <PlayerPackageCmpt>();
     }
     UpdateWorkingTime();
 }
コード例 #17
0
ファイル: UIRevive.cs プロジェクト: jvdbout/planetexplorers
    //float m_DelayTime = 100000.0f;
    //bool mStartReciprocal = false;

    public override void Show()
    {
        if (currentState == ReivieState.None)
        {
            Hide();
            return;
        }
        base.Show();

        playerPackage = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();

        mTsPlayer.gameObject.SetActive(currentState == ReivieState.Reivie_Player);
        mTsServant.gameObject.SetActive(currentState == ReivieState.Reivie_Servant);

        //mStartReciprocal = true;

        // m_DelayTime = 100000.0f;
    }
コード例 #18
0
    public override void Update()
    {
        base.Update();

        if (!_playerEventAdded)
        {
            if (PeCreature.Instance != null && PeCreature.Instance.mainPlayer != null)
            {
                PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
                if (pkg == null)
                {
                    return;
                }

                pkg.getItemEventor.Subscribe(OnPlayerItemPackageEvent);
                _playerEventAdded = true;
            }
        }
    }
コード例 #19
0
    private void TryExecAction()
    {
        if (null == _playerOperate || null == _monsterEntity)
        {
            return;
        }

        _rideTime = Time.realtimeSinceStartup;

        //lw:怪物血量高于50%不能乘骑
        if (_monsterEntity.HPPercent > 0.5f)
        {
            PeTipMsg.Register(PELocalization.GetString(LowHpTipsID), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }

        //lw:玩家有规定物品才能乘骑怪物
        PlayerPackageCmpt playerPackage = MainPlayer.Instance.entity.packageCmpt as PlayerPackageCmpt;

        ItemAsset.ItemObject item = playerPackage.package.FindItemByProtoId(RideItemID);
        if (item == null || MainPlayer.Instance.entity.UseItem.GetCdByItemProtoId(RideItemID) > PETools.PEMath.Epsilon)
        {
            PeTipMsg.Register(PELocalization.GetString(LackRideItemTipsID), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }

        //lz-2017.02.23 多人的时候先发消息请求控制权,请求回来再执行骑,避免坐骑系统Ai等运行不正常
        if (PeGameMgr.IsMulti)
        {
            //PlayerNetwork.RequestuseItem(item.instanceId);
            PlayerNetwork.RequestReqMonsterCtrl(_monsterEntity.Id);
        }
        else
        {
            if (ExecRide(Pathea.MainPlayer.Instance.entity))
            {
                //MainPlayer.Instance.entity.UseItem.Use(item);
                playerPackage.DestroyItem(item.instanceId, 1);
            }
        }
    }
コード例 #20
0
 void GetCutSlotList()
 {
     if (GameUI.Instance == null)
     {
         return;
     }
     if (GameUI.Instance.mMainPlayer == null)
     {
         return;
     }
     mPackageCmpt = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
     if (mPackageCmpt != null)
     {
         mCutSlotList = mPackageCmpt.shortCutSlotList;
         if (null != mCutSlotList)
         {
             mCutSlotList.onListUpdate += OnShortCutUpdate;
             OnShortCutUpdate();
         }
     }
 }
コード例 #21
0
    void OnAddFuelBtn()
    {
        //lz-2016.11.02 错误 #5426 空对象
        if (null == PeCreature.Instance || PeCreature.Instance.mainPlayer == null || null == m_PPCoal || null == m_Entity)
        {
            return;
        }

        if (!GameConfig.IsMultiMode)
        {
            PlayerPackageCmpt packageCmpt = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
            if (null == packageCmpt)
            {
                return;
            }
            ItemPackage accessor = packageCmpt.package._playerPak;
            if (null == accessor)
            {
                return;
            }

            foreach (CSUI_MaterialGrid mg in m_MatGrids)
            {
                if (null != mg && mg.ItemID != 0)
                {
                    accessor.Destroy(mg.ItemID, mg.NeedCnt);
                    CSUI_MainWndCtrl.CreatePopupHint(mg.transform.position, transform, new Vector3(10, -2, -5), " - " + mg.NeedCnt.ToString(), false);
                }
            }

            m_PPCoal.StartWorkingCounter();

            //		CSUI_Main.ShowStatusBar("The " +  m_Entity.Name +" is full with fuel now");
            CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mFullFuelTips.GetString(), m_Entity.Name));
        }
        else
        {
            m_PPCoal._ColonyObj._Network.PPC_AddFuel();
        }
    }
コード例 #22
0
    void BtnTakeAllOnClick()
    {
        if (servant == null)
        {
            return;
        }

        if (PeGameMgr.IsMulti)
        {
            PlayerNetwork.mainPlayer.RequestGetAllItemFromNpc(servant.Id, 0);
            return;
        }

        PlayerPackageCmpt package  = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
        List <ItemObject> itemList = mInteractionPackage.ToList();

        if (package.CanAddItemList(itemList))
        {
            package.AddItemList(itemList);
            mInteractionPackage.Clear();
        }
    }
コード例 #23
0
    void BtnTakeAllInventory2OnClick()
    {
        if (m_RefNpc == null || mInteractionPackage2 == null)
        {
            return;
        }

        if (PeGameMgr.IsMulti)
        {
            PlayerNetwork.mainPlayer.RequestGetAllItemFromNpc(m_RefNpc.NPC.Id, 1);
            return;
        }

        PlayerPackageCmpt package  = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();
        List <ItemObject> itemList = mInteractionPackage2.ToList();

        if (package.CanAddItemList(itemList))
        {
            package.AddItemList(itemList);
            mInteractionPackage2.Clear();
        }
    }
コード例 #24
0
    void StartToWork()
    {
        if (!GameConfig.IsMultiMode)
        {
            //lw:2017.4.6 crash PeCreature.Instance.mainPlayer可能为null
            if (PeCreature.Instance != null && PeCreature.Instance.mainPlayer != null)
            {
                PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.packageCmpt as PlayerPackageCmpt;
                if (pkg != null)
                {
                    ItemPackage accessor = pkg.package._playerPak;
                    if (m_CurType == CSConst.etEnhance)
                    {
                        //lw:2017.4.6 crash
                        if (m_Enhance != null && m_Enhance.m_Item != null && m_Enhance.m_Item.protoData != null)
                        {
                            // take out material from player
                            foreach (CSUI_MaterialGrid matGrid in m_MatList)
                            {
                                accessor.Destroy(matGrid.ItemID, matGrid.NeedCnt);
                            }

                            m_Enhance.StartCounter();

                            CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToEnhance.GetString(), m_Enhance.m_Item.protoData.GetName()));

                            // Popoup hints
                            foreach (CSUI_MaterialGrid mg in m_MatList)
                            {
                                Vector3 pos = mg.transform.position;
                                CSUI_MainWndCtrl.CreatePopupHint(pos, transform, new Vector3(10, -2, -8), " - " + mg.NeedCnt, false);
                            }
                        }
                    }
                    else if (m_CurType == CSConst.etRepair)
                    {
                        if (null != m_Repair && m_Repair.m_Item != null && m_Repair.m_Item.protoData != null)
                        {
                            // take out material from player
                            foreach (CSUI_MaterialGrid matGrid in m_MatList)
                            {
                                accessor.Destroy(matGrid.ItemID, matGrid.NeedCnt);
                            }

                            m_Repair.StartCounter();
                            CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToRepair.GetString(), m_Repair.m_Item.protoData.GetName()));
                        }
                    }
                    else if (m_CurType == CSConst.etRecyle)
                    {
                        if (m_Recycle != null && m_Recycle.m_Item != null && m_Recycle.m_Item.protoData != null)
                        {
                            m_Recycle.StartCounter();
                            CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToRecycle.GetString(), m_Recycle.m_Item.protoData.GetName()));
                        }
                    }
                }
            }
        }
        else
        {
            //multimode
            if (m_CurType == CSConst.etEnhance)
            {
                m_Enhance._ColonyObj._Network.EHN_Start();
            }
            else if (m_CurType == CSConst.etRepair)
            {
                m_Repair._ColonyObj._Network.RPA_Start();
            }
            else if (m_CurType == CSConst.etRecyle)
            {
                m_Recycle._ColonyObj._Network.RCY_Start();
            }
        }
    }
コード例 #25
0
    // Use this for initialization
    void Start()
    {
        m_MatItemList = new List <CSUI_MaterialGrid>();

        if (m_Entity == null)
        {
            return;
        }

        if (null != PeCreature.Instance && null != PeCreature.Instance.mainPlayer)
        {
            m_PlayerPackageCmpt = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
        }

        Tip = PELocalization.GetString(funcType == FuncType.Delete ? 82201081 : 82201082);

        //MergeSkill ms  = MergeSkill.s_tblMergeSkills.Find(
        //               delegate (MergeSkill hh)
        //                {
        //                    return hh.m_productItemId == m_Entity.ItemID;
        //                });

        Pathea.Replicator.Formula ms     = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_Entity.ItemID);
        List <MaterialItem>       miList = ItemProto.GetRepairMaterialList(m_Entity.ItemID);
        float percent = 0.0f;

        if (funcType == FuncType.Repair)
        {
            percent = (m_Entity.m_Info.m_Durability - m_Entity.BaseData.m_Durability) / m_Entity.m_Info.m_Durability;
        }
        else if (funcType == FuncType.Delete)
        {
            percent = m_Entity.BaseData.m_Durability / m_Entity.m_Info.m_Durability;
        }

        if (ms != null)
        {
            if (funcType == FuncType.Repair && miList != null && miList.Count > 0)
            {
                foreach (MaterialItem mi in miList)
                {
                    int count     = Mathf.CeilToInt(mi.count * percent);
                    int playerCnt = m_PlayerPackageCmpt.package.GetCount(mi.protoId);
                    CreateGrid(mi.protoId, playerCnt, count);
                    if (playerCnt < count && funcType == FuncType.Repair)
                    {
                        m_OkBtn.isEnabled = false;
                    }
                }
            }
            else
            {
                if (miList == null || miList.Count == 0)
                {
                    Debug.LogError("no ItemProto.repairMaterialList:" + m_Entity.ItemID);
                }
                List <Pathea.Replicator.Formula.Material> m_MSMIlist = ms.materials;

                foreach (Pathea.Replicator.Formula.Material msmi in m_MSMIlist)
                {
                    int count     = Mathf.CeilToInt(msmi.itemCount * percent);
                    int playerCnt = m_PlayerPackageCmpt.package.GetCount(msmi.itemId);
                    CreateGrid(msmi.itemId, playerCnt, count);
                    if (playerCnt < count && funcType == FuncType.Repair)
                    {
                        m_OkBtn.isEnabled = false;
                    }
                }

                m_MatGridRoot.repositionNow = true;
            }
        }
        else
        {
            for (int i = 0; i < m_DefItemCostsId.Length; i++)
            {
                int count     = Mathf.CeilToInt(m_DefItemCostsCnt[i] * percent);
                int playerCnt = m_PlayerPackageCmpt.package.GetCount(m_DefItemCostsId[i]);
                CreateGrid(m_DefItemCostsId[i], playerCnt, count);
                if (playerCnt < count && funcType == FuncType.Repair)
                {
                    m_OkBtn.isEnabled = false;
                }
            }

            m_MatGridRoot.repositionNow = true;
        }
    }
コード例 #26
0
    // Update is called once per frame
    void Update()
    {
        if (PeCreature.Instance.mainPlayer == null)
        {
            return;
        }
        if (playerPackageCmpt == null || player == null || player != PeCreature.Instance.mainPlayer)
        {
            player            = PeCreature.Instance.mainPlayer;
            playerPackageCmpt = player.GetCmpt <PlayerPackageCmpt>();
        }

        bool bEnoughMats = true;

        if (m_CurType != CSConst.etRecyle)
        {
            foreach (CSUI_MaterialGrid mg in m_MatList)
            {
                mg.ItemNum = playerPackageCmpt.package.GetCount(mg.ItemID);
                if (mg.ItemNum < mg.NeedCnt)
                {
                    bEnoughMats = false;
                }
            }
        }
        else
        {
            foreach (CSUI_MaterialGrid mg in m_MatList)
            {
                mg.ItemNum = 0;
            }
        }

        // Enable or Disable the Handle button
        if (m_CurType == CSConst.etEnhance)
        {
            if (m_Enhance.m_Item == null || !m_Enhance.IsRunning)
            {
                m_Handle.m_OKBtn.isEnabled    = false;
                m_Handle.m_ResetBtn.isEnabled = false;
            }
            else
            {
                if (!m_Enhance.isDeleting && !m_Enhance.IsEnhancing && bEnoughMats)
                {
                    m_Handle.m_OKBtn.isEnabled = true;
                }
                else
                {
                    m_Handle.m_OKBtn.isEnabled = false;
                }

                if (bEnoughMats)
                {
                    m_Handle.m_ResetBtn.isEnabled = !m_Handle.m_OKBtn.isEnabled;
                }
                else
                {
                    m_Handle.m_ResetBtn.isEnabled = false;
                }
            }
        }
        else if (m_CurType == CSConst.etRepair)
        {
            if (m_Repair.m_Item == null || !m_Repair.IsRunning || m_Repair.m_Item.GetValue().ExpendValue == 0f)
            {
                m_Handle.m_OKBtn.isEnabled    = false;
                m_Handle.m_ResetBtn.isEnabled = false;
            }
            else
            {
                if (m_Repair.m_Item != null && m_Repair.IsFull())
                {
                    m_Handle.m_OKBtn.isEnabled = false;
                }
                else if (!m_Repair.isDeleting && !m_Repair.IsRepairingM && bEnoughMats)
                {
                    m_Handle.m_OKBtn.isEnabled = true;
                }
                else
                {
                    m_Handle.m_OKBtn.isEnabled = false;
                }

                if (bEnoughMats)
                {
                    m_Handle.m_ResetBtn.isEnabled = !m_Handle.m_OKBtn.isEnabled;
                }
                else
                {
                    m_Handle.m_ResetBtn.isEnabled = false;
                }
            }
        }
        else if (m_CurType == CSConst.etRecyle)
        {
            if (m_Recycle.m_Item != null && !m_Recycle.isDeleting &&
                !m_Recycle.IsRecycling && m_Recycle.IsRunning)
            {
                m_Handle.m_OKBtn.isEnabled = true;
            }
            else
            {
                m_Handle.m_OKBtn.isEnabled = false;
            }

            if (m_Recycle.m_Item == null || !m_Recycle.IsRunning)
            {
                m_Handle.m_OKBtn.isEnabled    = false;
                m_Handle.m_ResetBtn.isEnabled = false;
            }
            else
            {
                if (!m_Recycle.isDeleting && !m_Recycle.IsRecycling)
                {
                    m_Handle.m_OKBtn.isEnabled = true;
                }
                else
                {
                    m_Handle.m_OKBtn.isEnabled = false;
                }

                m_Handle.m_ResetBtn.isEnabled = !m_Handle.m_OKBtn.isEnabled;
            }
        }
    }
コード例 #27
0
ファイル: UIShopWnd.cs プロジェクト: shrubba/planetexplorers
    public void Sell(Grid_N grid, int num)
    {
        //lz-2016.08.10 执行Sell的时候重置包裹当前的操作Item
        GameUI.Instance.mItemPackageCtrl.ResetCurOpItem();

        if (null == grid || null == grid.ItemObj)
        {
            Debug.LogError("Sell item is null");
            return;
        }

        int proid         = grid.ItemObj.protoId;
        int instanceid    = grid.ItemObj.instanceId;
        int maxStackCount = grid.ItemObj.GetStackMax();
        int cost          = grid.ItemObj.GetSellPrice();//(int)(grid.ItemObj.prototypeData.m_CurrencyValue * num * (0.8f * grid.ItemObj.Durability / grid.ItemObj.DurabilityMax + 0.2f));

        //        string itemname = grid.ItemObj.protoData.GetName();


        if (npc == null)
        {
            return;
        }

        NpcPackageCmpt npcpc = npc.GetCmpt <NpcPackageCmpt>();

        if (npcpc == null)
        {
            return;
        }

        cost *= num;

        if (cost > npcpc.money.current)
        {
            string         errInfo = "";
            EntityInfoCmpt cmpt    = npc.GetCmpt <EntityInfoCmpt>();
            if (cmpt != null)
            {
                string _name = "";
//                if (npc.entityProto.proto == EEntityProto.RandomNpc)
//                {
//                    _name = cmpt.characterName.fullName;
//                }
//                else if (npc.entityProto.proto == EEntityProto.Npc)
//                {
//                    _name = cmpt.characterName.givenName;
//                }
                _name = cmpt.characterName.fullName;
                //lz-2016.10.31 have no money to pay for you!
                errInfo = _name + " " + PELocalization.GetString(8000853);
            }
            else
            {
                //lz-2016.10.31 have no money to pay for you!
                errInfo = npc.name + " " + PELocalization.GetString(8000853);
            }
            new PeTipMsg(errInfo, PeTipMsg.EMsgLevel.Error);
            return;
        }

        //Add money to player
        if (PeGameMgr.IsMulti)
        {
            PlayerNetwork.mainPlayer.RequestSell(npc.Id, instanceid, num);
        }
        else
        {
            npcpc.money.current -= cost;


            ItemObject SellItemObj;
            if (maxStackCount == 1)
            {
                SellItemObj = grid.ItemObj;
            }
            else
            {
                SellItemObj = ItemMgr.Instance.CreateItem(proid);
            }
            PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();
            if (null == pkg)
            {
                return;
            }
            if (maxStackCount == 1)
            {
                pkg.Remove(SellItemObj);
            }
            else
            {
                pkg.DestroyItem(instanceid, num);
            }
            //if (grid.ItemObj.GetCount() > num)
            //{
            //    SellItemObj = ItemMgr.Instance.CreateItem(grid.ItemObj.protoId); // single
            //    SellItemObj.IncreaseStackCount(num);
            //    grid.ItemObj.DecreaseStackCount(num);
            //}
            //else
            //{
            //    SellItemObj = grid.ItemObj;
            //    PlayerFactory.mMainPlayer.GetItemPackage().RemoveItem(grid.ItemObj);
            //    GameUI.Instance.mUIItemPackageCtrl.ResetItem();
            //}
            //SellItemObj.SetProperty(ItemProperty.SellItemMark, 1f);
            AddRepurchase(SellItemObj, num);

            //            if (cost != 0 && !PeCreature.Instance.mainPlayer.AddToPkg(StroyManager.PRICE_ID, cost))
            //            {
            //                return;
            //            }

            pkg.money.current += cost;
            ResetItem();
        }


        //GameGui_N.Instance.mChatGUI.AddChat(PromptData.PromptType.PromptType_14, itemname, num, cost);

        mOpItem.SetItem(null);
        mOpGrid = null;
        mSellOpLayer.gameObject.SetActive(false);

        return;
    }
コード例 #28
0
ファイル: CSTrade.cs プロジェクト: shrubba/planetexplorers
    public void SellItem(int instanceId, int count)
    {
        ItemObject itemObj = ItemAsset.ItemMgr.Instance.Get(instanceId);

        if (itemObj == null)
        {
            Debug.LogError("Sell item is null");
            return;
        }

        if (count > itemObj.GetCount())
        {
            Debug.LogError("not enough count");
            return;
        }

        PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

        if (null == pkg)
        {
            return;
        }

        int protoId = itemObj.protoId;
        int cost    = itemObj.GetSellPrice() * count;

        if (colonyMoney < cost)
        {
            //lz-2016.10.31 The TradePost has no money to pay for you!
            new PeTipMsg(PELocalization.GetString(8000858), PeTipMsg.EMsgLevel.Error);
            return;
        }


        if (PeGameMgr.IsMulti)
        {
            _ColonyObj._Network.RPCServer(EPacketType.PT_CL_TRD_SellItem, instanceId, count);
            return;
        }
        else
        {
            colonyMoney -= cost;
            ItemObject SellItemObj;
            if (count == itemObj.stackCount)
            {
                SellItemObj = itemObj;
                pkg.Remove(itemObj);
            }
            else
            {
                SellItemObj = ItemMgr.Instance.CreateItem(protoId);
                SellItemObj.SetStackCount(count);
                pkg.DestroyItem(instanceId, count);
            }

            AddRepurchase(SellItemObj);
            pkg.money.current += cost;            //Add money to player
        }

        //--to do: updateUI
        UpdateRepurchaseDataToUI();
    }
コード例 #29
0
ファイル: CSTrade.cs プロジェクト: shrubba/planetexplorers
    public bool Buy(ItemObject itemObj, int count, ShopData data, bool isRepurchase)
    {
        int price;

        if (!isRepurchase)
        {
            price = Mathf.RoundToInt(data.m_Price * (1 + ColonyConst.TRADE_POST_CHARGE_RATE));
        }
        else
        {
            price = itemObj.GetSellPrice();
        }
        int cost = price * count;

        if (PlayerMoney.current < cost)
        {
            PeTipMsg.Register(PELocalization.GetString(Money.Digital? 8000092:8000073), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        ItemObject        addItem = null;
        PlayerPackageCmpt pkg     = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

        if (null == pkg)
        {
            PeTipMsg.Register(PELocalization.GetString(8000496), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        if (!pkg.package.CanAdd(itemObj.protoId, count))
        {
            PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning);
            return(false);
        }

        if (itemObj.protoData.maxStackNum == 1)
        {
            int NUM = count;
            for (int i = 0; i < NUM; i++)
            {
                count = 1;
                if (count < itemObj.GetCount())
                {
                    addItem = ItemMgr.Instance.CreateItem(itemObj.protoId);                     // single
                    addItem.SetStackCount(count);
                }
                else
                {
                    addItem = itemObj;
                    if (!isRepurchase)
                    {
                        mShopList[data.m_ID].ItemObjID = -1;
                    }
                }
                pkg.package.AddItem(addItem, !isRepurchase);
            }
            PlayerMoney.current -= cost;

            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }
        else
        {
            if (count == itemObj.GetCount())
            {
                if (!isRepurchase)
                {
                    mShopList[data.m_ID].ItemObjID = -1;
                }
            }
            pkg.package.Add(itemObj.protoId, count, !isRepurchase);
            PlayerMoney.current -= cost;
            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }

        return(true);
    }