Example #1
0
 //推送拾取列表
 private void PushPick(ObjDropItem _this, ObjPlayer picker)
 {
     if (_this.TableDrop != null && _this.TableDrop.Type == 300)
     {//buff类
         if (picker.Scene != null)
         {
             picker.Scene.OnPlayerPickItem(picker, _this);
         }
         _this.Remove();
         return;
     }
     if (_this.mPickList.Count > 0)
     {
         _this.mPickList[picker.ObjId] = 1;
         return;
     }
     CoroutineFactory.NewCoroutine(TryPick, _this, picker).MoveNext();
 }
Example #2
0
        private IEnumerator TryPick(Coroutine coroutine, ObjDropItem objDrop, ObjPlayer character)
        {
            //增加道具
            PlayerLog.WriteLog((int)LogType.DropItem, "TryPickDropItem  Id ={0}  ObjPlayer={1}", objDrop.ObjId,
                               character.ObjId);
            var result = SceneServer.Instance.LogicAgent.GiveItem(character.ObjId, objDrop.ItemId, objDrop.Count, -1);

            yield return(result.SendAndWaitUntilDone(coroutine));

            if (result.State != MessageState.Reply)
            {
                PlayerLog.WriteLog((int)LogType.DropItem, "PickUpItemSuccess not reply  Id ={0}  ObjPlayer={1}",
                                   objDrop.ObjId, character.ObjId);
                objDrop.Remove();
                yield break;
            }
            if (result.Response == (int)ErrorCodes.OK)
            {
//Logic增加道具成功
                //告诉客户端我拾取了
                if (character.Proxy != null)
                {
                    character.Proxy.PickUpItemSuccess(objDrop.ObjId);
                    character.Proxy.Wait(coroutine, TimeSpan.FromSeconds(3));
                }
                PlayerLog.WriteLog((int)LogType.DropItem, "PickUpItemSuccess  Id ={0}  ObjPlayer={1}", objDrop.ObjId,
                                   character.ObjId);
                //删除自己
                objDrop.Remove();
                if (character.Scene != null)
                {
                    character.Scene.OnPlayerPickItem(character, objDrop);
                }
            }
            else
            {
//Logic增加道具失败
                if (character.Proxy != null)
                {
                    character.Proxy.BagisFull(objDrop.ObjId, objDrop.ItemId, objDrop.Count);
                }
                objDrop.mPickList.Remove(character.ObjId);
                if (objDrop.mOverTrigger == null)
                {
                    yield break;
                }
                if (objDrop.mPickList.Count > 0)
                {
                    foreach (var i in objDrop.mPickList)
                    {
                        var uId = i.Key;
                        var cl  = CharacterManager.Instance.GetCharacterControllerFromMemroy(uId);
                        if (cl == null)
                        {
                            continue;
                        }
                        CoroutineFactory.NewCoroutine(TryPick, objDrop, cl).MoveNext();
                        //TryPick(coroutine, ObjDropItem objDrop, ObjPlayer character)
                        yield break;
                    }
                }
            }
        }
Example #3
0
 public void TimeOver(ObjDropItem _this)
 {
     PlayerLog.WriteLog((int)LogType.DropItem, "TimeOver  Id ={0}", _this.ObjId);
     _this.Remove();
 }