示例#1
0
        public void Update(GameTime gameTime)
        {
            //сначала с чем сталкиваемся потом что сталкиваем
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                TennisBall.BallVelocity *= 2f;
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = JumpButton.PanelPosition.X - mouse.X;
                y = JumpButton.PanelPosition.Y - mouse.Y;
                JumpButton.PanelPosition.X = Mouse.GetState().X + x;
                JumpButton.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Фиолетовый ускоритель поможет мячику забраться\n" +
                                "выше если его правильно использовать.\n", "Подсказка #4", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            JumpButton.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
示例#2
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Draw(background, new Vector2(0, 0), Color.White);
            TennisBall.Draw(spriteBatch);
            Panel.Draw(spriteBatch);
            JumpButton.Draw(spriteBatch);
            EndBlock.Draw(spriteBatch);

            gui.Draw(spriteBatch);
            spriteBatch.Draw(cursorTexture, cursorRectangle, Color.White);
        }
示例#3
0
        public void Update(GameTime gameTime)
        {
            if (SoccerBall.IntersectsPixel(SoccerBall.BallRectangle, SoccerBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                SoccerBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(SoccerBall.BallRectangle, SoccerBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                SoccerBall.Update(gameTime);
                finished = true;
            }
            else
            {
                SoccerBall.Update(gameTime);
            }
            if (Panel.IntersectsPixel(cursorRectangle, cursorTextureData, Panel.PanelRectangle, Panel.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !SoccerBall.started)
            {
                float x, y;
                x = Panel.PanelPosition.X - mouse.X;
                y = Panel.PanelPosition.Y - mouse.Y;
                Panel.PanelPosition.X = Mouse.GetState().X + x;
                Panel.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                SoccerBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                SoccerBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && SoccerBall.started == false)
            {
                MessageBox.Show("Используй наклонный блок для направления мяча.\n" +
                                "Пол также можно использовать для прохождения уровня!", "Подсказка #1", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            EndBlock.Update(gameTime);
            gui.Update(gameTime);

            //sprite.Update(gameTime);

            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
            mouse = Mouse.GetState();
        }
示例#4
0
        public void _Finish()
        {
            // Sort widths
            Pillars.SortWidths();
            Platforms.SortWidths();
            Ceilings.SortWidths();
            StartBlock.SortWidths();
            EndBlock.SortWidths();

            if (MyTileSetInfo.Pendulums.Group.Dict.Count == 0)
            {
                MyTileSetInfo.Pendulums.Group = PieceQuad.ElevatorGroup;
            }
            if (MyTileSetInfo.Elevators.Group.Dict.Count == 0)
            {
                MyTileSetInfo.Elevators.Group = PieceQuad.ElevatorGroup;
            }
            if (MyTileSetInfo.FallingBlocks.Group.Dict.Count == 0)
            {
                MyTileSetInfo.FallingBlocks.Group = PieceQuad.FallGroup;
            }
            if (MyTileSetInfo.BouncyBlocks.Group.Dict.Count == 0)
            {
                MyTileSetInfo.BouncyBlocks.Group = PieceQuad.BouncyGroup;
            }
            if (MyTileSetInfo.MovingBlocks.Group.Dict.Count == 0)
            {
                MyTileSetInfo.MovingBlocks.Group = PieceQuad.MovingGroup;
            }

            MyTileSetInfo.Pendulums.Group.SortWidths();
            MyTileSetInfo.Elevators.Group.SortWidths();
            MyTileSetInfo.FallingBlocks.Group.SortWidths();
            MyTileSetInfo.MovingBlocks.Group.SortWidths();
            MyTileSetInfo.BouncyBlocks.Group.SortWidths();
        }
示例#5
0
        public void Update(GameTime gameTime)
        {
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel1.PanelRectangle, Panel1.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel2.PanelRectangle, Panel2.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (Panel1.IntersectsPixel(cursorRectangle, cursorTextureData, Panel1.PanelRectangle, Panel1.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = Panel1.PanelPosition.X - mouse.X;
                y = Panel1.PanelPosition.Y - mouse.Y;
                Panel1.PanelPosition.X = Mouse.GetState().X + x;
                Panel1.PanelPosition.Y = Mouse.GetState().Y + y;
            }

            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Чтобы довести мяч до финиша используй\n" +
                                "отскок мяча от блоков. Есть только один\n" +
                                "путь до финиша!\n", "Подсказка #2", MessageBoxButtons.OK);
            }
            gui.Update(gameTime);
            Panel.Update(gameTime);
            Panel1.Update(gameTime);
            Panel2.Update(gameTime);
            EndBlock.Update(gameTime);


            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
示例#6
0
        internal IEnumerable<DxfCodePair> GetValuePairs(DxfAcadVersion version, bool outputHandles)
        {
            var list = new List<DxfCodePair>();
            list.Add(new DxfCodePair(0, BlockText));
            if (outputHandles && ((IDxfItemInternal)this).Handle != 0u)
            {
                list.Add(new DxfCodePair(5, DxfCommonConverters.UIntHandle(((IDxfItemInternal)this).Handle)));
            }

            if (version >= DxfAcadVersion.R14)
            {
                foreach (var group in ExtensionDataGroups)
                {
                    group.AddValuePairs(list, version, outputHandles);
                }
            }

            if (version >= DxfAcadVersion.R13)
            {
                if (((IDxfItemInternal)this).OwnerHandle != 0u)
                {
                    list.Add(new DxfCodePair(330, DxfCommonConverters.UIntHandle(((IDxfItemInternal)this).OwnerHandle)));
                }

                list.Add(new DxfCodePair(100, AcDbEntityText));
            }

            if (IsInPaperSpace)
            {
                list.Add(new DxfCodePair(67, DxfCommonConverters.BoolShort(IsInPaperSpace)));
            }

            list.Add(new DxfCodePair(8, Layer));
            if (version >= DxfAcadVersion.R13)
            {
                list.Add(new DxfCodePair(100, AcDbBlockBeginText));
            }

            list.Add(new DxfCodePair(2, Name));
            list.Add(new DxfCodePair(70, (short)Flags));
            list.Add(new DxfCodePair(10, BasePoint.X));
            list.Add(new DxfCodePair(20, BasePoint.Y));
            list.Add(new DxfCodePair(30, BasePoint.Z));
            if (version >= DxfAcadVersion.R12)
            {
                list.Add(new DxfCodePair(3, Name));
            }

            list.Add(new DxfCodePair(1, XrefName));

            if (!string.IsNullOrEmpty(Description))
            {
                list.Add(new DxfCodePair(4, Description));
            }

            // entities in blocks need handles for some applications
            list.AddRange(Entities.SelectMany(e => e.GetValuePairs(version, outputHandles)));

            list.AddRange(EndBlock.GetValuePairs(version, outputHandles));

            return list;
        }
示例#7
0
 public void Render(EndBlock endBlocks)
 {
     throw new NotImplementedException();
 }
示例#8
0
        public void Update(GameTime gameTime)
        {
            //сначала с чем сталкиваемся потом что сталкиваем
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                Block.PanelPosition.Y -= 1000;
            }
            else if (TennisBall.IntersectsPixel(Block.PanelRectangle, Block.PanelTextureData, TennisBall.BallRectangle, TennisBall.BallTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(EndBlock.PanelRectangle, EndBlock.PanelTextureData, TennisBall.BallRectangle, TennisBall.BallTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (Button.IntersectsPixel(Button.PanelRectangle, Button.PanelTextureData, cursorRectangle, cursorTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = Button.PanelPosition.X - mouse.X;
                y = Button.PanelPosition.Y - mouse.Y;
                Button.PanelPosition.X = Mouse.GetState().X + x;
                Button.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || !TennisBall.started)
            {
                TennisBall.started    = false;
                Block.PanelPosition.Y = 420;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Используй оранжевую кнопку чтобы\n" +
                                "убрать вертикальный блок и довести мяч до финиша.\n", "Подсказка #3", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            Button.Update(gameTime);
            Block.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
示例#9
0
        public void Update(GameTime gameTime)
        {
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                Block2.PanelPosition.Y -= 1000;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                TennisBall.BallVelocity.Y *= 2f;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Block2.PanelRectangle, Block2.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                float x, y;
                x = JumpButton.PanelPosition.X - mouse.X;
                y = JumpButton.PanelPosition.Y - mouse.Y;
                JumpButton.PanelPosition.X = Mouse.GetState().X + x;
                JumpButton.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                float x, y;
                x = Button.PanelPosition.X - mouse.X;
                y = Button.PanelPosition.Y - mouse.Y;
                Button.PanelPosition.X = Mouse.GetState().X + x;
                Button.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || !TennisBall.started)
            {
                TennisBall.started     = false;
                Block2.PanelPosition.Y = 420;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Используй 2 блока для направления\n" +
                                "мяча к финишу, незабудь про поверхость пола!\n", "Подсказка #5", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            JumpButton.Update(gameTime);
            Block2.Update(gameTime);

            Button.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
示例#10
0
 // picture box mouse down event
 private void pictureBox_MouseDown(object sender, MouseEventArgs e)
 {
     // disable buttons during block moving
     if (scrollDown)
     {
         return;
     }
     // if block has to start moving
     if (e.Button == MouseButtons.Middle && selected != null && !linking)
     {
         scrollDown      = true;
         pictureBoxImage = CreateImageWithoutSelectedBlock(selected);
         xDis            = selected.X - e.X;
         yDis            = selected.Y - e.Y;
     }
     // (un)select block
     if (e.Button == MouseButtons.Right)
     {
         SelectBlock(e.X, e.Y);
         RefreshScheme();
         pictureBoxImage = (Image)pictureBox.Image.Clone();
     }
     // left click mouse interaction
     if (e.Button == MouseButtons.Left)
     {
         // create operation block
         if (button == OperationBoxButton)
         {
             canvas = Graphics.FromImage(pictureBox.Image);
             OperatingBlock bloc = new OperatingBlock(e.X, e.Y, resourceManager.GetString("OperationBlock"));
             bloc.Draw(canvas);
             blockList.Add(bloc);
         }
         // create decide block
         else if (button == DecidingBoxButton)
         {
             canvas = Graphics.FromImage(pictureBox.Image);
             DecidingBlock bloc = new DecidingBlock(e.X, e.Y, resourceManager.GetString("DecideBlock"));
             bloc.Draw(canvas);
             blockList.Add(bloc);
         }
         // create start block
         else if (button == startBoxButton)
         {
             if (FindNearestBlock((Block b) =>
             {
                 if (b.GetType().Name == "StartBlock")
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }, blockList, e.X, e.Y) == null)
             {
                 // create
                 canvas = Graphics.FromImage(pictureBox.Image);
                 StartBlock bloc = new StartBlock(e.X, e.Y, resourceManager.GetString("StartBlock"));
                 bloc.Draw(canvas);
                 blockList.Add(bloc);
             }
             else
             {
                 // if already exist then show message
                 MessageBox.Show(resourceManager.GetString("DoubleStartBlockWarning"));
             }
         }
         //create end block
         else if (button == endBoxButton)
         {
             canvas = Graphics.FromImage(pictureBox.Image);
             EndBlock bloc = new EndBlock(e.X, e.Y, resourceManager.GetString("StopBlock"));
             bloc.Draw(canvas);
             blockList.Add(bloc);
         }
         // start link creating
         else if (button == linkButton)
         {
             LinkPoint x = null;
             foreach (Block block in blockList)
             {
                 if ((x = block.CheckPoint(e.X, e.Y, false)) != null)
                 {
                     selectedLinkPoint = x;
                 }
             }
             if (selectedLinkPoint != null)
             {
                 linking = true;
                 pictureBox.Refresh();
                 pictureBoxImage = (Image)pictureBox.Image.Clone();
             }
         }
         // delete block
         else if (button == deleteButton)
         {
             Block removed = FindNearestBlock((Block block) => block.Click(e.X, e.Y), blockList, e.X, e.Y);
             if (removed != null)
             {
                 textSelectedBlock.Enabled = false;
                 textSelectedBlock.Text    = "";
                 if (selected == removed)
                 {
                     selected = null;
                 }
                 removed.Remove();
                 blockList.Remove(removed);
             }
             RefreshScheme();
         }
     }
     pictureBox.Refresh();
 }
 public static void OnEndBlock(ITZXBlock block, int blockIndex)
 {
     EndBlock?.Invoke(block, blockIndex);
 }