示例#1
0
 public PowderKeg(Game game, Texture2D texture2D, Point coordinatesPoint, int squareSize, SoundEffect explosionEffect)
     : base(game, texture2D, coordinatesPoint, squareSize)
 {
     radiusExplosion = 100;
     damage = 50;
     this.explosionEffect = explosionEffect;
 }
        public void Render(RendererParameters parameters)
        {
            parameters.ThrowIfNull("parameters");

            if (!_state.Enabled || _state.TopLeftSelectionCoordinate == null)
            {
                return;
            }

            const int tileWidth = TextAdventure.Xna.Constants.Tile.TileWidth;
            const int tileHeight = TextAdventure.Xna.Constants.Tile.TileHeight;
            var topLeftPoint = new Point(
                _editorView.TopLeftPoint.X + (_state.TopLeftSelectionCoordinate.Value.X * tileWidth),
                _editorView.TopLeftPoint.Y + (_state.TopLeftSelectionCoordinate.Value.Y * tileHeight));
            var destinationRectangle = new Rectangle(topLeftPoint.X, topLeftPoint.Y, tileWidth * _state.SelectionSize, tileHeight * _state.SelectionSize);
            var topLine = new Rectangle(destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width, 1);
            var bottomLine = new Rectangle(destinationRectangle.X, destinationRectangle.Bottom - 1, destinationRectangle.Width, 1);
            var leftLine = new Rectangle(destinationRectangle.X, destinationRectangle.Y, 1, destinationRectangle.Height);
            var rightLine = new Rectangle(destinationRectangle.Right - 1, destinationRectangle.Y, 1, destinationRectangle.Height);
            Texture2D pixelTexture = parameters.TextureContent.Pixel;

            parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, new ScissoringRasterizerState());

            parameters.SpriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, _editorView.VisibleBoardSizeInPixels.Width, _editorView.VisibleBoardSizeInPixels.Height);

            parameters.SpriteBatch.Draw(pixelTexture, topLine, Color.Red);
            parameters.SpriteBatch.Draw(pixelTexture, bottomLine, Color.Red);
            parameters.SpriteBatch.Draw(pixelTexture, leftLine, Color.Red);
            parameters.SpriteBatch.Draw(pixelTexture, rightLine, Color.Red);

            parameters.SpriteBatch.End();
        }
示例#3
0
文件: Bomb.cs 项目: fiahil/Kaboom
 /// <summary>
 /// Draw the bomb and its patterns on the screen
 /// </summary>
 /// <param name="sb">the spritebatch</param>
 /// <param name="t">the gametime</param>
 /// <param name="p">the position of the bomb</param>
 public override void Draw(SpriteBatch sb, GameTime t, Point p)
 {
     base.Draw(sb, t, p);
     var mapDimension = Viewport.Instance.MapDimensions();
     if (highlight_ != "")
         foreach (
             var elt in
                 pattern_.GetPattern().Where(place => place != null).Select(
                     place => new Point(p.X + place.Point.X, p.Y + place.Point.Y)).Where(
                         temp => temp.X >= 0 && temp.Y >= 0 && temp.X < mapDimension.X && temp.Y < mapDimension.Y)
             )
         {
             sb.Draw(
                 KaboomResources.Textures[highlight_],
                 new Rectangle(
                     (elt.X * Camera.Instance.DimX) + Camera.Instance.OffX,
                     (elt.Y * Camera.Instance.DimY) + Camera.Instance.OffY,
                     Camera.Instance.DimX,
                     Camera.Instance.DimY),
                 KaboomResources.Textures[highlight_].Bounds,
                 Color.White,
                 0.0f,
                 Vector2.Zero,
                 0,
                 0.01f);
         }
 }
示例#4
0
        private void HandleMinimapBrowse(Board selectedBoard, XNA.Point realPosition)
        {
            int h = realPosition.X * selectedBoard.mag - parentBoard.Width / 2;
            int v = realPosition.Y * selectedBoard.mag - parentBoard.Height / 2;

            if (h < 0)
            {
                selectedBoard.hScroll = 0;
            }
            else if (h > parentBoard.maxHScroll)
            {
                selectedBoard.hScroll = parentBoard.maxHScroll;
            }
            else
            {
                selectedBoard.hScroll = h;
            }
            if (v < 0)
            {
                selectedBoard.vScroll = 0;
            }
            else if (v > parentBoard.maxVScroll)
            {
                selectedBoard.vScroll = parentBoard.maxVScroll;
            }
            else
            {
                selectedBoard.vScroll = v;
            }
        }
示例#5
0
 protected override void OnInitialize()
 {
     Position = new Point(0, 0);
     Size = new Point(800, 600);
     AddControl(new ResizePic(this, 0, 0, 3000, 800, 600));
     int rowwidth = 60;
     // caption string
     m_Label = (TextLabel)AddControl(new TextLabel(this, 50, 8, 0, null));
     // object that is hued based on the current overhue.
     m_HueDisplay = (HuedControl)AddControl(new HuedControl(this, 8305));
     LastControl.Position = new Point(745, 15);
     ((HuedControl)LastControl).Hue = 0;
     // unhued object
     AddControl(new HuedControl(this));
     LastControl.Position = new Point(-5, 10);
     ((HuedControl)LastControl).Hue = 0;
     // hue index 1 (uo hue -1), aka one of the "True Black" hues
     AddControl(new HuedControl(this));
     LastControl.Position = new Point(3, 10);
     ((HuedControl)LastControl).Hue = 1;
     for (int i = 0; i < 3000; i++) {
         AddControl(new HuedControl(this));
         LastControl.Position = new Point((i % rowwidth) * 11 - 5, (i / rowwidth) * 10 + 28);
         ((HuedControl)LastControl).Hue = i + 2;
     }
     using (FileStream file = new FileStream("hues0.png", FileMode.Create)) {
         HueData.HueTexture0.SaveAsPng(file, HueData.HueTexture0.Width, HueData.HueTexture0.Height);
     }
     using (FileStream file = new FileStream("hues1.png", FileMode.Create)) {
         HueData.HueTexture1.SaveAsPng(file, HueData.HueTexture1.Width, HueData.HueTexture1.Height);
     }
 }
