private List <Element>[,] FindAllMatches() { List <Element>[,] matchedElements = new List <Element> [size, size]; for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) { List <Element> matchedForCur = matchedElements[i, j] = new List <Element>(); Element el = field[i, j]; if (el == EMPTY) { continue; } Element.Type type = el.type; Point start = new Point(j, i); List <Element> vert = GetSameElementsInLine(start, new Point(0, -1), type); vert.AddRange(GetSameElementsInLine(start, new Point(0, 1), type)); List <Element> horiz = GetSameElementsInLine(start, new Point(-1, 0), type); horiz.AddRange(GetSameElementsInLine(start, new Point(1, 0), type)); if (horiz.Count >= 3 + 1) //el in list 2 times { matchedForCur.AddRange(horiz); } if (vert.Count >= 3 + 1) { matchedForCur.AddRange(vert); } matchedElements[i, j] = matchedForCur.Distinct().ToList(); } } return(matchedElements); }
internal static Color randomColor() { float red = (float)random.NextDouble(); float green = (float)random.NextDouble(); float blue = (float)random.NextDouble(); Color color = new Color(red, green, blue); Element.Type elementType = elementFor(color); Color elementTypeColor = Element.types[elementType].color; red = (red + elementTypeColor.R / 255.0f) / 2.0f; green = (green + elementTypeColor.G / 255.0f) / 2.0f; blue = (blue + elementTypeColor.B / 255.0f) / 2.0f; if (elementType != Element.Type.darkness) { float maxColor = 1.0f - Math.Max(Math.Max(red, green), blue); red = red + maxColor; green = green + maxColor; blue = blue + maxColor; } return(new Color(red, green, blue)); }
void GetTextElement(int pageNum, ElementReader reader, List <TextAndAxisValue> values, double bottomAxisValue, double topAixsValue, bool isMatchNum) { Element element; while ((element = reader.Next()) != null) { Element.Type elementType = element.GetType(); switch (elementType) { case Element.Type.e_text: ProcessText(pageNum, element, values, bottomAxisValue, topAixsValue, isMatchNum); break; case Element.Type.e_text_begin: GetTextElement(pageNum, reader, values, bottomAxisValue, topAixsValue, isMatchNum); break; case Element.Type.e_text_end: return; case Element.Type.e_form: reader.FormBegin(); GetTextElement(pageNum, reader, values, bottomAxisValue, topAixsValue, isMatchNum); reader.End(); break; } reader.ClearChangeList(); } }
Element CreateElement(int col, int row, Element.Type type, Rectangle rect) { Element el = new Element(Game, col, row, type, rect); el.onMouseUp += onMouseUpElement; el.onMouseIn += onMouseInElement; el.onMouseOut += onMouseOutElement; return(el); }
internal static Color randomColorFor(Element.Type someElement) { Color color = randomColor(); if (elementFor(color) == someElement) { return(color); } return(randomColorFor(someElement)); }
private List <Element> GetSameElementsInLine(Point start, Point shift, Element.Type type) { List <Element> line = new List <Element>(); for (Point cur = start; !OutOfRange(cur) && GetElementByPoint(cur).type == type; cur += shift ) { line.Add(GetElementByPoint(cur)); } return(line); }
private int CalcLine(Point start, Point shift, Element.Type type) { int count = 0; for (Point cur = start; !OutOfRange(cur) && GetElementByPoint(cur).type == type; cur += shift ) { ++count; } return(count); }
// Used in code snippet 2. static void ProcessElements(ElementReader reader) { Element element; while ((element = reader.Next()) != null) // Read page contents { // In this sample we process only paths & text, but the code can be // extended to handle any element type. Element.Type type = element.GetType(); if (type == Element.Type.e_path || type == Element.Type.e_text || type == Element.Type.e_path) { switch (type) { case Element.Type.e_path: // Process path ... Console.WriteLine(); Console.Write("PATH: "); break; case Element.Type.e_text: // Process text ... Console.WriteLine(); Console.WriteLine("TEXT: " + element.GetTextString()); break; case Element.Type.e_form: // Process form XObjects Console.WriteLine(); Console.Write("FORM XObject: "); //reader.FormBegin(); //ProcessElements(reader); //reader.End(); break; } // Check if the element is associated with any structural element. // Content items are leaf nodes of the structure tree. SElement struct_parent = element.GetParentStructElement(); if (struct_parent.IsValid()) { // Print out the parent structural element's type, title, and object number. Console.Write(" Type: " + struct_parent.GetType() + ", MCID: " + element.GetStructMCID()); if (struct_parent.HasTitle()) { Console.Write(". Title: " + struct_parent.GetTitle()); } Console.Write(", Obj#: " + struct_parent.GetSDFObj().GetObjNum()); } } } }
/// <summary> /// Process the elements of a pdf page. /// </summary> /// <param name="reader">ElementReader object</param> void ProcessElements(ElementReader reader) { Element element; while ((element = reader.Next()) != null) { Element.Type elementType = element.GetType(); switch (elementType) { case Element.Type.e_path: // Process path data... ProcessPath(element); break; } reader.ClearChangeList(); } }
public static float get_counter(Element.Type a, Element.Type b) { if (a == b) { return(1); } else if (a == Type.Fire && b == Type.Fire) { return(1); } else if (a == Type.Fire && b == Type.Terra) { return(base_accel); } else if (a == Type.Fire && b == Type.Water) { return(negative_accel); } else if (a == Type.Water && b == Type.Fire) { return(negative_accel); } else if (a == Type.Water && b == Type.Terra) { return(base_accel); } else if (a == Type.Water && b == Type.Water) { return(1); } else if (a == Type.Terra && b == Type.Fire) { return(negative_accel); } else if (a == Type.Terra && b == Type.Terra) { return(1.0f); } else if (a == Type.Terra && b == Type.Water) { return(base_accel); } else { return(0); } }
private bool MatchExists() { for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) { if (field[i, j] == EMPTY) { continue; } Element.Type type = field[i, j].type; if (CalcLine(new Point(j, i), new Point(1, 0), type) >= 3 || CalcLine(new Point(j, i), new Point(0, 1), type) >= 3 ) { return(true); } } } return(false); }
public Card(Element.Type a_Type, Vector2 a_Position, Level a_Level, State a_State) { m_Type = a_Type; m_Position = a_Position; m_State = a_State; m_Level = a_Level; LoadContent(a_Level); m_nFadeInTimer = 0; if (a_Type <= Element.Type.Earth) value = 25; else if (a_Type <= Element.Type.Stone) value = 50; else if (a_Type <= Element.Type.Death) value = 75; else if (a_Type <= Element.Type.Tree) value = 100; else if (a_Type <= Element.Type.Hurricane) value = 125; else value = 150; }
public ElementGenerator(Vector2 a_Position, Level a_Level, Element.Type a_Type) { m_Level = a_Level; m_Position = a_Position; m_Type = a_Type; }
private static Element.Type[] getElements(int tier) { Element.Type[] e; if (tier == 1) { e = new Element.Type[] { Element.Type.Wind, Element.Type.Water, Element.Type.Earth, Element.Type.Fire }; } else if (tier == 2) { e = new Element.Type[] { Element.Type.Combustion, Element.Type.Atmosphere, Element.Type.Steam, Element.Type.Coal, Element.Type.Cyclone, Element.Type.Life, Element.Type.River, Element.Type.Clay, Element.Type.Stone, Element.Type.Dust }; } else if (tier == 3) { e = new Element.Type[] { Element.Type.Magma, Element.Type.Creature, Element.Type.Energy, Element.Type.Sand, Element.Type.Lightning, Element.Type.Brick, Element.Type.Golem, Element.Type.Plant, Element.Type.Oil, Element.Type.Death}; } else if (tier == 4) { e = new Element.Type[] { Element.Type.Metal, Element.Type.Torrent, Element.Type.Glass, Element.Type.Diamond, Element.Type.Corpse, Element.Type.Shelter, Element.Type.Fish, Element.Type.Bird, Element.Type.Beast, Element.Type.Tree, Element.Type.Blood, Element.Type.Seed}; } else if (tier == 5) { e = new Element.Type[] { Element.Type.Phoenix, Element.Type.Tool, Element.Type.Electricity, Element.Type.Undead, Element.Type.Ash, Element.Type.Machine, Element.Type.Hurricane, Element.Type.Ent, Element.Type.Human, Element.Type.Pottery }; } else { e = new Element.Type[] { Element.Type.Spirit, Element.Type.Robot, Element.Type.Weapon, Element.Type.Wood, Element.Type.Light, Element.Type.Jewel, Element.Type.Industry, Element.Type.Vampire}; } return e; }