/// <summary> /// Adds a new PlacedCircle to the LockedCircleCanvas /// </summary> /// <param name="p">PlacedCircle to be added</param> /// <param name="c">Center point where it is to be located</param> public void addNewCircle(PlacementCircle o, PlacedCircle p, Point c) { lockedUnitCanvas.Children.Add(p); p.CenterX = c.X; p.CenterY = c.Y; units[p.TagVal].Center = new Point(c.X, c.Y); if (units[p.TagVal].SquadNo != 1337) { squadGroups[units[p.TagVal].SquadNo].Units.Add(units[p.TagVal]); UpdateSquads(); } p.Window = this; Canvas.SetLeft(p, p.CenterX - 75); Canvas.SetTop(p, p.CenterY - 75); circles[p.TagVal] = p; MyTagVisualizer.RemoveVisualization(o); }
private void lockUnlock(object sender, RoutedEventArgs e) { Unit checkunit = window.getUnit(tagVal); Point here = this.Center; if (checkunit.IsInitialPlacement) { if (window.getUnit(tagVal).SquadNo != 1337) { if (window.SquadExists(window.getUnit(tagVal).SquadNo)) { if (window.checkCohesion(here, checkunit, window.getUnit(tagVal).SquadNo)) { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); checkunit.IsInitialPlacement = false; if (window.isFullUnitPlaced(window.getUnit(tagVal).SquadNo)) { window.removeCohesionCircles(window.getUnit(tagVal).SquadNo); } else { RangeCircle r = new RangeCircle(); r.CenterX = here.X; r.CenterY = here.Y; r.VisibleCircle.Fill = Brushes.Red; r.VisibleCircle.Width = 384; r.VisibleCircle.Height = 384; r.TagVal = tagVal; window.addNewCohesion(r); } } else { window.FlashWarning(tagVal); } } else { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); checkunit.IsInitialPlacement = false; RangeCircle r = new RangeCircle(); r.CenterX = here.X; r.CenterY = here.Y; r.VisibleCircle.Fill = Brushes.Red; r.VisibleCircle.Width = 384; r.VisibleCircle.Height = 384; r.TagVal = tagVal; window.addNewCohesion(r); } } else { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); checkunit.IsInitialPlacement = false; } } else { if (window.getUnit(tagVal).SquadNo != 1337) { if (window.getUnit(tagVal).FirstToMove) { if (window.isWithinRange(tagVal, here)) { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); window.removeRange(tagVal); RangeCircle r = new RangeCircle(); r.CenterX = here.X; r.CenterY = here.Y; r.VisibleCircle.Fill = Brushes.Red; r.VisibleCircle.Width = 384; r.VisibleCircle.Height = 384; r.TagVal = tagVal; window.addNewCohesion(r); } else { window.FlashWarning(tagVal); } } else { if ((window.isWithinRange(tagVal, here)) && (window.checkCohesion(here, window.getUnit(tagVal), window.getUnit(tagVal).SquadNo))) { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); window.removeRange(tagVal); if (!window.isFullUnitPlaced(window.getUnit(tagVal).SquadNo)) { window.removeCohesionCircles(window.getUnit(tagVal).SquadNo); } else { RangeCircle r = new RangeCircle(); r.CenterX = here.X; r.CenterY = here.Y; r.VisibleCircle.Fill = Brushes.Red; r.VisibleCircle.Width = 384; r.VisibleCircle.Height = 384; r.TagVal = tagVal; window.addNewCohesion(r); } } else { window.FlashWarning(tagVal); } } } else { if (window.isWithinRange(tagVal, here)) { PlacedCircle newCircle = new PlacedCircle(); newCircle.TagVal = tagVal; window.addNewCircle(this, newCircle, here); window.removeTagDefinition(tagVal); window.removeRange(tagVal); } else { window.FlashWarning(tagVal); } } } }