コード例 #1
1
 // Reset
 public void Reset()
 {
     Offset = new Vector2();
     Scale = new Vector2( 1.0f );
     Rotation = new Vector3();
     TransformMatrix = Matrix.Identity;
 }
コード例 #2
1
ファイル: Cobalt.cs プロジェクト: iamnilay3/scrolling-shooter
        /// <summary>
        /// Updates the Cobalt ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // Sense the Player's position
            PlayerShip Player = ScrollingShooterGame.Game.Player;
            Vector2 PlayerPosition = new Vector2(Player.Bounds.Center.X, Player.Bounds.Center.Y);

            // Get a vector from our position to the Player's position
            Vector2 toPlayer = PlayerPosition - this.position;

            //Sense the Player from longer away but move slower.
            if (toPlayer.LengthSquared() < 80000)
            {
                // We sense the Player's ship!
                // Get a normalized steering vector
                toPlayer.Normalize();

                // Steer towards them!
                this.position += toPlayer * elapsedTime * 50;
            }
            if (toPlayer.LengthSquared() < 10000)
            {
                //Player is close fire weapons
                //Thinking of some type of pulse wave from the ship

            }
        }
コード例 #3
1
        private PyramidTest()
        {
            //Create ground
            FixtureFactory.CreateEdge(World, new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));

            Vertices box = PolygonTools.CreateRectangle(0.5f, 0.5f);
            PolygonShape shape = new PolygonShape(box, 5);

            Vector2 x = new Vector2(-7.0f, 0.75f);
            Vector2 deltaX = new Vector2(0.5625f, 1.25f);
            Vector2 deltaY = new Vector2(1.125f, 0.0f);

            for (int i = 0; i < Count; ++i)
            {
                Vector2 y = x;

                for (int j = i; j < Count; ++j)
                {
                    Body body = BodyFactory.CreateBody(World);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = y;
                    body.CreateFixture(shape);

                    y += deltaY;
                }

                x += deltaX;
            }
        }
コード例 #4
1
ファイル: SpiralEmitter.cs プロジェクト: Jaex/ParticleEngine
        public override void Emit(GameTime gameTime, Vector2 position)
        {
            foreach (Particle p in ParticleSystem.GetFreeParticles(50))
            {
                p.Texture = Texture;
                p.Position = position;
                p.Direction = MathHelpers.RadianToVector2(MathHelpers.Random.NextAngle());
                p.Speed = 500f;
                p.Lifetime = MathHelpers.Random.NextFloat(1f, 2f);
                p.Angle = MathHelpers.Random.NextAngle();
                p.AutoAngle = true;
                p.RectangleLimit = TestWindow.Bounds.Offset(10);
                p.RectangleLimitAction = ParticleRectangleLimitAction.Bounce;
                p.Scale = MathHelpers.Random.NextFloat(0.1f, 1f);
                p.Color = MathHelpers.Random.NextColor(Color.DarkBlue, Color.CornflowerBlue);
                p.Modifiers = new List<IParticleModifier> {
                    new DirectionModifier
                    {
                        InitialDirection = MathHelpers.RadianToVector2(angle),
                        FinalDirection = MathHelpers.DegreeToVector2(90f, 2f)
                    },
                    new OpacityModifier
                    {
                        InitialOpacity = 1f,
                        FinalOpacity = 0f
                    }
                };

                angle += MathHelpers.DegreeToRadian(0.5f);
            }
        }
コード例 #5
1
 public WorldMapView(SpriteBatch sb)
 {
     spriteBatch = sb;
     instructionPos = new Vector2(20, 21);
     instructionOffset = new Vector2(0, 40);
     tutorial = "Press I to open tutorial";
 }
コード例 #6
1
ファイル: FloppyDisc.cs プロジェクト: UnaviaMedia/CaptainCPA
        public FloppyDisc(Game game, SpriteBatch spriteBatch, Texture2D texture, Texture2D overlayTexture, Color color, Color overlayColor,
			Vector2 position, float rotation , float scale, float layerDepth, int points)
            : base(game, spriteBatch, texture, color, position, rotation, scale, layerDepth, points)
        {
            this.overlayTexture = overlayTexture;
            this.overlayColor = overlayColor;
        }
コード例 #7
1
ファイル: Toolbar.cs プロジェクト: hover024/Virus-Attack
 public Toolbar(Texture2D texture, SpriteFont font, Vector2 position)
 {
     _texture = texture;
     _font = font;
     _position = position;
     _textPosition=new Vector2(130,_position.Y+10);
 }
コード例 #8
1
        public override void Initialize()
        {
            Vector2 trans = new Vector2();
            _polygons = new List<Vertices>();

            _polygons.Add(PolygonTools.CreateGear(5f, 10, 0f, 6f));
            _polygons.Add(PolygonTools.CreateGear(4f, 15, 100f, 3f));

            trans.X = 0f;
            trans.Y = 8f;
            _polygons[0].Translate(ref trans);
            _polygons[1].Translate(ref trans);

            _polygons.Add(PolygonTools.CreateGear(5f, 10, 50f, 5f));

            trans.X = 22f;
            trans.Y = 17f;
            _polygons[2].Translate(ref trans);

            AddRectangle(5, 10);
            AddCircle(5, 32);

            trans.X = -20f;
            trans.Y = 8f;
            _polygons[3].Translate(ref trans);
            trans.Y = 20f;
            _polygons[4].Translate(ref trans);

            _subject = _polygons[0];
            _clip = _polygons[1];

            base.Initialize();
        }
コード例 #9
1
        public void DrawFlagScore(SpriteBatch spriteBatch, GameTime gameTime, float stoppingHeight)
        {
            scoreOrigin = ScoreFont.MeasureString(scoreText) / GameValues.ScoreSpriteScoreOriginOffset;

            spriteBatch.DrawString(ScoreFont, scoreText, new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreYOffset), Color.White, 0, scoreOrigin, 0.4f, SpriteEffects.None, 0f);

            if (Position.Y > stoppingHeight)
            {
                Position = new Vector2(Position.X, Position.Y - GameValues.ScoreSpriteDrawFlagScoreDropOffet);
            }
            else if (Position.Y <= stoppingHeight)
            {
                //Position.Y = stoppingHeight;
                Position = new Vector2(Position.X, stoppingHeight);
                if (scoreBuffer <= 0)
                {
                    scoreBuffer = GameValues.ScoreSpriteScoreBuffer;
                    ScoringOn = !ScoringOn;
                }
                else
                {
                    scoreBuffer--;
                }
            }
        }
コード例 #10
1
ファイル: Retractor.cs プロジェクト: Dragonsdoom/ParasiteP1
        public virtual void Update()
        {
            position += velocity;

            short newGrid = (short)((int)(position.X / 100) * 8 + (int)(position.Y / 100));
            coll = CollisionManager.BadGuys[newGrid];
            foreach (Enemy item in coll)
            {
                if ((item.Position - position).LengthSquared() < 2000 && !item.isDying)
                {
                    Parasite.Me.UseNewShip(item);

                    // choose type of bullet
                    if (item is OrbitEnemy)
                    {
                        Parasite.Me.controlShip.bulletTypeFlag = 2;
                    }
                    else if (item is SweepEnemy)
                    {
                        Parasite.Me.controlShip.bulletTypeFlag = 1;
                    }
                    else
                    {
                        Parasite.Me.controlShip.bulletTypeFlag = 0;
                    }

                    isDying = true;
                }
            }

            if (isDying || position.Y<-20)
            Parasite.Me.R = null;
        }
