protected void RunDrawTest(Action action) { var deferredAction = new DrawAction(action); lock (drawActions) { drawActions.Add(deferredAction); } deferredAction.WaitResult(); }
public static DrawAction <T> IsTypeThen <T>(GridType item, DrawAction <T> then, bool not = false) where T : IGridSpace { return((arr, x, y) => { if (arr.IsType(x, y, item)) { return then(arr, x, y); } return true; }); }
private void dgActions_SelectionChanged(object sender, EventArgs e) { if (dgActions.SelectedCells.Count == 0) { return; } int index = dgActions.SelectedCells[0].RowIndex; if (actionsList[index] is DrawAction daction) { activeAction = daction; dgObjects.Rows.Clear(); switch (dgActions.SelectedCells[0].ColumnIndex) { case 1: foreach (DrawableObject obj in activeAction.ShadowState) { dgObjects.Rows.Add(obj.Name, obj.ObjNumber, obj.zInstance); } break; case 2: foreach (DrawableObject obj in activeAction.AfterAction) { dgObjects.Rows.Add(obj.Name, obj.ObjNumber, obj.zInstance); } break; case 4: case 5: foreach (DrawableObject obj in activeAction.Selection) { dgObjects.Rows.Add(obj.Name, obj.ObjNumber, obj.zInstance); } break; default: foreach (DrawableObject obj in activeAction.DrawRef) { dgObjects.Rows.Add(obj.Name, obj.ObjNumber, obj.zInstance); } break; } } else { activeAction = null; dgObjects.Rows.Clear(); } pDrawRef.Refresh(); pShadow.Refresh(); pAfterAction.Refresh(); }
public BoxedAction(DrawAction <T> frontAction, DrawAction <T> middleAction, DrawAction <T> backAction) { this.FrontAction = frontAction; this.FrontLeftAction = frontAction; this.FrontRightAction = frontAction; this.LeftAction = middleAction; this.RightAction = middleAction; this.UnitAction = middleAction; this.BackAction = backAction; this.BackLeftAction = backAction; this.BackRightAction = backAction; }
public BoxedAction(DrawAction <T> frontAction, DrawAction <T> restAction) { this.FrontAction = frontAction; this.FrontLeftAction = frontAction; this.FrontRightAction = frontAction; this.LeftAction = restAction; this.RightAction = restAction; this.UnitAction = restAction; this.BackAction = restAction; this.BackLeftAction = restAction; this.BackRightAction = restAction; }
public void Draw(DrawAction action) { if (this.undoHover != null) { ApplyAction(this.undoHover); } DrawAction undoAction = ApplyAction(action); this.UndoQueue.Push(undoAction); this.RedoQueue.Clear(); this.undoHover = null; }
/// <summary> /// is the main method of this object. See also <see cref="Entity.CompileDraw(OpenGlDevice)"/>. /// </summary> /// <param name="Device">Device in which it willl be compiled.</param> /// <param name="Draw">a event, which holds the drawings.</param> public static MeshContainer CreateMeshes(OpenGlDevice Device, DrawAction Draw) { // sollte nur von compilesnapbuffer aufgerufen werden !!!! und erstellt die triangles bool Compiling = Entity.Compiling; if (Compiling) { MeshCreator.Push(); } bool SaveCompiling = Entity.Compiling; // Entity.Compiling = true; // Checken braucht es wegen line snap if (Selector.StoredSnapItems.Count == 0) { Selector.StoredSnapItems.Add(null); // braucht es nicht } MeshListCurrent = new MeshContainer(); // braucht es nicht MeshIndices.Clear(); // braucht es wahrscheinlich nicht RenderKind R = Device.RenderKind;// wieder heraus Draw(Device); Renew(); Device.RenderKind = R; Entity.Compiling = SaveCompiling; MeshContainer Result = MeshListCurrent; // MeshListCurrent.MySnapItem = new MeshSnapItem(MeshListCurrent); Device.RenderKind = RenderKind.SnapBuffer; TriangleList TL = new TriangleList(); for (int i = 0; i < MeshListCurrent.Progs.Count; i++) { if (MeshListCurrent.Progs[i] is Mesh) { Mesh M = MeshListCurrent.Progs[i] as Mesh; M.getTriangles(TL); } } TriangleArrays TA = TL.ToArrays(); Device.RenderKind = R; if (Compiling) { MeshCreator.Pop(); } return(Result); }
public static void DrawPotentialDoors(this Container2D <GenSpace> arr, DrawAction <GenSpace> action) { DrawAction <GenSpace> check = Draw.CanDrawDoor(); arr.DrawAll(new DrawAction <GenSpace>((arr2, x, y) => { if (check(arr2, x, y)) { action(arr2, x, y); } return(true); })); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; Window.Title = "T Rex Runner"; IsMouseVisible = false; MainForm = (Form)Control.FromHandle(Window.Handle); score = 0; drawAction = DrawAction.Crouch; runningFrames = RunningFrames.FirstFrame; crouchingFrames = CrouchingFrames.FirstFrame; }
public virtual void PerfromDrawAction(SpriteBatch b) { if (OutOfBounds) { return; } DrawAction?.Invoke(b, this); foreach (UIElement child in Children) { child.PerfromDrawAction(b); } }
public override bool DrawAll(DrawAction <T> call) { foreach (KeyValuePair <int, Dictionary <int, T> > row in multimap) { foreach (KeyValuePair <int, T> val in row.Value) { if (!call(this, val.Key, row.Key)) { return(false); } } } return(true); }
private void HandleEndDrawLine(Point currentMousePosition) { var line = new Line { X1 = _lineStartPoint.X, Y1 = _lineStartPoint.Y, X2 = currentMousePosition.X, Y2 = currentMousePosition.Y, Stroke = Brushes.Green }; MyCanvas.Children.Add(line); _drawAction = DrawAction.StartDrawLine; }
private DrawAction ApplyAction(DrawAction action) { Stack <Tile> previousTiles = new Stack <Tile>(); foreach (Tile tile in action.Tiles) { Tile previousTile = Draw(tile); if (previousTile != null) { previousTiles.Push(previousTile); } } DrawAction revertAction = new DrawAction(action.Name, previousTiles); return(revertAction); }
private void CheckUserInput(KeyboardState CurrentKeyState, KeyboardState OldKeyState) { if (CurrentKeyState.IsKeyDown(Keys.S) || CurrentKeyState.IsKeyDown(Keys.Down)) { drawAction = DrawAction.Crouch; } else if (CurrentKeyState.IsKeyDown(Keys.Space) || CurrentKeyState.IsKeyDown(Keys.Up) || CurrentKeyState.IsKeyDown(Keys.W)) { Jumping = true; drawAction = DrawAction.Idle; } else { drawAction = DrawAction.Running; } }
/* * Walk edges and if alternates more than twice, it's blocking */ public static DrawAction <T> Blocking <T>(DrawAction <T> action) { return((arr, x, y) => { int count = 0; bool status = action(arr, x - 1, y - 1); // Bottom left DrawAction <T> func = (arr2, x2, y2) => { if (action(arr2, x2, y2) != status) { status = !status; return ++count > 2; } return false; }; if (func(arr, x, y - 1)) { return true; // Bottom } if (func(arr, x + 1, y - 1)) { return true; // Bottom right } if (func(arr, x + 1, y)) { return true; // Right } if (func(arr, x + 1, y + 1)) { return true; // Top Right } if (func(arr, x, y + 1)) { return true; // Top } if (func(arr, x - 1, y + 1)) { return true; // Top Left } if (func(arr, x - 1, y)) { return true; // Left } return false; }); }
public override bool DrawAll(DrawAction <T> call) { for (int y = 0; y < arr.GetLength(0); y++) { for (int x = 0; x < arr.GetLength(1); x++) { if (present[y, x]) { if (!call(this, x, y)) { return(false); } } } } return(true); }
internal void SetDrawAction(DrawAction drawAction) { switch(drawAction) { case DrawAction.Intro: this.drawAction = this.DrawActionIntro; this.Duration = 60 * OneNanoSecond; break; case DrawAction.Main: this.drawAction = this.DrawActionMain; Duration = PluginProxy.Duration; break; case DrawAction.Outro: this.drawAction = this.DrawActionOutro; this.Duration = 60 * OneNanoSecond; break; } }
//Add an action to the actions collection public void AddDrawAction(RecordableAction.ActionTypes actionType, DrawingSheet sheet, List <DrawableObject> changingObjects, List <DrawableObject> selectedObjects, int focusIndex) { //Erase redo actions if (ActionIndex < Actions.Count) { if (SavedIndex > ActionIndex) { SavedIndex = -1; } Actions.RemoveRange(ActionIndex, Actions.Count - ActionIndex); } //Create the action object var action = new DrawAction(actionType, sheet, changingObjects, selectedObjects, focusIndex); sheet.Sketch.PerformAction(action); //Add new action Actions.Add(action); ActionIndex++; }
internal void SetDrawAction(DrawAction drawAction) { switch (drawAction) { case DrawAction.Intro: this.drawAction = this.DrawActionIntro; this.Duration = 60 * OneNanoSecond; break; case DrawAction.Main: this.drawAction = this.DrawActionMain; Duration = PluginProxy.Duration; break; case DrawAction.Outro: this.drawAction = this.DrawActionOutro; this.Duration = 60 * OneNanoSecond; break; } }
public static List <Value2D <GenSpace> > PlaceSomeDoors(this Container2D <GenSpace> arr, IEnumerable <Point> points, Theme theme, System.Random rand, int desiredWallToDoorRatio = -1, Point shift = null) { if (desiredWallToDoorRatio < 0) { desiredWallToDoorRatio = LevelGenerator.desiredWallToDoorRatio; } var acceptablePoints = new MultiMap <GenSpace>(); Counter numPoints = new Counter(); DrawAction <GenSpace> call = Draw.Count <GenSpace>(numPoints).And(Draw.CanDrawDoor().IfThen(Draw.AddTo(acceptablePoints))); if (shift != null) { call = call.Shift <GenSpace>(shift.x, shift.y); } arr.DrawPoints(points, call); if (DoorRatioPicker == null) { DoorRatioPicker = new ProbabilityList <int>(); DoorRatioPicker.Add(-2, .25); DoorRatioPicker.Add(-1, .5); DoorRatioPicker.Add(0, 1); DoorRatioPicker.Add(1, .5); DoorRatioPicker.Add(2, .25); } int numDoors = numPoints / desiredWallToDoorRatio; numDoors += DoorRatioPicker.Get(rand); if (numDoors <= 0) { numDoors = 1; } List <Value2D <GenSpace> > pickedPts = acceptablePoints.GetRandom(rand, numDoors, 1); foreach (Point picked in pickedPts) { arr.SetTo(picked, GridType.Door, theme); } return(pickedPts); }
protected bool FindNextPathPoints(Container2D <GenSpace> map, Container2D <GenSpace> runningConnected, out LayoutObject hit, DrawAction <GenSpace> pass, Queue <Value2D <GenSpace> > curQueue, Container2D <bool> curVisited, out Value2D <GenSpace> startPoint, out Value2D <GenSpace> endPoint) { if (!map.DrawBreadthFirstSearch( curQueue, curVisited, false, Draw.IsType <GenSpace>(GridType.NULL), pass, out endPoint)) { hit = null; startPoint = null; return(false); } if (!Container.GetObjAt(endPoint, out hit)) { startPoint = null; return(false); } Container2D <bool> hitVisited; Queue <Value2D <GenSpace> > hitQueue; ConstructBFS(hit, out hitQueue, out hitVisited); curQueue.Enqueue(hitQueue); curVisited.PutAll(hitVisited); return(map.DrawBreadthFirstSearch( hitQueue, hitVisited, false, Draw.IsType <GenSpace>(GridType.NULL), pass.And(Draw.ContainedIn(runningConnected)), out startPoint)); }
public void LoadMe(Prodef domainObject, UnitOfWork currentUnitOfWork) { Prodef prodef = domainObject; if (prodef == null) { throw new ArgumentOutOfRangeException("domainObject"); } if (this.mGraphDoc != null) { this.mGraphDoc.Reset(); } else { this.InitGraphDoc(); } if (this.mProDefDoc == null) { this.mProDefDoc = new ProDefDoc(); } this.mProDefDoc.Load(prodef, currentUnitOfWork); this.mProDefDoc.BuildGraphDoc(this.mGraphDoc, this.img32); this.mAction = DrawAction.SingleSelect; }
private void HandleStartDrawLine(Point currentMousePosition) { _lineStartPoint = currentMousePosition; _drawAction = DrawAction.EndDrawLine; }
private void StartDrawingCircles(object sender, RoutedEventArgs e) { _drawAction = DrawAction.DrawCircle; }
private void StartDrawingSquares(object sender, RoutedEventArgs e) { _drawAction = DrawAction.DrawSquare; }
private void StartDrawingLines(object sender, RoutedEventArgs e) { _drawAction = DrawAction.StartDrawLine; }
private void Clear(object sender, RoutedEventArgs e) { MyCanvas.Children.Clear(); _drawAction = DrawAction.None; }
internal void SetDrawAction(DrawAction drawAction) { frm.SetDrawAction(drawAction); }
public override bool DrawAll(DrawAction <GenSpace> call) { return(Grids.DrawAll(call)); }
public void DrawOnLayer(string layer, DrawAction drawAction) { drawActions[layer].Add(drawAction); }
private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { foreach (ToolBarButton button in this.toolBar1.Buttons) { if (!button.Equals(e.Button)) { button.Pushed = false; } } switch (e.Button.Tag.ToString()) { case "select": this.mAction = DrawAction.SingleSelect; return; case "delete": this.mGraphDoc.RemoveUnit(this.mGraphDoc.SelectedUnit); return; case "arrowline": this.mAction = DrawAction.Draw; this.mDrawType = DrawType.ArrowLine; return; } this.mImageIndex = int.Parse(e.Button.Tag.ToString()); this.mAction = DrawAction.Draw; this.mDrawType = DrawType.Node; this.mNodeType = (NodeType) int.Parse(e.Button.Tag.ToString()); }
internal void SetAction(DrawAction drawAction) { this.drawAction = drawAction; Create(); }
protected void ConfirmConnection() { #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printHeader(Logs.LevelGen, "Confirm Connections"); } #endregion DrawAction <GenSpace> passTest = Draw.ContainedIn <GenSpace>(Path.PathTypes).Or(Draw.CanDrawDoor()); var layoutCopy = Container.GetGrid().Array; List <LayoutObject> rooms = new List <LayoutObject>(Layout.Rooms.Cast <LayoutObject>()); var runningConnected = Container2D <GenSpace> .CreateArrayFromBounds(layoutCopy); // Create initial queue and visited var startingRoom = rooms.Take(); startingRoom.GetConnectedGrid().DrawAll(Draw.AddTo(runningConnected)); Container2D <bool> visited; Queue <Value2D <GenSpace> > queue; ConstructBFS(startingRoom, out queue, out visited); visited = visited.Array; LayoutObject fail; while (!startingRoom.ConnectedTo(rooms, out fail)) { // Find start points #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { runningConnected.ToLog(Logs.LevelGen, "Source Setup"); fail.ToLog(Logs.LevelGen, "Failed to connect to this"); } #endregion Value2D <GenSpace> startPoint; Value2D <GenSpace> endPoint; LayoutObject hit; if (!FindNextPathPoints(layoutCopy, runningConnected, out hit, passTest, queue, visited, out startPoint, out endPoint)) { throw new ArgumentException("Cannot find path to fail room"); } // Connect #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { layoutCopy.SetTo(startPoint, GridType.INTERNAL_RESERVED_CUR, Theme); layoutCopy.ToLog(Logs.LevelGen, "Largest after putting blocked"); BigBoss.Debug.w(Logs.LevelGen, "Start Point:" + startPoint); } #endregion var hitConnected = hit.GetConnectedGrid(); var stack = layoutCopy.DrawJumpTowardsSearch( startPoint.x, startPoint.y, 3, 5, Draw.IsType <GenSpace>(GridType.NULL).And(Draw.Inside <GenSpace>(layoutCopy.Bounding.Expand(5))), passTest.And(Draw.ContainedIn(hitConnected)), Rand, endPoint, true); var path = new Path(stack); if (path.Valid) { #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { path.Bake(null).ToLog(Logs.LevelGen, "Connecting Path"); } #endregion path.Simplify(); Point first = path.FirstEnd; Point second = path.SecondEnd; LayoutObject leaf1, leaf2; LayoutObject pathObj = path.Bake(Theme); Container.ConnectTo(first, pathObj, first, out leaf1, out pathObj); Container.ConnectTo(second, pathObj, second, out leaf2, out pathObj); if (leaf1[first].Type == GridType.Wall) { leaf1.SetTo(first, GridType.Door, Theme); } if (leaf2[second].Type == GridType.Wall) { leaf2.SetTo(second, GridType.Door, Theme); } foreach (var v in pathObj) { layoutCopy[v] = v.val; runningConnected.Put(v); if (!visited[v]) { queue.Enqueue(v); } visited[v] = true; } foreach (var p in path) { layoutCopy.DrawAround(p.x, p.y, false, Draw.IsType <GenSpace>(GridType.NULL).IfThen(Draw.SetTo(pathObj, GridType.Floor, Theme).And(Draw.SetTo(GridType.Floor, Theme)))); layoutCopy.DrawCorners(p.x, p.y, new DrawAction <GenSpace>((arr, x, y) => { if (!arr.IsType(x, y, GridType.NULL)) { return(false); } return(arr.Cornered(x, y, Draw.IsType <GenSpace>(GridType.Floor))); }).IfThen(Draw.SetTo(pathObj, GridType.Floor, Theme))); } Container.Objects.Add(pathObj); hitConnected.DrawAll(Draw.AddTo(runningConnected)); #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { Container.ToLog(Logs.LevelGen, "Final Connection"); } #endregion } else { throw new ArgumentException("Cannot create path to hit room"); } } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printFooter(Logs.LevelGen, "Confirm Connections"); } #endregion }
public List <Bounding> Find() { List <Bounding> ret = new List <Bounding>(); if (_width >= _arr.Width || _height >= _arr.Height) { return(ret); } if (_width == 1 && _height == 1) { return(SingleFind()); } // Initialize _x = _scope.XMin; _y = _scope.YMin; _lastPassedX = int.MaxValue; _lastTestedX = _scope.XMin; _lastTestedY = _scope.YMin; xShift = _arr.Bounding.XMin; _lastPassedXArr = new bool[_arr.Width]; if (_tester.StrokeAction == null && _width > 3 && _height > 3) { // Just unit FindSkip(ret); } else if (_tester.StrokeAction != null && _tester.UnitAction != null && _width > 5 && _height > 5) { // Unit and stroke with optimization // Find non-stroke options, then test stroke DrawAction <T> stroke = _tester.StrokeAction; _tester.StrokeAction = null; _width -= 2; _height -= 2; FindSkip(ret); _width += 2; _height += 2; _tester.StrokeAction = stroke; List <Bounding> retTmp = new List <Bounding>(ret); ret.Clear(); StrokedAction <T> strokeTest = new StrokedAction <T>() { StrokeAction = _tester.StrokeAction }; foreach (Bounding b in retTmp) { b.Expand(1); if (_arr.DrawRect(b.XMin, b.XMax, b.YMin, b.YMax, strokeTest)) { ret.Add(b); } } } else { FindNormal(ret); } if (_tryFlipped && ret.Count == 0) { // Flip and try again _tryFlipped = false; int tmp = _width; _width = _height; _height = tmp; return(Find()); } return(ret); }