Ejemplo n.º 1
0
 public override void Resize(Rct _newRct)
 {
     base.Resize(_newRct);
     m_messages.Resize(new Rct(Rct.Left, 0, Rct.Width, MESSAGES_HEIGHT));
     m_map.Resize(new Rct(ContentRct.Left, m_messages.Rct.Height, Rct.Width, Rct.Height - m_messages.Rct.Height - STAT_HEIGHT));
     m_stats.Resize(new Rct(0, Rct.Bottom - STAT_HEIGHT + 1, Rct.Width, STAT_HEIGHT));
 }
Ejemplo n.º 2
0
 public override void Resize(Rct _newRct)
 {
     base.Resize(_newRct);
     World.TheWorld.LiveMap.SetViewPortSize(new Point(ContentRct.Width, ContentRct.Height));
     World.TheWorld.LiveMap.Reset();
     World.TheWorld.UpdateDPoint();
 }
Ejemplo n.º 3
0
        public SelectTargetUiBlock(TurnMessageUiBlock _messages, Rct _mapRct, AskMessage _message)
            : base(_mapRct, null, FColor.Gray)
        {
            m_messages    = _messages;
            m_act         = _message.Act;
            m_maxDistance = _message.GetFirstParameter <int>();
            var points = new List <Point>();

            for (var x = -m_maxDistance; x < m_maxDistance; ++x)
            {
                for (var y = -m_maxDistance; y < m_maxDistance; ++y)
                {
                    var point = new Point(x, y);
                    if (point.Lenght > m_maxDistance)
                    {
                        continue;
                    }

                    var liveCell = World.TheWorld.Avatar[point];
                    if (liveCell.Creature != null && !liveCell.Creature.IsAvatar)
                    {
                        points.Add(point);
                    }
                }
            }

            m_targets.AddRange(points.Where(_point => _point.Lenght < m_maxDistance).OrderBy(_point => _point.Lenght));

            Rebuild();
        }
Ejemplo n.º 4
0
        public override void Prepare()
        {
            TArrowLine Line, Lnb;
            Point P1 = new Point(), P2 = new Point(), VP = new Point();
            int tmp_x;
            TTfeRectShape Rct;
            TTfeRhombShape Rhomb;

            Rct = (TTfeRectShape)(GetWorkShape(0));
            Rhomb = (TTfeRhombShape)(GetWorkShape(1));
            Rct.GetTailPoint(0, ref P1);
            Rhomb.GetTailPoint(0, ref P2);
            VP.X = P1.X - 4 * F_Step;
            VP.Y = P2.Y;

            //1
            Line = (TArrowLine)(GetWorkLine(0));
            Line.xStart = StartPoint.X;
            Line.yStart = StartPoint.Y;
            Line.xEnd = VP.X;
            Line.yEnd = VP.Y;
            Line.Bend = CalcBend(Line.xStart, Line.xEnd);
            Lnb = Line;

            //2
            Line = (TArrowLine)(GetWorkLine(1));
            Line.xStart = Lnb.xEnd;
            Line.yStart = Lnb.yEnd;
            Line.xEnd = P1.X;
            Line.yEnd = P1.Y;
            Line.Bend = 2;

            Rct.GetTailPoint(1, ref P1);
            Rhomb.GetTailPoint(1, ref P2);
            //3
            Line = (TArrowLine)(GetWorkLine(2));
            Line.xStart = P1.X;
            Line.yStart = P1.Y;
            Line.xEnd = P2.X;
            Line.yEnd = P2.Y;
            Line.Bend = 1;

            Rhomb.GetTailPoint(0, ref P1);
            //4
            Line = (TArrowLine)(GetWorkLine(3));
            Line.xStart = P1.X;
            Line.yStart = P1.Y;
            Line.xEnd = Lnb.xEnd;
            Line.yEnd = Lnb.yEnd;

            //5
            Rhomb.GetTailPoint(2, ref P1);
            Line = (TArrowLine)(GetWorkLine(4));
            Line.xStart = P1.X;
            Line.yStart = P1.Y;
            Line.xEnd = P1.X + 2 * F_Step;
            Line.yEnd = P1.Y;

            base.Prepare();
        }
        void mainPointerManager_Removed(object sender, PointerManagerEvent e)
        {
            if (!(DataContext as AttributeTransformationViewModel).IsDraggable)
            {
                return;
            }
            if (_shadow == null &&
                _manipulationStartTime + TimeSpan.FromSeconds(0.5).Ticks > DateTime.Now.Ticks)
            {
                if ((DataContext as AttributeTransformationViewModel).IsMenuEnabled && InputFieldViewModelTapped != null)
                {
                    Debug.WriteLine("--TAPP");
                    InputFieldViewModelTapped(this, new EventArgs());
                }
            }

            if (_shadow != null)
            {
                InkableScene inkableScene = MainViewController.Instance.InkableScene;

                Rct bounds = _shadow.GetBounds(inkableScene);
                (DataContext as AttributeTransformationViewModel).FireDropped(bounds,
                                                                              new AttributeTransformationModel((DataContext as AttributeTransformationViewModel).AttributeTransformationModel.AttributeModel)
                {
                    AggregateFunction = (DataContext as AttributeTransformationViewModel).AttributeTransformationModel.AggregateFunction
                });

                inkableScene.Remove(_shadow);
                _shadow = null;
            }

            _manipulationStartTime = 0;
        }