コード例 #11
1
        public override void DrawObjects(GraphicsDevice graphicDevice, SpriteBatch spriteBatch, ContentManager content)
        {
            graphicDevice.Clear(Color.CornflowerBlue);
            SpriteFont newFont = content.Load<SpriteFont>(@"Fonts/Text");

            spriteBatch.Begin();

            this.controlScreenBackgroundPosition = new Vector2(0, 0);
            spriteBatch.Draw(this.controlScreenBackgroundTexture, this.controlScreenBackgroundPosition, Color.White);

            if (this.controlScreenItems.Count < 1)
            {
                // Back planket and text;
                this.buttonPosition = new Vector2(840, 660);
                this.controlScreenItems.Add(new MenuItems(this.button, this.buttonPosition, "Back", newFont, false));
            }

            this.controlScreenItems[this.selectedEntry].Selected = true;
            foreach (var item in this.controlScreenItems)
            {
                item.DrawMenuItems(spriteBatch, new Color(248, 218, 127));
            }

            this.DrawCursor(spriteBatch);
            spriteBatch.End();
        }
コード例 #12
1
ファイル: SpriteBatchItem.cs プロジェクト: Zeludon/FEZ
 public void Set(float x, float y, float w, float h, Color color, Vector2 texCoordTL, Vector2 texCoordBR)
 {
   this.vertexTL.Position.X = x;
   this.vertexTL.Position.Y = y;
   this.vertexTL.Position.Z = this.Depth;
   this.vertexTL.Color = color;
   this.vertexTL.TextureCoordinate.X = texCoordTL.X;
   this.vertexTL.TextureCoordinate.Y = texCoordTL.Y;
   this.vertexTR.Position.X = x + w;
   this.vertexTR.Position.Y = y;
   this.vertexTR.Position.Z = this.Depth;
   this.vertexTR.Color = color;
   this.vertexTR.TextureCoordinate.X = texCoordBR.X;
   this.vertexTR.TextureCoordinate.Y = texCoordTL.Y;
   this.vertexBL.Position.X = x;
   this.vertexBL.Position.Y = y + h;
   this.vertexBL.Position.Z = this.Depth;
   this.vertexBL.Color = color;
   this.vertexBL.TextureCoordinate.X = texCoordTL.X;
   this.vertexBL.TextureCoordinate.Y = texCoordBR.Y;
   this.vertexBR.Position.X = x + w;
   this.vertexBR.Position.Y = y + h;
   this.vertexBR.Position.Z = this.Depth;
   this.vertexBR.Color = color;
   this.vertexBR.TextureCoordinate.X = texCoordBR.X;
   this.vertexBR.TextureCoordinate.Y = texCoordBR.Y;
 }
