コード例 #1
0
    /// <summary>
    /// initial the shortCut
    /// </summary>
    /// <param name="stream"></param>
    void RPC_S2C_InitShortcut(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        byte[] data = stream.Read <byte[]>();

        if (Equals(null, entity))
        {
            return;
        }

        Dictionary <int, int> shortcut = new Dictionary <int, int>();

        PETools.Serialize.Import(data, r =>
        {
            int count = BufferHelper.ReadInt32(r);
            for (int i = 0; i < count; i++)
            {
                int index       = BufferHelper.ReadInt32(r);
                int objId       = BufferHelper.ReadInt32(r);
                shortcut[index] = objId;
            }
        });

        Pathea.PlayerPackageCmpt cmpt = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null == cmpt)
        {
            return;
        }

        foreach (KeyValuePair <int, int> kv in shortcut)
        {
            ItemObject item = ItemMgr.Instance.Get(kv.Value);
            cmpt.shortCutSlotList.PutItemObj(item, kv.Key);
        }
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
#if PLANET_EXPLORERS
        ItemSample item = new ItemSample(m_GameItemId);
        if (item.protoData == null)
        {
            return;
        }

        m_IconSprite.spriteName = item.iconString0;

        //ItemAsset.ItemData item = ItemAsset.ItemData.s_tblItemData.Find(iter => iter.m_ID == m_GameItemId);
        //m_IconSprite.spriteName = item.m_Icon.Split(',')[0];
        m_NameLabel.text = VCUtils.Capital(item.nameText, true);
        //if ( PlayerFactory.mMainPlayer != null )
        if (PeCreature.Instance.mainPlayer != null)
        {
            if (VCEditor.Instance.m_CheatWhenMakeCreation)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Cheat".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else if (Pathea.PeGameMgr.IsSingleBuild)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Build".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else if (PeGameMgr.playerType == PeGameMgr.EPlayerType.Tutorial)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Tutorial".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else
            {
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                int have = pkg.package.GetCount(m_GameItemId);
                if (have >= m_GameItemCost)
                {
                    m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + have.ToString("#,##0").Trim() + "[-]";
                    m_IsEnough        = true;
                }
                else
                {
                    m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [FF0000]" + have.ToString("#,##0").Trim() + "[-]";
                    m_IsEnough        = false;
                }
            }
        }
        else
        {
            m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim();
            m_IsEnough        = false;
        }
#else
        m_IconSprite.spriteName = "";
        m_NameLabel.text        = m_GameItemId.ToString();
        m_CountLabel.text       = m_GameItemCost.ToString("# ##0");
        m_IsEnough = false;
#endif
    }
コード例 #3
0
 public void OnCleanBtn()
 {
     if (!GameConfig.IsMultiMode)
     {
         plant.UpdateStatus();
         int needNum = (int)((plant.mPlantInfo.mCleanLevel[1] - plant.mClean) / VarPerOp);
         Pathea.PlayerPackageCmpt packageCmpt = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
         int haveNum = packageCmpt.GetItemCount(ProtoTypeId.INSECTICIDE);
         if (haveNum <= 0)
         {
             MessageBox_N.ShowOkBox(PELocalization.GetString(8000091));
         }
         else
         {
             plant.mClean += VarPerOp * Mathf.Min(haveNum, needNum);
             packageCmpt.Destory(ProtoTypeId.INSECTICIDE, Mathf.Min(haveNum, needNum));
             plant.UpdateStatus();
         }
     }
     else
     {
         if (null != PlayerNetwork.mainPlayer)
         {
             PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_InGame_Plant_Clean, plant.mPlantInstanceId);
         }
     }
     HideItemOpGui();
     //UpdateCmdList();
 }
コード例 #4
0
    void RPC_S2C_MissionPackageIndex(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        byte[] data = stream.Read <byte[]>();

        if (Equals(null, entity))
        {
            return;
        }

        Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null == pkg)
        {
            return;
        }

        PETools.Serialize.Import(data, r =>
        {
            int count = BufferHelper.ReadInt32(r);
            for (int i = 0; i < count; i++)
            {
                int key   = BufferHelper.ReadInt32(r);
                int id    = BufferHelper.ReadInt32(r);
                int tab   = key >> 16;
                int index = key & 0x0000FFFF;

                pkg.package.ResetPackageItems(tab, index, id, true);
            }
        });

        if (IsOwner)
        {
            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }
    }
