public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { currentTexture = content.Load<Texture2D>(assetName); origin = new Vector2(currentTexture.Width / 2, currentTexture.Height / 2); body = BodyFactory.Instance.CreateCircleBody(CurrentTexture.Width /2, 1.0f); geom = GeomFactory.Instance.CreateCircleGeom(body, CurrentTexture.Width/2, 100); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); return true; }
public Animation starAnimation; //this olds the animation #endregion Fields #region Methods public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { currentTexture = content.Load<Texture2D>(assetName); origin = new Vector2((currentTexture.Width / 2) / 2, currentTexture.Height / 2); body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Width / 2), currentTexture.Height, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Width / 2), currentTexture.Height); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); animationPlayer.PlayAnimation(starAnimation);//plays the animation return true; }
public Animation teleAnimation; //this holds the teleport animation #endregion Fields #region Methods public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { teleAnimation = new Animation(content.Load<Texture2D>("portalv2"), 0.1f, true); //creates the animation. 0.1f is the time between frames and true means is looping currentTexture = content.Load<Texture2D>(assetName); origin = new Vector2((currentTexture.Height / 4) / 2, currentTexture.Height / 2); body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Height / 4), currentTexture.Height, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Height / 4), currentTexture.Height); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); animationPlayer.PlayAnimation(teleAnimation);//plays the teleport animation return true; }
public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { quarkAnimation = new Animation(content.Load<Texture2D>("Sprites\\quark"), 0.1f, true); //quarkAnimation has 0.1 units between frames, and is looping currentTexture = content.Load<Texture2D>(assetName); origin = new Vector2(currentTexture.Width / 2, currentTexture.Height / 2); body = BodyFactory.Instance.CreateRectangleBody(currentTexture.Width, currentTexture.Height, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, currentTexture.Width / 9, currentTexture.Height); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); this.geom.CollisionEnabled = false; // this object should not collide with other objects animationPlayer.PlayAnimation(quarkAnimation);//plays the quark animation return true; }
public Animation pickupAnimation; // the animation for the pickup #endregion Fields #region Methods public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { currentTexture = content.Load<Texture2D>(assetName); pickupAnimation = new Animation(content.Load<Texture2D>("pickup"), 0.1f, true); origin = new Vector2((currentTexture.Width / 8) / 2, currentTexture.Height / 2); body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Width / 8), currentTexture.Height, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Width / 8), currentTexture.Height); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); animationPlayer.PlayAnimation(pickupAnimation); isAlive = true; //if boolean is true, it has no been picked up return true; }
public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { currentTexture = content.Load<Texture2D>(assetName); bouncyAnimation = new Animation(content.Load<Texture2D>("sprites//bouncing platform2"), 0.1f, true); origin = new Vector2((currentTexture.Width / 5) / 2, currentTexture.Height / 2); // width is devided by 5 due to 5 frames on the spritesheet body = BodyFactory.Instance.CreateRectangleBody((currentTexture.Width / 5), currentTexture.Height, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, (currentTexture.Width / 5), currentTexture.Height); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); animationPlayer.PlayAnimation(bouncyAnimation); //initial animation for the bouncy tile return true; }
public override bool OnCollision(FarseerGames.FarseerPhysics.Collisions.Geom geom1, FarseerGames.FarseerPhysics.Collisions.Geom geom2, FarseerGames.FarseerPhysics.Collisions.ContactList contacts) { if (!alive) return true; FarseerGames.FarseerPhysics.Collisions.Geom another; if (geom1 == this._geom) another = geom2; else another = geom1; if (another.Tag == null) return true; GameObject3D obj = another.Tag as GameObject3D; Vector2 force =this._body.Position- another.Body.Position; obj.EnemyHit(force); return true; }
public override bool OnCollision(FarseerGames.FarseerPhysics.Collisions.Geom geom1, FarseerGames.FarseerPhysics.Collisions.Geom geom2, FarseerGames.FarseerPhysics.Collisions.ContactList contacts) { FarseerGames.FarseerPhysics.Collisions.Geom anotherGeom; if (geom1 == _geom) anotherGeom = geom2; else anotherGeom = geom1; //Game1.Instance.debugTexts.Add("Col:" + anotherGeom.CollisionCategories.ToString()); if (anotherGeom.CollisionCategories == FarseerGames.FarseerPhysics.CollisionCategory.Cat3) { Enemy obj = (Enemy)anotherGeom.Tag; if (!obj.alive) return false; obj.BulletHit(); } //return base.OnCollision(geom1, geom2, contacts); lifeSpan = -1; Game1.Instance.particles.Add(new BulletSpark(Get3Dpos(), 0.00001f, -_body.LinearVelocity)); return true; }
bool OnSpringUpdated(Spring sender, FarseerGames.FarseerPhysics.Dynamics.Body body) { Update(); return true; }
public override bool Load(string assetName, Microsoft.Xna.Framework.Content.ContentManager content, FarseerGames.FarseerPhysics.PhysicsSimulator simulator) { currentTexture = content.Load<Texture2D>(assetName); //varius animations, the units between each frame, and whether they are repeating (true) runAnimation = new Animation(content.Load<Texture2D>("Run"), 0.1f, true); idleAnimation = new Animation(content.Load<Texture2D>("still"), 0.1f, false); jumpStillAnimation = new Animation(content.Load <Texture2D>("JumpStill"), 0.1f, false); jumpRunAnimation = new Animation(content.Load<Texture2D>("runJump"), 0.05f,true); origin = new Vector2(42 / 2, 76 / 2); body = BodyFactory.Instance.CreateRectangleBody(42, 76, 1); geom = GeomFactory.Instance.CreateRectangleGeom(body, 42, 76); body.Position = position; body.Tag = this; geom.Tag = this; simulator.Add(body); simulator.Add(geom); Body.MomentOfInertia = 9999999999; //Stops player from spinning and landing on his head body.LinearDragCoefficient = 10; //air resistance (effects jump behaviour) return true; }