コード例 #13
1
        public Vector2 AmountFaceRightUp(PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
        {
            Vector2 amountFaceRightUp;
            bool w, a, s, d;
            w = a = s = d = false;
            if (controllingPlayer.HasValue && GamePad.GetState((PlayerIndex)controllingPlayer).IsConnected)
            {
                playerIndex = (PlayerIndex)controllingPlayer; //we have the player set if it's a controller.
                amountFaceRightUp = GamePad.GetState((PlayerIndex)controllingPlayer).ThumbSticks.Left;
            }
            else
            {
                w = IsKeyDown(Keys.W, controllingPlayer, out playerIndex);
                a = IsKeyDown(Keys.A, controllingPlayer, out playerIndex);
                s = IsKeyDown(Keys.S, controllingPlayer, out playerIndex);
                d = IsKeyDown(Keys.D, controllingPlayer, out playerIndex);

                float amountFaceRight = ((d) ? 1.0f : 0.0f) + (((a)) ? -1.0f : 0.0f);
                float amountFaceUp = ((w) ? 1.0f : 0.0f) + (((s)) ? -1.0f : 0.0f);

                amountFaceRightUp = new Vector2(amountFaceRight, amountFaceUp);
            }

            return amountFaceRightUp;
        }
コード例 #14
1
ファイル: Particles.cs プロジェクト: vkd/Ctrl-Space
 public void Emit(ParticleParameters particleParameters, Vector2 position, Vector2 speed)
 {
     var particle = _particlePool.GetParticle(particleParameters);
     particle.Position = position;
     particle.Speed = speed;
     _particles.Add(particle);
 }
コード例 #15
1
        public Invader(SpaceInvaders game)
            : base(game)
        {
            _Game = game;

                        _Velocity = Vector2.Zero;
        }
コード例 #16
1
ファイル: Wall.cs プロジェクト: rubna/MetroidClone
        public Wall(Rectangle boundingBox)
        {
            BoundingBox = boundingBox;

            size = new Vector2(BoundingBox.Width, BoundingBox.Height);
            quarterSize = new Vector2(BoundingBox.Width / 2f, BoundingBox.Height / 2f);
        }
コード例 #17
1
ファイル: Bullet.cs プロジェクト: isaque/Schmup
 public Bullet(SchmupGame game, Vector2 position, Vector2 velocity, string bulletTexturePath)
     : base(game)
 {
     Position = position;
     Velocity = velocity;
     this.bulletTexturePath = bulletTexturePath;
 }
コード例 #18
1
 public override void Draw(SpriteBatch spriteBatch,Vector2 screenOffset)
 {
     foreach (Sprite sprite in sourceImages)
     {
         spriteBatch.Draw(sprite.SourceImage, ConnectedGameObject.Position - screenOffset, new Rectangle(frameWidth * currentFrame, 0, frameWidth, frameHeight), Color.White, ConnectedGameObject.Rotation, ImageOffset, ConnectedGameObject.Scale, SpriteEffects.None, sprite.Layer);
     }
 }
コード例 #19
1
ファイル: Sprite.cs プロジェクト: kayhen/PongCloneDemo
 public Sprite(Texture2D texture, Vector2 location, Rectangle gameBoundaries)
 {
     this.texture = texture;
     Location = location;
     this.gameBoundaries = gameBoundaries;
     Velocity = Vector2.Zero;
 }
コード例 #20
1
 public Position2DComponent(uint id)
     : base(id)
 {
     Position = Vector2.Zero;
     Rotation = 0.0f;
     Origin = Vector2.Zero;
 }
コード例 #21
1
        public void Draw(SpriteBatch spriteBatch, Vector2 location, ObjectState state)
        {
            this.SpriteWidth = this.Texture.Width / this.Columns;
            this.SpriteHeight = this.Texture.Height / this.Rows;

            if (state == ObjectState.Moving)
            {
                int row = (int)((float)this.currentFrame / this.Columns);
                int column = this.currentFrame % this.Columns;

                var sourceRectangle = new Rectangle(this.SpriteWidth * column, this.SpriteHeight * row, this.SpriteWidth, this.SpriteHeight);
                var destinationRectangle = new Rectangle((int)location.X, (int)location.Y, this.SpriteWidth, this.SpriteHeight);

                spriteBatch.Begin();
                spriteBatch.Draw(this.Texture, destinationRectangle, sourceRectangle, Color.White, this.Rotation, new Vector2(0, 0), this.Effects, 0f);
                spriteBatch.End();
            }
            else
            {
                var sourceRectangle = new Rectangle(0, 0, this.SpriteWidth, this.SpriteHeight);
                var destinationRectangle = new Rectangle((int)location.X, (int)location.Y, this.SpriteWidth, this.SpriteHeight);

                spriteBatch.Begin();
                spriteBatch.Draw(this.Texture, destinationRectangle, sourceRectangle, Color.White, this.Rotation, new Vector2(0, 0), this.Effects, 0f);
                spriteBatch.End();
            }
        }
コード例 #22
1
ファイル: LinkFactory.cs プロジェクト: scastle/Solitude
        /// <summary>
        /// Creates a chain.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <param name="linkWidth">The width.</param>
        /// <param name="linkHeight">The height.</param>
        /// <param name="fixStart">if set to <c>true</c> [fix start].</param>
        /// <param name="fixEnd">if set to <c>true</c> [fix end].</param>
        /// <param name="numberOfLinks">The number of links.</param>
        /// <param name="linkDensity">The link density.</param>
        /// <returns></returns>
        public static Path CreateChain(World world, Vector2 start, Vector2 end, float linkWidth, float linkHeight, bool fixStart, bool fixEnd, int numberOfLinks, float linkDensity)
        {
            // Chain start / end
            Path path = new Path();
            path.Add(start);
            path.Add(end);

            // A single chainlink
            PolygonShape shape = new PolygonShape(PolygonTools.CreateRectangle(linkWidth, linkHeight));

            // Use PathManager to create all the chainlinks based on the chainlink created before.
            List<Body> chainLinks = PathManager.EvenlyDistibuteShapesAlongPath(world, path, shape, BodyType.Dynamic, numberOfLinks, linkDensity);

            if (fixStart)
            {
                // Fix the first chainlink to the world
                JointFactory.CreateFixedRevoluteJoint(world, chainLinks[0], new Vector2(0, -(linkHeight / 2)), chainLinks[0].Position);
            }

            if (fixEnd)
            {
                // Fix the last chainlink to the world
                JointFactory.CreateFixedRevoluteJoint(world, chainLinks[chainLinks.Count - 1], new Vector2(0, (linkHeight / 2)), chainLinks[chainLinks.Count - 1].Position);
            }

            // Attach all the chainlinks together with a revolute joint
            PathManager.AttachBodiesWithRevoluteJoint(world, chainLinks, new Vector2(0, -linkHeight), new Vector2(0, linkHeight),
                                                      false, false);

            return (path);
        }
コード例 #23
1
ファイル: Help.cs プロジェクト: HATtrick-games/ICT309
        public override void Draw(GameTime gameTime)
        {
            if (_inputService.IsDown(Keys.F1) || _inputService.IsDown(Buttons.Start, PlayerIndex.One))
              {
            // F1 is pressed:

            // Clear screen.
            GraphicsDevice.Clear(Color.White);

            // Draw help text.
            float left = GraphicsDevice.Viewport.TitleSafeArea.Left;
            float top = GraphicsDevice.Viewport.TitleSafeArea.Top;
            Vector2 position = new Vector2(left, top);

            _spriteBatch.Begin();
            _spriteBatch.DrawString(_spriteFont, Text, position, Color.Black);
            _spriteBatch.End();
              }
              else
              {
            // F1 is not pressed:

            // Draw a help hint at the bottom of the screen.
            float left = GraphicsDevice.Viewport.TitleSafeArea.Left;
            float bottom = GraphicsDevice.Viewport.TitleSafeArea.Bottom - 30;
            Vector2 position = new Vector2(left, bottom);
            const string text = "Press <F1> or <Start> to display Help";

            _spriteBatch.Begin();
            _spriteBatch.DrawStringOutlined(_spriteFont, text, position, Color.Black, Color.White);
            _spriteBatch.End();
              }

              base.Draw(gameTime);
        }
コード例 #24
1
        public override void Draw(GameTime gameTime)
        {
            Vector3 direction;
            Vector3.Subtract(ref destination, ref source, out direction);

            spriteBatch.Begin();

            Vector3 innerVector;
            Vector3 outerVector;
            Vector3.Multiply (ref direction, innerDist, out outerVector);
            Vector3.Multiply(ref direction, outerDist, out innerVector);
            Vector3.Add(ref source, ref outerVector, out outerVector);
            Vector3.Add(ref source, ref innerVector, out innerVector);
            Vector2 outerPosition = new Vector2(outerVector.X, outerVector.Y);
            Vector2 innerPosition = new Vector2(innerVector.X, innerVector.Y);

            Vector2 offset = new Vector2(outer.Width, outer.Height);
            Vector2.Multiply(ref offset, 0.5f, out offset);
            Vector2.Subtract(ref outerPosition, ref offset, out outerPosition);
            Vector2.Subtract(ref innerPosition, ref offset, out innerPosition);

            spriteBatch.Draw(inner, innerPosition, targetColor);
            spriteBatch.Draw(outer, outerPosition, targetColor);

            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #25
1
ファイル: Pyramid.cs プロジェクト: tinco/Farseer-Physics
        public Pyramid(World world, Vector2 position, int count, float density)
        {
            Vertices rect = PolygonTools.CreateRectangle(0.5f, 0.5f);
            PolygonShape shape = new PolygonShape(rect, density);

            Vector2 rowStart = position;
            rowStart.Y -= 0.5f + count * 1.1f;

            Vector2 deltaRow = new Vector2(-0.625f, 1.1f);
            const float spacing = 1.25f;

            // Physics
            _boxes = new List<Body>();

            for (int i = 0; i < count; i++)
            {
                Vector2 pos = rowStart;

                for (int j = 0; j < i + 1; j++)
                {
                    Body body = BodyFactory.CreateBody(world);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = pos;
                    body.CreateFixture(shape);
                    _boxes.Add(body);

                    pos.X += spacing;
                }
                rowStart += deltaRow;
            }

            //GFX
            _box = new Sprite(ContentWrapper.PolygonTexture(rect, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f));
        }
コード例 #26
0
ファイル: VirtualStick.cs プロジェクト: tinco/Farseer-Physics
        public void Update(TouchLocation touchLocation)
        {
            if (touchLocation.State == TouchLocationState.Pressed && _picked < 0)
            {
                Vector2 delta = touchLocation.Position - _position;
                if (delta.LengthSquared() <= 2025f)
                    _picked = touchLocation.Id;
            }

            if ((touchLocation.State == TouchLocationState.Pressed || touchLocation.State == TouchLocationState.Moved) && touchLocation.Id == _picked)
            {
                Vector2 delta = touchLocation.Position - _center;
                if (delta != Vector2.Zero)
                {
                    float length = delta.Length();

                    if (length > 25f)
                        delta *= (25f / length);

                    StickPosition = delta / 25f;
                    StickPosition.Y *= -1f;
                    _position = _center + delta;
                }
            }
            if (touchLocation.State == TouchLocationState.Released && touchLocation.Id == _picked)
            {
                _picked = -1;
                _position = _center;
                StickPosition = Vector2.Zero;
            }
        }
コード例 #27
0
ファイル: ReadyQ.cs プロジェクト: HaKDMoDz/4DBlockEngine
        public override void DrawGraph()
        {
            BasicShapes.DrawSolidPolygon(m_primitiveBatch, BackgroundPolygon, 4, Color.Black, true);

            float x = Bounds.X;
            var deltaX = Bounds.Width / (float)ValuesToGraph;
            var yScale = Bounds.Bottom - (float)Bounds.Top;

            // we must have at least 2 values to start rendering
            if (GraphValues.Count <= 2)
                return;

            // start at last value (newest value added)
            // continue until no values are left
            for (var i = GraphValues.Count - 1; i > 0; i--)
            {
                var y1 = Bounds.Bottom - ((GraphValues[i] / (m_adaptiveMaximum - m_adaptiveMinimum)) * yScale);
                var y2 = Bounds.Bottom - ((GraphValues[i - 1] / (m_adaptiveMaximum - m_adaptiveMinimum)) * yScale);

                var x1 = new Vector2(MathHelper.Clamp(x, Bounds.Left, Bounds.Right), MathHelper.Clamp(y1, Bounds.Top, Bounds.Bottom));

                var x2 = new Vector2(MathHelper.Clamp(x + deltaX, Bounds.Left, Bounds.Right), MathHelper.Clamp(y2, Bounds.Top, Bounds.Bottom));

                BasicShapes.DrawSegment(m_primitiveBatch, x1, x2, Color.DeepSkyBlue);

                x += deltaX;
            }
        }
コード例 #28
0
        public CampDock(Vector2 position, ControlManager controlManager)
            : base(position, controlManager)
        {
            Thumbnail = new ImageButton96(
                 GameGraphics.GetTexture("trainingcamp_96").SourceTexture, ThumbnailPosition);

            Controls.Add(Thumbnail);

            #region create buttons for the farmer
            ImageButton48 createSwordsmanBtn = new ImageButton48(
              GameGraphics.GetTexture("swordsman_create_button").SourceTexture,
              ButtonsPositions[0]);
            createSwordsmanBtn.Click += new System.EventHandler(createSwordsmanBtn_Click);
            Controls.Add(createSwordsmanBtn);

            ImageButton48 createKnightBtn = new ImageButton48(
              GameGraphics.GetTexture("knight_create_button").SourceTexture,
              ButtonsPositions[1]);
            createKnightBtn.Click += new System.EventHandler(createKnightBtn_Click);
            Controls.Add(createKnightBtn);
            #endregion

            // add all controls
            AddControls();
        }
コード例 #29
0
ファイル: MusicNoteEffect.cs プロジェクト: Azarem/RogueAPI
 protected MusicNoteEffect()
 {
     _spriteName = "NoteWhite_Sprite";
     _scale = new Vector2(2f);
     _opacity = 0;
     _animateFlag = true;
 }
コード例 #30
0
ファイル: SpriteBatchItem.cs プロジェクト: Zeludon/FEZ
 public void Set(float x, float y, float dx, float dy, float w, float h, float sin, float cos, Color color, Vector2 texCoordTL, Vector2 texCoordBR)
 {
   this.vertexTL.Position.X = (float) ((double) x + (double) dx * (double) cos - (double) dy * (double) sin);
   this.vertexTL.Position.Y = (float) ((double) y + (double) dx * (double) sin + (double) dy * (double) cos);
   this.vertexTL.Position.Z = this.Depth;
   this.vertexTL.Color = color;
   this.vertexTL.TextureCoordinate.X = texCoordTL.X;
   this.vertexTL.TextureCoordinate.Y = texCoordTL.Y;
   this.vertexTR.Position.X = (float) ((double) x + ((double) dx + (double) w) * (double) cos - (double) dy * (double) sin);
   this.vertexTR.Position.Y = (float) ((double) y + ((double) dx + (double) w) * (double) sin + (double) dy * (double) cos);
   this.vertexTR.Position.Z = this.Depth;
   this.vertexTR.Color = color;
   this.vertexTR.TextureCoordinate.X = texCoordBR.X;
   this.vertexTR.TextureCoordinate.Y = texCoordTL.Y;
   this.vertexBL.Position.X = (float) ((double) x + (double) dx * (double) cos - ((double) dy + (double) h) * (double) sin);
   this.vertexBL.Position.Y = (float) ((double) y + (double) dx * (double) sin + ((double) dy + (double) h) * (double) cos);
   this.vertexBL.Position.Z = this.Depth;
   this.vertexBL.Color = color;
   this.vertexBL.TextureCoordinate.X = texCoordTL.X;
   this.vertexBL.TextureCoordinate.Y = texCoordBR.Y;
   this.vertexBR.Position.X = (float) ((double) x + ((double) dx + (double) w) * (double) cos - ((double) dy + (double) h) * (double) sin);
   this.vertexBR.Position.Y = (float) ((double) y + ((double) dx + (double) w) * (double) sin + ((double) dy + (double) h) * (double) cos);
   this.vertexBR.Position.Z = this.Depth;
   this.vertexBR.Color = color;
   this.vertexBR.TextureCoordinate.X = texCoordBR.X;
   this.vertexBR.TextureCoordinate.Y = texCoordBR.Y;
 }
コード例 #31
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            MPlayer modPlayer = player.GetModPlayer <MPlayer>(mod);

            if (modPlayer.glove)
            {
                for (int i = 0; i < 1; ++i)
                {
                    if (player.FindBuffIndex(mod.BuffType("BottledSpirit")) != -1)
                    {
                        Projectile.NewProjectile(position.X, position.Y, speedX + 2, speedY + 2, 297, damage, knockBack, Main.myPlayer);
                    }
                    if (player.FindBuffIndex(mod.BuffType("BigBottledSpirit")) != -1)
                    {
                        Projectile.NewProjectile(position.X, position.Y, speedX + 3, speedY + 3, 297, damage, knockBack, Main.myPlayer);
                        Projectile.NewProjectile(position.X, position.Y, speedX + 2, speedY + 2, 297, damage, knockBack, Main.myPlayer);
                    }
                    Projectile.NewProjectile(position.X, position.Y, speedX + 1, speedY + 1, type, damage, knockBack, Main.myPlayer);
                    Projectile.NewProjectile(position.X, position.Y, speedX + 1, speedY + 1, type, damage, knockBack, Main.myPlayer);
                    int k = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, Main.myPlayer);
                    Main.projectile[k].friendly = true;
                }
                return(false);
            }
            if (player.FindBuffIndex(mod.BuffType("BottledSpirit")) != -1 && !modPlayer.glove)
            {
                for (int i = 0; i < 1; ++i)
                {
                    Projectile.NewProjectile(position.X, position.Y, speedX + 1, speedY + 1, 297, damage, knockBack, Main.myPlayer);
                    int k = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, Main.myPlayer);
                    Main.projectile[k].friendly = true;
                }
                return(false);
            }
            if (player.FindBuffIndex(mod.BuffType("BigBottledSpirit")) != -1 && !modPlayer.glove)
            {
                for (int i = 0; i < 1; ++i)
                {
                    Projectile.NewProjectile(position.X, position.Y, speedX + 2, speedY + 2, 297, damage, knockBack, Main.myPlayer);
                    Projectile.NewProjectile(position.X, position.Y, speedX + 1, speedY + 1, 297, damage, knockBack, Main.myPlayer);
                    int k = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, Main.myPlayer);
                    Main.projectile[k].friendly = true;
                }
                return(false);
            }
            return(true);
        }
