private void button1_Click_1(object sender, EventArgs e) { if (listBoxLevels.SelectedIndex > -1) { //Прежде чем забрать машину, надо выбирать с какого уровня будем забирать string level = listBoxLevels.Items[listBoxLevels.SelectedIndex].ToString(); if (maskedTextBox1.Text != "") { try { ITechnique plane = parking.GetPlaneInParking(Convert.ToInt32(maskedTextBox1.Text)); Bitmap bmp = new Bitmap(pictureBox2.Width, pictureBox2.Height); Graphics gr = Graphics.FromImage(bmp); plane.setPosition(0, 0); plane.drawBombardir(gr); pictureBox2.Image = bmp; Draw(); log.Info("Забрали с места: " + Convert.ToInt32(maskedTextBox1.Text)); } catch (ParkingIndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Неверный номер", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Общая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void Transport_Click(object sender, EventArgs e) { inter = new Plane(maxSpeed, maxCountPass, weight, color); Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); inter.drawBombardir(gr); pictureBox1.Image = bmp; ButtonBomb.Enabled = false; }
private void ButtonBomb_Click(object sender, EventArgs e) { if (checkFields()) { inter = new Bombardir(maxSpeed, maxCountPass, weight, color, checkBox1.Checked, checkBox2.Checked, dopColor); Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); inter.giveBomb(gr); pictureBox1.Image = bmp; } }
public static Missile CreateMissile(LauncherController LaunHandler) { string type = UserInputValidator.ReadMissileTypeName("Which Type of missile would you like to create?"); LauncherMenuRunner.ShowTechniquesMenu(LaunHandler.Launcher); ITechnique tech = UserInputValidator.GetChoiceOfDictionary <int, ITechnique>(LaunHandler.Launcher.LaunchTechniques); while (tech.TargetMissile != type) { Console.WriteLine($"The technique does not fit to {type} missile, please choose the currect on:"); tech = UserInputValidator.GetChoiceOfDictionary <int, ITechnique>(LaunHandler.Launcher.LaunchTechniques); } return(CreateMissile(type, tech)); }
private void panel1_DragDrop(object sender, DragEventArgs e) { switch (e.Data.GetData(DataFormats.Text).ToString()) { case "Plane": plane = new Plane(100, 4, 500, Color.White); break; case "Bombardir": plane = new Bombardir(100, 4, 500, Color.White, true, true, true, Color.Black); break; } DrawPlane(); }
public void AddTechnique(ITechnique technique) { int lastDictKey; try { lastDictKey = Launcher.LaunchTechniques.Keys.Last(); lastDictKey++; } catch (InvalidOperationException) { lastDictKey = 1; } Launcher.LaunchTechniques.Add(lastDictKey, technique); }
private void AddPlane(ITechnique plane) { if (plane != null) { int place = parking.PutPlaneInParking(plane); if (place > -1) { Draw(); MessageBox.Show("Ваше место: " + place); } else { MessageBox.Show("Технику не удалось поставить"); } } }
public FormSelectCar() { InitializeComponent(); panel2.MouseDown += panelColor_MouseDown; panel3.MouseDown += panelColor_MouseDown; panel4.MouseDown += panelColor_MouseDown; panel5.MouseDown += panelColor_MouseDown; panel6.MouseDown += panelColor_MouseDown; panel7.MouseDown += panelColor_MouseDown; panel8.MouseDown += panelColor_MouseDown; panel9.MouseDown += panelColor_MouseDown; buttonCancel.Click += (object sender, EventArgs e) => { plane = null; Close(); }; }
/// <summary> /// Renders a renderable object using a given technique /// </summary> public void ApplyTechnique( ITechnique technique, IRenderable renderable ) { if ( renderable == null ) { return; } if ( GlobalTechnique != null ) { if ( technique != null ) { if ( technique.Effect != null ) { // GlobalTechnique and technique exist. technique is part of an effect group. Apply a substitute to GlobalTechnique technique.Effect.SubstituteTechnique( GlobalTechnique ).Apply( this, renderable ); } else if ( technique.IsSubstituteFor( GlobalTechnique ) ) { // GlobalTechnique and technique exist. technique is a substitute for GlobalTechnique. Apply technique technique.Apply( this, renderable ); } else { // GlobalTechnique and technique exist. technique is not a substitute for GlobalTechnique. Apply GlobalTechnique GlobalTechnique.Apply( this, renderable ); } } else { // GlobalTechnique exists, technique was null. Apply GlobalTechnique GlobalTechnique.Apply( this, renderable ); } } else if ( technique != null ) { // GlobalTechnique doesn't exist, technique does. Apply technique technique.Apply( this, renderable ); } else { // Neither GlobalTechnique or technique exist. Render object directly renderable.Render( this ); } }
public static Missile CreateMissile(string missileType, ITechnique technique) { switch (missileType) { case "Torpedo": return(new Torpedo(missileType, technique)); case "Cruise": return(new Cruise(missileType, technique)); case "Balistic": return(new Balistic(missileType, technique)); case "LongDistance": return(new LongDistance(missileType, technique)); default: return(null); } }
/// <summary> /// Eliminate a possible value from this square. /// </summary> /// <param name="pValue">The value to eliminate.</param> /// <param name="pTechnique">The technique used to eliminate the value.</param> public void EliminatePossibility(char pValue, ITechnique pTechnique) { // Remove the value and update the technique rank if necessary var value = mValues[pValue]; value.Techniques.Add(pTechnique); if (value.TechRank > pTechnique.Rank) { value.TechRank = pTechnique.Rank; } // If there is only one value left for the square then generate a method if (PossibleValues.Count() == 1) { var foundValue = PossibleValues.Single(); AddMethod(foundValue, Method.CreateOnlyValue(foundValue, this)); } mEntities.ForEach(e => e.EliminatePossibility(pValue, this)); }
private void AddPlane(ITechnique plane) { if (plane != null) { try { int place = parking.PutPlaneInParking(plane); Draw(); log.Info("Добавление на место: " + place); MessageBox.Show("Ваше место: " + place); } catch (ParkingOverflowException ex) { MessageBox.Show(ex.Message, "Ошибка переполнения", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Общая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Builds the star box (dome, sphere, thing) /// </summary> public StarBox( ) { EffectAssetHandle effect = new EffectAssetHandle( "Effects/Planets/stars.cgfx", false ); m_Technique = new TechniqueSelector( effect, "DefaultTechnique" ); Draw.ISurface surface = Graphics.Draw.NewSurface( Graphics.Draw.NewBrush( Color.Black ), null ); surface.FaceBrush.State.CullFaces = false; surface.FaceBrush.State.DepthWrite = false; surface.FaceBrush.State.DepthTest = false; Graphics.Draw.StartCache( ); Graphics.Draw.Sphere( surface, Point3.Origin, 100, 10, 10 ); m_Box = Graphics.Draw.StopCache( ); m_Texture = Graphics.Factory.CreateCubeMapTexture( ); LoadStarBoxTextures( m_Texture, "Star Fields/Default/" ); //int imageIndex = 0; //foreach ( Bitmap bmp in m_Texture.ToBitmaps( ) ) //{ // bmp.Save( "StarBoxCubeMapFace" + imageIndex++ + ".bmp", ImageFormat.Bmp ); //} }
/// <summary> /// Inserts a value into this square. /// </summary> /// <param name="pValue">The value to insert.</param> public void InsertValue(char pValue) { if (Filled) { return; } Filled = true; // Prepare entities for insertion mEntities.ForEach(e => e.PreInsertion(pValue)); // Remove all possible values from this square since it is now occupied ITechnique tech = Technique.CreateOccupiedTechnique(pValue, Index); foreach (char value in Constants.ALL_VALUES) { EliminatePossibility(value, tech); } // Insert the value into the entities mEntities.ForEach(e => e.StartInsertion(Index)); mEntities.ForEach(e => e.EndInsertion()); }
public Earth(ITechnique attack, int extraDamage, string modifierText) : base(attack) { ExtraDamage = extraDamage; ModifierText = modifierText; }
/// <summary> /// Returns true if this technique is a substitude for another /// </summary> public bool IsSubstituteFor( ITechnique technique ) { return Name == technique.Name; }
/// <summary> /// Calls a rendering method using a given technique /// </summary> /// <param name="technique">Technique to render with</param> /// <param name="render">Render method delegate</param> /// <remarks> /// Equivalent to <see cref="ITechnique.Apply(IRenderContext,RenderDelegate)"/>. Differs in that if technique is a valid substitute to the /// global technique (<see cref="GlobalTechnique"/>), technique is used to render the object, otherwise, the /// global technique is used. /// </remarks> public void ApplyTechnique( ITechnique technique, RenderDelegate render ) { m_InnerContext.ApplyTechnique( technique, render ); }
public Cruise(ITechnique technique = null) { Technique = technique ?? new ProbabilityTwentyTechnique(); RocketType = RocketType.Cruise; TryLaunch = false; }
public Matcher(ITechnique technique) { _technique = technique; }
public Ballistic(ITechnique technique = null) { Technique = technique ?? new ProbabilityFiftyTechnique(); RocketType = RocketType.Ballistic; TryLaunch = false; }
public void ChangeTechnique(ITechnique technique) { LaunchTechnique = technique; }
/// <summary> /// Disposes of the viewer and its components /// </summary> public void Dispose( ) { Dispose( m_FpsDisplay ); Dispose( m_Camera ); Dispose( m_Renderable ); Dispose( m_Technique ); m_Control = null; m_FpsDisplay = null; m_Camera = null; m_Renderable = null; m_Technique = null; }
public Cruise(string missileType, ITechnique launchTechnique) : base(launchTechnique) { MissileType = "Cruise"; }
public LongDistance(string missileType, ITechnique launchTechnique) : base(launchTechnique) { MissileType = "LongDistance"; }
public PlanetTerrainRenderer( ) { IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/terrestrialPlanetTerrain.cgfx" ); TechniqueSelector selector = new TechniqueSelector( effect, "DefaultTechnique" ); m_PlanetTerrainTechnique = selector; float hDim = 1; Point3[] cubePoints = new Point3[] { new Point3( -hDim, -hDim, -hDim ), new Point3( +hDim, -hDim, -hDim ), new Point3( +hDim, +hDim, -hDim ), new Point3( -hDim, +hDim, -hDim ), new Point3( -hDim, -hDim, +hDim ), new Point3( +hDim, -hDim, +hDim ), new Point3( +hDim, +hDim, +hDim ), new Point3( -hDim, +hDim, +hDim ), }; int res = 3; int defaultLodLevel = 0; CubeSide[] sides = new CubeSide[ ] { new CubeSide( res, cubePoints[ 0 ], cubePoints[ 1 ], cubePoints[ 3 ], defaultLodLevel, true ), // -z new CubeSide( res, cubePoints[ 7 ], cubePoints[ 6 ], cubePoints[ 4 ], defaultLodLevel, true ), // +z new CubeSide( res, cubePoints[ 4 ], cubePoints[ 5 ], cubePoints[ 0 ], defaultLodLevel, true ), // +y new CubeSide( res, cubePoints[ 6 ], cubePoints[ 7 ], cubePoints[ 2 ], defaultLodLevel, true ), // -y new CubeSide( res, cubePoints[ 0 ], cubePoints[ 3 ], cubePoints[ 4 ], defaultLodLevel, true ), // -x new CubeSide( res, cubePoints[ 5 ], cubePoints[ 6 ], cubePoints[ 1 ], defaultLodLevel, true ) // +x }; foreach ( CubeSide side in sides ) { side.PreBuild( m_Builder ); foreach ( TerrainPatch patch in side.TerrainPatches ) { m_Patches.Add( patch ); } } // Arrange patches in a spiral, with the centre patch on side -y at position 0 //int ringSize = 1; //CubeSide bottomSide = sides[ 3 ]; //for ( int offsetFromCentre = 0; offsetFromCentre < res; ++offsetFromCentre ) //{ // if ( offsetFromCentre == 0 ) // { // continue; // } // int start = ( res / 2 ) - offsetFromCentre; // ringSize += 2; //} //int[] cubeSides = new int[] // { // 0, 1, 3, // -z // 7, 6, 4, // +z // 4, 5, 0, // +y // 6, 7, 2, // -y // 0, 3, 4, // -x // 5, 6, 1 // +x // }; //int[] sideConnections = new int[] // { // // Left Top Right Bottom // 4, 2, 5, 3, // Side 0 (-z) // // 0, 0, 0, 0, // Side 1 (+z) // // 0, 0, 0, 0, // Side 2 (+y) // // 0, 0, 0, 0, // Side 3 (-y) // // 0, 0, 0, 0, // Side 4 (-x) // // 0, 0, 0, 0, // Side 5 (+x) // }; // for ( int side = 0; side < cubeSides.Length / 3; ++side ) //for ( int side = 0; side < 1; ++side ) //{ // CubeSide leftSide = sides[ sideConnections[ side * 4 ] ]; // CubeSide topSide = sides[ sideConnections[ side * 4 + 1 ] ]; // CubeSide rightSide = sides[ sideConnections[ side * 4 + 2 ] ]; // CubeSide bottomSide = sides[ sideConnections[ side * 4 + 3 ] ]; // sides[ side ].Link( leftSide, topSide, rightSide, bottomSide ); //} foreach ( CubeSide side in sides ) { side.Build( m_Builder ); } m_PatchRenderState = Graphics.Factory.CreateRenderState( ); m_PatchRenderState.DepthTest = true; m_PatchRenderState.DepthWrite = true; m_PatchRenderState.CullBackFaces = true; m_PatchRenderState.FaceRenderMode = PolygonRenderMode.Lines; }
/// <summary> /// Adds a technique to the global technique stack /// </summary> public void PushGlobalTechnique( ITechnique technique ) { m_GlobalTechniques.Add( technique ); }
/// <summary> /// Returns true if this technique is a reasonable substitute for the specified technique /// </summary> /// <param name="technique">Technique to substitute</param> /// <returns>true if this technique can substitute the specified technique</returns> public bool IsSubstituteFor( ITechnique technique ) { return ( Technique != null ) && ( Technique.Name == technique.Name ); }
/// <summary> /// Selects a named technique from the current effect /// </summary> /// <param name="name">Technique name</param> /// <exception cref="ArgumentException">Thrown if name does not correspond to a technique in the current effect</exception> public void Select( string name ) { Technique = Effect.Techniques[ name ]; }
public OpenGlSpherePlanetRenderer( SpherePlanet planet ) : base(planet) { IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/terrestrialPlanet.cgfx" ); TechniqueSelector selector = new TechniqueSelector( effect, "DefaultTechnique" ); int res = 128; // IPlanetTerrainGenerator terrainGenerator = new TestStPlanetTerrainGenerator( ); // IPlanetTerrainGenerator terrainGenerator = new TestFacePlanetTerrainGenerator( ); // IPlanetTerrainGenerator terrainGenerator = new TestCloudGenerator( ); IPlanetTerrainGenerator terrainGenerator = new TestNoisePlanetTerrainGenerator( ); ICubeMapTexture planetTexture = Graphics.Factory.CreateCubeMapTexture( ); planetTexture.Build ( GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosX, res ), GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegX, res ), GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosY, res ), GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegY, res ), GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosZ, res ), GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegZ, res ), true ); int cloudRes = 128; ICubeMapTexture cloudTexture = Graphics.Factory.CreateCubeMapTexture( ); IPlanetTerrainGenerator cloudGenerator = new TestCloudGenerator( ); cloudTexture.Build ( GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosX, cloudRes ), GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegX, cloudRes ), GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosY, cloudRes ), GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegY, cloudRes ), GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosZ, cloudRes ), GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegZ, cloudRes ), true ); int bmpIndex = 0; foreach ( Bitmap bitmap in planetTexture.ToBitmaps( ) ) { bitmap.Save( planet.Name + " Planet Texture " + bmpIndex++ + ".jpg", ImageFormat.Jpeg ); } m_PlanetTexture = planetTexture; m_CloudTexture = cloudTexture; m_PlanetTechnique = selector; IEffect cloudEffect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/cloudLayer.cgfx" ); m_CloudTechnique = new TechniqueSelector( cloudEffect, "DefaultTechnique" ); Graphics.Draw.StartCache( ); RenderSphere( 8 ); m_PlanetGeometry = Graphics.Draw.StopCache( ); }
public LongRange(ISystem consoleSystem, ITechnique technique = null) { Technique = technique ?? new RangeTechnique(consoleSystem); RocketType = RocketType.LongRange; TryLaunch = false; }
/// <summary> /// Selects a named technique from the specified effect /// </summary> /// <param name="effect">Effect to select from</param> /// <param name="name">Technique name</param> /// <exception cref="ArgumentException">Thrown if name does not correspond to a technique in the current effect</exception> public void Select( IEffect effect, string name ) { Effect = effect; Technique = Effect.Techniques[ name ]; }
/// <summary> /// Adds a technique to the global technique stack /// </summary> /// <seealso cref="GlobalTechnique"/> public void PushGlobalTechnique( ITechnique technique ) { Arguments.CheckNotNull( technique, "technique" ); m_InnerContext.PushGlobalTechnique( technique ); }
public Missile(ITechnique launchTechnique) { IsFailed = false; LaunchTechnique = launchTechnique; }
/// <summary> /// Setup constructor /// </summary> /// <param name="indices">Index buffer</param> /// <param name="technique">Rendering technique</param> /// <param name="textures">Textures</param> public CellGeometryGroup( int[] indices, ITechnique technique, ITexture2d[] textures ) { m_Indices = indices; m_Textures = textures; m_Technique = technique; }
public Torpedo(ITechnique technique = null) { Technique = technique ?? new ProbabilityOneHundredTechnique(); RocketType = RocketType.Torpedo; TryLaunch = false; }
/// <summary> /// Finds a technique in this effect that can substitute the specified technique /// </summary> /// <param name="technique">Technique to substitute</param> /// <returns> /// Returns an ITechnique from this effect that can substitute technique. If none /// can be found, technique is returned. /// </returns> public ITechnique SubstituteTechnique( ITechnique technique ) { foreach ( ITechnique substituteTechnique in m_Techniques.Values ) { if ( substituteTechnique.IsSubstituteFor( technique ) ) { return substituteTechnique; } } return technique; }
/// <summary> /// Assigns this to a planet /// </summary> protected override void AssignToPlanet( IPlanetRenderer renderer, bool remove ) { renderer.TerrainRenderer = remove ? null : this; m_Technique = remove || ( renderer.Planet == null ) ? null : CreatePatchTechnique( renderer.Planet ); }
/// <summary> /// Helper method for adding a technique to the technique dictionary /// </summary> public void Add( ITechnique technique ) { Techniques.Add( technique.Name, technique ); technique.Effect = this; }
public Balistic(string missileType, ITechnique launchTechnique) : base(launchTechnique) { MissileType = "Balistic"; }
/// <summary> /// Setup constructor /// </summary> /// <param name="technique">Group technique</param> /// <param name="textures">Group textures</param> public GroupMaterial( ITechnique technique, ITexture2d[] textures ) { m_Technique = technique; m_Textures = textures; }
// поставить машину на парковку public int PutPlaneInParking(ITechnique plane) { return(parkingStages[currentLevel] + plane); }
public Torpedo(string missileType, ITechnique launchTechnique) : base(launchTechnique) { MissileType = "Torpedo"; }
/// <summary> /// Renders a renderable object using a given technique /// </summary> /// <param name="technique">Technique to render with</param> /// <param name="renderable">Object to render</param> /// <remarks> /// Equivalent to <see cref="ITechnique.Apply(IRenderContext,IRenderable)"/>. Differs in that if technique is a valid substitute to the /// global technique (<see cref="GlobalTechnique"/>), technique is used to render the object, otherwise, the /// global technique is used. /// </remarks> public void ApplyTechnique( ITechnique technique, IRenderable renderable ) { m_InnerContext.ApplyTechnique( technique, renderable ); }
//Decorator function takes an altered component public AttackDecorator(ITechnique attack) { _attack = attack; //New component then overwrites the original }
public AttackDecorator(ITechnique attack) //Decorator function takes an altered component { _attack = attack; //New component then overwrites the original }
public Fire(ITechnique attack, int extraDamage, string modifierText) : base(attack) { ExtraDamage = extraDamage; ModifierText = modifierText; }
public int PutPlaneInParking(ITechnique plane) { return(parking + plane); }
/// <summary> /// Sets the selected technique /// </summary> public TechniqueSelector( ITechnique technique ) { Technique = technique; }