internal static Scene SphereScene (int level, Vector center, double radius) { Sphere sphere = new Sphere (center, radius); if (level == 1) { return sphere; } else { Group scene = new Group (new Sphere (center, 3.0 * radius)); scene.Add (sphere); double rn = 3.0 * radius / Math.Sqrt (12.0); for (int dz = -1; dz <= 1; dz += 2) { for (int dx = -1; dx <= 1; dx += 2) { Vector c2 = new Vector ( center.x - dx * rn , center.y + rn , center.z - dz * rn ); scene.Add (SphereScene (level - 1, c2, radius / 2.0)); } } return scene; } }
public static void Main(string[] args) { Application.Init (); Stage stage = Stage.Default as Stage; (stage as Stage).KeyPressEvent += delegate { Clutter.Main.Quit(); }; // fixme: add constructor Clutter.Color stage_color = new Clutter.Color (0xcc, 0xcc, 0xcc, 0xff); stage.SetColor (stage_color); Clutter.Group group = new Group(); stage.Add (group); group.Show (); // Make a hand Clutter.Actor hand = new Texture ("redhand.png"); hand.SetPosition (0,0); hand.Show (); // Make a rect Clutter.Rectangle rect = new Clutter.Rectangle(); rect.SetPosition (0,0); rect.SetSize ((int)hand.Width, (int)hand.Height); Clutter.Color rect_bg_color = new Clutter.Color (0x33, 0x22, 0x22, 0xff); rect.SetColor (rect_bg_color); rect.BorderWidth = 10; rect.Show (); group.Add (rect); group.Add (hand); // Make a timeline Timeline timeline = new Timeline (100, 26); timeline.Loop = true; Alpha alpha = new Alpha (timeline, (a) => a.Value); Behaviour o_behave = new BehaviourOpacity (alpha, 0x33, 0xff); o_behave.Apply (group); // Make a path behaviour and apply that too Behaviour p_behave = new BehaviourPath(alpha, knots); // fixme: add custom constructor? p_behave.Apply (group); // start timeline timeline.Start (); stage.ShowAll(); // launch Application.Run (); }
private Group GetHitBrickGroup(GameObject hitBrick) { Group group = new Group(); group.Add(hitBrick); group.SetHitGroup(); return(group); }
public void Add(Entity entity) { if (Filter(entity)) { entities.Add(entity); OnAdd.Apply(entity); } }
private void AddGroups() { barsGroup = new Group("Bars"); barsGroup.Add("Pad", DataObjectType.String, 0); barsGroup.Add("SelectorKey", Instrument.Symbol); kGroup = new Group("K"); kGroup.Add("Pad", 1); kGroup.Add("SelectorKey", Instrument.Symbol); kGroup.Add("Color", Color.White); k2Group = new Group("K2"); k2Group.Add("Pad", 1); k2Group.Add("SelectorKey", Instrument.Symbol); k2Group.Add("Color", Color.Red); dGroup = new Group("D"); dGroup.Add("Pad", 2); dGroup.Add("SelectorKey", Instrument.Symbol); dGroup.Add("Color", Color.Yellow); d2Group = new Group("D2"); d2Group.Add("Pad", 2); d2Group.Add("SelectorKey", Instrument.Symbol); d2Group.Add("Color", Color.Yellow); jGroup = new Group("J"); jGroup.Add("Pad", 3); jGroup.Add("SelectorKey", Instrument.Symbol); jGroup.Add("Color", Color.Yellow); j2Group = new Group("J2"); j2Group.Add("Pad", 3); j2Group.Add("SelectorKey", Instrument.Symbol); j2Group.Add("Color", Color.Red); GroupManager.Add(barsGroup); GroupManager.Add(kGroup); GroupManager.Add(dGroup); GroupManager.Add(jGroup); GroupManager.Add(k2Group); GroupManager.Add(d2Group); GroupManager.Add(j2Group); }
/// <summary> /// Create an T Section shape /// </summary> /// <param name="tft">Thickness of Flange</param> /// <param name="tfw">Width of flange</param> /// <param name="wt">thickness of web</param> /// <param name="wd">depth of web</param> /// <param name="r1">web radius</param> /// <param name="r2">toe radius</param> /// <returns></returns> public static Group <Curve> CreateTee(double tft, double tfw, double wt, double wd, double r1, double r2) { Group <Curve> perimeter = new Group <Curve>(); Point p = new Point(wt / 2, 0, 0); perimeter.Add(new Line(p, p = p + Vector.YAxis(wd - r1))); if (r1 > 0) { perimeter.Add(Create.Arc(p, p = p + new Vector(r1, r1, 0), new Plane(p - Vector.YAxis(r1), Vector.ZAxis()))); } perimeter.Add(new Line(p, p = p + Vector.XAxis(tfw / 2 - wt / 2 - r1 - r2))); if (r2 > 0) { perimeter.Add(Create.Arc(p, p = p + new Vector(r2, r2, 0), new Plane(p - Vector.XAxis(r2), Vector.ZAxis()))); } perimeter.Add(new Line(p, p = p + Vector.YAxis(tft - r2))); Group <Curve> oppositeSide = perimeter.DuplicateGroup(); oppositeSide.Mirror(new Plane(Point.Origin, Vector.XAxis(1))); perimeter.AddRange(oppositeSide); perimeter.Add(new Line(p, p - Vector.XAxis(tfw))); perimeter.Add(new Line(Point.Origin + Vector.XAxis(-wd / 2), Point.Origin + Vector.XAxis(wd / 2))); perimeter.Update(); return(perimeter); }
protected override void OnStrategyStart() { // barChartGroup = new Group("Bars"); barChartGroup.Add("Pad", DataObjectType.Int, 0); barChartGroup.Add("SelectorKey", DataObjectType.String, "VWAP " + Instrument.Symbol); // fillChartGroup = new Group("Fills"); fillChartGroup.Add("Pad", DataObjectType.Int, 0); fillChartGroup.Add("SelectorKey", DataObjectType.String, "VWAP " + Instrument.Symbol); // GroupManager.Add(barChartGroup); GroupManager.Add(fillChartGroup); }
protected void AddExpandElement(UI.Element element) { EffectsTop.Add(new ExpandEffect(element)); ExpandEffect.Add(new Tuple <UI.Element, double>(element, (double)element.FixedWidth)); ExpandEffect.Refresh(); element.FixedWidth = 50; element.TextColor = Color.MultAlpha(element.TextColor, 0); AddElement(element); }
private static void ExecuteComposite() { var group1 = new Group(); group1.Add(new Shape()); group1.Add(new Shape()); var group2 = new Group(); group2.Add(new Shape()); group2.Add(new Shape()); var group = new Group(); group.Add(group1); group.Add(group2); group.Render(); }
protected override void OnStrategyStart() { // barChartGroup = new Group("Bars"); barChartGroup.Add("Pad", 0); barChartGroup.Add("SelectorKey", Instrument.Symbol); // fillChartGroup = new Group("Fills"); fillChartGroup.Add("Pad", 0); fillChartGroup.Add("SelectorKey", Instrument.Symbol); // GroupManager.Add(barChartGroup); GroupManager.Add(fillChartGroup); }
/* Shuffle the Group into Group g */ public void ShuffleInto(Group g) { foreach (int i in group) { g.Add(i); } networkView.RPC("NetworkClear", RPCMode.All); UpdateSprite(); g.UpdateSprite(); }
//////////////////////////////////////// static public void Main() { Person tariq = new Person("Tariq", 12345M); Person steve = new Person("Steve", 12345M); Person devi = new Person("Devi"); Group grp = new Group("GRB-Dynamics"); grp.Add(tariq); grp.Add(steve); grp.Add(devi); grp.Print(); tariq.UpdateSalary(); grp.Print(); grp.SayHello(); }
public CompositePatternMain() { var group1 = new Group(); group1.Add(new Shape()); // Square group1.Add(new Shape()); // Square var group2 = new Group(); group2.Add(new Shape()); // Circle group2.Add(new Shape()); // Circle var group3 = new Group(); group3.Add(group1); group3.Add(group2); group3.Render(); }
private Group IsSimilar(Group hand, Tile tile, int nb) { Group ret = new Group(); for (int i = 0; i < hand.Count; i++) { if ((hand[i].GetNumber() == tile.GetNumber()) && (hand[i].GetFamily() == tile.GetFamily())) { ret.Add(hand[i]); } if (ret.Count == nb) { ret.Add(tile); return(ret); } } ret.Clear(); return(ret); }
private void ETWCollector_ProcessEvent(ProcessData obj) { Application.Current.Dispatcher.Invoke((Action)(() => { lock (GroupLock) { Group.Add(obj); } })); }
public void AddChildToGroup() { var g = new Group(); var s = new TestShape(); g.Add(s); Assert.NotEmpty(g); Assert.Contains(s, g); Assert.Equal(g, s.Parent); }
private void AddGroups() { // Create bars group. barsGroup = new Group("Bars"); barsGroup.Add("Pad", DataObjectType.String, 0); barsGroup.Add("SelectorKey", Instrument.Symbol); // Create fills group. fillGroup = new Group("Fills"); fillGroup.Add("Pad", 0); fillGroup.Add("SelectorKey", Instrument.Symbol); // Create equity group. equityGroup = new Group("Equity"); equityGroup.Add("Pad", 2); equityGroup.Add("SelectorKey", Instrument.Symbol); // Create RSI values group. rsiGroup = new Group("RSI"); rsiGroup.Add("Pad", 1); rsiGroup.Add("SelectorKey", Instrument.Symbol); rsiGroup.Add("Color", Color.Blue); // Create BuyLevel values group. buyLevelGroup = new Group("BuyLevel"); buyLevelGroup.Add("Pad", 1); buyLevelGroup.Add("SelectorKey", Instrument.Symbol); buyLevelGroup.Add("Color", Color.Red); // Create SellLevel values group. sellLevelGroup = new Group("SellLevel"); sellLevelGroup.Add("Pad", 1); sellLevelGroup.Add("SelectorKey", Instrument.Symbol); sellLevelGroup.Add("Color", Color.Red); // Add groups to manager. GroupManager.Add(barsGroup); GroupManager.Add(fillGroup); GroupManager.Add(equityGroup); GroupManager.Add(rsiGroup); GroupManager.Add(buyLevelGroup); GroupManager.Add(sellLevelGroup); }
private void AddGroups() { // Create bars group. barsGroup = new Group("Bars"); barsGroup.Add("Pad", DataObjectType.String, 0); barsGroup.Add("SelectorKey", Instrument.Symbol); // Create fills group. fillGroup = new Group("Fills"); fillGroup.Add("Pad", 0); fillGroup.Add("SelectorKey", Instrument.Symbol); // Create equity group. equityGroup = new Group("Equity"); equityGroup.Add("Pad", 1); equityGroup.Add("SelectorKey", Instrument.Symbol); // Create BBU group. bbuGroup = new Group("BBU"); bbuGroup.Add("Pad", 0); bbuGroup.Add("SelectorKey", Instrument.Symbol); bbuGroup.Add("Color", Color.Blue); // Create BBL group. bblGroup = new Group("BBL"); bblGroup.Add("Pad", 0); bblGroup.Add("SelectorKey", Instrument.Symbol); bblGroup.Add("Color", Color.Blue); // Create SMA group. smaGroup = new Group("SMA"); smaGroup.Add("Pad", 0); smaGroup.Add("SelectorKey", Instrument.Symbol); smaGroup.Add("Color", Color.Yellow); // Add groups to manager. GroupManager.Add(barsGroup); GroupManager.Add(fillGroup); GroupManager.Add(equityGroup); GroupManager.Add(bbuGroup); GroupManager.Add(bblGroup); GroupManager.Add(smaGroup); }
public static void AddBarChart(Group elements, float x, float y) { AddCaptionAndRectangle(elements, "Bar Chart", x, y, 225, 225); // Create a chart Chart chart = new Chart(x + 10, y + 25, 200, 200, Font.Helvetica, 10, RgbColor.Black); // Create a plot area PlotArea plotArea = chart.PrimaryPlotArea; // Create header title and add it to the chart Title title1 = new Title("Website Visitors"); chart.HeaderTitles.Add(title1); // Create a indexed bar series and add values to it IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A"); barSeries1.Values.Add(new float[] { 5, 7, 9, 6 }); IndexedBarSeries barSeries2 = new IndexedBarSeries("Website B"); barSeries2.Values.Add(new float[] { 4, 2, 5, 8 }); IndexedBarSeries barSeries3 = new IndexedBarSeries("Website C"); barSeries3.Values.Add(new float[] { 2, 4, 6, 9 }); // Create autogradient and assign it to series AutoGradient autogradient1 = new AutoGradient(180f, CmykColor.Red, CmykColor.IndianRed); barSeries1.Color = autogradient1; AutoGradient autogradient2 = new AutoGradient(180f, CmykColor.Green, CmykColor.YellowGreen); barSeries2.Color = autogradient2; AutoGradient autogradient3 = new AutoGradient(180f, CmykColor.Blue, CmykColor.LightBlue); barSeries3.Color = autogradient3; // Add indexed bar series to the plot area plotArea.Series.Add(barSeries1); plotArea.Series.Add(barSeries2); plotArea.Series.Add(barSeries3); // Create a title and add it to the xaxis Title lTitle = new Title("Visitors (in millions)"); barSeries1.XAxis.Titles.Add(lTitle); //Adding AxisLabels to the yAxis barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q1", 0)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q2", 1)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q3", 2)); barSeries1.YAxis.Labels.Add(new IndexedYAxisLabel("Q4", 3)); chart.Legends[0].Visible = false; elements.Add(chart); }
public override void InitWorld() { Light(-4.9, 4.9, -1); DefaultFloor().Material = new Material(new CheckerPattern(Color.White * 0.35, Color.White * 0.65) { //Transform = Helper.RotationY(45) }, reflective: 0.4, specular: 0); var sky = new Plane { Material = new Material(new SolidPattern(Blue) { Transform = Helper.RotationY(45) }, reflective: 0.4, specular: 0) }.Translate(ty: 10); Add(sky); Material material = new Material(new Color(1, 0, 0.2), ambient: 0, diffuse: 0.4, specular: 0.9, shininess: 300, reflective: 0.9, transparency: 0.9, refractiveIndex: 1); var c1 = new Cube { Material = material, HasShadow = false }; Add(c1.Translate(-2)); var s1 = new Sphere().Scale(0.2).Translate(tx: -2, ty: 0.2); Add(s1); var g = new Group() { HasShadow = true }; var c2 = new Cube { Material = material, HasShadow = false }; g.Add(c2); var s2 = new Sphere().Scale(0.2).Translate(ty: 0.2); g.Add(s2); Add(g.Translate(tx: 2)); }
private void AddGroups() { barsGroup = new Group("Bars"); barsGroup.Add("Pad", DataObjectType.String, 0); barsGroup.Add("SelectorKey", Instrument.Symbol); pcGroup = new Group("PC"); pcGroup.Add("Pad", 1); pcGroup.Add("SelectorKey", Instrument.Symbol); pcGroup.Add("Color", Color.Red); pcValueGroup = new Group("PC.Value"); pcValueGroup.Add("Pad", 1); pcValueGroup.Add("SelectorKey", Instrument.Symbol); pcValueGroup.Add("Color", Color.Blue); GroupManager.Add(barsGroup); GroupManager.Add(pcGroup); GroupManager.Add(pcValueGroup); }
public void TestGroupChild() { var g = new Group(); var s = new Sphere(); g.Add(s); Assert.AreEqual(g.Count, 1); Assert.AreEqual(g[0], s); Assert.AreEqual(s.Parent, g); }
public void TestGroupIntersectHit() { var child = new TestShape(); var shape = new Group(); shape.Add(child); var r = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1)); var xs = shape.Intersect(r); Assert.IsNotNull(child.SavedRay); }
public override async Task <Group> GetGroup( Input input, Conversation conversation, Message message) { Group group = new Group(); foreach (Grouper grouper in innerGroupers) { group.Add(await grouper.GetGroup(input, conversation, message)); } return(group); }
void AddTileInternal(int x, int y, Tile tile) { Dirty = true; int link = tile.Link; tile = (Tile)tile.GetType().GetConstructor(new Type[] { }).Invoke(new object[] { }); tile.Position = new Vec2(Tile.Size.X * x * 2, Tile.Size.Y * y * 2); tile.ID = GetID(x, y); tile.Link = link; tiles[y, x] = tile; if (tile.IsMoving) { movingTiles.Add(tile); movingTiles.Refresh(); } else { PosTiles.Add(tile, tile.Position); } }
public override NPC SpawnMinion(NPCEntry entry, ref Vector3 position, int durationMillis) { var minion = base.SpawnMinion(entry, ref position, durationMillis); if (Group == null) { Group = new AIGroup(this); } Group.Add(minion); return(minion); }
public void IntersectingRayAndGroupDoesntTestChildrenIfBoxIsMissed() { var child = new TestShape(); var shape = new Group(); shape.Add(child); var r = new Ray(new Point(0, 0, -5), new Vector(0, 1, 0)); var xs = shape.Intersects(r); Assert.IsNull(child.SavedRay); }
public void IntersectingRayGroupTestsChildrenIfBoxIsHit() { var child = new TestShape(); var shape = new Group(); shape.Add(child); var r = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1)); var xs = shape.Intersects(r); Assert.IsNotNull(child.SavedRay); }
public void AddingAChildToAGroup() { var g = new Group(); var s = new TestShape(); g.Add(s); Assert.AreNotEqual(0, g.Count); Assert.IsTrue(g.Contains(s)); Assert.AreEqual(g, s.Parent); }
protected override void OnAttachedTo(BindableObject bindable) { base.OnAttachedTo(bindable); _view = bindable as View; _view.PropertyChanged += OnPropertyChanged; if (Group != null) { Group.Add(this); } }
protected void AddParticle(T p) { Particles.Add(p); if (ParticleInitAction != null) { ParticleInitAction.Apply(p); } p.Position = Size == null ? Position : Position + new Vec2(Size.Value.X * Program.Random.NextDouble(-1, 1), Size.Value.Y * Program.Random.NextDouble(-1, 1)); new Timer(Life, () => { Particles.Remove(p); }); }
public static void Main() { var group1 = new Group(); group1.Add(new Shape()); // square group1.Add(new Shape()); // square var group2 = new Group(); group2.Add(new Shape()); // circle group2.Add(new Shape()); // circle var group = new Group(); group.Add(group1); group.Add(group2); group.Render(); group.Move(); }
static void Main(string[] args) { //Group 1, Diabetics var Diabetics = new Group("Diabetic Patients"); var U1 = new Diabetic("Carlota"); U1.GiveDose(2, 3); var U2 = new Diabetic("Marcia"); U2.GiveDose(3, 2); var U3 = new Diabetic("Cynthia"); U3.GiveDose(2, 2); Diabetics.Add(U1); Diabetics.Add(U2); Diabetics.Add(U3); //Group 2, Hypertensives var Hypertensives = new Group("Hypertensive Patients"); var U4 = new Hypertensive("Felix"); U4.GiveDose(5, 5); var U5 = new Hypertensive("Poh"); U5.GiveDose(10, 5); Hypertensives.Add(U4); Hypertensives.Add(U5); //Just one Athlete var U6 = new Athlete("Shaniqua"); U6.GiveDose(20, 30); //All Patients var allPatients = new Group("Patients"); allPatients.Add(Diabetics); allPatients.Add(Hypertensives); allPatients.Add(U6); //Show All Patients allPatients.Display(0); Console.ReadLine(); }
public List<Group> GroupFiles() { List<Group> groups = new List<Group>(); List<Group> copyGroups = new List<Group>(groups); Group newGroup = null; try { DirectoryInfo directoryInfo = new DirectoryInfo(Path); IEnumerable<FileInfo> files = directoryInfo.GetFiles(); // var temp = files.AsParallel().AsOrdered().Where(file => ListGroup(file)).ToList(); // groups.Add(temp.ToList<Group>()); int i = 0; foreach (FileInfo file in files) { byte[] hash = GetContentHash(file); //lock Group group = groups.AsParallel().Where(g => g.Hash.SequenceEqual(hash)).FirstOrDefault(); if (group != null) { group.Add(file); } else { newGroup = new Group(file, hash); newGroup.Add(file); groups.Add(newGroup); } // Console.WriteLine("File " + i++); } } catch (Exception e) { // Console.Write(e); } return groups; }
public override Task OnConnected() { Debug.WriteLine("OnConnected"); /* object tempObject; Context.Request.Environment.TryGetValue("server.RemoteIpAddress", out tempObject); */ bool found = false; foreach (KeyValuePair<string, Group> g in groups) { Group group = g.Value; if(group.Add(Context.ConnectionId)) { found = true; break; } } Debug.WriteLine("found: " + found); if (!found) { Group newGroup = new Group(); newGroup.Add(Context.ConnectionId); groups.TryAdd(groups.Count.ToString(), newGroup); Debug.WriteLine("group created"); } Debug.WriteLine("connection id: " + Context.ConnectionId); return base.OnConnected(); }
public void TestSize() { Group a = new Group(); a.Add(0); a.Add(10); Assert.AreEqual(10, Group.Size(a)); Assert.True(a.CompareTo(5) > 0); Assert.True(a.CompareTo(12) < 0); Assert.True(a.CompareTo(10) <= 0); Assert.False(a.CompareTo(10) < 0); Assert.True(a.CompareTo(10) >= 0); }
public void TestIntersect1() { Group a = new Group(); a.Add(0); a.Add(10); Group b = new Group(); b.Add(5); b.Add(15); Group c = a * b; Assert.AreEqual(2, c.Count); Assert.AreEqual(5, c [0]); Assert.AreEqual(10, c [1]); }
public void TestSubtract2() { Group a = new Group(); a.Add(0); a.Add(10); Group b = a - 0; Assert.True(b[0] == 1); Assert.True(b[1] == 10); }
public void TestSubtract1() { Group a = new Group(); a.Add(0); a.Add(10); Group b = new Group(); b.Add(9); b.Add(12); Group c = a - b; Assert.AreEqual(2, c.Count); Assert.AreEqual(0, c [0]); Assert.AreEqual(9, c [1]); }
public void TestUnion2() { Group a = new Group(); a.Add(0); a.Add(10); Group b = new Group(); Group c = a + b; Assert.True(a.CompareTo(c) == 0); }
public void TestUnion1() { Group a = new Group(); a.Add(0); a.Add(10); Group b = new Group(); b.Add(9); b.Add(12); Group c = a + b; Assert.AreEqual(2, c.Count); Assert.AreEqual(0, c [0]); Assert.AreEqual(12, c [1]); }
public void TestIntersect2() { Group a = new Group(); a.Add(0); a.Add(10); Group b = new Group(); Group c = a * b; Assert.AreEqual(true, Group.IsEmpty(c)); }
/// <summary> /// The contructor for Interpreter.Group. /// </summary> /// <param name="parentGroup"> /// The Group that contains this Group. If parentGroup is not null, then this group will be appended to /// parentGroup. /// </param> public Group(Group parentGroup) { ParentGroup = parentGroup; if (parentGroup != null) parentGroup.Add(this); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Publish the service, allowing everything to use the spriteBatch Services.AddService(typeof(SpriteBatch), spriteBatch); // Player classes. player1 = new Player(this, Pallet.PlayerNumber.PlayerOne); player1.Name = "Player 1"; player2 = new Player(this, Pallet.PlayerNumber.PlayerTwo); player2.Name = "Player 2"; // Ball classes. ball = new Ball(this); // Collision groups collisionGroup = new Group("Collisions"); playerGroup = new Group("Players"); playerGroup.Add(player1.Pallet); playerGroup.Add(player2.Pallet); // Groups GroupList GameGroups = new GroupList(); GameGroups.Add(collisionGroup); GameGroups.Add(playerGroup); //Add the list of groups into the services so objects can retrieve info about items in specific groups Services.AddService(typeof(GroupList), GameGroups); // Blocks BlockList = new BlockManager(this); // Will initialize the basic graphical objects. base.Initialize(); // Goes to LoadContent() // Placed after general initialisation so the texture is already loaded and its size initialized player1.Pallet.placeInDefaultPosition(); player2.Pallet.placeInDefaultPosition(); /* Define the block safe zone, it's meant to restrict where the blocks can appear so they don't get on top of the pallet * or behind it. */ BlockList.BlocksSafeZone = new Rectangle((int)player1.Pallet.Position.X + 1, 0, (int)player2.Pallet.Position.X + (int)player2.Pallet.ObjectRectangle.Width - (int)player1.Pallet.ObjectRectangle.X - BlockList.MaxBlockSize, Window.ClientBounds.Height - BlockList.MaxBlockSize); // Places the ball in the center position and give it a random angle. ball.placeInDefaultPosition(); }
public static void Init(string path) { ResourceManager resources = new ResourceManager("INVedit.Resources", typeof(Data).Assembly); unknown = (Image)resources.GetObject("unknown"); string[] lines = File.ReadAllLines(path); for (int i = 1; i <= lines.Length; ++i) { try { string line = lines[i-1].TrimStart(); if (line=="" || line[0]=='#') continue; string[] split; if (line[0] == ':') { split = line.Split(new char[]{' '}, 2, StringSplitOptions.RemoveEmptyEntries); switch (split[0].ToLower()) { case ":version": try { version = int.Parse(split[1]); } catch (Exception e) { throw new DataException("Failed to parse option "+split[0]+" at line "+i+" in file '"+path+"'.", e); } break; default: throw new DataException("Unknown option '"+split[0]+"' at line "+i+" in file '"+path+"'."); } continue; } split = line.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries); Exception ex = new DataException("Invalid number of colums at line "+i+" in file '"+path+"'."); if (line[0]=='~') { if (split.Length != 4) throw ex; } else { if (split.Length < 4 || split.Length > 5) throw ex; } string name = split[1].Replace('_', ' '); if (line[0]=='~') { short icon; try { icon = short.Parse(split[2]); } catch (Exception e) { throw new DataException("Failed to parse column 'ICON' at line "+i+" in file '"+path+"'.", e); } if (!items.ContainsKey(icon)) throw new DataException("Invalid item id '"+icon+"' in column 'ICON' at line "+i+" in file '"+path+"'."); int imageIndex = items[icon].imageIndex; string[] l = split[3].Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries); Group group = new Group(name, imageIndex); foreach (string n in l) { short s; try { s = short.Parse(n); } catch (Exception e) { throw new DataException("Failed to parse column 'ITEMS' at line "+i+" in file '"+path+"'.", e); } if (items.ContainsKey(s)) group.Add(items[s]); else MessageBox.Show("Invalid item id '"+s+"' in column 'ITEMS' at line "+i+" in file '"+path+"'.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } groups.Add(name, group); } else { Image image; try { image = LoadImage(split[2]); } catch (Exception e) { throw new DataException("Failed to load image '"+split[2]+"' at line "+i+" in file '"+path+"' ("+e.Message+").", e); } short id; try { id = short.Parse(split[0]); } catch (Exception e) { throw new DataException("Failed to parse column 'ID' at line "+i+" in file '"+path+"'.", e); } string[] cords = split[3].Split(','); if (cords.Length != 2) throw new DataException("Failed to parse column 'CORDS' at line "+i+" in file '"+path+"'."); int x, y; try { x = int.Parse(cords[0]); y = int.Parse(cords[1]); } catch (Exception e) { throw new DataException("Failed to parse column 'CORDS' at line "+i+" in file '"+path+"'.", e); } if (x < 0 || y < 0 || x*16+16 > image.Width || y*16+16 > image.Height) throw new DataException("Invalid image cords "+x+","+y+" at line "+i+" in file '"+path+"'."); bool stackable = true; short maxDamage = 0; if (split.Length == 5) { stackable = false; try { maxDamage = short.Parse(split[4]); } catch (Exception e) { throw new DataException("Failed to parse column 'DAMAGE' at line "+i+" in file '"+path+"'.", e); } if (maxDamage < 0) throw new DataException("Failed to parse column 'DAMAGE' at line "+i+" in file '"+path+"'."); } items.Add(id, new Item(id, name, stackable, maxDamage, image, x, y)); } } catch (Exception e) { if (MessageBox.Show(e.Message, "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) return; } } }