コード例 #32
0
        private static Queue <Vector2> AStar(Node source, Node dest, Pet pet)
        {
            NodeMap cameFrom = new NodeMap();

            CostMap g = new CostMap();

            g.Add(source, 0);

            CostMap f = new CostMap();

            f.Add(source, Heur(source, dest));

            List <Node> openSet = new List <Node>()
            {
                source
            };

            int loops = 0;

            while (openSet.Count > 0 && loops++ < 100)
            {
                Node current = openSet[0];
                if (current == dest)
                {
                    return(ReconstructPath(cameFrom, current));
                }

                openSet.Remove(current);

                foreach (Node neighbor in GetPassableNeighbors(current, pet))
                {
                    int tentative_g = GetCost(g, current) + 1;

                    if (tentative_g < GetCost(g, neighbor))
                    {
                        Add(cameFrom, neighbor, current);
                        Add(g, neighbor, tentative_g);
                        Add(f, neighbor, tentative_g + Heur(neighbor, dest));
                        if (!openSet.Contains(neighbor))
                        {
                            AddSorted(openSet, neighbor, f);
                        }
                    }
                }
            }
            return(new Queue <Vector2>());
        }
コード例 #33
0
ファイル: OrionPistol.cs プロジェクト: Steviegt6/SpiritMod
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY - 1)) * 45f;

            if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
            {
                position += muzzleOffset;
            }
            if (type == ProjectileID.Bullet)
            {
                type = ModContent.ProjectileType <OrionBullet>();
            }

            int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, 23, knockBack, player.whoAmI);

            return(false);
        }
