Exemplo n.º 1
0
        // 获取给定物品在玩家身上相同类型的物品的容量
        public static float GetCapacity(FreeData fd, int cat, int id)
        {
            foreach (string name in fd.freeInventory.GetInventoryManager().GetInventoryNames())
            {
                if (name != ChickenConstant.BagGround)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(name);
                    if (ii != null)
                    {
                        foreach (ItemPosition ip in ii.GetItems())
                        {
                            FreeItemInfo currentInfo = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());
                            if (currentInfo.cat == (int)ECategory.Avatar && cat == (int)ECategory.Avatar)
                            {
                                RoleAvatarConfigItem avatar1 = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(currentInfo.id);
                                RoleAvatarConfigItem avatar2 = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(id);

                                if (avatar1.Type == avatar2.Type)
                                {
                                    return(avatar1.Capacity);
                                }
                            }
                        }
                    }
                }
            }

            return(0);
        }
        private void LoadAvatar(SceneObjectEntity sceneObjectEntity, PlayerEntity playerEntity,
                                RoleAvatarConfigItem avatarCfg)
        {
            var role = SingletonManager.Get <RoleConfigManager>().GetRoleItemById(playerEntity.playerInfo.RoleModelId);

            if (null != role)
            {
                switch ((Sex)role.Sex)
                {
                case Sex.Female:
                    var fAvatarAsset = new AssetInfo(avatarCfg.Bundle, avatarCfg.FPrefab);
                    _assetManager.LoadAssetAsync(sceneObjectEntity, fAvatarAsset,
                                                 simpleLoadHandler.OnLoadUnityObjectSucess);
                    break;

                case Sex.Male:
                    var mAvatarAsset = new AssetInfo(avatarCfg.Bundle, avatarCfg.MPrefab);
                    _assetManager.LoadAssetAsync(sceneObjectEntity, mAvatarAsset,
                                                 simpleLoadHandler.OnLoadUnityObjectSucess);
                    break;
                }

                sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
            }
        }
Exemplo n.º 3
0
        // 获取玩家总容量
        public static float GetCapacity(FreeData fd)
        {
            float w = 20;

            foreach (string name in fd.freeInventory.GetInventoryManager().GetInventoryNames())
            {
                if (name != "ground")
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(name);
                    if (ii != null)
                    {
                        foreach (ItemPosition ip in ii.GetItems())
                        {
                            FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());
                            if (info.cat == 9)
                            {
                                RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id);
                                w += avatar.Capacity;
                            }
                        }
                    }
                }
            }

            return(w);
        }
Exemplo n.º 4
0
        private bool HandleBag(string from, string to, ServerRoom room, FreeData fd)
        {
            FreeItemInfo info = null;

            if (from.StartsWith(ChickenConstant.BagGround))
            {
                SimpleItemInfo sinfo = PickupItemUtil.GetGroundItemInfo(room, fd, from);
                info = FreeItemConfig.GetItemInfo(sinfo.cat, sinfo.id);
            }
            else
            {
                ItemPosition ip = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, from, fd.freeInventory.GetInventoryManager());
                if (ip == null)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(from.Trim());
                    if (ii != null && ii.posList.Count > 0)
                    {
                        ip = ii.posList[0];
                    }
                }
                if (ip != null)
                {
                    info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                }
            }

            if (info != null && info.cat == 9)
            {
                RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id);
                if (avatar.Capacity > 0)
                {
                    if (from.StartsWith(ChickenConstant.BagGround) && !to.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanAddToBag(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id, 1));
                    }

                    if (to.StartsWith(ChickenConstant.BagGround) && !from.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanTakeOff(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id));
                    }
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        // 获取玩家总容量
        public static float GetCapacity(FreeData fd)
        {
            float w = 70;

            /*foreach (string name in fd.freeInventory.GetInventoryManager().GetInventoryNames())
             * {
             *  if (name != ChickenConstant.BagGround)
             *  {
             *      ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(name);
             *      if (ii != null)
             *      {
             *          foreach (ItemPosition ip in ii.GetItems())
             *          {
             *              FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());
             *              if (info.cat == 9)
             *              {
             *                  RoleAvatarConfigItem avatar = SingletonManager.Get<RoleAvatarConfigManager>().GetConfigById(info.id);
             *                  w += avatar.Capacity;
             *              }
             *          }
             *      }
             *  }
             * }*/
            ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagBag);

            if (ii != null)
            {
                foreach (ItemPosition ip in ii.GetItems())
                {
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());
                    if (info.cat == 9)
                    {
                        RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id);
                        w += avatar.Capacity;
                    }
                }
            }
            return(w);
        }