示例#6
0
        public override void Update()
        {
            PreviousCellPosition = CellPosition;
            CellPosition = Engine.VectorToCell(Position, Dimension);

            base.Update();
        }
示例#7
0
 public ExpandableScroll(Control owner, int page, int x, int y, int height)
     : base(0, 0)
 {
     m_owner = owner;
     Position = new Point(x, y);
     m_expandableScrollHeight = height;
 }
示例#8
0
 public Tilemap(Node parent, string name, Texture2D tileTexture, Point size, Point tileSize)
     : base(parent, name)
 {
     Body = new Body(this, "Body");
     Render = new TilemapRender(this, "TilemapRender", tileTexture, size, tileSize);
     Render.LinkDependency(TilemapRender.DEPENDENCY_BODY, Body);
 }
示例#9
0
 public LayerSection(Rectangle bounds, Point position, int order, Texture2D background)
 {
     _bounds = bounds;
     _position = position;
     _order = order;
     _background = background;
 }
        public void Update( )
        {
            if( _model.Level.ActiveLayer == null )
            {
                return ;
            }

            Vector2 distance = MouseStatus.WorldPosition - _canvas.GrabPoint ;

            if( distance.Length( ) > 0 )
            {
                _canvas.SelectionRectangle = Extensions.RectangleFromVectors( _canvas.GrabPoint, MouseStatus.WorldPosition ) ;

                var itemsCoveredByDragRectangle = _model.ActiveLayer.Items.Where(
                    i =>
                        {
                            var point = new Point( (int) i.ItemProperties.Position.X, (int) i.ItemProperties.Position.Y ) ;

                            return i.ItemProperties.Visible && _canvas.SelectionRectangle.Contains( point ) ;
                        } ).ToList( ) ;

                itemsCoveredByDragRectangle.Reverse( ) ;
                _model.SelectEditors( new SelectedEditors( itemsCoveredByDragRectangle ) ) ;
            }

            if( MouseStatus.LeftButton == ButtonState.Released )
            {
                _canvas.SetModeToIdle( ) ;
            }
        }
示例#11
0
        public void ColorAtPositionNegativeTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            Assert.AreEqual( null, block.ColorAt( position ) );
        }
 public void SetyoucelanContent(Microsoft.Xna.Framework.Point viewportSize)
 {
     //if (content is FrameContent)
     //{
     this.tabList.SetyoucelanContent(viewportSize);
     //}
 }