コード例 #34
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int num6 = Main.rand.Next(1, 6);

            for (int index = 0; index < num6; ++index)
            {
                float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f;
                float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f;
                int   beam   = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f);
                Main.projectile[beam].damage = item.damage;
            }
            if (Main.rand.Next(1, 3) == 2)
            {
                Projectile.NewProjectile(position.X, position.Y, speedX * 1.5f, speedY * 1.5f, mod.ProjectileType("TrueAngelsSorrowProj"), damage, knockBack, player.whoAmI, 0.0f, 0.0f);
            }
            return(false);
        }
コード例 #35
0
ファイル: MonoGameGraphics.cs プロジェクト: mildmelon/mini2Dx
 public MonoGameGraphics(GraphicsDevice graphicsDevice)
 {
     _spriteBatch     = new SpriteBatch(graphicsDevice);
     _graphicsDevice  = graphicsDevice;
     _translation     = Vector2.Zero;
     _scale           = Vector2.One;
     _rotationCenter  = Vector2.Zero;
     _clipRectangle   = new org.mini2Dx.core.geom.Rectangle(0, 0, getWindowWidth(), getWindowHeight());
     _shapeRenderer   = new MonoGameShapeRenderer(graphicsDevice, (MonoGameColor)_setColor, _spriteBatch, _rotationCenter, _translation, _scale, _tint);
     _rasterizerState = new RasterizerState()
     {
         ScissorTestEnable = false
     };
     _graphicsDevice.ScissorRectangle = new Rectangle();
     _font = Mdx.fonts.defaultFont();
     updateFilter();
 }
コード例 #36
0
        private static void Render(
            GameTile tile,
            int tileIndex, // Tile index in its layer
            Map map,
            ContentManager contentManager,
            SpriteBatch spriteBatch,
            Camera camera
            )
        {
            if (tile.kind == GameTile.Kind.Empty)
            {
                // Skip empty tiles
                return;
            }

            PhysicalVector2 tilePos  = GetTilePosition(map, tileIndex);
            var             position = new Ecs.Components.Position()
            {
                data = tilePos
            };

            Tileset   tileset             = map.GameTileset;
            Texture2D tilesetTexture      = GetTexture(contentManager, tileset);
            int       tileFrame           = tile.GetTileFrame;
            var       texturePosRectangle = GetTexturePosRectangleWithTileFrame(
                tileFrame,
                tileset,
                map
                );
            var destRectangle = GetDestRectangle(map);

            var sprite = new EcsExt.Components.Visibles.Sprite()
            {
                texture             = tilesetTexture,
                texturePosRectangle = texturePosRectangle,
                destRectangle       = destRectangle,
                tint = Color.White
            };

            EcsExt.Systems.SpriteRender.Render(
                sprite,
                position,
                spriteBatch,
                camera
                );
        }
コード例 #37
0
        public static GameObject instance_place(Vector2 vec, Type go)
        {
            List <GameObject> appliable = SceneObjects.FindAll(x => x.GetType() == go);
            Point             s         = currentObject.Sprite.ImageRectangle.Size;
            Rectangle         fr        = new Rectangle((int)vec.X, (int)vec.Y, s.X, s.Y);

            foreach (GameObject g in appliable)
            {
                RectangleF r = new Rectangle((int)g.Position.X, (int)g.Position.Y, g.Sprite.ImageRectangle.Width, g.Sprite.ImageRectangle.Height);
                if (r.Intersects(fr))
                {
                    return(g);
                }
            }

            return(null);
        }
コード例 #38
0
        private void setButtonsPositions()
        {
            bool isHeadlinePresent = (HeadlineText != null);

            m_HeadlineTextBlock.Position = m_InitialPosition;
            Vector2 currentButtonsPosition = isHeadlinePresent
                ? new Vector2(m_InitialPosition.X,
                              m_InitialPosition.Y + m_HeadlineTextBlock.Bounds.Height)
                : m_InitialPosition;

            foreach (Button button in this.Components)
            {
                button.Position = currentButtonsPosition;
                float currentButtonHeight = button.Bounds.Height;
                currentButtonsPosition.Y += currentButtonHeight + k_SpaceBetweenButtonsInYAxis;
            }
        }
コード例 #39
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int   i     = Main.myPlayer;
            float num72 = item.shootSpeed;
            int   num73 = damage;
            float num74 = knockBack;

            num74           = player.GetWeaponKnockback(item, num74);
            player.itemTime = item.useTime;
            Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
            Vector2 value   = Vector2.UnitX.RotatedBy((double)player.fullRotation, default(Vector2));
            Vector2 vector3 = Main.MouseWorld - vector2;
            float   num78   = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
            float   num79   = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;

            if (player.gravDir == -1f)
            {
                num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
            }
            float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
            float num81 = num80;

            if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
            {
                num78 = (float)player.direction;
                num79 = 0f;
                num80 = num72;
            }
            else
            {
                num80 = num72 / num80;
            }
            num78     = 0f;
            num79     = 0f;
            vector2.X = (float)Main.mouseX + Main.screenPosition.X;
            vector2.Y = (float)Main.mouseY + Main.screenPosition.Y;
            Projectile.NewProjectile(vector2.X, vector2.Y, num78, num79, ModContent.ProjectileType <UltimateLeader1>(), num73, num74, i, 0f, 0f);
            Projectile.NewProjectile(vector2.X, vector2.Y, num78, num79, ModContent.ProjectileType <UltimateLeader2>(), num73, num74, i, 0f, 0f);
            if (player.ownedProjectileCounts[ModContent.ProjectileType <UltimateLeader3>()] == 0)
            {
                Projectile.NewProjectile(player.position.X, player.position.Y - 32, num78, num79, ModContent.ProjectileType <UltimateLeader3>(), num73, num74, i, 0f, 0f);
            }


            return(player.altFunctionUse != 2);
        }
