Example #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);
        }
Example #2
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);
        }