/// <summary>
 /// 赠送
 /// </summary>
 public static void SendRelationGive(long char_idx, PropID item_id)
 {
     c2ss.RelationGive msg = PacketPools.Get(c2ss.msg.RELATION_GIVE) as c2ss.RelationGive;
     msg.target_char_idx = char_idx;
     msg.item_id         = item_id;
     ClientNetManager.Instance.Send(msg);
 }
Esempio n. 2
0
        /// <summary>
        /// 好友赠送
        /// </summary>
        public void FriendGiveClient(long target_char_idx, PropID item_id)
        {
            //先查找是否有好友
            RelationInfo relation_info;

            if (!m_relations.TryGetValue(target_char_idx, out relation_info) || relation_info.flags != eRelationFlag.Friend)
            {
                return;
            }

            //是否今日已经赠送
            //TODO

            //赠送是否合法
            if (!item.IsValidProp(item_id))
            {
                return;
            }

            //发送到gl
            ss2gl.RelationGive msg = PacketPools.Get(ss2gl.msg.RELATION_GIVE) as ss2gl.RelationGive;
            msg.char_idx        = m_char_idx;
            msg.target_char_idx = target_char_idx;
            msg.item_id         = item_id;
            ServerNetManager.Instance.Send2GL(msg);
        }
Esempio n. 3
0
        /// <summary>
        /// 关系操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            int col = e.ColumnIndex; //获取当前列的索引

            if (col == 5)
            {
                PropID item_id = new PropID();
                item_id.type      = ePropType.CURRENCY;
                item_id.obj_type  = (uint)eCurrencyType.Gold;
                item_id.obj_value = 1000;

                string idx      = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long   char_idx = long.Parse(idx);
                ServerMsgSend.SendRelationGive(char_idx, item_id);
            }
            else if (col == 6)
            {
                string            idx       = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long              char_idx  = long.Parse(idx);
                RelationAddTarget target_id = new RelationAddTarget();
                target_id.type     = eRelationAddType.Idx;
                target_id.char_idx = char_idx;
                ServerMsgSend.SendRelationAdd(target_id, eRelationFlag.Block, "");
            }
            else if (col == 7)
            {
                string idx      = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long   char_idx = long.Parse(idx);
                m_list_relation.Rows.RemoveAt(row);
                RelationDataManager.Instance.RemoveRelation(char_idx);
                ServerMsgSend.SendRelationRemove(char_idx);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 好友赠送
        /// </summary>
        public void FriendGiveCommand(long target_char_idx, PropID item_id)
        {
            Unit player = UnitManager.Instance.GetUnitByIdx(m_char_idx);

            if (player == null)
            {
                return;
            }

            //先查找是否有好友
            RelationInfo relation_info;

            if (!m_relations.TryGetValue(target_char_idx, out relation_info) || relation_info.flags != eRelationFlag.Friend)
            {
                return;
            }

            //赠送是否合法
            if (!item.IsValidProp(item_id))
            {
                return;
            }

            //写入事件
            RelationEventInfo e_info = new RelationEventInfo();

            e_info.target_char_idx = target_char_idx;
            e_info.source_char_idx = m_char_idx;
            e_info.event_type      = eRelationEvent.Give;
            e_info.bin_content.bin_give_content.char_name = player.char_name;
            e_info.bin_content.bin_give_content.item_id   = item_id;
            SQLRelationHandle.InsertRelationEvent(e_info);
            //立刻通知接受者:这里先注释,不需要及时通知
            //this.BroadcastEvent(e_info.target_char_idx, e_info.event_type);
        }
Esempio n. 5
0
 public void Add(PropID obj)
 {
     if (items == null)
     {
         items = new List <PropID>();
     }
     items.Add(obj);
 }
Esempio n. 6
0
        /// <summary>
        /// 消耗物品
        /// </summary>
        /// <param name="info"></param>
        public void Consume(PropID item_id, eClientEventAction action = eClientEventAction.Unknow)
        {
            switch (item_id.type)
            {
            case ePropType.ITEM:
                ConsumeItem(item_id.obj_type, item_id.obj_value);
                break;

            case ePropType.CURRENCY:
                ConsumeCurrency((eCurrencyType)item_id.obj_type, item_id.obj_value);
                break;
            }
        }
Esempio n. 7
0
        public void Write(ByteArray by)
        {
            by.WriteString(subject);
            by.WriteString(content);
            ushort count = (ushort)items.Count;

            by.WriteUShort(count);
            for (int i = 0; i < count; ++i)
            {
                PropID obj = items[i];
                obj.Write(by);
            }
        }
Esempio n. 8
0
        public void Read(ByteArray by)
        {
            subject = by.ReadString();
            content = by.ReadString();
            ushort count = by.ReadUShort();

            for (int i = 0; i < count; ++i)
            {
                PropID obj = new PropID();
                obj.Read(by);
                this.Add(obj);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 赠送
        /// </summary>
        public void FriendGiveGL(PlayerIDName src_player_id, PropID item_id)
        {
            Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player;

            if (player == null)
            {
                return;
            }

            if (!m_relations.ContainsKey(src_player_id.char_idx))
            {
                return;
            }

            ss2c.RelationGive rep_msg = PacketPools.Get(ss2c.msg.RELATION_GIVE) as ss2c.RelationGive;
            rep_msg.player_id = src_player_id;
            rep_msg.item_id   = item_id;
            ServerNetManager.Instance.SendProxy(player.client_uid, rep_msg);
        }
Esempio n. 10
0
        /// <summary>
        /// 物品是否合法
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool IsValidProp(PropID item_id)
        {
            switch (item_id.type)
            {
            case ePropType.CURRENCY:
                eCurrencyType sub_type = (eCurrencyType)item_id.obj_type;
                if (sub_type != eCurrencyType.Diamond && sub_type != eCurrencyType.Gold && sub_type != eCurrencyType.Silver)
                {
                    return(false);
                }

                break;

            case ePropType.ITEM:

                break;

            default:
                break;
            }
            return(true);
        }