예제 #1
0
        //public override void Init(ulong characterId, int dataId)
        //{
        //    base.Init(characterId, dataId);

        //}

        //输出成一个objdata用于客户端创建
        public ObjData DumpObjData(ObjDropItem _this, ReasonType reason)
        {
            var data = ObjBase.GetImpl().DumpObjData(_this, reason);

            data.Pos = Utility.MakePositionDataByPosAndDir(_this.OrginPos, _this.GetDirection());
            var span = DateTime.Now - _this.mDropTime;

            data.Owner = new Uint64Array();
            data.Owner.Items.AddRange(_this.OwnerList);
            data.ExtData.Add(60 - span.Seconds); //temp
            data.TargetPos.Add(new Vector2Int32
            {
                x = Utility.MultiplyPrecision(_this.GetPosition().X),
                y = Utility.MultiplyPrecision(_this.GetPosition().Y)
            });
            if (DateTime.Now.GetDiffSeconds(_this.mDropTime) > ObjDropItem.DROP_TIME)
            {
                data.ExtData.Add(0);
            }
            else
            {
                data.ExtData.Add(1);
            }
            return(data);
        }
예제 #2
0
        //创建
        public void InitObjDropItem(ObjDropItem _this,
                                    int type,
                                    List <ulong> ownerList,
                                    ulong teamId,
                                    int itemId,
                                    int count)
        {
            _this.BelongType = type;
            _this.OwnerList  = ownerList;
            _this.TeamId     = teamId;
            _this.ItemId     = itemId;
            _this.Count      = count;
            _this.mDropTime  = DateTime.Now;
            _this.TableDrop  = Table.GetItemBase(itemId);
            var stayseconds = 180;

            switch (type)
            {
            case 0:     //队内自由拾取
            {
                stayseconds = ObjDropItem.StaySecondsByTeamFree;
            }
            break;

            case 1:     //队内伤害拾取
            {
                stayseconds = ObjDropItem.StaySecondsByTeamDamage;
            }
            break;

            case 2:     //队内分别拾取
            {
                stayseconds = ObjDropItem.StaySecondsByTeamAll;
            }
            break;

            case 3:     //所有人分别拾取
            {
                stayseconds = ObjDropItem.StaySecondsByAll;
            }
            break;

            case 99:     //潜规则的类型,5秒消失
            {
                stayseconds      = 5;
                _this.BelongType = 0;
            }
            break;
            }
            _this.mOverTrigger = SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddSeconds(stayseconds), () =>
            {
                _this.TimeOver();
                _this.mOverTrigger = null;
            });

            SceneServerMonitor.CreatedDropItemRate.Mark();
        }
예제 #3
0
        public override void OnPlayerPickItem(ObjPlayer player, ObjDropItem item)
        {
            if (item.ItemId == (int)eResourcesType.GoldRes)
            {
                nPickMoney += item.Count;

                var unit = mFubenInfoMsg.Units[0];
                unit.Params[0]    = nPickMoney;
                mIsFubenInfoDirty = true;
            }
        }
예제 #4
0
 //移除
 public void Remove(ObjDropItem _this)
 {
     if (_this.mOverTrigger != null)
     {
         SceneServerControl.Timer.DeleteTrigger(_this.mOverTrigger);
         _this.mOverTrigger = null;
         if (null != _this.Scene)
         {
             _this.Scene.LeaveScene(_this);
         }
     }
 }
예제 #5
0
 public void Destroy(ObjDropItem _this)
 {
     if (null != _this.mEnterSceneTrigger)
     {
         SceneServerControl.Timer.DeleteTrigger(_this.mEnterSceneTrigger);
         _this.mEnterSceneTrigger = null;
     }
     if (null != _this.mOverTrigger)
     {
         SceneServerControl.Timer.DeleteTrigger(_this.mOverTrigger);
         _this.mOverTrigger = null;
     }
 }
예제 #6
0
 //进入场景
 public void EnterScene(ObjDropItem _this, Scene scene, int delayTime = 0)
 {
     if (delayTime < 50)
     {
         scene.EnterScene(_this);
         return;
     }
     _this.mEnterSceneTrigger = SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddMilliseconds(delayTime),
                                                                       () =>
     {
         scene.EnterScene(_this);
         _this.mEnterSceneTrigger = null;
     });
 }
예제 #7
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();
 }