Ejemplo n.º 6
0
 public SelectDestinationUiBlock(TurnMessageUiBlock _messages, Rct _mapRct, Act _act)
     : base(_mapRct, null, FColor.Gray)
 {
     m_messages = _messages;
     m_act      = _act;
     Rebuild();
 }
Ejemplo n.º 7
0
 public Room(Rct _roomRect, Rct _areaRect, Point _blockId)
 {
     RoomRectangle = _roomRect;
     AreaRectangle = _areaRect;
     BlockId       = _blockId;
     ConnectedTo   = new List <Room>();
 }
Ejemplo n.º 8
0
        private static Room MakeRoom(Rct _rct, Random _random, ICollection <Point> _objects, Point _blockId)
        {
            var contains = new List <Point>();

            foreach (var point in _objects)
            {
                if (_rct.Contains(point))
                {
                    contains.Add(point);
                }
            }

            var size = new Point(MIN_ROOM_SIZE + _random.Next(_rct.Width - MIN_ROOM_SIZE), MIN_ROOM_SIZE + _random.Next(_rct.Height - MIN_ROOM_SIZE));

            for (;;)
            {
                var xy   = new Point(_random.Next(_rct.Width - size.X + 1), _random.Next(_rct.Height - size.Y + 1));
                var rect = new Rct(_rct.LeftTop + xy, size.X, size.Y);
                if (contains.Count == 0 || contains.All(rect.Contains))
                {
                    foreach (var contain in contains)
                    {
                        _objects.Remove(contain);
                    }
                    return(new Room(rect, _rct, _blockId));
                }
            }
        }
Ejemplo n.º 9
0
        public WorldMapGenerator(int _size, Random _rnd)
        {
            m_rnd  = _rnd;
            m_size = _size;
            m_sqr  = m_size * m_size;
            m_map  = new ushort[m_size, m_size];
            m_rct  = new Rct(0, 0, m_size, m_size);

            m_zones         = m_imax = m_size * m_size / 2;
            m_forbidToUnite = new bool[m_imax + 1];
            m_sizes         = new int[m_imax + 1];
            m_neighbours    = new bool[m_imax + 1, m_imax + 1];
            m_united        = new ushort[m_imax + 1];

            m_infos.Add(EMapBlockTypes.SEA, new MapTypeInfo(BORDER_WATER_PART));
            m_infos.Add(EMapBlockTypes.DEEP_SEA, new MapTypeInfo(0));
            m_infos.Add(EMapBlockTypes.COAST, new MapTypeInfo(0));
            m_infos.Add(EMapBlockTypes.LAKE_COAST, new MapTypeInfo(LAKE_COAST_PART));
            m_infos.Add(EMapBlockTypes.FRESH_WATER, new MapTypeInfo(LAKE_PART));
            m_infos.Add(EMapBlockTypes.DEEP_FRESH_WATER, new MapTypeInfo(0));
            m_infos.Add(EMapBlockTypes.ETERNAL_SNOW, new MapTypeInfo(MOUNT_PART));
            m_infos.Add(EMapBlockTypes.MOUNT, new MapTypeInfo(0));
            m_infos.Add(EMapBlockTypes.GROUND, new MapTypeInfo(0));
            m_infos.Add(EMapBlockTypes.FOREST, new MapTypeInfo(FOREST_PART));
            m_infos.Add(EMapBlockTypes.SWAMP, new MapTypeInfo(SWAMP_PART));
            m_infos.Add(EMapBlockTypes.SHRUBS, new MapTypeInfo(0));
        }
