public BrickWall(Project2Game game, LevelPiece levelPiece, Vector3 offset, int height, int width, bool interleaved) : base(game, levelPiece, offset) { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { float sizeScaler = 4f; Vector3 brickPosition = this.originPosition + offset + new Vector3(2f * i, 1f * j, 0f) * (sizeScaler); brickPosition.Y += sizeScaler/2f; //push all bricks off the ground if (interleaved) { if (j % 2 == 1) { brickPosition.X += sizeScaler; } } Brick newBrick = new Brick( game, game.models["box"], brickPosition, new Vector3(2f, 1f, 1f) * sizeScaler, false ); this.AddChild(newBrick); } } }
public SeeSaw(Project2Game game, LevelPiece levelPiece, Vector3 offset) : base(game, levelPiece, offset) { var baseHeight = 2; Box seeSawbase = new Box( game, game.models["box"], this.originPosition + new Vector3(0f, 0.5f * baseHeight, 0f), new Vector3(30f, 3f, 1.5f) ); seeSawbase.PhysicsDescription.IsStatic = true; Box seeSawPlatform= new Box( game, game.models["box"], this.originPosition + new Vector3(0f, 2f * baseHeight, 0f), new Vector3(50f, 1f, 40f) ); seeSawPlatform.PhysicsDescription.IsStatic = false; seeSawPlatform.PhysicsDescription.Mass = 50f; //var constraint = new Jitter.Dynamics.Joints.HingeJoint(game.physics.World, seeSawbase.physicsDescription.RigidBody, seeSawPlatform.physicsDescription.RigidBody, PhysicsSystem.toJVector(this.originPosition + new Vector3(0f, baseHeight, 0f)), Jitter.LinearMath.JVector.Right); //constraint.PointOnPointConstraint1.Softness = 0.001f; var constraint = new Jitter.Dynamics.Constraints.PointOnPoint(seeSawbase.PhysicsDescription, seeSawPlatform.PhysicsDescription, PhysicsSystem.toJVector(originPosition + new Vector3(0, 0.5f * baseHeight, 0))); constraint.BiasFactor = 100f; //constraint.Softness = 0.001f; //game.physics.World.AddConstraint(constraint); this.AddChild(seeSawPlatform); this.AddChild(seeSawbase); }
public FriendlyBoid(Project2Game game, Flock flock, Model model, Vector3 position) : base(game, flock, model, position, Flock.BoidType.Friendly) { maxHealth = 200; health = maxHealth; attack = 10; healthyColor = Color.Green; }
public TerrainEndZone(Project2Game game, Level level, Vector3 position) : base(game, level, position) { var endPuzzle = new EndGoal(game, this, position + new Vector3(Level.PreferedTileWidth/2.0f, 0, Level.PreferedTileHeight/2.0f)); AddChild(endPuzzle); this.endGoal = endPuzzle.obelisk; }
public Monkey(Project2Game game, Model model, Vector3 position) : base(game, model, position) { // Load custom rainbox monkey effect effect = game.Content.Load<Effect>("Shaders\\Cel"); PhysicsDescription.Mass = 20f; //PhysicsDescription.Tag = "player"; }
public EnemyBoid(Project2Game game, Flock flock, Model model, Vector3 position) : base(game, flock, model, position, Flock.BoidType.Enemy) { maxHealth = 80; health = maxHealth; attack = 20; healthyColor = Color.Red; }
public EndGoal(Project2Game game, LevelPiece levelPiece, Vector3 offset) : base(game, levelPiece, offset) { // place obelisk var scale = new Vector3(6, 6, 6); obelisk = new Obelisk(game, offset + new Vector3(0, scale.Y * 0.5f, 0), scale); obelisk.PhysicsDescription.IsStatic = true; this.AddChild(obelisk); }
public ModelGameObject(Project2Game game, Model model, Vector3 position, Vector3 orientation, Vector3 scale) : base(game, position, orientation, scale) { this.model = model; if (model != null) { boundingSphere = model.CalculateBounds(WorldMatrix); } }
protected ModelPhysicsObject(Project2Game game, Model model, Vector3 position, Vector3 orientation, Vector3 size) : base(game, model, position, orientation, size) { this.PhysicsDescription = GeneratePhysicsDescription(); this.Position = PhysicsSystem.toVector3(PhysicsDescription.Position); game.physics.AddBody(PhysicsDescription); ToDestroy = false; }
public HeightMapTerrain(Project2Game game, Vector3 position, Texture2D heightMap, float xScale, float zScale) : base(game,position,xScale,zScale) { this.HeightMap = heightMap; this.TerrainData = GenerateTerrainData(); this.GenerateGeometry(); this.CreateBuffers(); this.PhysicsDescription = GeneratePhysicsDescription(); game.physics.AddBody(PhysicsDescription); }
public Boid(Project2Game game, Flock flock, Model model, Vector3 position, Flock.BoidType boidType) : base(game, model, position) { this.health = maxHealth; this.PhysicsDescription.Mass = 0.25f; this.boidType = boidType; this.flock = flock; this.game.physics.World.CollisionSystem.CollisionDetected += HandleCollision; effect = game.Content.Load<Effect>("Shaders\\Cel"); }
public Level(Project2Game game) { this.game = game; Children = new List<INode>(); player = new Monkey(this.game, game.models["bigmonkey"], getStartPosition()); AddChild(player); flock = new Flock(this.game, this); AddChild(flock); }
protected Terrain(Project2Game game, Vector3 position, float xScale, float zScale) : base(game,position) { this.xScale = xScale; this.zScale = zScale; basicEffect.VertexColorEnabled = true; // These will have to happen in the subclasses because of needing access to subclass constructor arguments/fields //this.TerrainData = GenerateTerrainData(); //this.PhysicsDescription = GeneratePhysicsDescription(); //this.Position = PhysicsSystem.toVector3(PhysicsDescription.Position); //game.physics.AddBody(PhysicsDescription); }
public GamePage() { this.InitializeComponent(); Window.Current.Content = this; Window.Current.Activate(); game = new Project2Game(Project2.LevelSelection.Level1); game.PauseRequest += game_PauseRequest; game.ScoreUpdated += updateScore; if(!game.IsRunning) game.Run(this); }
/// <summary> /// Construct a static physics mesh terrain procedurally using diamond-square. Density is n, a square with width 2^n-1 will be generated. /// </summary> /// <param name="game"></param> /// <param name="position">Bottom left corner of heightfield</param> /// <param name="density">Controls number of points in height field as square of side length 2^n-1 (e.g. 6)</param> /// <param name="scale">Distance between height field points</param> /// <param name="amplitude">Variance of height field</param> public DiamondSquareTerrain(Project2Game game, Vector3 position, int density, float xScale, float zScale, float amplitude) : base(game, position,xScale, zScale) { this.Density = density; this.Amplitude = amplitude; this.TerrainData = GenerateTerrainData(); this.GenerateGeometry(); this.CreateBuffers(); this.PhysicsDescription = GeneratePhysicsDescription(); game.physics.AddBody(PhysicsDescription); }
/// <summary> /// Constructs a flat terrain /// </summary> /// <param name="game"></param> /// <param name="position"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> public FlatTerrain(Project2Game game, Vector3 position, float xScale, float zScale, float frontHeight = 0.0f, float backHeight = 0.0f) : base(game, position, xScale, zScale) { this.frontHeight = frontHeight; this.backHeight = backHeight; this.TerrainData = GenerateTerrainData(); GenerateGeometry(); SetColour(); CreateBuffers(); this.PhysicsDescription = GeneratePhysicsDescription(); this.Position = PhysicsSystem.toVector3(PhysicsDescription.Position); game.physics.AddBody(PhysicsDescription); //this.basicEffect.DirectionalLight0.Direction = new Vector3(0f, -2f, -1f); this.basicEffect.SpecularPower = 5000f; }
public LevelPlane(Project2Game game, Level level, Vector3 position, SlopeType slopeType, float slopeHeight = 16f, int xSize = Level.PreferedTileWidth, int ySize = Level.PreferedTileHeight) : base (game, level, position) { this.xSize = xSize; this.ySize = ySize; // this should be z size for consistency in 3D float frontHeight = 0f; float backHeight = 0f; if (slopeType == SlopeType.SlopeUp) { backHeight = slopeHeight; } if (slopeType == SlopeType.SlopeDown) { frontHeight = slopeHeight; } // calculate the angle of gradient var angle = (float)Math.Atan2(backHeight - frontHeight, xSize - 0); //y_2 - y_2 / x_2 - x_1 = gradient var separation = xSize; // disatance between walls (default to tile width) var wallWidth = 2.0f; // width of wall var wallHeight = 4.0f; // height of wall // vertical displacement of wall, offset so it sits on the ground var heightDisplacement = Math.Abs((backHeight - frontHeight)/2.0f) + wallHeight / 2.0f; // instantiate a wall for either side of the plane var box1 = new Box(game, game.models["box"], position + new Vector3(0f, heightDisplacement, ySize / 2.0f), new Vector3(wallWidth, wallHeight, ySize), new Vector3(0, -angle, 0)); var box2 = new Box(game, game.models["box"], position + new Vector3(separation, heightDisplacement, ySize / 2.0f), new Vector3(wallWidth, wallHeight, ySize), new Vector3(0, -angle, 0)); box1.PhysicsDescription.IsStatic = true; box2.PhysicsDescription.IsStatic = true; AddChild(box1); AddChild(box2); if (slopeType == SlopeType.Flat) { //this.physicsPuzzles.Add(new PhysicsPuzzles.SeeSaw(game, this, new Vector3(32, 0, 32))); } // add floor var floor = new FlatTerrain(game, position, (float)xSize, (float)ySize, frontHeight, backHeight); floor.PhysicsDescription.IsStatic = true; AddChild(floor); }
public Ball(Project2Game game, Model model, Vector3 position) : base(game, model, position) { this.PhysicsDescription.Mass = 600f; }
/// <summary> /// Create new GameObject with default orientation and size. /// </summary> /// <param name="game"></param> /// <param name="position"></param> protected GameObject(Project2Game game, Vector3 position) : this(game, position, Vector3.Zero, Vector3.One) { }
protected GameObject(Project2Game game, Vector3 position, Vector3 orientation, Vector3 scale) { this.game = game; Children = new List<INode>(); // Just in case...? WorldMatrix = Matrix.Identity; Scale = scale; Orientation = orientation; Position = position; // Setup rendering effect basicEffect = new BasicEffect(game.GraphicsDevice) { VertexColorEnabled = false, View = game.camera.view, Projection = game.camera.projection, World = Matrix.Identity, LightingEnabled = true }; basicEffect.EnableDefaultLighting(); basicEffect.SpecularPower = 5000f; }
/// <summary> /// Create a new GameObject with default orientation. /// </summary> /// <param name="game"></param> /// <param name="position"></param> /// <param name="scale"></param> protected GameObject(Project2Game game, Vector3 position, Vector3 scale) : this(game, position, Vector3.Zero, scale) { }
/// <summary> /// Create a new Brick with default orientation /// </summary> /// <param name="game"></param> /// <param name="model"></param> /// <param name="position"></param> /// <param name="size"></param> /// <param name="isStatic"></param> public Brick(Project2Game game, Model model, Vector3 position, Vector3 size, Boolean isStatic) : base(game, model, position, Vector3.Zero, size) { this.PhysicsDescription.Mass = 20f; }
/// <summary> /// Construct a static physics mesh terrain procedurally using diamond-square. Density is n, a square with width 2^n-1 will be generated. /// </summary> /// <param name="game"></param> /// <param name="position">Bottom left corner of heightfield</param> /// <param name="density">Controls number of points in height field as square of side length 2^n-1 (e.g. 6)</param> /// <param name="scale">Distance between height field points</param> /// <param name="amplitude">Variance of height field</param> public Terrain(Project2Game game, Vector3 position, int density, double scale, double amplitude) : this(game, GeneratePhysicsDescription(position, density, scale, amplitude, true)) { }
/// <summary> /// Constructs a flat terrain /// </summary> /// <param name="game"></param> /// <param name="position"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> public Terrain(Project2Game game, Vector3 position, int xScale, int yScale, float frontHeight = 0.0f, float backHeight = 0.0f) : this(game, GeneratePhyicsDescription(position, xScale, yScale, frontHeight, backHeight, true)) { }
public Obelisk(Project2Game game, Vector3 position, Vector3 size) : base(game, game.Content.Load<Model>("Models\\Crate_Barrel"), position, size, Vector3.Zero) { effect = game.Content.Load<Effect>("Shaders\\Cel"); }
private Terrain(Project2Game game, PhysicsDescription physicsDescription) : base(game, physicsDescription) { // This is the old super constructor call. Needs to be updated }
public Box(Project2Game game, Model model, Vector3 position, Vector3 size) : this(game, model, position, size, Vector3.Zero) { }
public Box(Project2Game game, Model model, Vector3 position, Vector3 size, Vector3 orientation) : base(game, model, position, orientation, size) { }
public TerrainLevel(Project2Game game) : base(game) { BuildLevel(); // virtual member call in constructor, like I give a }
public NeutralBoid(Project2Game game, Flock flock, Model model, Vector3 position) : base(game, flock, model, position, Flock.BoidType.Neutral) { }