示例#13
0
 public Platform(Game game, Texture2D texture2D, int squareSize, Point coordinatesPoint)
     : base(game, texture2D)
 {
     PositionRectangle = new Rectangle(squareSize*coordinatesPoint.X, squareSize*coordinatesPoint.Y, squareSize,
         squareSize);
     IsGravity = false;
 }
        protected void ApplyBrushPaint(List <int> brushTileIndex)
        {
            if (brushTileIndex.Count < 1)
            {
                return;
            }

            int layer = TileGridEditor.Instance.SelectedLayer;
            int count = 0;

            for (int x = 0; x < _brushSize.X; x++)
            {
                for (int y = 0; y < _brushSize.Y; y++)
                {
                    Point tileIndex = new Point(x + _brushStartPoint.X, y + _brushStartPoint.Y);
                    if (tileIndex.X < TileGrid.TileCols && tileIndex.Y < TileGrid.TileRows)
                    {
                        int Index = brushTileIndex[0];
                        if (brushTileIndex.Count > count)
                        {
                            Index = brushTileIndex[count];
                        }
                        TileGrid.TileLayers[layer].Tiles[tileIndex.X][tileIndex.Y].Index    = Index;
                        TileGrid.TileLayers[layer].Tiles[tileIndex.X][tileIndex.Y].Rotation = 0;
                        TileGrid.TileLayers[layer].Tiles[tileIndex.X][tileIndex.Y].HFlip    = false;
                        TileGrid.TileLayers[layer].Tiles[tileIndex.X][tileIndex.Y].VFlip    = false;
                    }
                    ++count;
                }
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            var graphicsDevice = SharedGraphicsDeviceManager.Current.GraphicsDevice;

            graphicsDevice.SetSharingMode(true);

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(graphicsDevice);

            // TODO: use this.content to load your game content here
            _t1 = new Texture2D(graphicsDevice, 32, 32);
            _t1.SetData(Enumerable.Repeat(Color.Red, 32 * 32).ToArray());
            _t2 = new Texture2D(graphicsDevice, 32, 32);
            _t2.SetData(Enumerable.Repeat(Color.Green, 32 * 32).ToArray());
            _t3 = new Texture2D(graphicsDevice, 32, 32);
            _t3.SetData(Enumerable.Repeat(Color.Blue, 32 * 32).ToArray());
            _textures = new[] { _t1, _t2, _t3 };
            _levels   = new int[4 * 4]
            {
                2, 0, 0, 0,
                0, 0, 1, 0,
                1, 1, 1, 0,
                0, 0, 0, 1,
            };
            _player = new Point();

            TouchPanel.EnabledGestures = GestureType.Flick;
            // Start the timer
            _timer.Start();

            base.OnNavigatedTo(e);
        }
示例#16
0
        public override void GetCurrentFrame(ref Microsoft.Xna.Framework.Point currentFrame)
        {
            switch (DrawDirection)
            {
            case Direction.Up:
                currentFrame.X = 129;
                currentFrame.Y = 2;
                break;

            case Direction.Left:
                currentFrame.X = 162;
                currentFrame.Y = 1;
                break;

            case Direction.Right:
                currentFrame.X = 225;
                currentFrame.Y = 1;
                break;

            case Direction.Down:
                currentFrame.X = 193;
                currentFrame.Y = 1;
                break;

            default:
                break;
            }
        }
示例#17
0
 public void UpdateOffsetControls()
 {
     DisableEvents();
     if (offsetListBox.SelectedIndex < 0)
     {
         defaultChkBox.Enabled = false;
         offsetX.Enabled       = false;
         offsetY.Enabled       = false;
     }
     else
     {
         defaultChkBox.Enabled = true;
         if (LoadedTileSheet.FrameOffsets.ContainsKey(offsetListBox.SelectedIndex))
         {
             defaultChkBox.Checked = false;
             offsetX.Enabled       = true;
             offsetY.Enabled       = true;
             Microsoft.Xna.Framework.Point offset =
                 LoadedTileSheet.FrameOffsets[offsetListBox.SelectedIndex];
             offsetX.Value = offset.X;
             offsetY.Value = offset.Y;
         }
         else
         {
             defaultChkBox.Checked = true;
             offsetX.Value         = 0;
             offsetY.Value         = 0;
             offsetX.Enabled       = false;
             offsetY.Enabled       = false;
         }
     }
     EnableEvents();
 }
示例#18
0
        public void UpdateOffsetList()
        {
            DisableEvents();
            int           oldSelection = offsetListBox.SelectedIndex;
            List <string> offsets      = new List <string>();

            for (int i = 0; i < LoadedTileSheet.TileCount; i++)
            {
                StringBuilder buf = new StringBuilder();
                buf.Append(i);
                buf.Append(": ");
                if (LoadedTileSheet.FrameOffsets.ContainsKey(i))
                {
                    Microsoft.Xna.Framework.Point offset = LoadedTileSheet.FrameOffsets[i];
                    buf.Append("<");
                    buf.Append(offset.X);
                    buf.Append(", ");
                    buf.Append(offset.Y);
                    buf.Append(">");
                }
                else
                {
                    buf.Append("Default");
                }
                offsets.Add(buf.ToString());
            }
            offsetListBox.DataSource    = null;
            offsetListBox.DataSource    = offsets;
            offsetListBox.SelectedIndex = oldSelection;
            EnableEvents();
        }
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            MouseState mouseState = Mouse.GetState();
            Vector2 v = new Vector2(mouseState.X, mouseState.Y) / Camera2D.PhoneScale;
            mousePos = new Point((int)v.X, (int)v.Y);

            //if (keyboardState.IsKeyDown(Keys.F1) && prevKeyboardState.IsKeyUp(Keys.F1))
            //    DebugMode = !DebugMode;

            #if WINDOWS
            if (keyboardState.IsKeyDown(Keys.F2) && prevKeyboardState.IsKeyUp(Keys.F2))
            {
                BitSitsGames.bloom.Visible = !BitSitsGames.bloom.Visible;
                BitSitsGames.bloom.Settings = BloomSettings.PresetSettings[5];
            }

            if (keyboardState.IsKeyDown(Keys.F3) && prevKeyboardState.IsKeyUp(Keys.F3))
            {
                bloomSettingsIndex = (bloomSettingsIndex + 1) %
                                     BloomSettings.PresetSettings.Length;

                BitSitsGames.bloom.Settings = BloomSettings.PresetSettings[bloomSettingsIndex];
            }
            #endif

            if (keyboardState.IsKeyDown(Keys.Space) && prevKeyboardState.IsKeyDown(Keys.Space))
                ShowBonds = !ShowBonds;

            prevKeyboardState = keyboardState;
        }
示例#20
0
文件: Level.cs 项目: MSigma/ZooBurst
 public void Swap(Swap swap)
 {
     var from = new Point(swap.From.X, swap.From.Y);
     var to = new Point(swap.To.X, swap.To.Y);
     _animals[from.X, from.Y] = swap.To; swap.To.MoveTo(from.X, from.Y);
     _animals[to.X, to.Y] = swap.From; swap.From.MoveTo(to.X, to.Y);
 }
示例#21
0
 public void SetLastPosition(string gumpID, Point position)
 {
     if (LastPositions.ContainsKey(gumpID))
         LastPositions[gumpID] = position;
     else
         LastPositions.Add(gumpID, position);
 }
示例#22
0
        public Scientist()
        {
            DrawOrder = 9999;

            pos = new Point(200, 150);
            frameSize = new Point(24, 55);
        }
示例#23
0
 public SignpostBase()
 {
     DimensionsInCells = new Point(1, 2);
     Visible = true;
     RenderLayer = 2;
     Frame = new Rectangle(0, 0, Definitions.CellSizeInPixels, Definitions.CellSizeInPixels + Plate_Vertical_Offset);
 }
示例#24
0
 public Sprite(Texture2D texture, Point offset, Rectangle source, int hue)
 {
     m_Texture = texture;
     m_Offset = offset;
     m_SourceRect = source;
     m_Hue = hue;
 }
 public void Reset(Point point)
 {
     CurrentFrame = point;
     FinishedAnimation = false;
     lastFrameUpdatedTime = 0;
     definition.Loop = true;
 }