コード例 #5
0
ファイル: ItemBox.cs プロジェクト: shrubba/planetexplorers
 public void SendAllItemToPlayer()
 {
     if (GameConfig.IsMultiMode)
     {
         if (null != mNetWork)
         {
             mNetWork.GetAllItem();
         }
     }
     else
     {
         foreach (int itemObjID in mItemList)
         {
             ItemObject itemObj = ItemMgr.Instance.Get(itemObjID);
             //if(PlayerFactory.mMainPlayer.AddItem(itemObj))
             //    mItemList.Remove(itemObj.instanceId);
             //else
             //{
             //    ResetUI();
             //    break;
             //}
             if (null != Pathea.MainPlayerCmpt.gMainPlayer)
             {
                 Pathea.PlayerPackageCmpt pPC = Pathea.MainPlayerCmpt.gMainPlayer.GetComponent <Pathea.PlayerPackageCmpt>();
                 pPC.Add(itemObj);
             }
         }
         mItemList.Clear();
         CheckDestroy();
     }
 }
コード例 #6
0
    void RPC_S2C_ExchangeItem(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int id        = stream.Read <int>();
        int destIndex = stream.Read <int>();
        int destId    = stream.Read <int>();
        int srcIndex  = stream.Read <int>();

        Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null == pkg)
        {
            return;
        }

        ItemObject item = ItemMgr.Instance.Get(id);

        if (null == item)
        {
            return;
        }

        if (-1 == destId)
        {
            pkg.Remove(item);
        }
        else
        {
            ItemObject destItem = ItemMgr.Instance.Get(destId);
            if (null != destItem)
            {
                pkg.package.PutItem(destItem, srcIndex, (ItemPackage.ESlotType)item.protoData.tabIndex);
            }
        }

        pkg.package.PutItem(item, destIndex, (ItemPackage.ESlotType)item.protoData.tabIndex);
    }
コード例 #7
0
    void OnIsoClick(int index)
    {
        if (mWndCtrl.IsoListSelectIndex > -1)
        {
            mWndCtrl.ClearCostList();

            BSIsoHeadData header = m_IsoHeaders[mWndCtrl.IsoListSelectIndex];
            foreach (var kvp in header.costs)
            {
                int item_id = PEBuildingMan.GetBlockItemProtoID(kvp.Key);

                //				if (item_id < PEBuildingMan.c_MinItemProtoID || item_id > PEBuildingMan.c_MaxItemProtoID)
                //					continue;
                if (item_id == -1)
                {
                    return;
                }

                ItemProto proto = ItemProto.Mgr.Instance.Get(item_id);
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                int player_cnt = pkg.GetItemCount(item_id);
                int final_cnt  = Mathf.Clamp(player_cnt, 0, 9999);
                mWndCtrl.AddCostListItem(proto.GetName(), Mathf.CeilToInt(kvp.Value / 4.0f).ToString() + '/' + final_cnt.ToString(), proto.icon[0], "Icon");
            }
            IsoRePos = true;
            //mWndCtrl.ResetCostPostion();
        }
    }
コード例 #8
0
    static void RemoveItemFromPlayerPkg(int itemId)
    {
        if (null == pkg)
        {
            return;
        }

        ItemObject itemObj = ItemMgr.Instance.Get(itemId);

        if (itemObj == null)
        {
            return;
        }

        pkg.Remove(itemObj);



        if (Pathea.PlayerPackageCmpt.LockStackCount)
        {
            Pathea.PlayerPackageCmpt playerPkg = pkg as Pathea.PlayerPackageCmpt;
            if (playerPkg != null)
            {
                playerPkg.package.Add(itemObj.protoId, 1);
            }
        }
    }
コード例 #9
0
    /// <summary>
    /// 删除背包中的物品
    /// </summary>
    /// <param name="stream"></param>
    void RPC_S2C_DeleteItemInPackage(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int _objId;

        stream.TryRead <int>(out _objId);

        ItemObject obj = ItemMgr.Instance.Get(_objId);

        if (null == obj)
        {
            return;
        }

        Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null != pkg)
        {
            pkg.Remove(obj);
        }

        if (IsOwner)
        {
            GameUI.Instance.mItemPackageCtrl.ResetItem();
            //MainMidGui_N.Instance.UpdateLink();
        }

        //  if (null != PlayerFactory.mMainPlayer && null != PlayerFactory.mMainPlayer.m_PlayerMission)
        //   PlayerFactory.mMainPlayer.m_PlayerMission.CheckItemMissionList(nItemID);
    }