Ejemplo n.º 10
0
        public override void MoveTo(Pt lastInkPt)
        {
            Vec delta = hitPt - AllStroqs.First()[0] + lastInkPt - moveStrokeStart;
            Rct r     = AllStroqs.GetBounds();

            AllStroqs.Move(delta);
        }
Ejemplo n.º 11
0
 public void FireDropped(Rct bounds, AttributeGroupModel attributeGroupModel)
 {
     if (InputGroupViewModelDropped != null)
     {
         InputGroupViewModelDropped(this, new InputGroupViewModelEventArgs(bounds, attributeGroupModel));
     }
 }
        private void updateRendering()
        {
            var c = new Canvas();
            var filterLinkViewModel = DataContext as FilterLinkViewModel;

            if (filterLinkViewModel.FromOperationViewModels.Count > 0)
            {
                _visualizationViewModelGeometries.Clear();
                _visualizationViewModelCenterGeometries.Clear();
                _visualizationViewModelIconGeometries.Clear();

                var destinationRct = new Rct(filterLinkViewModel.ToOperationViewModel.Position,
                                             new Vec(filterLinkViewModel.ToOperationViewModel.Size.X, filterLinkViewModel.ToOperationViewModel.Size.Y));

                var attachmentCenter   = updateAttachmentCenter(LinkType.Filter, c);
                var attachmentLocation = getAttachmentLocation(destinationRct, attachmentCenter);

                drawLinesFromModelsToAttachmentCenter(LinkType.Filter, attachmentCenter, c);
                if (filterLinkViewModel.FilterLinkModels.Any(lm => lm.LinkType == LinkType.Filter))
                {
                    drawFilterAttachment(attachmentCenter, c, attachmentLocation);
                }

                attachmentCenter = updateAttachmentCenter(LinkType.Brush, c);
                drawLinesFromModelsToAttachmentCenter(LinkType.Brush, attachmentCenter, c);
                if (filterLinkViewModel.FilterLinkModels.Any(lm => lm.LinkType == LinkType.Brush))
                {
                    drawBrushAttachment(attachmentCenter, c);
                }
            }
            Content = c;
        }
Ejemplo n.º 13
0
        public void createShadow(Point fromInkableScene)
        {
            InkableScene inkableScene = MainViewController.Instance.InkableScene;

            if (inkableScene != null && DataContext != null)
            {
                _currentFromInkableScene = fromInkableScene;
                _shadow             = new AttributeGroupView();
                _shadow.DataContext = new InputGroupViewModel()
                {
                    AttributeOperationModel = (DataContext as InputGroupViewModel).AttributeOperationModel,
                    IsShadow = true
                };


                _shadow.Measure(new Size(double.PositiveInfinity,
                                         double.PositiveInfinity));

                _shadow.Width  = this.ActualWidth;
                _shadow.Height = _shadow.DesiredSize.Height;

                _shadow.RenderTransform = new TranslateTransform()
                {
                    X = fromInkableScene.X - _shadow.Width / 2.0,
                    Y = fromInkableScene.Y - _shadow.Height
                };


                inkableScene.Add(_shadow);
                _shadow.SendToFront();

                Rct bounds = _shadow.GetBounds(inkableScene);
                (DataContext as InputGroupViewModel).FireMoved(bounds, (DataContext as InputGroupViewModel).AttributeOperationModel);
            }
        }