예제 #8
0
        public ObjDropItem CreateDropItem(Scene _this,
                                          int type,
                                          List <ulong> ownerList,
                                          ulong teamId,
                                          int itemId,
                                          int count,
                                          Vector2 pos)
        {
            if (count <= 0)
            {
                return(null);
            }
            var item = new ObjDropItem(type, ownerList, teamId, itemId, count);

            item.InitBase(_this.GenerateNextId(), itemId);

            PlayerLog.WriteLog((int)LogType.DropItem, "CreateDropItem  Id ={0} SceneId={1} pos={2},{3}", item.ObjId,
                               _this.TypeId, pos.X, pos.Y);
            var randomRadian = MyRandom.Random() * 2 * Math.PI;

            const float MaxDistance = 10f;
            const float MinDistance = 6f;

            var distance  = MyRandom.Random((int)MinDistance, (int)MaxDistance) / 10.0f;
            var targetPos = pos +
                            new Vector2(distance * (float)Math.Cos(randomRadian), distance * (float)Math.Sin(randomRadian));

            if (SceneObstacle.ObstacleValue.Obstacle == _this.GetObstacleValue(targetPos.X, targetPos.Y))
            {
                item.SetPosition(pos);
            }
            else
            {
                item.SetPosition(targetPos);
            }
            item.OrginPos = pos;
            _this.EnterScene(item);

            return(item);
        }
예제 #9
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;
                    }
                }
            }
        }
예제 #10
0
        //拾取
        public bool Pickup(ObjDropItem _this, ObjPlayer picker)
        {
            if (picker.mIsDead)//死亡玩家尸体无法拾取
            {
                return(false);
            }
            var IsCan = false;

            if ((picker.GetPosition() - _this.GetPosition()).LengthSquared() > ObjDropItem.PickDistanceSquared)
            {
                return(false);
            }
            if (_this.IsOwnerList(picker.ObjId))
            {
                IsCan = true;
            }
            else
            {
                switch (_this.BelongType)
                {
                case 0:     //队内自由拾取
                {
                    if (DateTime.Now >= _this.mDropTime.AddSeconds(ObjDropItem.SafeSecondsByTeamFree))
                    {
                        IsCan = true;
                    }
                }
                break;

                case 1:     //队内伤害拾取
                {
                    if (_this.TeamId == 0)
                    {
//没有队
                        if (DateTime.Now >= _this.mDropTime.AddSeconds(ObjDropItem.TeamSecondsByTeamDamage))
                        {
                            IsCan = true;
                        }
                    }
                    else if (picker.GetTeamId() == _this.TeamId)
                    {
//本队成员
                        if (DateTime.Now >= _this.mDropTime.AddSeconds(ObjDropItem.SafeSecondsByTeamDamage))
                        {
                            IsCan = true;
                        }
                    }
                    else
                    {
//非本队成员
                        if (DateTime.Now >= _this.mDropTime.AddSeconds(ObjDropItem.TeamSecondsByTeamDamage))
                        {
                            IsCan = true;
                        }
                    }
                }
                break;

                case 2:     //队内分别拾取
                {
                }
                break;

                case 3:     //所有人分别拾取
                {
                }
                break;

                case 4:
                {
                    IsCan = true;
                }
                break;
                }
            }
            if (IsCan)
            {
                PushPick(_this, picker);
            }
            return(IsCan);
        }
예제 #11
0
 public void TimeOver(ObjDropItem _this)
 {
     PlayerLog.WriteLog((int)LogType.DropItem, "TimeOver  Id ={0}", _this.ObjId);
     _this.Remove();
 }
예제 #12
0
 //是否在优先拾取列表
 public bool IsOwnerList(ObjDropItem _this, ulong pickerId)
 {
     return(_this.OwnerList.Contains(pickerId));
 }
예제 #13
0
        public override void OnPlayerPickItem(ObjPlayer player, ObjDropItem item)
        {
            if (player.mIsDead)
            {
                return;
            }
            if (item.TableDrop.Type != 300)
            {
                return;
            }
            var tbChecken = Table.GetChecken(item.TableDrop.Exdata[0]);

            if (tbChecken == null)
            {
                return;
            }
            var p = _playerList.Find(r => r.objId == player.ObjId);

            if (p == null)
            {
                return;
            }

            //播放特效
            player.Proxy.NotifyPlayEffect(700);

            //添加经验
            OnPlayerGetExp(player, p, tbChecken.ExData1);
            int idx = _playerList.FindIndex(r => r.objId == player.ObjId);

            //添加吃鸡的积分
            if (_playerList[idx] != null)
            {
                _playerList[idx].point += tbChecken.ExData2;
            }

            //添加Buff
            player.AddBuff(tbChecken.BuffId, 1, player);
            //添加道具
            Dict_int_int_Data data = new Dict_int_int_Data();

            for (int i = 0; i < tbChecken.ItemID.Length && i < tbChecken.Num.Length; i++)
            {
                if (tbChecken.ItemID[i] > 0 && tbChecken.Num[i] > 0)
                {
                    data.Data.Add(tbChecken.ItemID[i], tbChecken.Num[i]);
                }
            }
            for (int i = 0; i < dropBuffList.Count; i++)
            {
                if (item.ObjId == dropBuffList[i].ObjId)
                {
                    dropBuffList.RemoveAt(i);
                    break;
                }
            }
            for (int i = 0; i < dropChickenList.Count; i++)
            {
                if (item.ObjId == dropChickenList[i].ObjId)
                {
                    dropChickenList.RemoveAt(i);
                    break;
                }
            }

            CoroutineFactory.NewCoroutine(GiveItemList, player, data).MoveNext();
        }