コード例 #10
0
        void Reload()
        {
            if (null != gun && motionMgr.IsActionRunning(ActionType) && null != entity)
            {
                m_ReloadEnd = true;

                if (null != gun.m_MagazineObj)
                {
                    gun.m_MagazineObj.SetActive(false);
                }

                if (null == gun.m_AmmoItemIDList || gun.m_AmmoItemIDList.Length <= m_TargetAmmoIndex ||
                    gun.m_AmmoItemIDList.Length <= gun.curAmmoItemIndex)
                {
                    gun.magazineValue = gun.magazineSize;
                    return;
                }
                int oldAmmoItemId = gun.m_AmmoItemIDList[m_TargetAmmoIndex];
                if (GameConfig.IsMultiMode && !m_IgnoreItem && null != PlayerNetwork.mainPlayer)
                {
                    PlayerNetwork.mainPlayer.RequestReload(entity.Id, gun.ItemObj.instanceId, oldAmmoItemId, gun.m_AmmoItemIDList[m_TargetAmmoIndex], gun.magazineSize);
                }

                if (!GameConfig.IsMultiMode && gun.magazineValue > 0 && null != packageCmpt && !m_IgnoreItem)
                {
                    PlayerPackageCmpt playerPackage = packageCmpt as PlayerPackageCmpt;
                    if (playerPackage != null)
                    {
                        playerPackage.package.Add(gun.m_AmmoItemIDList[gun.curAmmoItemIndex], Mathf.RoundToInt(gun.magazineValue));
                    }
                    else
                    {
                        packageCmpt.Add(gun.m_AmmoItemIDList[gun.curAmmoItemIndex], Mathf.RoundToInt(gun.magazineValue));
                    }
                }

                gun.curAmmoItemIndex = m_TargetAmmoIndex;

                int packageNum = Mathf.RoundToInt(gun.magazineSize);

                if (!m_IgnoreItem && null != packageCmpt)
                {
                    packageNum = packageCmpt.GetItemCount(gun.m_AmmoItemIDList[m_TargetAmmoIndex]);
                }

                if (packageNum > 0)
                {
                    int addCount = Mathf.Min(packageNum, Mathf.RoundToInt(gun.magazineSize));
                    gun.magazineValue = addCount;
                    if (!m_IgnoreItem && 0 != packageNum)                    //!GameConfig.IsMultiMode &&
                    {
                        packageCmpt.Destory(gun.m_AmmoItemIDList[m_TargetAmmoIndex], addCount);
                    }
                }
            }
        }
コード例 #11
0
        static void AddMoneyToPlayer(int money)
        {
            PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

            if (null == pkg)
            {
                return;
            }

            pkg.money.current = money;
        }
コード例 #12
0
        void InitData(EIdentity eIdentity)
        {
            m_AbnormalList = new PEAbnormal_N[(int)PEAbnormalType.Max];
            if (PeGameMgr.IsBuild || PeGameMgr.playerType == PeGameMgr.EPlayerType.Tutorial)
            {
                return;
            }
            int mask = 0;

            switch (eIdentity)
            {
            case EIdentity.Player:
                mask = 1;
                break;

            case EIdentity.Npc:
                mask = 2;
                break;

            case EIdentity.Neutral:
                mask = 4;
                break;
            }

            for (int type = 1; type < (int)PEAbnormalType.Max; type++)
            {
                AbnormalData data = AbnormalData.GetData((PEAbnormalType)type);
                if (null != data && (data.target & mask) == mask)
                {
                    AddAbnormal((PEAbnormalType)type, data);
                }
            }

            if (null != Entity.aliveEntity)
            {
                Entity.aliveEntity.evtOnBuffAdd    += OnBuffAdd;
                Entity.aliveEntity.evtOnBuffRemove += OnBuffRemove;
            }

            PlayerPackageCmpt playercmpt = Entity.packageCmpt as PlayerPackageCmpt;

            if (null != playercmpt)
            {
                playercmpt.getItemEventor.Subscribe(OnItemAdd);
            }
        }
コード例 #13
0
        public bool ReviveServent(bool usePlayer = true)
        {
            NpcPackageCmpt Serventpackage = this.GetComponent <NpcPackageCmpt>();

            if (Serventpackage == null)
            {
                return(false);
            }
            ItemAsset.SlotList   package = Serventpackage.GetSlotList();
            ItemAsset.ItemObject Obj     = package.FindItemByProtoId(ReviveItemProtoId);

            if (null == Obj)
            {
                package = Serventpackage.GetHandinList();
                Obj     = package.FindItemByProtoId(ReviveItemProtoId);
            }

            if (Obj == null && !usePlayer)
            {
                return(false);
            }

            if (Obj == null)
            {
                if (GameUI.Instance.mMainPlayer == null)
                {
                    return(false);
                }
                PlayerPackageCmpt playerPackage = GameUI.Instance.mMainPlayer.GetCmpt <PlayerPackageCmpt>();

                if (playerPackage == null)
                {
                    return(false);
                }
                ItemAsset.ItemObject Obj2 = playerPackage.package.FindItemByProtoId(ReviveItemProtoId);
                if (Obj2 == null)
                {
                    return(false);
                }

                return(Use(Obj2, playerPackage));
                //return false ;
            }

            return(Use(Obj));
        }
