Exemplo n.º 1
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);
        }