示例#26
0
        public Status() : base(30, 30)
        {
            // Setup some fake status
            CellData.Print(1, 0, "SadConsole + RogueSharp".Align(System.Windows.HorizontalAlignment.Center, 29).CreateGradient(Color.Moccasin, Color.Gray, null));

            CellData.Print(2, 2, "Health", Color.GreenYellow);
            CellData.Print(10, 2, new string((char)176, 19).CreateGradient(Color.Red, Color.GreenYellow, null));

            CellData.Print(2, 4, "Energy", Color.GreenYellow);
            CellData.Print(10, 4, new string((char)176, 19).CreateGradient(Color.Blue, Color.GreenYellow, null));


            // Draw a line down the side
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(0, 0);
            line.EndingLocation   = new Point(0, 29);
            new CellAppearance(Color.LightGray, Color.Black, 186, Microsoft.Xna.Framework.Graphics.SpriteEffects.None).CopyAppearanceTo(line.CellAppearance);
            line.UseEndingCell   = false;
            line.UseStartingCell = false;
            line.Draw(this.CellData);


            // Position the console to the right of the map view
            Position = new Microsoft.Xna.Framework.Point(30, 0);
        }
示例#27
0
        private void GetObjsUnderPointFromList(IMapleList list, Point locationVirtualPos, ref BoardItem itemUnderPoint, ref BoardItem selectedUnderPoint, ref bool selectedItemHigher)
        {
            if (!list.IsItem)
            {
                return;
            }
            SelectionInfo sel = selectedBoard.GetUserSelectionInfo();

            if (list.ListType == ItemTypes.None)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    BoardItem item = (BoardItem)list[i];
                    if ((selectedBoard.EditedTypes & item.Type) != item.Type)
                    {
                        continue;
                    }
                    if (IsPointInsideRectangle(locationVirtualPos, item.Left, item.Top, item.Right, item.Bottom) &&
                        !(item is HaCreator.MapEditor.Input.Mouse) &&
                        item.CheckIfLayerSelected(sel) &&
                        !item.IsPixelTransparent(locationVirtualPos.X - item.Left, locationVirtualPos.Y - item.Top))
                    {
                        if (item.Selected)
                        {
                            selectedUnderPoint = item;
                            selectedItemHigher = true;
                        }
                        else
                        {
                            itemUnderPoint     = item;
                            selectedItemHigher = false;
                        }
                    }
                }
            }
            else if ((selectedBoard.EditedTypes & list.ListType) == list.ListType)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    BoardItem item = (BoardItem)list[i];
                    if (IsPointInsideRectangle(locationVirtualPos, item.Left, item.Top, item.Right, item.Bottom) &&
                        !(item is HaCreator.MapEditor.Input.Mouse) &&
                        !(item is HaCreator.MapEditor.Input.Mouse) &&
                        item.CheckIfLayerSelected(sel) &&
                        !item.IsPixelTransparent(locationVirtualPos.X - item.Left, locationVirtualPos.Y - item.Top))
                    {
                        if (item.Selected)
                        {
                            selectedUnderPoint = item;
                            selectedItemHigher = true;
                        }
                        else
                        {
                            itemUnderPoint     = item;
                            selectedItemHigher = false;
                        }
                    }
                }
            }
        }
示例#28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseSprite"/> class.
 /// Sets the position of the sprite by using tiles.
 /// </summary>
 /// <param name="image"> The image of the sprite. </param>
 /// <param name="sourceRectangle"> The source rectangle of the sprite. </param>
 /// <param name="tile"> The tile to set the position of the sprite to. </param>
 public BaseSprite(Texture2D image, Rectangle? sourceRectangle, Point tile)
     : this(image, sourceRectangle)
 {
     this.position = new Vector2(
         tile.X * Engine.TileWidth,
         tile.Y * Engine.TileHeight);
 }
示例#29
0
 public void HandleInput(Point screenInputTouchPosition)
 {
     if(showing)
     {
         HandleTouchInput(screenInputTouchPosition);
     }
 }
        public override void Draw(SpriteBatchUI spriteBatch, Point position)
        {
            bool isMouseOver = (m_BG[0].IsMouseOver || m_BG[1].IsMouseOver || m_BG[2].IsMouseOver);
            if (m_IsMouseDown)
            {
                m_BG[0].IsVisible = false;
                m_BG[1].IsVisible = false;
                m_BG[2].IsVisible = true;

            }
            else if (isMouseOver)
            {
                m_BG[0].IsVisible = false;
                m_BG[1].IsVisible = true;
                m_BG[2].IsVisible = false;
            }
            else
            {
                m_BG[0].IsVisible = true;
                m_BG[1].IsVisible = false;
                m_BG[2].IsVisible = false;
            }

            if (m_IsMouseDown)
                m_Caption.Position = new Point(m_Caption.Position.X, m_Caption.Position.Y + 1);

            base.Draw(spriteBatch, position);

            if (m_IsMouseDown)
                m_Caption.Position = new Point(m_Caption.Position.X, m_Caption.Position.Y - 1);
        }
示例#31
0
 void BuildGumpling(int x, int y, int font, int hue, string text)
 {
     Position = new Point(x, y);
     Hue = hue;
     FontID = font;
     Text = text;
 }
示例#32
0
 public Collectable()
 {
     DimensionsInCells = new Point(1, 1);
     Visible = true;
     RenderLayer = 2;
     Frame = new Rectangle(0, 0, Definitions.CellSizeInPixels, Definitions.CellSizeInPixels);
 }