コード例 #14
0
    // Update is called once per frame
    void Update()
    {
#if PLANET_EXPLORERS
        if (PeCreature.Instance.mainPlayer != null)
        {
            if (VCEditor.Instance.m_CheatWhenMakeCreation)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Cheat".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else if (Pathea.PeGameMgr.IsSingleBuild)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Build".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else if (PeGameMgr.playerType == PeGameMgr.EPlayerType.Tutorial)
            {
                m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + "Tutorial".ToLocalizationString() + "[-]";
                m_IsEnough        = true;
            }
            else
            {
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
                int have = pkg.package.GetCount(m_GameItemId);
                if (have >= m_GameItemCost)
                {
                    m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [60FF00]" + have.ToString("#,##0").Trim() + "[-]";
                    m_IsEnough        = true;
                }
                else
                {
                    m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim() + " / [FF0000]" + have.ToString("#,##0").Trim() + "[-]";
                    m_IsEnough        = false;
                }
            }
        }
        else
        {
            m_CountLabel.text = m_GameItemCost.ToString("#,##0").Trim();
            m_IsEnough        = false;
        }
#else
        m_CountLabel.text = m_GameItemCost.ToString("# ##0");
        m_IsEnough        = false;
#endif
    }
コード例 #15
0
 public void UpdateNum(int num)
 {
     if (num < 1)
     {
         num = 1;
     }
     if (mGrid.Item != null)
     {
         mNumCost.text = (mCosPerItem * num).ToString();
         Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
         HaveEnoughItem(pkg.package.GetCount(mGrid.Item.protoId) >= mCosPerItem * num);
     }
     else
     {
         mNumCost.text = "";
     }
 }
コード例 #16
0
        public bool Revive()
        {
            //only player package
            PlayerPackageCmpt playerPkg = mPkg as PlayerPackageCmpt;

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

            ItemAsset.ItemObject Obj = playerPkg.package.FindItemByProtoId(ReviveItemProtoId);
            if (Obj == null)
            {
                return(false);
            }

            return(Use(Obj));
        }
コード例 #17
0
    /// <summary>
    /// 初始化背包大小
    /// </summary>
    /// <param name="stream"></param>
    void RPC_S2C_InitPackage(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int itemMax     = stream.Read <int>();
        int equipMax    = stream.Read <int>();
        int resourceMax = stream.Read <int>();
        int armMax      = stream.Read <int>();

        if (Equals(null, entity))
        {
            return;
        }

        Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null != pkg)
        {
            pkg.package.ExtendPackage(itemMax, equipMax, resourceMax, armMax);
        }
    }
コード例 #18
0
    void RPC_S2C_SplitItem(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int id    = stream.Read <int>();
        int index = stream.Read <int>();

        ItemObject item = ItemMgr.Instance.Get(id);

        if (null == item)
        {
            return;
        }

        Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null == pkg)
        {
            return;
        }

        pkg.package.PutItem(item, index, (ItemPackage.ESlotType)item.protoData.tabIndex);
    }
コード例 #19
0
        static void AddItemToPlayer(ItemAsset.MaterialItem[] items)
        {
            PlayerPackageCmpt pkg = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>();

            if (null == pkg)
            {
                return;
            }

            foreach (ItemAsset.MaterialItem item in items)
            {
                pkg.package.Add(item.protoId, item.count);
                //Use default itembox
                ItemObject obj = pkg.package._playerPak.GetItemByProtoID(item.protoId);
                if (null != obj)
                {
                    PeCreature.Instance.mainPlayer.UseItem.Use(obj);
                }
            }
            pkg.package._playerPak.Sort(ItemPackage.ESlotType.Item);
        }
コード例 #20
0
    void RPC_S2C_RemoveItemFromPackage(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int instanceId = stream.Read <int>();

        //if (null != player)
        //    player.GetItemPackage().RemoveItem(objID);
        ItemObject item = ItemMgr.Instance.Get(instanceId);

        if (item != null)
        {
            Pathea.PlayerPackageCmpt pkg = entity.GetCmpt <Pathea.PlayerPackageCmpt>();
            if (null != pkg)
            {
                pkg.Remove(item);
            }
        }
        if (IsOwner)
        {
            GameUI.Instance.mItemPackageCtrl.ResetItem();
        }
    }
コード例 #21
0
ファイル: CSUI_Grid.cs プロジェクト: shrubba/planetexplorers
    void OnRightMouseClicked(Grid_N grid)
    {
        if (grid.Item == null)
        {
            return;
        }

        if (onCheckItem != null && !onCheckItem(null, ECheckItemType.RightMounseClick))
        {
            return;
        }

        if (GameConfig.IsMultiMode)
        {
            OnRightMouseClickedMulti(grid, m_Index);
            return;
        }

        ItemObject oldItem = grid.ItemObj;

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

        if (package.package.CanAdd(grid.ItemObj))
        {
            package.Add(grid.ItemObj);
            GameUI.Instance.mItemPackageCtrl.ResetItem();
            grid.SetItem(null);

            if (OnItemChanged != null)
            {
                OnItemChanged(null, oldItem, m_Index);
            }
        }
        else
        {
            CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mNotEnoughGrid.GetString(), Color.red);
        }
    }