Ejemplo n.º 14
0
        void mainPointerManager_Moved(object sender, PointerManagerEvent e)
        {
            if (e.NumActiveContacts == 1)
            {
                GeneralTransform gt           = this.TransformToVisual(MainViewController.Instance.InkableScene);
                Point            currentPoint = gt.TransformPoint(e.CurrentContacts[e.TriggeringPointer.PointerId].Position);

                Vec delta = gt.TransformPoint(e.StartContacts[e.TriggeringPointer.PointerId].Position).GetVec() - currentPoint.GetVec();

                if (delta.Length > 10 && _shadow == null)
                {
                    createShadow(currentPoint);
                }

                if (_shadow != null)
                {
                    InkableScene inkableScene = MainViewController.Instance.InkableScene;
                    _shadow.RenderTransform = new TranslateTransform()
                    {
                        X = currentPoint.X - _shadow.Width / 2.0,
                        Y = currentPoint.Y - _shadow.Height
                    };
                    if (inkableScene != null)
                    {
                        inkableScene.Add(_shadow);

                        Rct bounds = _shadow.GetBounds(inkableScene);
                        (DataContext as InputGroupViewModel).FireMoved(bounds, (DataContext as InputGroupViewModel).AttributeOperationModel);
                    }
                }

                _mainPointerManagerPreviousPoint = currentPoint;
            }
        }
Ejemplo n.º 15
0
 public ConfirmQuitBlock()
     : base(new Rct(2, 2, 15, 5), Frame.Frame1, FColor.Black)
 {
     ContentRct = new Rct(ContentRct.Left + 1,
                          ContentRct.Top,
                          ContentRct.Width - 1 * 2,
                          ContentRct.Height);
 }
Ejemplo n.º 16
0
 protected UIBlock(Rct _rct, Frame _frame, FColor _color)
 {
     BlockFrame      = _frame;
     ForeColor       = _color;
     Rct             = _rct;
     BackgroundColor = new FColor(1, 0, 0, 0);
     UpdateContentRct();
 }
Ejemplo n.º 17
0
 public void ClearTiles(Rct _rct, FColor _backgroundColor)
 {
     if (m_gameProvider.TileMapRenderer == null)
     {
         return;
     }
     m_gameProvider.TileMapRenderer.Clear(_rct, _backgroundColor);
 }
Ejemplo n.º 18
0
        public BackpackUiBlock(Rct _rct, AskMessage _message)
            : base(_rct, _message.GetFirstParameter <ESelectItemDialogBehavior>(), _message.Act, World.TheWorld.Avatar.GetBackPackItems().OrderBy(_thingDescriptor => _thingDescriptor.UiOrderIndex))

        {
            var category = _message.GetParameters <EItemCategory>();

            m_allowedCategories = category ?? new EItemCategory[0];
        }
Ejemplo n.º 19
0
 public BackpackUiBlock(Rct _rct)
     : base(
         _rct,
         ESelectItemDialogBehavior.ALLOW_CHANGE_FILTER,
         null,
         World.TheWorld.Avatar.GetBackPackItems().OrderBy(_thingDescriptor => _thingDescriptor.UiOrderIndex))
 {
     m_allowedCategories = new EItemCategory[0];
 }
Ejemplo n.º 20
0
        public static Rct Bounds(IEnumerable <Pt> pc, Mat xform)
        {
            Rct bounds = Rct.Null;

            foreach (Pt p in pc)
            {
                bounds = bounds.Union(xform * p);
            }
            return(bounds);
        }
Ejemplo n.º 21
0
        static public Geometry ComputeGeometry(Expr e, double fsize, out Rct nombbox)
        {
            EDrawingContext edc = new EDrawingContext(fsize, null, Colors.Black);
            EWPF            us  = new EWPF(false);
            Box             b   = us.Compose(e);

            b.Measure(edc);
            nombbox = b.nombbox;
            return(b.ComputeGeometry(edc));
        }