示例#33
0
 public PushAnim(Texture2D image, PlayerAvatar pusher, Vector2 offset, Point destination)
 {
     this.image = image;
     this.pusher = pusher;
     pushOffset = offset;
     destinationGridPos = destination;
 }
示例#34
0
        public void ContainsPoint()
        {
            Rectangle rectangle = new Rectangle(0,0,64,64);

            var p1 = new Point(-1, -1);
            var p2 = new Point(0, 0);
            var p3 = new Point(32, 32);
            var p4 = new Point(63, 63);
            var p5 = new Point(64, 64);

            bool result;

            rectangle.Contains(ref p1, out result);
            Assert.AreEqual(false, result);
            rectangle.Contains(ref p2, out result);
            Assert.AreEqual(true, result);
            rectangle.Contains(ref p3, out result);
            Assert.AreEqual(true, result);
            rectangle.Contains(ref p4, out result);
            Assert.AreEqual(true, result);
            rectangle.Contains(ref p5, out result);
            Assert.AreEqual(false, result);

            Assert.AreEqual(false, rectangle.Contains(p1));
            Assert.AreEqual(true, rectangle.Contains(p2));
            Assert.AreEqual(true, rectangle.Contains(p3));
            Assert.AreEqual(true, rectangle.Contains(p4));
            Assert.AreEqual(false, rectangle.Contains(p5));
        }
        public SplitItemStackGump(Item item, Point pickupOffset)
            : base(0, 0)
        {
            Item = item;
            m_PickupOffset = pickupOffset;

            IsMoveable = true;

            // Background
            AddControl(new GumpPic(this, 0, 0, 0x085c, 0));
            // Slider
            m_Slider = (HSliderBar)AddControl(new HSliderBar(this, 30, 16, 104, 0, item.Amount, item.Amount, HSliderBarStyle.BlueWidgetNoBar));
            m_LastValue = m_Slider.Value;
            // Ok button
            AddControl(new Button(this, 102, 38, 0x085d, 0x085e, ButtonTypes.Default, 0, 0));
            ((Button)LastControl).GumpOverID = 0x085f;
            ((Button)LastControl).MouseClickEvent += ClickOkayButton;
            // Text entry field
            m_AmountEntry = (TextEntry)AddControl(new TextEntry(this, 30, 39, 60, 16, 0, 0, 5, item.Amount.ToString()));
            m_AmountEntry.HtmlTag = "<big>";
            m_AmountEntry.LegacyCarat = true;
            m_AmountEntry.Hue = 1001;
            m_AmountEntry.ReplaceDefaultTextOnFirstKeypress = true;
            m_AmountEntry.NumericOnly = true;
        }
示例#36
0
 public Block(BlockType type, int x, int y)
     : this()
 {
     Position = new Point(x, y);
     Type = type;
     Rotate = 0;
 }
示例#37
0
        public void Circle_ContainsPoint()
        {
            var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);

            var p1 = new Point(-1, -1);
            var p2 = new Point(110, 300);
            var p3 = new Point(200, 300);
            var p4 = new Point(290, 300);
            var p5 = new Point(400, 400);

            bool result;

            circle.Contains(ref p1, out result);
            Assert.AreEqual(false, result);
            circle.Contains(ref p2, out result);
            Assert.AreEqual(true, result);
            circle.Contains(ref p3, out result);
            Assert.AreEqual(true, result);
            circle.Contains(ref p4, out result);
            Assert.AreEqual(true, result);
            circle.Contains(ref p5, out result);
            Assert.AreEqual(false, result);

            Assert.AreEqual(false, circle.Contains(p1));
            Assert.AreEqual(true, circle.Contains(p2));
            Assert.AreEqual(true, circle.Contains(p3));
            Assert.AreEqual(true, circle.Contains(p4));
            Assert.AreEqual(false, circle.Contains(p5));
        }
示例#38
0
        public override void Draw(SpriteBatchUI spriteBatch, Point position)
        {
            if (m_Texture == null)
            {
                IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>();
                if (IsFemale)
                {
                    int index = Item.ItemData.AnimID + 60000;
                    int indexTranslated, hueTranslated;
                    if (GumpDefTranslator.ItemHasGumpTranslation(index, out indexTranslated, out hueTranslated))
                    {
                        index = indexTranslated;
                        m_HueOverride = hueTranslated;
                        m_Texture = provider.GetUITexture(index);
                    }
                }
                if (m_Texture == null)
                {
                    int index = Item.ItemData.AnimID + 50000;
                    int indexTranslated, hueTranslated;
                    if (GumpDefTranslator.ItemHasGumpTranslation(index, out indexTranslated, out hueTranslated))
                    {
                        index = indexTranslated;
                        m_HueOverride = hueTranslated;
                        m_Texture = provider.GetUITexture(index);
                    }
                    m_Texture = provider.GetUITexture(index);
                }
                Size = new Point(m_Texture.Width, m_Texture.Height);
            }

            int hue = (Item.Hue == 0 & m_HueOverride != 0) ? m_HueOverride : Item.Hue;
            spriteBatch.Draw2D(m_Texture, new Vector3(position.X, position.Y, 0), Utility.GetHueVector(hue));
            base.Draw(spriteBatch, position);
        }