コード例 #22
0
    private void OnItemChange(object sender, ItemAsset.ItemPackage.EventArg arg)
    {
        for (int i = 0; i < m_Achievements.Length; i++)
        {
            if (m_Achievements[i].m_bAchieved)
            {
                continue;
            }
            if (m_Achievements[i].m_ProtoId == 0)
            {
                continue;
            }

            if (Pathea.PeCreature.Instance != null && Pathea.PeCreature.Instance.mainPlayer != null)
            {
                Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.packageCmpt as Pathea.PlayerPackageCmpt;
                if (pkg != null)
                {
                    int count = pkg.package.GetCount(m_Achievements[i].m_ProtoId);
                    OnItemValueChange(m_Achievements[i].m_eAchievementID, count);
                }
            }
        }
    }
コード例 #23
0
        public bool Use(ItemAsset.ItemObject item, PlayerPackageCmpt UsePkg)
        {
            CheckMainPlayerUseItem(item.protoId);
            bool destroy = false;

            destroy = ExtractBundle(item.GetCmpt <ItemAsset.Bundle>()) || destroy;
            destroy = ConsumeItem(item.GetCmpt <ItemAsset.Consume>()) || destroy;
            destroy = LearnReplicatorFormula(item.GetCmpt <ItemAsset.ReplicatorFormula>()) || destroy;
            destroy = LearnMetalScan(item.GetCmpt <ItemAsset.MetalScan>()) || destroy;

            bool remove = TakeOnEquipment(item.GetCmpt <ItemAsset.Equip>());

            if (UsePkg != null)
            {
                if (destroy)
                {
                    UsePkg.DestroyItem(item, 1);
                }
                else if (remove)
                {
                    UsePkg.Remove(item);
                }
            }

            bool ret = destroy || remove;

            if (ret)
            {
                eventor.Dispatch(new EventArg()
                {
                    itemObj = item
                }, this);
            }

            return(ret);
        }
コード例 #24
0
    protected void RemoveFromBag()
    {
        Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.packageCmpt;

        //some item stack count > 1, seed eg.
        if (itemDragging.itemObj.stackCount > 1)
        {
            pkg.DestroyItem(itemDragging.itemObj, 1);
        }
        else
        {
            pkg.Remove(itemDragging.itemObj);
        }

        if (Pathea.PlayerPackageCmpt.LockStackCount &&
            !ItemAsset.ItemMgr.IsCreationItem(itemDragging.itemObj.protoId))
        {
            Pathea.PlayerPackageCmpt playerPkg = pkg as Pathea.PlayerPackageCmpt;
            if (playerPkg != null)
            {
                playerPkg.package.Add(itemDragging.itemObj.protoId, 1);
            }
        }
    }
コード例 #25
0
    public override void Show()
    {
        playerPackage = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();

        ResetItem();
        if (GameUI.Instance.mItemPackageCtrl != null)
        {
            if (!GameUI.Instance.mItemPackageCtrl.isShow)
            {
                GameUI.Instance.mItemPackageCtrl.Show();
            }
            else
            {
                mCurrentPickTab = GameUI.Instance.mItemPackageCtrl.CurrentPickTab;
                mPageIndex      = 0;
            }
        }

        base.Show();
        if (OnShow != null)
        {
            OnShow.Invoke();
        }
    }
コード例 #26
0
    public static void CopyCretion(ECreation type)
    {
        Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
        if (null == pkg)
        {
            return;
        }
        List <int> creationInstanceid = pkg.package.GetCreationInstanceId(type);

        if (creationInstanceid == null || creationInstanceid.Count == 0)
        {
            return;
        }
        CreationData cd = CreationMgr.GetCreation(creationInstanceid[0]);

        if (Pathea.PeGameMgr.IsMulti)
        {
            ulong hash   = CRC64.Compute(cd.m_Resource);
            ulong fileId = SteamWorkShop.GetFileHandle(hash);
            VCGameMediator.SendIsoDataToServer(cd.m_IsoData.m_HeadInfo.Name, cd.m_IsoData.m_HeadInfo.SteamDesc,
                                               cd.m_IsoData.m_HeadInfo.SteamPreview, cd.m_Resource, SteamWorkShop.AddNewVersionTag(cd.m_IsoData.m_HeadInfo.ScenePaths()), true, fileId, true);
        }
        else
        {
            CreationData new_creation = new CreationData();
            new_creation.m_ObjectID   = CreationMgr.QueryNewId();
            new_creation.m_RandomSeed = UnityEngine.Random.value;
            new_creation.m_Resource   = cd.m_Resource;
            new_creation.ReadRes();

            // Attr
            new_creation.GenCreationAttr();
            if (new_creation.m_Attribute.m_Type == ECreation.Null)
            {
                Debug.LogWarning("Creation is not a valid type !");
                new_creation.Destroy();
                return;
            }

            // SaveRes
            if (new_creation.SaveRes())
            {
                new_creation.BuildPrefab();
                new_creation.Register();
                CreationMgr.AddCreation(new_creation);
                ItemAsset.ItemObject item;
                int send_retval = new_creation.SendToPlayer(out item);

                Debug.Log("Make creation succeed !");
                if (send_retval == 0)
                {
                    return; // Error
                }
                else if (send_retval == -1)
                {
                    return; // Item Package Full
                }
                else
                {
                    return; // Succeed
                }
            }
            else
            {
                Debug.LogWarning("Save creation resource file failed !");
                new_creation.Destroy();
                return;
            }
        }
    }