Ejemplo n.º 22
0
 protected ItemsSelectorUiBlock(Rct _rct,
                                ESelectItemDialogBehavior _behavior,
                                Act _act,
                                IEnumerable <EssenceDescriptor> _descriptors)
     : base(_rct, Frame.Frame2, FColor.Green)
 {
     m_behavior      = _behavior;
     m_act           = _act;
     m_currentFilter = '*';
     m_descriptors   = _descriptors;
 }
 public static GeoAPI.Geometries.ILineString GetLineString(this Rct r)
 {
     GeoAPI.Geometries.Coordinate[] coords;
     coords    = new GeoAPI.Geometries.Coordinate[5];
     coords[0] = new GeoAPI.Geometries.Coordinate(r.TopLeft.X, r.TopLeft.Y);
     coords[1] = new GeoAPI.Geometries.Coordinate(r.TopRight.X, r.TopRight.Y);
     coords[2] = new GeoAPI.Geometries.Coordinate(r.BottomRight.X, r.BottomRight.Y);
     coords[3] = new GeoAPI.Geometries.Coordinate(r.BottomLeft.X, r.BottomLeft.Y);
     coords[4] = new GeoAPI.Geometries.Coordinate(r.TopLeft.X, r.TopLeft.Y);
     return(new NetTopologySuite.Geometries.LineString(coords));
 }
Ejemplo n.º 24
0
 public virtual void AddedToBlock(BaseMapBlock _mapBlock)
 {
     BlockId            = _mapBlock.BlockId;
     WorldRoomRectangle = new Rct
                          (
         RoomRectangle.Left + BlockId.X * Constants.MAP_BLOCK_SIZE,
         RoomRectangle.Top + BlockId.Y * Constants.MAP_BLOCK_SIZE,
         RoomRectangle.Width,
         RoomRectangle.Height);
     RandomSeed = _mapBlock.RandomSeed + RoomRectangle.LeftTop.GetHashCode();
 }
        public static IEnumerable <Pt> GetPoints(this Rct r)
        {
            List <Pt> pts = new List <Pt>();

            pts.Add(r.TopLeft);
            pts.Add(r.TopRight);
            pts.Add(r.BottomRight);
            pts.Add(r.BottomLeft);
            pts.Add(r.TopLeft);

            return(pts);
        }
Ejemplo n.º 26
0
 public SelectToTakeOnUiBlock(Rct _rct,
                              EquipmentUiBlock _equipmentUiBlock,
                              EquipmentPresenter _equipmentPresenter) :
     base(
         _rct,
         ESelectItemDialogBehavior.SELECT_ONE,
         null,
         _equipmentUiBlock.Intelligent.GetBackPackItems())
 {
     m_equipmentPresenter = _equipmentPresenter;
     m_equipmentUiBlock   = _equipmentUiBlock;
 }
Ejemplo n.º 27
0
        override public void Prepare()
        {
            TArrowLine    Line, Lnb;
            Point         P1 = new Point(), P2 = new Point();
            int           tmp_x;
            TTfeRectShape Rct;
            TTfeEllShape  Ell;

            Rct = (TTfeRectShape)(GetWorkShape(0));
            Ell = (TTfeEllShape)(GetWorkShape(1));
            Rct.GetTailPoint(0, ref P1);
            Line        = (TArrowLine)(GetWorkLine(0));
            Line.xStart = StartPoint.X;
            Line.yStart = StartPoint.Y;
            Line.xEnd   = P1.X - 2 * F_Step;
            Line.yEnd   = P1.Y;
            Line.Bend   = CalcBend(Line.xStart, Line.xEnd);
            Lnb         = Line;

            Line        = (TArrowLine)(GetWorkLine(1));
            Line.xStart = Lnb.xEnd;
            Line.yStart = Lnb.yEnd;
            Line.xEnd   = P1.X;
            Line.yEnd   = P1.Y;

            Rct.GetTailPoint(1, ref P1);
            Ell.GetTailPoint(0, ref P2);

            Line        = (TArrowLine)(GetWorkLine(2));
            Line.xStart = P1.X;
            Line.yStart = P1.Y;
            Line.xEnd   = P2.X;
            Line.yEnd   = P2.Y;

            Rct.GetTailPoint(0, ref P1);
            Ell.GetTailPoint(1, ref P2);

            Line        = (TArrowLine)(GetWorkLine(3));
            Line.xStart = P1.X;
            Line.yStart = P1.Y;
            Line.xEnd   = P2.X;
            Line.yEnd   = P2.Y;

            Ell.GetTailPoint(2, ref P2);
            Line        = (TArrowLine)(GetWorkLine(4));
            Line.xStart = P2.X;
            Line.yStart = P2.Y;
            Line.xEnd   = P2.X + 2 * F_Step;
            Line.yEnd   = P2.Y;

            base.Prepare();
        }