コード例 #40
0
 public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
 {
     if (player.altFunctionUse != 2)
     {
         Vector2 SPos = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY); //this make so the projectile will spawn at the mouse cursor position
         position = SPos;
         for (int l = 0; l < Main.projectile.Length; l++)
         {                                                              //this make so you can only spawn one of this projectile at the time,
             Projectile proj = Main.projectile[l];
             if (proj.active && proj.type == item.shoot && proj.owner == player.whoAmI)
             {
                 proj.active = false;
             }
         }
     }
     return(true);
 }
コード例 #41
0
        public static void CalculateVelocity(Entity entity, GameTime gameTime)
        {
            // Air friction.
            entity.ApplyForce(Dungeon.FrictionCoeffAir * -entity.Velocity);
            // Gravity.
            //if (entity.AffectedByGravity)
            //{
            //    entity.ApplyForceY(GameWorld.GravitationalForce);
            //}

            // Sum forces and get acceleration.
            var forceTotal   = new Microsoft.Xna.Framework.Vector2(entity.Forces.Sum(i => i.X), entity.Forces.Sum(i => i.Y));
            var acceleration = forceTotal / entity.Mass;

            entity.Velocity += acceleration * (float)gameTime.ElapsedGameTime.TotalSeconds;
            entity.Forces.Clear();
        }
コード例 #42
0
        public static Microsoft.Xna.Framework.Vector2 StickyTiles(Microsoft.Xna.Framework.Vector2 Position, Microsoft.Xna.Framework.Vector2 Velocity, int Width, int Height)
        {
            Microsoft.Xna.Framework.Vector2 vector = Position;
            int num  = (int)(Position.X / 16f) - 1;
            int num2 = (int)((Position.X + (float)Width) / 16f) + 2;
            int num3 = (int)(Position.Y / 16f) - 1;
            int num4 = (int)((Position.Y + (float)Height) / 16f) + 2;

            if (num < 0)
            {
                num = 0;
            }
            if (num2 > Main.maxTilesX)
            {
                num2 = Main.maxTilesX;
            }
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 > Main.maxTilesY)
            {
                num4 = Main.maxTilesY;
            }
            for (int i = num; i < num2; i++)
            {
                for (int j = num3; j < num4; j++)
                {
                    if (Main.tile[i, j] != null && Main.tile[i, j].active && Main.tile[i, j].type == 51)
                    {
                        Microsoft.Xna.Framework.Vector2 vector2;
                        vector2.X = (float)(i * 16);
                        vector2.Y = (float)(j * 16);
                        if (vector.X + (float)Width > vector2.X && vector.X < vector2.X + 16f && vector.Y + (float)Height > vector2.Y && (double)vector.Y < (double)vector2.Y + 16.01)
                        {
                            if ((double)(Math.Abs(Velocity.X) + Math.Abs(Velocity.Y)) > 0.7 && Main.rand.Next(30) == 0)
                            {
                                Dust.NewDust(new Microsoft.Xna.Framework.Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 30, 0f, 0f, 0, default(Microsoft.Xna.Framework.Color), 1f);
                            }
                            return(new Microsoft.Xna.Framework.Vector2((float)i, (float)j));
                        }
                    }
                }
            }
            return(new Microsoft.Xna.Framework.Vector2(-1f, -1f));
        }
コード例 #43
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            //remove any other owned SpiritBow projectiles, just like any other sentry minion
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                Projectile p = Main.projectile[i];
                if (p.active && p.type == item.shoot && p.owner == player.whoAmI)
                {
                    p.active = false;
                }
            }
            //projectile spawns at mouse cursor
            Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);

            position = value18;
            return(true);
        }
コード例 #44
0
    public override void Fire(IngameState state, Microsoft.Xna.Framework.Vector2 mousePos)
    {
        Vector2 vector = state.camera.relativeXY(new Vector2(mousePos.X, mousePos.Y)) - firePosition;

        vector.Normalize();

        //The angle by which we rotate the bullet vectors by for spread shot.
        float angle = (float)state.rand.Next(-100, 100) / 1000;

        //Creating and using a Matrix to rotate the line by an angle.
        Matrix rotMatrix = Matrix.CreateRotationZ(angle);

        state.bullets.Add(new Bullet(firePosition, Vector2.Transform(vector, rotMatrix), damage, true));

        gunSound.Play();
        timeSinceShot = 0;
    }
コード例 #45
0
        public static bool LavaCollision(Microsoft.Xna.Framework.Vector2 Position, int Width, int Height)
        {
            int num  = (int)(Position.X / 16f) - 1;
            int num2 = (int)((Position.X + (float)Width) / 16f) + 2;
            int num3 = (int)(Position.Y / 16f) - 1;
            int num4 = (int)((Position.Y + (float)Height) / 16f) + 2;

            if (num < 0)
            {
                num = 0;
            }
            if (num2 > Main.maxTilesX)
            {
                num2 = Main.maxTilesX;
            }
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 > Main.maxTilesY)
            {
                num4 = Main.maxTilesY;
            }
            for (int i = num; i < num2; i++)
            {
                for (int j = num3; j < num4; j++)
                {
                    if (Main.tile[i, j] != null && Main.tile[i, j].liquid > 0 && Main.tile[i, j].lava)
                    {
                        Microsoft.Xna.Framework.Vector2 vector;
                        vector.X = (float)(i * 16);
                        vector.Y = (float)(j * 16);
                        int   num5 = 16;
                        float num6 = (float)(256 - (int)Main.tile[i, j].liquid);
                        num6     /= 32f;
                        vector.Y += num6 * 2f;
                        num5     -= (int)(num6 * 2f);
                        if (Position.X + (float)Width > vector.X && Position.X < vector.X + 16f && Position.Y + (float)Height > vector.Y && Position.Y < vector.Y + (float)num5)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #46
0
ファイル: PlagueOfToads.cs プロジェクト: Joost8910/Joostmod
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float  spread    = 90f * 0.0174f;
            float  baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);

            for (int i = 0; i < 4; i++)
            {
                double randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
                speedX = baseSpeed * (float)Math.Sin(randomAngle);
                speedY = baseSpeed * (float)Math.Cos(randomAngle);

                Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI);
            }
            Main.PlaySound(29, (int)player.position.X, (int)player.position.Y, 13);
            return(false);
        }
