コード例 #1
0
        public bool TakeCard(Player player, int index)
        {
            if (player.CanTakeOut == false)
            {
                return(false);
            }

            if (player.IsActive == false || index < 0 || index > 7 || player.HasTakeCard || Cards[index] > 0)
            {
                return(false);
            }

            MapGoodsInfo info = MapMgr.GetRandomAward(m_map.Info.ID, m_map.Info.Type);

            bool isItem = false;
            int  value  = 100;

            if (info != null)
            {
                if (info.GoodsID > 0)
                {
                    ItemTemplateInfo temp = ItemMgr.GetSingleGoods(info.GoodsID);
                    if (temp != null)
                    {
                        isItem = true;
                        value  = info.GoodsID;
                        player.PlayerDetail.TempInventory.AddItemTemplate(temp, info);
                    }
                }
                else if (info.GoodsID == -1)
                {
                    value = info.Value;
                }
            }

            if (isItem == false)
            {
                value = player.PlayerDetail.AddGold(value);
            }

            player.HasTakeCard = true;
            Cards[index]       = 1;

            GSPacketIn pkg = player.PlayerDetail.Out.SendGamePlayerTakeCard(player, index, isItem, value);

            SendToAll(pkg, player.PlayerDetail);

            return(true);
        }