public MatchingCondition(string excelPropertyName, NodeLevel level) { this.ExcelPropertyName = excelPropertyName; this.NodeLevel = level; SetDatabaseTableName(); }
/// <summary> /// Process a single line of text into the Node that is the current /// context. /// </summary> protected void ProcessLine(string line) { // Determine if line is at same level of indentation as previous NodeLevel context = _stack.Peek(); Node node; string indent = line; line = line.TrimStart(null); indent = indent.Substring(0, indent.Length - line.Length); int indentation = indent.Length; // Ensure indentation is via spaces and not tabs if (indent.IndexOf('\t') >= 0) { throw new ParseException("Tab characters must not be used for indentation (use spaces instead)", _preprocessor.File, _preprocessor.Line); } if (indentation < context.Indentation) { // Finished populating current nesting while (indentation < context.Indentation) { _stack.Pop(); context = _stack.Peek(); } if (indentation != context.Indentation) { throw new ParseException("Unexpected indentation level (got " + indentation + ", expected " + context.Indentation + ")", _preprocessor.File, _preprocessor.Line); } } if (indentation == context.Indentation) { _stack.Pop(); context = _stack.Peek(); } if (line.StartsWith("-")) { node = ProcessListElement(context.Node, line); } else if (line.IndexOf(":") > 0) { node = ProcessDictionaryElement(context.Node, line); } else { // NOTE: Non-standard YAML, but simplifies control file specification // Basically, if we find a line that is simply a string on its own, // assume it is a list element and process it as such. node = ProcessListElement(context.Node, "- " + line); } _stack.Push(new NodeLevel() { Node = node, Indentation = indentation }); }
public MatchingCondition(string excelPropertyName, NodeLevel level, XmlNodes xmlPropertyName) { this.ExcelPropertyName = excelPropertyName; this.NodeLevel = level; this.XmlPropertyName = xmlPropertyName; SetDatabaseTableName(); SetDatabaseFieldName(); }
/// <summary> /// Attempts to parse the YAML file contents of templateFile into a YAML /// Node object. /// </summary> /// <returns>A YAML Node object to the root node if parsing is /// successful. /// </returns> public Node ParseFile(string fileName, Dictionary <string, object> variables) { // Create root node _stack.Clear(); NodeLevel context = new NodeLevel() { Node = new Node(), Indentation = -2 }; _stack.Push(context); using (_preprocessor = new Preprocessor(fileName, variables)) { string line; // Process each line of the file do { line = _preprocessor.ReadLine(); if (line == null) { continue; } if (line.Trim().Length > 0 && !line.Trim().StartsWith("#")) { // First line determines type of parent collection try { ProcessLine(line, variables); } catch (ParseException) { throw; } catch (Exception ex) { throw new ParseException("An exception occurred", ex, _preprocessor.File, _preprocessor.Line); } } }while (line != null); } // Get root object to return; this is at the bottom of the stack do { context = _stack.Pop(); }while (_stack.Count > 0); return(context.Node); }
public void AddToDictionary(NodeLevel ndlvl) { if (finalLists.ContainsKey(ndlvl.Level)) { finalLists[ndlvl.Level].Add(ndlvl.Node); } else { finalLists.Add(ndlvl.Level, new List <TreeNode>() { ndlvl.Node }); } }
public static List <NodeLevel> MakeTree(List <Node> nodes) //лист приходит сортированным { List <NodeLevel> list = new List <NodeLevel>(); //добавляем записи в лист с ветвями foreach (Node node in nodes) { NodeLevel n = new NodeLevel(node.Symbol, node.Value); list.Add(n); } var nodeZero = new NodeLevel(); var nodeOne = new NodeLevel(); while (true) { nodeZero = list[0]; nodeOne = list[1]; var symbolSum = nodeOne.Symbol + nodeZero.Symbol; var valueSum = nodeOne.Value + nodeZero.Value; var nodeSum = new NodeLevel(symbolSum, valueSum, nodeZero, nodeOne); //добавляем нижний уровень - суммарную ветку ref NodeLevel nodeSumRef = ref nodeSum; nodeZero.Parrent = nodeSumRef; // добавляем ссылку на родительский элемент nodeOne.Parrent = nodeSumRef; list.Remove(list[0]); //удаляем две верхние записи list.Remove(list[0]); list.Add(nodeSum); list = list.OrderBy(x => x.Value).ToList(); if (list.Count == 1) { break; } }
public void printTree() { string treePrint = ""; Stack <NodeLevel> nodeStack = new Stack <NodeLevel>(); Node currentNode = this; nodeStack.Push(new NodeLevel { level = 0, node = currentNode }); while (nodeStack.Count != 0) { NodeLevel nextNode = nodeStack.Pop(); treePrint += new string('-', nextNode.level) + nextNode.node.name + "\n"; for (int i = nextNode.node.children.Count - 1; i >= 0; i--) { nodeStack.Push(new NodeLevel { level = nextNode.level + 1, node = nextNode.node.children[i] }); } } Debug.Log(treePrint); }
private void AddNode(NodeState state, NodeLevel level, string text, Font font, int inset, int parent, bool visible, int region, int market) { ShopsTreenode locNode = new ShopsTreenode(state); locNode.NodeID = _count++; if (level.Equals(NodeLevel.Company)) { locNode.Label.Text = text; } else { locNode.Label.Text = string.Format("{0} {1}", level, text); } locNode.NodeValue = text; locNode.Label.Font = font; locNode.Inset = inset; locNode.Level = level; locNode.State = state; locNode.NodeParent = parent; locNode.NodeRegion = region; locNode.NodeMarket = market; locNode.Visible = visible; LoanInquiryShops.LocationsTreeview.Add(locNode); }
private void HandleSocketState(Dictionary <EventType, List <GameEvent> > gameEvents) { BoardPlayerLayer.BoardPlayerLayer currentPlayerLayer = this.NodeLevel.GetLayerFromPlayer(this.OwnerCardEntity.Card.CurrentOwner); if (gameEvents.TryGetValue(EventType.SOCKET_CARD, out List <GameEvent> gameEventsSocket)) { GameEvent socketEvent = gameEventsSocket.FirstOrDefault(); if (socketEvent != null) { StarEntity starEntity = socketEvent.Entity as StarEntity; if (this.ToStarEntities.Contains(starEntity)) { this.ExecuteBehavior(starEntity); this.NbBehaviorUse--; this.NodeLevel.BoardNotifLayer.NotifyNotifBehaviorUseChanged(this.NbBehaviorUse); this.mustNotifyBehaviorEnd = true; return; } } } if (gameEvents.TryGetValue(EventType.PICK_CARD, out List <GameEvent> gameEventsPicks)) { GameEvent nullPickEvent = gameEventsPicks.FirstOrDefault(pElem => pElem.Layer == currentPlayerLayer && pElem.Entity == null); GameEvent entityPickEvent = gameEventsPicks.FirstOrDefault(pElem => pElem.Layer == currentPlayerLayer && pElem.Entity != null); if (nullPickEvent != null) { CardEntity cardToAdd = NodeLevel.UnpickCard(currentPlayerLayer, nullPickEvent.Details); this.FromCardEntities.Add(cardToAdd); this.State = ResurrectState.PICK_CARD; } if (entityPickEvent != null) { CardEntity cardToRemove = entityPickEvent.Entity as CardEntity; this.FromCardEntities.Remove(cardToRemove); this.NodeLevel.PickCard(currentPlayerLayer, cardToRemove); this.CardBehaviorOwner.OnBehaviorCardPicked(this, this.NodeLevel.BoardGameLayer.CardEntityPicked); this.State = ResurrectState.SOCKET_CARD; } } if (gameEvents.TryGetValue(EventType.NEXT_BEHAVIOR, out List <GameEvent> gameEventsNextBehavior)) { if (gameEventsNextBehavior.Any()) { this.IsActive = false; this.mustNotifyBehaviorEnd = true; return; } } }
public bool scavengeParts(Node node_type, NodeLevel resource_level, int x, int z) { if(getScavengeAPCost() > current_ap) throw new System.Exception("Don't have enough AP to scavenge, why is this being offered????"); if(resource_level == NodeLevel.Empty) return false; int num_of_each_type = (int) resource_level; if(node_type == Node.Factory) { part_count[Part.Piston] += num_of_each_type; entityManagerS.createPartEffect(x,z,Part.Piston); part_count[Part.Gear] += num_of_each_type; entityManagerS.createPartEffect(x,z,Part.Gear); } else if(node_type == Node.Outpost) { part_count[Part.Strut] += num_of_each_type; entityManagerS.createPartEffect(x,z,Part.Strut); part_count[Part.Plate] += num_of_each_type; entityManagerS.createPartEffect(x,z,Part.Plate); } else { //increase random part count by two, twice for(int i =0; i < 2; i++) { int ind = UnityEngine.Random.Range(0, 3); part_count[(Part) ind] += num_of_each_type; entityManagerS.createPartEffect(x,z,(Part) ind); } } current_ap -= getScavengeAPCost(); allowSelectionHexesDraw(); entityManagerS.updateNodeLevel(x, z, resource_level); return true; }
public readonly int z; //level z coord (N / S) #endregion Fields #region Constructors public NodeData(int _x, int _z, Node _type, NodeLevel _lvl) { x = _x; z = _z; node_type = _type; node_level = _lvl; }
/// <summary> /// Attempts to parse the YAML file contents of templateFile into a YAML /// Node object. /// </summary> /// <returns>A YAML Node object to the root node if parsing is /// successful. /// </returns> public Node ParseFile(string fileName, Dictionary<string, object> variables) { // Create root node _stack.Clear(); NodeLevel context = new NodeLevel() { Node = new Node(), Indentation = -2 }; _stack.Push(context); using(_preprocessor = new Preprocessor(fileName, variables)) { string line; // Process each line of the file do { line = _preprocessor.ReadLine(); if(line == null) { continue; } if(line.Trim().Length > 0 && !line.Trim().StartsWith("#")) { // First line determines type of parent collection try { ProcessLine(line); } catch(ParseException) { throw; } catch(Exception ex) { throw new ParseException("An exception occurred", ex, _preprocessor.File, _preprocessor.Line); } } } while(line != null); } // Get root object to return; this is at the bottom of the stack do { context = _stack.Pop(); } while (_stack.Count > 0); return context.Node; }
private void FillSubNodes(object sender, TreeViewCancelEventArgs e) { TreeNode ClickedNode = e.Node; TreeNode node; NodeLevel l = (NodeLevel)ClickedNode.Tag; ClickedNode.Nodes.Clear(); switch (l) { case NodeLevel.AllToys: node = ClickedNode.Nodes.Add("Battery Powered Toys"); node.Tag = NodeLevel.BatteryToys; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Board Games"); node.Tag = NodeLevel.BoardGameToys; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Electronic Games"); node.Tag = NodeLevel.ElectronicToys; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Models"); node.Tag = NodeLevel.ModelToys; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Plush Toys"); node.Tag = NodeLevel.PlushToys; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Video Games"); node.Tag = NodeLevel.VideoToys; node.Nodes.Add("VirtualNode"); break; case NodeLevel.AllClothes: node = ClickedNode.Nodes.Add("Gloves and Hats"); node.Tag = NodeLevel.ClothingGloves; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Jackets"); node.Tag = NodeLevel.ClothingJackets; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Pants"); node.Tag = NodeLevel.ClothingPants; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Sweaters"); node.Tag = NodeLevel.ClothingSweaters; node.Nodes.Add("VirtualNode"); node = ClickedNode.Nodes.Add("Tops"); node.Tag = NodeLevel.ClothingTops; node.Nodes.Add("VirtualNode"); break; case NodeLevel.ModelToys: UpdateTree(toys.Models.Brands, ClickedNode); break; case NodeLevel.BatteryToys: UpdateTree(toys.BatteryPowered.Brands, ClickedNode); break; case NodeLevel.BoardGameToys: UpdateTree(toys.BoardGames.Brands, ClickedNode); break; case NodeLevel.ElectronicToys: UpdateTree(toys.Electronic.Brands, ClickedNode); break; case NodeLevel.FigureToys: UpdateTree(toys.ActionFigures.Brands, ClickedNode); break; case NodeLevel.PlushToys: UpdateTree(toys.Plush.Brands, ClickedNode); break; case NodeLevel.VideoToys: UpdateTree(toys.Video.Brands, ClickedNode); break; case NodeLevel.ClothingFootware: UpdateTree(Clothes.Footware.Brands, ClickedNode); break; case NodeLevel.ClothingGloves: UpdateTree(Clothes.GlovesHats.Brands, ClickedNode); break; case NodeLevel.ClothingJackets: UpdateTree(Clothes.Jackets.Brands, ClickedNode); break; case NodeLevel.ClothingPants: UpdateTree(Clothes.Pants.Brands, ClickedNode); break; case NodeLevel.ClothingSweaters: UpdateTree(Clothes.Sweaters.Brands, ClickedNode); break; case NodeLevel.ClothingTops: UpdateTree(Clothes.Tops.Brands, ClickedNode); break; } }
public DeletingCondition(string excelPropertyName, NodeLevel level) { this.ExcelPropertyName = excelPropertyName; this.NodeLevel = level; }
public void SendNodeLevel(int value) { NodeLevel nLevel = new NodeLevel(value); networkIdentity.GetSocket().Emit("NodeLevel", new JSONObject(JsonUtility.ToJson(nLevel))); }
public NodeLevel(string symbols, int value, NodeLevel zero, NodeLevel one) : base(symbols, value) { BranchZero = zero; BranchOne = one; }
public static void updateNodeLevel(int x, int z, NodeLevel previous_level) { foreach(entityNodeS node in resource_node_list) if(x == node.x && z == node.z) { if(previous_level == NodeLevel.Full) node.node_level = NodeLevel.Sparse; else node.node_level = NodeLevel.Empty; node.SetVisiual(); } }
//create a base for the level public static bool instantiateResourceNode(int x, int z, Node node_type, NodeLevel node_level) { if(node_type == Node.Factory || node_type == Node.Junkyard || node_type == Node.Outpost) { GameObject new_entity = instantiateEntityNode(x, z, node_type); entityNodeS new_node = (entityNodeS) new_entity.AddComponent("entityNodeS"); if(new_node == null) throw new System.Exception("Node Entity not created properly D:"); new_node.x = x; new_node.z = z; new_node.node_type = node_type; new_node.node_level = node_level; new_node.SetVisiual(); resource_node_list.Add(new_node); return true; } else { throw new System.Exception("Trying to create a resource node, but passing in an invalid EntityE type! D:"); } }