コード例 #47
0
ファイル: UIWindowManager.cs プロジェクト: ryancheung/WinWar
        internal static bool PointerMoved(Microsoft.Xna.Framework.Vector2 position)
        {
            for (int i = windows.Count - 1; i >= 0; i--)
            {
                if (!WinWarCS.Util.MathHelper.InsideRect(position, new Rectangle((int)windows[i].X, (int)windows[i].Y, windows[i].Width, windows[i].Height)))
                {
                    continue;
                }

                if (windows[i].PointerMoved(position))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #48
0
        /// <summary>
        /// Determines whether the closest point on the segment lies on one of the endpoints.
        /// </summary>
        /// <param name="point">The point to test to.</param>
        /// <returns>Whether the closest point on this segment to the argument point lies on the endpoints.</returns>
        #endregion
        public bool IsClosestPointOnEndpoint(ref Point point)
        {
            sUnitSegmentForIsClosestPointOnEndpoint.X = (float)(this.Point2.X - this.Point1.X);
            sUnitSegmentForIsClosestPointOnEndpoint.Y = (float)(Point2.Y - Point1.Y);
            sUnitSegmentForIsClosestPointOnEndpoint.Normalize();

            sPointVectorForIsClosestPointOnEndpoint.X = (float)(point.X - this.Point1.X);
            sPointVectorForIsClosestPointOnEndpoint.Y = (float)(point.Y - Point1.Y);

#if FRB_MDX
            float l = Vector2.Dot(sPointVectorForIsClosestPointOnEndpoint, sUnitSegmentForIsClosestPointOnEndpoint);
#else
            float l;
            Vector2.Dot(ref sPointVectorForIsClosestPointOnEndpoint, ref sUnitSegmentForIsClosestPointOnEndpoint, out l);
#endif
            return(l < 0 || l * l > this.GetLengthSquared());
        }
コード例 #49
0
ファイル: Yaniv.cs プロジェクト: TheIdanLapid/YanivDesktop
        // --- INITIALIZATION --- //
        public Yaniv()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible        = true;

            // LISTS
            tableCards          = new List <Card>();
            players             = new List <Player>();
            playersCardDrawings = new CardDrawing[3];
            for (var i = 0; i < 3; i++)
            {
                players.Add(new Player(i, String.Empty));
                playersCardDrawings[i] = CardDrawing.NONE;
            }
            scoresTable = Deserialized();
            scoresTable.Sort((score, other) => score.Score - other.Score);

            // VECTORS
            rotationVector        = new Vector2((float)79 / 2, (float)123 / 2);
            defaultTookCardVector = new Vector2(310, 60);
            nameVector            = new Vector2(265, 355);
            scoresTableVector     = new Vector2(60, 260);
            playersCardsVectors   = new[] {
                new List <Vector2>(),
                new List <Vector2>(),
                new List <Vector2>()
            };
            playersScoresSignVectors = new[] {
                new Vector2(450, 390),
                new Vector2(50, 80),
                new Vector2(600, 80)
            };
            playersCallingSignVectors = new[] {
                new Vector2(130, 340),
                new Vector2(110, 60),
                new Vector2(340, 60)
            };

            // OTHERS
            deck             = new int[54];
            lastDeletedIndex = new int[3];
            random           = new Random();
            nameString       = new StringBuilder(string.Empty);
        }
コード例 #50
0
        /// <summary>
        /// Draw frame
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="offset"></param>
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Vector2 offset)
        {
            if (this.DisplayingType == BlockType.Delete || this.DisplayingType == BlockType.None)
            {
                return;
            }

            Texture2D temp = _texture;
            var       ramp = _source.BlockType == BlockType.LeftRamp || _source.BlockType == BlockType.RightRamp;

            if (this.IsTransitioning)
            {
                _texture             = _intermediateTexture;
                this.SourceRectangle = _texture.Bounds;
                base.Draw(gameTime, offset);
            }
            else
            {
                if (this.IsShadowVisible && !this.IsTransitioning)
                {
                    _texture             = _shadowTexture;
                    this.SourceRectangle = _texture.Bounds;
                    base.Draw(gameTime, offset - Vector2.UnitY * 50);
                }

                _texture             = temp;
                this.SourceRectangle = _texture.Bounds;
                base.Draw(gameTime, offset - (ramp ? Vector2.UnitY * 1 : Vector2.Zero));

                if (_jumpSpotLeft != null)
                {
                    _jumpSpotLeft.Draw(gameTime, offset - Vector2.UnitX * 5 - this.Position - Vector2.UnitY * 7);
                }
                if (_jumpSpotRight != null)
                {
                    _jumpSpotRight.Draw(gameTime, offset - Vector2.UnitX * 50 - this.Position - Vector2.UnitY * 7);
                }
                if (_jumpSpotAlert != null)
                {
                    _jumpSpotAlert.Draw(gameTime, offset - this.Position + Vector2.UnitX * 25 + Vector2.UnitY * 60);
                }
            }

            _texture = temp;
        }
コード例 #51
0
        public static Microsoft.Xna.Framework.Vector2 WaterCollision(Microsoft.Xna.Framework.Vector2 Position, Microsoft.Xna.Framework.Vector2 Velocity, int Width, int Height, bool fallThrough = false, bool fall2 = false)
        {
            Microsoft.Xna.Framework.Vector2 result  = Velocity;
            Microsoft.Xna.Framework.Vector2 vector  = Position + Velocity;
            Microsoft.Xna.Framework.Vector2 vector2 = Position;
            int num  = (int)(Position.X / 16f) - 1;
            int num2 = (int)((Position.X + (float)Width) / 16f) + 2;
            int num3 = (int)(Position.Y / 16f) - 1;
            int num4 = (int)((Position.Y + (float)Height) / 16f) + 2;

            if (num < 0)
            {
                num = 0;
            }
            if (num2 > Main.maxTilesX)
            {
                num2 = Main.maxTilesX;
            }
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 > Main.maxTilesY)
            {
                num4 = Main.maxTilesY;
            }
            for (int i = num; i < num2; i++)
            {
                for (int j = num3; j < num4; j++)
                {
                    if (Main.tile[i, j] != null && Main.tile[i, j].liquid > 0)
                    {
                        int num5 = (int)Math.Round((double)((float)Main.tile[i, j].liquid / 32f)) * 2;
                        Microsoft.Xna.Framework.Vector2 vector3;
                        vector3.X = (float)(i * 16);
                        vector3.Y = (float)(j * 16 + 16 - num5);
                        if (vector.X + (float)Width > vector3.X && vector.X < vector3.X + 16f && vector.Y + (float)Height > vector3.Y && vector.Y < vector3.Y + (float)num5 && vector2.Y + (float)Height <= vector3.Y && !fallThrough)
                        {
                            result.Y = vector3.Y - (vector2.Y + (float)Height);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #52
0
ファイル: MMG.cs プロジェクト: Eldrazi/Mharadium
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 relativeCenter = player.RotatedRelativePoint(player.MountedCenter, true);

            float   num5      = player.inventory[player.selectedItem].shootSpeed * item.scale;
            Vector2 vector2_3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - relativeCenter;

            if ((double)player.gravDir == -1.0)
            {
                vector2_3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - relativeCenter.Y;
            }
            Vector2 vector2_4 = Vector2.Normalize(vector2_3);

            if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
            {
                vector2_4 = -Vector2.UnitY;
            }
            vector2_4    *= num5;
            item.velocity = vector2_4;

            float   rotationOffset = 8;
            int     positionOffset = 2;
            Vector2 projectilePos  = player.Center + new Vector2(0, Main.rand.Next(-positionOffset, positionOffset + 1));
            Vector2 spinningpoint  = Vector2.Normalize(item.velocity) * rotationOffset;

            spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
            {
                spinningpoint = -Vector2.UnitY;
            }

            float   angle   = (float)Math.Atan(speedY / speedX);
            Vector2 vector2 = new Vector2(projectilePos.X + 80F * (float)Math.Cos(angle), projectilePos.Y + 80F * (float)Math.Sin(angle));
            float   mouseX  = Main.mouseX + Main.screenPosition.X;

            if (mouseX < projectilePos.X)
            {
                vector2 = new Vector2(projectilePos.X - 80F * (float)Math.Cos(angle), projectilePos.Y - 80F * (float)Math.Sin(angle));
            }

            position = vector2;
            speedX   = spinningpoint.X * 3; // * 3 for faster bullet speed.
            speedY   = spinningpoint.Y * 3; // * 3 for faster bullet speed.
            return(true);                   // Spawn the bullet with the changed position and rotation.
        }
コード例 #53
0
ファイル: Jewolver.cs プロジェクト: Link250/QuaNinMod
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float  baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);

            position.X += 40 * (float)Math.Sin(baseAngle);
            position.Y += 40 * (float)Math.Cos(baseAngle);

            for (int i = 0; i < 1; ++i)
            {
                double randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * 0.00001;
                speedX = baseSpeed * (float)Math.Sin(randomAngle) * ((Main.rand.NextFloat() * 0.2f + 0.9f));
                speedY = baseSpeed * (float)Math.Cos(randomAngle) * ((Main.rand.NextFloat() * 0.2f) + 0.9f);

                Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, 287, damage, 32f, Main.myPlayer);
            }
            return(false);
        }