コード例 #27
0
    void OnDropItem(Grid_N grid)
    {
        //lz-2016.10.25 因为多人暂时只支持从背包中拖到充电中,所以统一多人和单人,避免出现显示问题
        if (SelectItem_N.Instance.Place != ItemPlaceType.IPT_Bag)
        {
            return;
        }

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

        if (grid.Item == null)
        {
            switch (SelectItem_N.Instance.Place)
            {
            case ItemPlaceType.IPT_HotKeyBar:
                SelectItem_N.Instance.SetItem(null);
                break;

            default:
                if (SetItem(SelectItem_N.Instance.ItemObj))
                {
                    if (GameConfig.IsMultiMode)
                    {
                        if (OnDropItemMulti != null)
                        {
                            OnDropItemMulti(m_Index, grid);
                        }
                    }
                    SelectItem_N.Instance.RemoveOriginItem();
                    SelectItem_N.Instance.SetItem(null);

                    if (!m_bUseMsgBox)
                    {
                        CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToCharge.GetString(), grid.Item.protoData.GetName()));
                    }
                    //						CSUI_Main.ShowStatusBar("Start to charge the " + grid.Item.mItemData.m_Englishname + ".");
                }
                else
                {
                    if (!m_bUseMsgBox)
                    {
                        CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mNotToBeCharged.GetString(), SelectItem_N.Instance.ItemObj.protoData.GetName()), Color.red);
                    }
                    //						CSUI_Main.ShowStatusBar("The " + SelectItem_N.Instance.ItemObj.mItemData.m_Englishname + " is not need to be charged.", Color.red);
                }
                break;
            }
        }
        else
        {
            ItemObject io = grid.ItemObj;
            Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
            if (pkg.package.CanAdd(io) && SetItem(SelectItem_N.Instance.ItemObj))
            {
                pkg.package.AddItem(io);
                SelectItem_N.Instance.RemoveOriginItem();
                SelectItem_N.Instance.SetItem(null);

                if (!m_bUseMsgBox)
                {
                    if (grid.Item != null)
                    {
                        CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToCharge.GetString(), grid.Item.protoData.GetName()));
                    }
                }
                //					CSUI_Main.ShowStatusBar("Start to charge the " + grid.Item.mItemData.m_Englishname + ".");
            }
            else
            {
                if (!m_bUseMsgBox)
                {
                    //					CSUI_Main.ShowStatusBar("The " + SelectItem_N.Instance.ItemObj.mItemData.m_Englishname + " is not need to be charged.", Color.red);
                    CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mNotToBeCharged.GetString(), SelectItem_N.Instance.ItemObj.protoData.GetName()), Color.red);
                }
            }
        }
    }
