/// <summary> /// Begins a reaction in the area. /// </summary> public void BeginReaction(Reaction Reaction) { Reaction._Initialize(this._Effects); this._Reactions.Add(Reaction); }
public Window() : base(640, 480, GraphicsMode.Default, "Driftoid") { this.VSync = VSyncMode.Off; this.WindowState = WindowState.Maximized; GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.ColorMaterial); this._Area = new Area(); for (int x = 0; x < 6; x++) { for (int y = 0; y < 6; y++) { this._Area.Spawn( Driftoid.Make( PrimitiveDriftoid.GetConstructor((PrimitiveType)y), new Vector((double)x * 3.0, (double)y * 3.0 - 7.5)) as LinkedDriftoid); } } this._Area.Spawn( Driftoid.Make( NucleusDriftoid.GetConstructor(this._Player = new Player(Color.RGB(1.0, 0.0, 0.0))), new Vector(-8.0, 0.0)) as LinkedDriftoid); this._Area.Spawn( Driftoid.Make( WeightedDriftoid.GetConstructor(0), new Vector(-8.0, 7.0)) as LinkedDriftoid); this._Starfield = Starfield.CreateDefault(512, 5); this._View = new View(new Vector(), 0.0, 0.1); this.Mouse.ButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (e.Button == MouseButton.Left) { Vector pos = this.MouseWorldPosition; this._Dragged = this._Area.Pick(pos); } if (e.Button == MouseButton.Right) { Vector pos = this.MouseWorldPosition; LinkedDriftoid ldr = this._Area.Pick(pos) as LinkedDriftoid; if (ldr != null) { this._Area.TryDelink(this._Player, ldr); } } }; this.Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e) { // Test reaction if (e.Key == Key.F) { Vector mousepos = this.MouseWorldPosition; LinkedDriftoid ldr = this._Area.Pick(mousepos); if (ldr != null) { if (ldr.ReactionClear && this._Area.HasLinkControl(this._Player, ldr)) { //DriftoidConstructor product = Recipe.Master.GetProduct(new Structure(ldr)); DriftoidConstructor product = PrimitiveDriftoid.GetConstructor(PrimitiveType.Sulfur); if (product != null) { Reaction r = new Reaction() { Product = product, Target = ldr }; this._Area.BeginReaction(r); } } } } }; }