コード例 #54
0
 public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
 {
     if (player.altFunctionUse != 2)
     {
         Vector2 SPos = new Vector2((float)player.position.X, (float)player.position.Y);
         position = SPos;
         for (int l = 0; l < Main.projectile.Length; l++)
         {
             Projectile proj = Main.projectile[l];
             if (proj.active && proj.type == item.shoot && proj.owner == player.whoAmI)
             {
                 proj.active = false;
             }
         }
         return(true);
     }
     return(true);
 }
コード例 #55
0
ファイル: SkeletalonStaff.cs プロジェクト: TheFirel/SpiritMod
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            //projectile spawns at mouse cursor
            Vector2 value18 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);

            position = value18;
            for (int i = 0; i <= Main.rand.Next(1, 2); i++)
            {
                int        proj       = Terraria.Projectile.NewProjectile(position.X + Main.rand.Next(-30, 30), position.Y, 0f, 0f, type, damage, knockBack, player.whoAmI);
                Projectile projectile = Main.projectile[proj];
                for (int j = 0; j < 10; j++)
                {
                    int d = Dust.NewDust(projectile.Center, projectile.width, projectile.height, 0, (float)(Main.rand.Next(5) - 2), (float)(Main.rand.Next(5) - 2), 133);
                    Main.dust[d].scale *= .75f;
                }
            }
            return(false);
        }
コード例 #56
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 55f;

            if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
            {
                position += muzzleOffset;
            }
            for (int l = 0; l < Main.projectile.Length; l++)
            {
                Projectile proj = Main.projectile[l];
                if (proj.active && proj.type == item.shoot && proj.owner == player.whoAmI)
                {
                    proj.active = false;
                }
            }
            return(true);
        }
コード例 #57
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Guns/Revolver"), position);
            if (shotCounter < 1)
            {
                Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType <SkullBusterProj>(), damage, knockBack, player.whoAmI);
                shotsHit = 0;
            }
            shotCounter++;
            Vector2 direction = new Vector2(speedX, speedY);

            direction = direction.RotatedBy(recoil);
            int proj = Projectile.NewProjectile(position, direction, type, damage, knockBack, player.whoAmI);

            Main.projectile[proj].GetGlobalProjectile <SkullBusterGlobalProj>().shotFromGun = true;
            recoil = Main.rand.NextFloat(0.5f, 0.8f) * (Main.rand.NextBool() ? 1 : -1);
            return(false);
        }
コード例 #58
0
 public Building(TextureValue texture, Vector2 position, TextureValue Icon, ProjectileManager proj, Stats teamStats) : base(texture, position, teamStats, Color.Blue)
 {
     Cost     = new Wallet();
     name     = "Building";
     Position = new Vector2(0, 0);
     Size     = new Vector2(0, 0);
     stats.Add(new Health("Health", 100000));
     currentHealth       = 0;
     healthBar           = new HealthBar(new Rectangle(this.Position.ToPoint() - new Point(0, (int)(this.Size.Y * 16 + 1)), Size.ToPoint()));
     GarrisonedUnits     = new List <IUnit>();
     this.Icon           = Icon;//if the texture values change this breaks it find a better way to do this
     queueableThings     = new List <IQueueable <TextureValue> >();
     trainingQueue       = new Queue <IQueueable <TextureValue> >();
     BuildingDescription = "";
     techObservers       = new List <ITechObserver>();
     this.proj           = proj;
     this.teamStats      = teamStats;
 }
コード例 #59
0
 public ServerFarm(TextureValue texture, Vector2 position, TextureValue icon, ProjectileManager proj, Stats teamStats) : base(texture, position, icon, proj, teamStats)
 {
     Cost = new Wallet();
     Cost.Deposit(new Steel(), 100);
     Cost.Deposit(new Wood(), 200);
     Cost.Deposit(new Money(), 100);
     ChargeAMinute = new List <int>(5);
     ChargeTypes   = new List <IResource>()
     {
         new Energy()
     };
     name     = "Server Farm";
     Position = position;
     Size     = new Vector2(3, 3);
     stats.Add(new Health("Health", 2000));
     healthBar           = new HealthBar(new Rectangle(new Point((int)position.X, (int)position.Y - 1), new Point((int)(Size.X * 16), (int)(Size.Y))));
     BuildingDescription = "Used if a unit cap is implemented, at the moment this is also useless.";
 }
コード例 #60
0
ファイル: MouseJoint.cs プロジェクト: matrix4x4/Space
        /// <summary>Initializes the joint with the specified properties.</summary>
        /// <param name="target">The initial world target point. This is assumed to coincide with the body anchor initially.</param>
        /// <param name="maxForce">
        ///     The maximum constraint force that can be exerted to move the candidate body. Usually you will
        ///     express as some multiple of the weight (multiplier * mass * gravity).
        /// </param>
        /// <param name="frequency">The response speed in Hz.</param>
        /// <param name="dampingRatio">The damping ratio. 0 = no damping, 1 = critical damping.</param>
        internal void Initialize(WorldPoint target, float maxForce, float frequency, float dampingRatio)
        {
            System.Diagnostics.Debug.Assert(maxForce >= 0.0f);
            System.Diagnostics.Debug.Assert(frequency >= 0.0f);
            System.Diagnostics.Debug.Assert(dampingRatio >= 0.0f);

            _targetA      = target;
            _localAnchorB = BodyB.GetLocalPoint(_targetA);

            _maxForce = System.Math.Max(0, maxForce);
            _impulse  = Vector2.Zero;

            _frequency    = System.Math.Max(0, frequency);
            _dampingRatio = System.Math.Max(0, dampingRatio);

            _tmp.Beta  = 0.0f;
            _tmp.Gamma = 0.0f;
        }