コード例 #28
0
    private void Update()
    {
        if (!SteamManager.Initialized)
        {
            return;
        }

        if (!m_bRequestedStats)
        {
            // Is Steam Loaded? if no, can't get stats, done
            if (!SteamManager.Initialized)
            {
                m_bRequestedStats = true;
                return;
            }

            // If yes, request our stats
            bool bSuccess = SteamUserStats.RequestCurrentStats();

            // This function should only return false if we weren't logged in, and we already checked that.
            // But handle it being false again anyway, just ask again later.
            m_bRequestedStats = bSuccess;
        }

        if (!m_bStatsValid)
        {
            return;
        }

#if UNITY_EDITOR
        if (ResetAchivements)
        {
            ResetAllAchievements();
            ResetAllStats();
            ResetAchivements = false;
        }

        if (Test)
        {
            OnGameStateChange(AchivementType);
            Test = false;
        }
#endif

        //获取当前玩家entity
        if (Pathea.PeCreature.Instance != null && Pathea.PeCreature.Instance.mainPlayer != null)
        {
            if (!m_Maiplayer || !m_Maiplayer.Equals(Pathea.PeCreature.Instance.mainPlayer))
            {
                m_Maiplayer = Pathea.PeCreature.Instance.mainPlayer;
                m_playerPkg = (m_Maiplayer.packageCmpt as Pathea.PlayerPackageCmpt);

                if (m_playerPkg != null)
                {
                    m_playerPkg.package._playerPak.changeEventor.Subscribe(OnItemChange);
                }
            }
        }


        if (m_Maiplayer && Pathea.Money.Digital)
        {
            if (m_Maiplayer.packageCmpt != null && m_Maiplayer.packageCmpt.money != null && m_Maiplayer.packageCmpt.money.current >= 10000)
            {
                //完成成就:富可敌国
                OnGameStateChange(Eachievement.Richer);
            }
        }

        // Get info from sources

        // Evaluate achievements
        int achedNum = 0;
        for (int i = 0; i < m_Achievements.Length; i++)
        {
            if (m_Achievements[i].m_bAchieved)
            {
                achedNum++;
                continue;
            }

            if (m_Stats[(int)m_Achievements[i].m_eAchievementID].IsAccomplish())
            {
                UnlockAchievement(m_Achievements[i]);
            }
        }

        //全部成就完成
        if (achedNum == ((int)Eachievement.Max - 2))
        {
            if (!m_Achievements[(int)Eachievement.ALL].m_bAchieved)
            {
                UnlockAchievement(m_Achievements[(int)Eachievement.ALL]);
            }
        }

        //Store stats by self
        if (m_bStoreStats)
        {
            //保存更改
            bool bSuccess = false;//SteamUserStats.StoreStats();
            for (int i = 0; i < m_Achievements.Length; i++)
            {
                if (string.IsNullOrEmpty(m_StatNames[(int)m_Achievements[i].m_eStatID]))
                {
                    continue;
                }

                bSuccess = StatsUserPrefs.SaveIntValue(m_StatNames[(int)m_Achievements[i].m_eStatID], m_Stats[(int)m_Achievements[i].m_eAchievementID].m_StatValue);
            }
            SteamUserStats.StoreStats();
            // If this failed, we never sent anything to the server, try
            // again later.
            m_bStoreStats = !bSuccess;
        }
    }