示例#39
0
 public override void Draw(SpriteBatchUI spriteBatch, Point position, double frameMS)
 {
     Vector3 hueVector = Utility.GetHueVector(Hue);
     int width = (int)(m_PercentWidthDrawn * Width);
     spriteBatch.Draw2D(m_Texture, new Rectangle(position.X, position.Y, width, Height), new Rectangle(0, 0, width, Height), hueVector);
     base.Draw(spriteBatch, position, frameMS);
 }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            Point _relativeMousePos = GetTileRelativeMousePos(e.X, e.Y);

            if (e.Button == MouseButtons.Left)
            {
                _brushStartPoint = _relativeMousePos;
                if (PaintMode == TileGridPaintMode.Brush)
                {
                    if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
                    {
                        ApplyBrushPaint(TileGridEditor.Instance.SelectedBrushTile);
                    }
                }
                else if (PaintMode == TileGridPaintMode.Eraser)
                {
                    if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
                    {
                        ApplyBrushPaint(-1);
                    }
                }
                else if (PaintMode == TileGridPaintMode.Edit)
                {
                    if (_selectionExpandOrigin.X > -1 && _selectionExpandOrigin.Y > -1 &&
                        _relativeMousePos.X > -1 && _relativeMousePos.Y > -1)
                    {
                        ExpandSelectionSize(_relativeMousePos);
                    }
                }
            }
            else if (e.Button == MouseButtons.None)
            {
                if (PaintMode == TileGridPaintMode.Brush || PaintMode == TileGridPaintMode.Eraser)
                {
                    if (_brushSizeExpandOrigin.X != -1 && _brushSizeExpandOrigin.Y != -1 &&
                        ((Control.ModifierKeys & Keys.Control) == Keys.Control ||
                         (Control.ModifierKeys & Keys.Shift) == Keys.Shift))
                    {
                        ExpandBrushSize(_relativeMousePos);
                    }
                    else
                    {
                        _brushStartPoint = _relativeMousePos;
                    }
                }
                else if (PaintMode == TileGridPaintMode.Bucket)
                {
                    _brushStartPoint = _relativeMousePos;
                }
            }
            if (PaintMode == TileGridPaintMode.Edit)
            {
                if (_isPastingTiles)
                {
                    _drawPosPastingSelection = _relativeMousePos;
                }
            }
        }
 public static bool IsPointInsideRectangle(Point point, int left, int top, int right, int bottom)
 {
     if (bottom > point.Y && top < point.Y && left < point.X && right > point.X)
     {
         return(true);
     }
     return(false);
 }
        public void SetCenterPosition(Point _centerPosition)
        {
            centerPosition.X = _centerPosition.X;
            centerPosition.Y = _centerPosition.Y;
#if DEBUG
            UpdateRectangle();
#endif
        }
示例#43
0
 public FreeTextList()
 {
     this.TextList      = new List <TextItem>();
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.Builder       = new FreeTextBuilder();
 }
 public void ResetStatus()
 {
     ClearSelection();
     _isSelectingArea       = false;
     _selectionExpandOrigin = new Point(-1, -1);
     _brushStartPoint       = new Point(-1, -1);
     _isPastingTiles        = false;
 }
示例#45
0
        // CONSTRUCTOR //

        public Window(string fontFile, int width, int height)
        {
            this.fontFile = fontFile;
            this.width    = width;
            this.height   = height;
            minSize       = new Microsoft.Xna.Framework.Point(100 * 12, 50 * 12);
            Init(fontFile, width, height);
        }
示例#46
0
        public static Dictionary <string, int> SerializePoint(XNA.Point p)
        {
            Dictionary <string, int> result = new Dictionary <string, int>(2);

            result.Add("x", p.X);
            result.Add("y", p.Y);
            return(result);
        }
 private bool ClickOnMinimap(Board selectedBoard, XNA.Point position)
 {
     if (selectedBoard.MiniMap == null || !UserSettings.useMiniMap)
     {
         return(false);
     }
     return(position.X > 0 && position.X < selectedBoard.MinimapArea.Width && position.Y > 0 && position.Y < selectedBoard.MinimapArea.Height);
 }
示例#48
0
        /// <summary>
        /// Instantiates a gem and puts it in the level.
        /// </summary>
        private Tile LoadGemTile(int x, int y)
        {
            Point position = GetBounds(x, y).GetCenter();

            gems.Add(new Gem(this, new Vector2(position.X, position.Y)));

            return(new Tile(null, TileCollision.Passable));
        }