Ejemplo n.º 28
0
        public void DrawRect(Rct _rct, FColor _toFColor)
        {
            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.Color4(_toFColor.R, _toFColor.G, _toFColor.B, _toFColor.A);

            GL.Begin(BeginMode.Quads);
            GL.Vertex2(_rct.Left, _rct.Top);
            GL.Vertex2(_rct.Right + 1, _rct.Top);
            GL.Vertex2(_rct.Right + 1, _rct.Bottom + 1);
            GL.Vertex2(_rct.Left, _rct.Bottom + 1);
            GL.End();
        }
Ejemplo n.º 29
0
        public static TextBox MakeText(string text, Rct rct)
        {
            TextBox tb         = new TextBox();
            Pt      loc        = rct.BottomLeft;
            double  fontHeight = rct.Height / 2;

            tb.Text            = text;
            tb.FontSize        = fontHeight;
            tb.AcceptsReturn   = true;
            tb.BorderThickness = new Thickness(0);
            tb.RenderTransform = new TranslateTransform(loc.X, loc.Y - tb.FontSize * 2);
            tb.Focusable       = true;
            return(tb);
        }
Ejemplo n.º 30
0
        public Bitmap this[ETextureSet _texture, int _x, int _y, FColor _fColor, bool _removeTransparency, bool _grayScale, bool _isTerrain, bool _plusHalfX, bool _plusHalfY]
        {
            get
            {
                Dictionary <Tuple <int, int, FColor, bool, bool, bool, bool>, Bitmap> dictionary;
                if (!m_tiles.TryGetValue(_texture, out dictionary))
                {
                    dictionary        = new Dictionary <Tuple <int, int, FColor, bool, bool, bool, bool>, Bitmap>();
                    m_tiles[_texture] = dictionary;
                }
                Bitmap bitmap;
                var    key = new Tuple <int, int, FColor, bool, bool, bool, bool>(_x, _y, _fColor, _removeTransparency, _grayScale, _plusHalfX, _plusHalfY);
                if (!dictionary.TryGetValue(key, out bitmap))
                {
                    var txtr = this[_texture, _isTerrain];
                    bitmap = new Bitmap(Constants.TILE_SIZE, Constants.TILE_SIZE);
                    using (var gr = Graphics.FromImage(bitmap))
                    {
                        gr.DrawImage(txtr, 0, 0, new Rectangle(
                                         Constants.TILE_SIZE * _x + (_plusHalfX ? (Constants.TILE_SIZE / 2) : 0),
                                         Constants.TILE_SIZE * _y + (_plusHalfY ? (Constants.TILE_SIZE / 2) : 0),
                                         Constants.TILE_SIZE, Constants.TILE_SIZE), GraphicsUnit.Pixel);
                    }
                    var transparent = txtr.GetPixel(0, 0);
                    var rct         = new Rct(0, 0, Constants.TILE_SIZE, Constants.TILE_SIZE);
                    foreach (var point in rct.AllPoints)
                    {
                        var pixel = bitmap.GetPixel(point.X, point.Y);
                        if (pixel == transparent)
                        {
                            continue;
                        }
                        var fcolor = new FColor(pixel.A, pixel.R, pixel.G, pixel.B).Multiply(1f / 255f);
                        if (_grayScale)
                        {
                            fcolor = fcolor.ToGrayScale();
                        }
                        var result = fcolor.Multiply(_fColor).GetColor();                        //.Multiply(255);
                        if (_removeTransparency)
                        {
                            result.A = 255;
                        }
                        bitmap.SetPixel(point.X, point.Y, Color.FromArgb(result.A, result.R, result.G, result.B));
                    }

                    dictionary.Add(key, bitmap);
                }
                return(bitmap);
            }
        }