public void T16_PlaneGetsRepairedAfter10TurnsOnRunway() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir, damage: PlaneDamage.Damaged, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Runway runway = new Runway("runway 01", RunwayStatus.Empty); runway.AcceptPlane(plane); for (int i = 0; i < 9; i++) // 9 turns have passed { time.AddTurn(); } Assert.IsTrue(plane.Damage == PlaneDamage.Damaged); // When time.AddTurn(); // Then Assert.IsTrue(plane.Damage == PlaneDamage.None); }
public void T11_MakingSurePlaneWorksProperly() { // Given int initialFuel = 100; int fuelBurn = 1; int fuelGain = 3; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir, fuel: initialFuel, passingTime: time); time.AddTurn(); time.AddTurn(); time.AddTurn(); time.AddTurn(); Runway runway = new Runway("runway 01", RunwayStatus.Empty); plane.TryLandOn(runway); // When time.AddTurn(); // Then Assert.IsTrue(plane.Fuel == initialFuel - 4 * fuelBurn + 1 * fuelGain); }
public void T18_GoToRunwayAfter3TurnsOnHangar() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Plane plane2 = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Hangar.AddPlaneToHangar(plane); Hangar.AddPlaneToHangar(plane2); Runway runway = new Runway("runway 01", RunwayStatus.Empty); ControlTower tower = new ControlTower(new Runway[] { runway }); runway.AcceptPlane(plane); for (int i = 0; i < 3; i++) // 9 turns have passed { time.AddTurn(); } // When time.AddTurn(); // Then Assert.IsTrue(plane.Location == PlaneLocation.OnRunway); Assert.IsTrue(plane2.Location == PlaneLocation.OnRunway); }
public void Plane_OK() { Image image = Utils.Utils.GetImageResource <Terrain>("Landscape.Terrains.Grass.png"); IPlane plane = PlaneFactory.Create(false, new Vbo() { Position = new Vector3(-1, 0, -1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-1, 0, 1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(1, 0, 1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(1, 0, -1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, image, OpenTK.Graphics.OpenGL.TextureWrapMode.Clamp); Assert.AreEqual(2, plane.Width, "Plane Width"); Assert.AreEqual(0, plane.Height, "Plane Height"); Assert.AreEqual(2, plane.Depth, "Plane Depth"); }
public void T02_RunwayDoesNotAcceptAPlaneIfPlaneOnRunwayAndRunwayEmpty() { // Given Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway); Runway runway = new Runway("runway 01", RunwayStatus.Empty); // When runway.AcceptPlane(plane); // Then Assert.IsTrue(runway.Status == RunwayStatus.Empty); }
public void T01_RunwayAcceptsAPlaneIfPlaneInAirAndRunwayEmpty() { // Given Plane plane = PlaneFactory.Create(PlaneLocation.InAir); Runway runway = new Runway("runway 01", RunwayStatus.Empty); // When runway.AcceptPlane(plane); // Then Assert.IsTrue(runway.Status == RunwayStatus.Full); }
public override void Begin() { Plane = new List <Plane>(); Fac = Game.Fac[PlaneKind]; Seed = new System.Random(); Plane.Add(Fac.Create()); Plane[0].Entity.transform.localPosition = GetRandomPosition(); if (!Unbeatable) { Game.Planes.Add(Plane[0]); } }
public override void Update() { while (Time.time > BeginTime + ((EndTime - BeginTime) / GenerateAmount) * Plane.Count) { Plane p = Fac.Create(); Plane.Add(p); p.Entity.transform.localPosition = GetRandomPosition(); if (!Unbeatable) { Game.Planes.Add(p); } } }
public void T07_SinglePlaneCannotLandOnNullRunway() { // Given Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir); Runway runway = null; // When LandingStatus result = plane.TryLandOn(runway); // Then Assert.IsTrue(runway == null); Assert.IsTrue(result == LandingStatus.Failure); Assert.IsTrue(plane.Location == PlaneLocation.InAir); }
public void T04_SinglePlaneCanLandOnSingleEmptyRunway() { // Given Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir); Runway runway = new Runway("runway 01", RunwayStatus.Empty); // When LandingStatus result = plane.TryLandOn(runway); // Then Assert.IsTrue(result == LandingStatus.Success); Assert.IsTrue(plane.Location == PlaneLocation.OnRunway); Assert.IsTrue(runway.Status == RunwayStatus.Full); }
public void T10_PlaneRefuelsOnGround() { // Given int initialFuel = 100; int fuelGain = 3; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, fuel: initialFuel, passingTime: time); // When time.AddTurn(); // Then Assert.IsTrue(plane.Fuel == initialFuel + fuelGain); }
public void T09_PlaneLosesFuelInAir() { // Given int initialFuel = 100; int fuelBurn = 1; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir, fuel: initialFuel, passingTime: time); // When time.AddTurn(); // Then Assert.IsTrue(plane.Fuel == initialFuel - fuelBurn); }
public void T12_PlaneHasMaxFuel() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); // When time.AddTurn(); // Then Assert.IsTrue(plane.Fuel == initialFuel); }
public void T15_PlaneCannotStartIfIsDamaged() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.InAir, damage: PlaneDamage.Damaged, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Runway runway = new Runway("runway 01", RunwayStatus.Empty); runway.AcceptPlane(plane); time.AddTurn(); // When Plane launched = runway.LaunchPlane(); // Then Assert.IsTrue(launched == null); Assert.IsTrue(runway.Status == RunwayStatus.Full); }
public void T14_PlaneCannotStartIfHasLessThanHalfMaxFuel() { // Given int initialFuel = 10; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(name: "Omega Flight", location: PlaneLocation.InAir, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Runway runway = new Runway("runway 01", RunwayStatus.Empty); runway.AcceptPlane(plane); time.AddTurn(); // When Plane launched = runway.LaunchPlane(); // Then Assert.IsTrue(launched == null); Assert.IsTrue(runway.Status == RunwayStatus.Full); }
public void T17_PlaneAddToHangarAfter25TurnsOnRunway() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Runway runway = new Runway("runway 01", RunwayStatus.Empty); ControlTower tower = new ControlTower(new Runway[] { runway }); runway.AcceptPlane(plane); for (int i = 0; i < 24; i++) // 9 turns have passed { time.AddTurn(); } // When time.AddTurn(); // Then Assert.IsTrue(Hangar.Planes.Contains(plane)); }
public CubeMap(float width, bool invertAllFaces, Vector3 centeredAt, Image frontTextureImage, Image backTextureImage, Image bottomTextureImage, Image topTextureImage, Image leftTextureImage, Image rightTextureImage) { Planes = new List <IPlane>(); Width = width; Center = new Vector3(0, 0, 0); MyProgramHandler = new int[5]; CubeCenterPosition = new Vector3(Width / 2 + centeredAt.X, Width / 2 + centeredAt.Y, Width / 2 + centeredAt.Z); IPlane backPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(1, 0) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(0, 1) }, backTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); IPlane frontPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(1, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, 0, 1), TexCoord = new Vector2(0, 1) }, frontTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); IPlane topPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(1, 0) }, topTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); IPlane leftPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(-1, 0, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(1, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(0, 1) }, leftTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); IPlane rightPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(1, 0) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(1, 0, 0), TexCoord = new Vector2(0, 1) }, rightTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); IPlane bottomPlane = PlaneFactory.Create(invertAllFaces, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, -Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(Width / 2.0f + centeredAt.X, -Width / 2.0f + centeredAt.Y, Width / 2.0f + centeredAt.Z), Normal = new Vector3(0, -1, 0), TexCoord = new Vector2(1, 0) }, topTextureImage, OpenTK.Graphics.OpenGL.TextureWrapMode.ClampToEdge); TopPlane = topPlane; BackPlane = backPlane; FrontPlane = frontPlane; LeftPlane = leftPlane; RightPlane = rightPlane; BottomPlane = bottomPlane; Planes.AddRange(new List <IPlane> { topPlane, backPlane, frontPlane, leftPlane, rightPlane, bottomPlane }); }
static void Main(string[] args) { var gameWindow = new GameWindow(WindowWidth, WindowHeight, new GraphicsMode(32, 24, 0, 8), "Ocean sim (Grestner waves) and terrain", GameWindowFlags.Default, DisplayDevice.AvailableDisplays.Last()); gameWindow.MakeCurrent(); gameWindow.Context.LoadAll(); Utils.Utils.GLRenderProperties(WindowWidth, WindowHeight); _camera = Factory <Camera.Camera> .Create(_cameraPosition0, LookAt0, new Vector3(0, 1, 0)); _light = LightFactory.Create(new Vector3(-350.0f, 300.0f, 0.0f), new Color4(255, 255, 255, 1), new Color4(255, 255, 255, 1), new Color4(252, 252, 252, 1), LightName.Light0); _light.Load(); _terrain = Terrainfactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.TOPOMAP1.GIF"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Dirt.jpg"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.sand.jpg"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Grass.png"), Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Rock.png")); _terrain.Load(); _cubeMap = CubeMapFactory.Create(2500, false, new Vector3(256, 0, 256), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_back.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_top.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_left.jpg"), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_right.jpg") ); _cubeMap.Load(); _woodenChest = CubeMapFactory.Create(100, true, new Vector3(256, 150, 256), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.plank.jpg")); _woodenChest.Load(); _water = new Water(WaterWidth, WaterHeight); _water.Load(); _seaBed = PlaneFactory.Create(true, new Vbo() { Position = new Vector3(0, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(0, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(WaterWidth, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 1) }, new Vbo() { Position = new Vector3(WaterWidth, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 0) }, Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.seabed.jpg"), TextureWrapMode.ClampToEdge); _seaBed.Load(); _birdTexture = FramBufferOBjectFactory.Create(512, 512); _birdTexture.Load(); gameWindow.RenderFrame += gameWindow_RenderFrame; gameWindow.UpdateFrame += gameWindow_UpdateFrame; gameWindow.Keyboard.KeyDown += Keyboard_KeyDown; gameWindow.Run(60.0, 30.0); }