示例#49
0
        /// <summary>
        ///     Checks if the square has three or more squares in a line with the same owner and is not already
        /// </summary>
        /// <param name="checkPoint">The point to check</param>
        /// <param name="owner">The owner</param>
        /// <returns>the new line points</returns>
        public List <Point> CheckForLine(Point checkPoint, Player owner)
        {
            List <Point> output = new List <Point>();

            // Return if the square is not valid
            if ((IsValidBranchPoint(checkPoint, owner) ?? false) == false)
            {
                return(new List <Point>());
            }

            List <Point> directions = new List <Point> {
                new Point(-1), new Point(0, -1), new Point(1, -1), new Point(-1, 0)
            };

            // Check neighboring squares that are not already part of a line
            foreach (Point point in directions)
            {
                List <Point> points = new List <Point> {
                    checkPoint
                };
                int j = 1, i = j;
                while (true)
                {
                    Point branchPoint = new Point(point.X * i, point.Y * i) + checkPoint;
                    // Keep branching if the point has the same owner and is not already in a line
                    while (IsValidBranchPoint(branchPoint, owner) ?? false)
                    {
                        // Add point to list
                        points.Add(branchPoint);
                        i          += j;
                        branchPoint = new Point(point.X * i, point.Y * i) + checkPoint;
                    }

                    // If i is positive flip restart loop to go other direction
                    if (j > 0)
                    {
                        j = -1;
                        i = j;
                    }
                    else
                    {
                        break;
                    }
                }

                if (points.Count >= minLineLength)
                {
                    foreach (Point p in points)
                    {
                        Squares[p.X, p.Y].SetIsInLine(true);
                    }
                    // add to output
                    output.AddRange(points);
                }
            }

            return(output);
        }
 protected override void OnMouseClick(MouseEventArgs e)
 {
     base.OnMouseClick(e);
     if (e.Button == MouseButtons.Left)
     {
         if (PaintMode == TileGridPaintMode.Brush)
         {
             _brushStartPoint = GetTileRelativeMousePos(e.X, e.Y);
             // if clicked in the tile grid zone
             if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
             {
                 ApplyBrushPaint(TileGridEditor.Instance.SelectedBrushTile);
             }
         }
         else if (PaintMode == TileGridPaintMode.Eraser)
         {
             _brushStartPoint = GetTileRelativeMousePos(e.X, e.Y);
             // if clicked in the tile grid zone
             if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
             {
                 ApplyBrushPaint(-1);
             }
         }
         else if (PaintMode == TileGridPaintMode.Bucket)
         {
             _brushStartPoint = GetTileRelativeMousePos(e.X, e.Y);
             // if clicked in the tile grid zone
             if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
             {
                 ApplyFillBucketPaint(_brushStartPoint.X, _brushStartPoint.Y, TileGridEditor.Instance.SelectedBrushTile);
             }
         }
         else if (PaintMode == TileGridPaintMode.Edit)
         {
             _brushStartPoint = GetTileRelativeMousePos(e.X, e.Y);
             if (_isPastingTiles && _brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
             {
                 PasteTilesAtPos(_brushStartPoint);
                 _isPastingTiles = false;
             }
             else
             {
                 // if clicked in the tile grid zone and tile is not selected already
                 if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1 && _isSelectingArea == false)
                 {
                     // if holding Ctrl down, add the tile to the others
                     if ((Control.ModifierKeys & Keys.Control) != Keys.Control)
                     {
                         ClearSelection();
                     }
                     SelectTile(_brushStartPoint);
                 }
                 _isSelectingArea       = false;
                 _selectionExpandOrigin = new Point(-1, -1);
             }
         }
     }
 }
示例#51
0
        /// <summary>
        /// Align not implemented
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="source"></param>
        /// <param name="dest"></param>
        /// <param name="tileSize"></param>
        /// <param name="align"></param>
        public void DrawTiled(Texture2D tex, Rectangle source, Rectangle dest, Microsoft.Xna.Framework.Point tileSize, GuiAlign align)
        {
            //DrawTiledRow( tex, source, dest, tileSize, align );

            int width;
            int height;

            Rectangle iSource = source;
            Rectangle iDest   = dest;

            for (int iy = dest.Top; iy < dest.Bottom; iy += tileSize.Y)
            {
                height = dest.Bottom - iy;

                if (height > tileSize.Y)
                {
                    height         = tileSize.Y;
                    iSource.Height = source.Height;
                }
                else
                {
                    iSource.Height = source.Height / tileSize.Y * height;
                }

                iDest.Y      = iy;
                iDest.Height = height;


                for (int ix = dest.Left; ix < dest.Right; ix += tileSize.X)
                {
                    width = dest.Right - ix;
                    if (width > tileSize.X)
                    {
                        width         = tileSize.X;
                        iSource.Width = source.Width;
                    }
                    else
                    {
                        iSource.Width = source.Width / tileSize.X * width;
                    }

                    iDest.X     = ix;
                    iDest.Width = width;

                    Draw(tex, iSource, iDest, align);
                }

                //if ( ix < dest.Right )
                //{
                //    Draw( tex, source, new Rectangle( ix, iy, dest.Right - ix, tileSize.Y ) );
                //}
            }

            //if ( iy < dest.Bottom )
            //{
            //    //Draw( tex, source, new Rectangle( ix, iy, dest.Right - ix, dest.Bottom - ) );
            //}
        }
示例#52
0
 public void Open(Point openningPoint)
 {
     if (_opened)
     {
         return;
     }
     _opened        = true;
     _openningPoint = openningPoint;
 }
示例#53
0
 private BoardItem GetObjectUnderPoint(Point location)
 {
     bool selectedItemHigher;
     BoardItemPair objsUnderPoint = GetObjectsUnderPoint(location, out selectedItemHigher);
     if (objsUnderPoint.SelectedItem == null && objsUnderPoint.NonSelectedItem == null) return null;
     else if (objsUnderPoint.SelectedItem == null) return objsUnderPoint.NonSelectedItem;
     else if (objsUnderPoint.NonSelectedItem == null) return objsUnderPoint.SelectedItem;
     else return selectedItemHigher ? objsUnderPoint.SelectedItem : objsUnderPoint.NonSelectedItem;
 }
示例#54
0
 public virtual void LoadContent()
 {
     if (Texture != null)
     {
         TextureSize = Texture.Bounds.Size;
     }
     State = SpriteState.Starting;
     Start();
 }
示例#55
0
 public FreeText(FreeTextBuilder builder)
 {
     this.position      = Microsoft.Xna.Framework.Rectangle.Empty;
     this.displayOffset = Microsoft.Xna.Framework.Point.Zero;
     this.align         = TextAlign.None;
     this.textColor     = Microsoft.Xna.Framework.Graphics.Color.Black;
     this.textTexture   = null;
     this.Builder       = builder;
 }