コード例 #29
0
    /// <summary>
    /// voxel modify check event before really undo and redo. Call by BSVoxelModify
    /// </summary>
    bool OnCheckVoxelModify(int opType, IntVector3[] indexes, BSVoxel[] voxels, BSVoxel[] oldvoxels, EBSBrushMode mode, IBSDataSource ds)
    {
        if (IsGod)
        {
            return(true);
        }

        if (Pathea.PeCreature.Instance.mainPlayer == null)
        {
            return(false);
        }

        bool result = true;


        if (mode == EBSBrushMode.Add)
        {
            Dictionary <int, int> items = new Dictionary <int, int>();
            // Calculate the needed items;
            int adder = 1;
            foreach (BSVoxel voxel in voxels)
            {
                int id = 0;
                if (ds == BuildingMan.Blocks)
                {
                    if (voxel.IsExtendable())
                    {
                        if (!voxel.IsExtendableRoot())
                        {
                            id    = GetBlockItemProtoID((byte)(voxel.materialType >> 2));
                            adder = 1;
                        }
                        else
                        {
                            adder = 0;
                        }
                    }
                    else
                    {
                        id = GetBlockItemProtoID(voxel.materialType);
                    }
                }
                else if (ds == BuildingMan.Voxels)
                {
                    id = GetVoxelItemProtoID(voxel.materialType);
                }

                if (id <= 0)
                {
                    continue;
                }

                if (id != 0)
                {
                    if (items.ContainsKey(id))
                    {
                        items[id] += adder;
                    }
                    else
                    {
                        items.Add(id, adder);
                    }
                }
            }
            _costsItems = items;

            float divisor = 1.0f;

            if (ds == BuildingMan.Blocks)
            {
                divisor = (float)(1 << BSBlock45Data.s_ScaleInverted);
            }

            // Has player enough items ?
            Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PackageCmpt>();

            _playerItems.Clear();
            foreach (KeyValuePair <int, int> kvp in items)
            {
                _playerItems.Add(kvp.Key, pkg.GetItemCount(kvp.Key));
                if (pkg.GetItemCount(kvp.Key) < Mathf.CeilToInt(kvp.Value / divisor))
                {
                    result = false;
                }
            }

            // now delete
            if (result)
            {
                if (GameConfig.IsMultiMode)
                {
                    if (null == PlayerNetwork.mainPlayer)
                    {
                        return(false);
                    }

                    if (!Pathea.PeGameMgr.IsMultiCoop && VArtifactUtil.IsInTownBallArea(PlayerNetwork.mainPlayer._pos))
                    {
                        new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning);
                        return(false);
                    }

                    //if (!PlayerNetwork.OnLimitBoundsCheck(brushBound))
                    //{
                    //	new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning);
                    //	return false;
                    //}

                    PlayerNetwork.mainPlayer.RequestRedo(opType, indexes, oldvoxels, voxels, mode, ds.DataType, ds.Scale);

                    DigTerrainManager.BlockClearGrass(ds, indexes);

                    return(true);
                }
                else
                {
                    string debug_log = "";

                    foreach (KeyValuePair <int, int> kvp in items)
                    {
                        if (pkg.Destory(kvp.Key, Mathf.CeilToInt(kvp.Value / divisor)))
                        {
                            debug_log += "\r\n Rmove Item from player package ID[" + kvp.Key.ToString() + "]" + " count - " + kvp.Value.ToString();
                        }
                    }

                    if (ds == BuildingMan.Blocks)
                    {
                        for (int i = 0; i < indexes.Length; i++)
                        {
                            Vector3 pos = new Vector3(indexes[i].x * ds.Scale, indexes[i].y * ds.Scale, indexes[i].z * ds.Scale) - ds.Offset;
                            PeGrassSystem.DeleteAtPos(pos);

                            PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y - 1, pos.z));

                            //PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y + 1, pos.z));
                        }
                    }
                    else if (ds == BuildingMan.Voxels)
                    {
                        for (int i = 0; i < indexes.Length; i++)
                        {
                            Vector3 pos = new Vector3(indexes[i].x, indexes[i].y, indexes[i].z);
                            PeGrassSystem.DeleteAtPos(pos);

                            PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y - 1, pos.z));

                            //PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y + 1, pos.z));
                        }
                    }

                    //Debug.LogWarning(debug_log);
                }
            }
            else
            {
                new PeTipMsg(PELocalization.GetString(821000001), PeTipMsg.EMsgLevel.Warning);
            }
        }
        else if (mode == EBSBrushMode.Subtract)
        {
            Dictionary <int, int> items = new Dictionary <int, int>();
            // Calculate the needed items;
            int adder = 1;
            foreach (BSVoxel voxel in oldvoxels)
            {
                int id = 0;
                if (ds == BuildingMan.Blocks)
                {
                    if (voxel.IsExtendable())
                    {
                        if (!voxel.IsExtendableRoot())
                        {
                            id    = GetBlockItemProtoID((byte)(voxel.materialType >> 2));
                            adder = 1;
                        }
                        else
                        {
                            adder = 0;
                        }
                    }
                    else
                    {
                        if (!BuildingMan.Blocks.VoxelIsZero(voxel, 0))
                        {
                            id = GetBlockItemProtoID((byte)(voxel.materialType));
                        }
                    }
                }
                else if (ds == BuildingMan.Voxels)
                {
                    if (!BuildingMan.Voxels.VoxelIsZero(voxel, 1))
                    {
                        id = GetVoxelItemProtoID(voxel.materialType);
                    }
                }

                if (id <= 0)
                {
                    continue;
                }

                if (items.ContainsKey(id))
                {
                    items[id] += adder;
                }
                else
                {
                    items.Add(id, adder);
                }
            }


            float divisor = 1.0f;

            if (ds == BuildingMan.Blocks)
            {
                divisor = (float)(1 << BSBlock45Data.s_ScaleInverted);
            }

            // Has player enough package ?
            Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();

            MaterialItem[] array = new MaterialItem[items.Count];

            int i = 0;
            foreach (KeyValuePair <int, int> kvp in items)
            {
                array[i] = new MaterialItem()
                {
                    protoId = kvp.Key,
                    count   = Mathf.FloorToInt(kvp.Value / divisor)
                };
                i++;
            }

            result = pkg.package.CanAdd(array);

            // Really add
            if (result)
            {
                if (GameConfig.IsMultiMode)
                {
                    if (null == PlayerNetwork.mainPlayer)
                    {
                        return(false);
                    }

                    //if (!PlayerNetwork.OnLimitBoundsCheck(brushBound))
                    //{
                    //	new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning);
                    //	return false;
                    //}

                    PlayerNetwork.mainPlayer.RequestRedo(opType, indexes, oldvoxels, voxels, mode, ds.DataType, ds.Scale);
                    return(true);
                }
                else
                {
                    string debug_log = "";
                    foreach (MaterialItem mi in array)
                    {
                        if (mi.count != 0)
                        {
                            pkg.Add(mi.protoId, mi.count);
                        }
                        debug_log += "Add Item from player package ID[" + mi.protoId.ToString() + "]" + " count - " + mi.count.ToString() + "\r\n";
                    }

                    Debug.LogWarning(debug_log);
                }
            }
        }

        if (result)
        {
            if (onVoxelMotify != null)
            {
                onVoxelMotify(indexes, voxels, oldvoxels, mode, ds);
            }
        }

        return(result);
    }
コード例 #30
0
 public override void Start()
 {
     base.Start();
     mPackage = Entity.GetCmpt <PlayerPackageCmpt>();
 }