示例#56
0
 public Chunk(Point id, bool dontLoad = false)
 {
     ChunkspacePosition = id.ToVector2();
     Position           = ChunkspacePosition * new Vector2(ChunkWidth, ChunkHeight);
     if (!dontLoad)
     {
         Dimension.LoadChunk(this);
     }
 }
示例#57
0
        public static Microsoft.Xna.Framework.Point UiToScale(this Microsoft.Xna.Framework.Point point)
        {
            float scale = GameService.Graphics.GetScaleRatio(GameService.Graphics.UIScale);

            return(new Microsoft.Xna.Framework.Point(
                       (int)(point.X / scale),
                       (int)(point.Y / scale)
                       ));
        }
 public Board CreateHiddenBoard(Point mapSize, Point centerPoint)
 {
     lock (this)
     {
         Board newBoard = new Board(mapSize, centerPoint, this, null, ItemTypes.None, ItemTypes.None);
         newBoard.CreateLayers();
         return(newBoard);
     }
 }
示例#59
0
        internal void SetPosition(ShowPosition showPosition)
        {
            Microsoft.Xna.Framework.Rectangle rectDes = new Microsoft.Xna.Framework.Rectangle(0, 0, Session.MainGame.mainGameScreen.viewportSize.X, Session.MainGame.mainGameScreen.viewportSize.Y);
            //Microsoft.Xna.Framework.Rectangle rect = new Microsoft.Xna.Framework.Rectangle(0, 0, this.BackgroundSize.X, this.BackgroundSize.Y);
            Rectangle rect = new Rectangle(0, 0, Convert.ToInt16(this.BackgroundSize.X * Scale.X), Convert.ToInt16(this.BackgroundSize.Y * Scale.Y));

            switch (showPosition)
            {
            case ShowPosition.Center:
                rect = StaticMethods.GetCenterRectangle(rectDes, rect);
                break;

            case ShowPosition.Top:
                rect = StaticMethods.GetTopRectangle(rectDes, rect);
                break;

            case ShowPosition.Left:
                rect = StaticMethods.GetLeftRectangle(rectDes, rect);
                break;

            case ShowPosition.Right:
                rect = StaticMethods.GetRightRectangle(rectDes, rect);
                break;

            case ShowPosition.Bottom:
                rect = StaticMethods.GetBottomRectangle(rectDes, rect);
                break;

            case ShowPosition.TopLeft:
                rect = StaticMethods.GetTopLeftRectangle(rectDes, rect);
                break;

            case ShowPosition.TopRight:
                rect = StaticMethods.GetTopRightRectangle(rectDes, rect);
                break;

            case ShowPosition.BottomLeft:
                rect = StaticMethods.GetBottomLeftRectangle(rectDes, rect);
                break;

            case ShowPosition.BottomRight:
                rect = StaticMethods.GetBottomRightRectangle(rectDes, rect);
                break;
            }
            this.DisplayOffset = new Microsoft.Xna.Framework.Point(rect.X, rect.Y + 20);
            foreach (LabelText text in this.LabelTexts)
            {
                text.Label.DisplayOffset = this.DisplayOffset;
                text.Text.DisplayOffset  = this.DisplayOffset;
            }
            foreach (TechniqueItem item in this.AllTechniques)
            {
                item.Text.DisplayOffset = new Microsoft.Xna.Framework.Point(this.ButtonStartPosition.X + this.DisplayOffset.X, this.ButtonStartPosition.Y + this.DisplayOffset.Y);
            }
            this.CommentsText.DisplayOffset = new Microsoft.Xna.Framework.Point(this.DisplayOffset.X + this.CommentsClient.X, this.DisplayOffset.Y + this.CommentsClient.Y);
        }
示例#60
0
        /// <summary>
        /// Update this handler
        /// </summary>
        /// <param name="hoverPoint">the currently hovered block</param>
        public void Handle(Microsoft.Xna.Framework.Point hoverPoint)
        {
            this.tmpMarker.Clear();

            if (FenrirGame.Instance.Properties.Input.RightClick)
            {
                this.scene.DisposeCurrentModeHandler();
                return;
            }

            if (this.scene.IsAboveBuildLevel(hoverPoint))
            {
                hoverPoint = new Microsoft.Xna.Framework.Point(hoverPoint.X, this.scene.Properties.StartingAreaBlocksBottom);
            }

            if (FenrirGame.Instance.Properties.Input.LeftClick && this.canBeMined(hoverPoint))
            {
                // add a marker für the currently hovered position
                this.addTmpMarker(hoverPoint);

                if (!this.scene.Markers.ContainsKey(hoverPoint))
                {
                    this.scene.Markers.Add(hoverPoint, new Marker(MarkerType.Tunnel, hoverPoint));
                }
            }
            else if (FenrirGame.Instance.Properties.Input.LeftDrag)
            {
                FenrirGame.Instance.InGame.Camera.blockCameraMovement = true;
                if (!this.dragStart.HasValue)
                {
                    this.dragStart = hoverPoint;
                }
                else
                {
                    this.mark(this.dragStart.Value, hoverPoint);
                }
            }
            else if (this.dragStart.HasValue)
            {
                this.mark(this.dragStart.Value, hoverPoint);
                this.dragStart = null;

                foreach (KeyValuePair <Point, Marker> marker in this.tmpMarker)
                {
                    if (!this.scene.Markers.ContainsKey(marker.Key) && marker.Value.Type == MarkerType.Tunnel)
                    {
                        this.scene.Markers.Add(marker.Key, marker.Value);
                    }
                }
            }
            else
            {
                // add a marker für the currently hovered position
                this.addTmpMarker(hoverPoint);
            }
        }