public void AddHexToLevel(HexTypeEnum hexType, Vector2 location, ElementAttribute attribute) { throw new System.NotImplementedException("TODO: use hex location to modify the hex tile at that location(?)"); //levelBeingEdited.hexs[1] = new MapElement(HexTypeEnum.HexTile_MenuOptionEdit, new Vector2Int(1, 0), new MenuButtonElementAttribute(Command.Edit)); }
private static int GetElementAttributeValue(BaseWeapon weapon, ElementAttribute element) { int phys, fire, cold, pois, nrgy, chao; weapon.GetDamageTypes(null, out phys, out fire, out cold, out pois, out nrgy, out chao); switch (element) { case ElementAttribute.Physical: return(phys); case ElementAttribute.Fire: return(fire); case ElementAttribute.Cold: return(cold); case ElementAttribute.Poison: return(pois); case ElementAttribute.Energy: return(nrgy); } return(-1); }
public void AddElementAttribute(ElementAttribute paElementAttribute, String paValue) { if (!String.IsNullOrEmpty(paValue)) { AddAttribute(paElementAttribute.ToString().ToLower(), paValue); } }
private static void ToXmlRecursive <T>(this T item, XmlNode node, XmlDocument document) // The generic parameter should be a class where T : class { // Getting the object Type var type = item.GetType(); // Getting the properties of the object var properties = type.GetProperties(); // Iterating through each properties foreach (var property in properties) { #region Value Attribute // Checking wheather the Value Attribute present ValueAttribute valueAttribute = ReflectionHelper.GetCustomeAttribute <ValueAttribute>(property); // If present if (valueAttribute != null) { AddValueToNode(item, property, node); continue; } #endregion #region Element Attribute // Checking wheather there is any Element Attribute present ElementAttribute elementAttribute = ReflectionHelper.GetCustomeAttribute <ElementAttribute>(property); // If present if (elementAttribute != null) { // Getting the name of node var name = ReflectionHelper.GetName(elementAttribute, property); AddElementToNode(item, property, node, name, document); continue; } #endregion #region Property Attribute // Getting the property attribute PropertyAttribute propertyAttribute = ReflectionHelper.GetCustomeAttribute <PropertyAttribute>(property); if (propertyAttribute != null) { var name = ReflectionHelper.GetName(propertyAttribute, property); AddPropertyToNode(item, property, node, name, document); continue; } #endregion } }
private static int AssignElementalDamage(BaseWeapon weapon, ElementAttribute attr, int totalDamage) { if (totalDamage <= 0) { return(0); } int random = Utility.Random((int)(totalDamage / 10) + 1) * 10; // TODO: Refactor this // weapon.ElementDamages[attr] = random; switch (attr) { case ElementAttribute.Cold: weapon.WeaponAttributes.DamageColdPercent = random; break; case ElementAttribute.Energy: weapon.WeaponAttributes.DamageEnergyPercent = random; break; case ElementAttribute.Fire: weapon.WeaponAttributes.DamageFirePercent = random; break; case ElementAttribute.Poison: weapon.WeaponAttributes.DamagePoisonPercent = random; break; } return(totalDamage - random); }
//--------------------------------------------------------------------------------------------------------------------------------------------- #if UNITY_EDITOR //機率設定初始化 public void ProbabilityInitialize() { if (ScrollManager.Instance.applyRoulette == null || ScrollManager.Instance.elementAttribute == null) { return; //若未設定輪盤 或 未設定圖格元素, 則程序直接結束 } List <Roulette> _roulette = ScrollManager.Instance.applyRoulette; //取得輪盤 elementAttribute = ScrollManager.Instance.elementAttribute; //取得圖格設定 //機率設定物件創立 if (probUnitList == null) { probUnitList = new List <ProbabilitySettingUnit>(); //若列表不存在則初始化新物件 } for (int i = 0; i < elementAttribute.m_data.Count; i++) { if (probUnitList.Count < elementAttribute.m_data.Count) //組合項目物件不足時, 創建之 { GameObject _go = Instantiate(probabilitySettingUnit, probUnitHolder); ProbabilitySettingUnit _pb = _go.GetComponent <ProbabilitySettingUnit>(); //取得腳本 probUnitList.Add(_pb); //加入列表 } ElementCountCollected += probUnitList[i].FeedbackAmount; //訂閱數量回報事件 } for (int i = elementAttribute.m_data.Count; i < probUnitList.Count; i++) //暫時隱藏多餘的機率設定單元 { probUnitList[i].Invalid(); } ReloadProbabilitySetting(); //讀取機率設定 }
public static void AssignElementalDamage(BaseWeapon weapon, ElementAttribute attr) { int fire, phys, cold, nrgy, pois; weapon.GetDamageTypes(null, out phys, out fire, out cold, out pois, out nrgy); AssignElementalDamage(weapon, attr, phys); weapon.Hue = weapon.GetElementalDamageHue(); }
public void InitializeElement() { foreach (XmlAttribute attribute in this.XmlAttributes) { // validate required bool valid = this.getValidAttributes().Contains(attribute.Name); if (valid) { ElementAttribute _elementAttr = new ElementAttribute(attribute.Name, attribute.Value); this.Attributes.Add(attribute.Name, _elementAttr); } } }
private void treeViewDataset_AfterCheck(object sender, TreeViewEventArgs e) { ElementAttribute attrib = e.Node.Tag as ElementAttribute; if (e.Node.Checked) { if (_ExcludeList.Contains(attrib.Tag)) { _ExcludeList.Remove(attrib.Tag); } } else { _ExcludeList.Add(attrib.Tag); } BuildDataSet(); SelectMPPSDatasetNode(e.Node); }
private void SelectMPPSDatasetNode(TreeNode node) { if (node.IsSelected) { ElementAttribute attrib = node.Tag as ElementAttribute; if (attrib != null) { TreeNode datasetNode = FindDatasetTag(treeViewMPPSDataset.Nodes, attrib.Tag); if (datasetNode != null) { treeViewMPPSDataset.SelectedNode = datasetNode; datasetNode.EnsureVisible(); } } } }
private static void SetClosedResult(Element E3) { ElementAttribute att = null; if (E3.TagName.ToLowerCase() == "b") { E3 = E3.ParentNode; } att = E3.Attributes.GetNamedItem("data"); if (att == null) { return; } Util.SetOption("list", att.Value); }
private void treeViewDataset_BeforeCheck(object sender, TreeViewCancelEventArgs e) { ElementAttribute attrib = e.Node.Tag as ElementAttribute; if (attrib != null) { if (attrib.Requirement == DicomIodUsageType.Type1MandatoryElement || attrib.Requirement == DicomIodUsageType.Type2MandatoryElement) { e.Cancel = true; return; } } if (e.Node.ForeColor == SystemColors.InactiveCaption) { e.Cancel = true; return; } EnableChildNodes(e.Node, !e.Node.Checked); }
public static void AssignElementalDamage( BaseWeapon weapon, ElementAttribute attr ) { int fire, phys, cold, nrgy, pois; weapon.GetDamageTypes( null, out phys, out fire, out cold, out pois, out nrgy ); AssignElementalDamage( weapon, attr, phys ); weapon.Hue = weapon.GetElementalDamageHue(); }
private void CheckNode(TreeNode node, ElementAttribute attrib) { node.Checked = attrib.Requirement == DicomIodUsageType.Type1MandatoryElement || attrib.Requirement == DicomIodUsageType.Type2MandatoryElement || !_ExcludeList.Contains(attrib.Tag); }
private static bool TryGetAttribute(string name, IReadOnlyList <ElementAttribute> attributes, out ElementAttribute retn) { for (int i = 0; i < attributes.Count; i++) { if (attributes[i].name == name) { retn = attributes[i]; return(true); } } retn = default; return(false); }
public MapElement(HexTypeEnum hexType, Vector2Int gridPos, ElementAttribute hexAttributes = null) { this.hexType = hexType; this.gridPos = gridPos; this.hexAttribute = hexAttributes; }
private static int GetElementAttributeValue( BaseWeapon weapon, ElementAttribute element ) { int phys, fire, cold, pois, nrgy, chao; weapon.GetDamageTypes( null, out phys, out fire, out cold, out pois, out nrgy, out chao ); switch ( element ) { case ElementAttribute.Physical: return phys; case ElementAttribute.Fire: return fire; case ElementAttribute.Cold: return cold; case ElementAttribute.Poison: return pois; case ElementAttribute.Energy: return nrgy; } return -1; }
private static int AssignElementalDamage( BaseWeapon weapon, ElementAttribute attr, int totalDamage ) { if ( totalDamage <= 0 ) return 0; int random = Utility.Random( (int) ( totalDamage / 10 ) + 1 ) * 10; // TODO: Refactor this // weapon.ElementDamages[attr] = random; switch ( attr ) { case ElementAttribute.Cold: weapon.WeaponAttributes.DamageColdPercent = random; break; case ElementAttribute.Energy: weapon.WeaponAttributes.DamageEnergyPercent = random; break; case ElementAttribute.Fire: weapon.WeaponAttributes.DamageFirePercent = random; break; case ElementAttribute.Poison: weapon.WeaponAttributes.DamagePoisonPercent = random; break; } return ( totalDamage - random ); }
private static void ApplyAttribute( ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high, int offset ) { attrs[attr] = Scale( min, max, low + offset, high + offset ); }
void DisplayHexAttributeOptions() { GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.onHover.textColor = Color.green; GUILayoutOption[] buttonLayoutOptions = new GUILayoutOption[] { GUILayout.MinWidth(150), GUILayout.MaxWidth(150), }; GUILayout.Height(100); HexTypeEnum prevHexType = hexType; GUILayout.Label("Select the type of hex and attibute you wish to add to the level.", EditorStyles.boldLabel); GUILayout.Space(20); hexType = (HexTypeEnum)EditorGUILayout.EnumPopup("Type of Hex", hexType); //location = EditorGUILayout.Vector2Field("Hex Location", location); EditorGUILayout.Vector2Field("Hex Location", gridLoc); #region attribute GUILayout.BeginHorizontal(); GUILayout.Label("Attribute"); choiceIndex = EditorGUILayout.Popup(choiceIndex, attributeChoices); GUILayout.EndHorizontal(); GUILayout.Space(40); #endregion switch (attributeChoices[choiceIndex]) { case "None": break; case "DigitElementAttribute": if (attribute == null || attribute.GetType() != typeof(DigitElementAttribute)) { attribute = new DigitElementAttribute(0); } ShowLayout_DigitAttribute(); break; case "MenuButtonElementAttribute": if (attribute == null || attribute.GetType() != typeof(MenuButtonElementAttribute)) { attribute = new MenuButtonElementAttribute(Command.NextMenu); } ShowLayout_MenuButtonAttribute(); break; default: break; } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save Level", buttonStyle, buttonLayoutOptions)) { SaveLevel(); } if (GUILayout.Button("Load Level", buttonStyle, buttonLayoutOptions)) { LoadLevel(); } if (GUILayout.Button("New Level", buttonStyle, buttonLayoutOptions)) { NewLevel(); } //GUILayout.Space(this.position.width - 310); GUILayout.EndHorizontal(); GUILayout.Space(40); UpdateAttributeChoices(); if (prevHexType != hexType) { UpdateHexCursorObject(); } Repaint(); }
private void OnGUI() { GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.onHover.textColor = Color.green; GUILayoutOption[] buttonLayoutOptions = new GUILayoutOption[] { GUILayout.MinWidth(150), GUILayout.MaxWidth(150), }; GUILayout.Height(100); HexTypeEnum prevHexType = hexType; GUILayout.Label("Select the type of hex and attibute you wish to add to the level.", EditorStyles.boldLabel); GUILayout.Space(20); hexType = (HexTypeEnum)EditorGUILayout.EnumPopup("Type of Hex", hexType); location = EditorGUILayout.Vector2Field("Hex Location", location); #region attribute GUILayout.BeginHorizontal(); GUILayout.Label("Attribute"); choiceIndex = EditorGUILayout.Popup(choiceIndex, attributeChoices); GUILayout.EndHorizontal(); GUILayout.Space(40); #endregion switch (attributeChoices[choiceIndex]) { case "None": break; case "DigitElementAttribute": if (attribute == null || attribute.GetType() != typeof(DigitElementAttribute)) { attribute = new DigitElementAttribute(0); } ShowLayout_DigitAttribute(); break; case "MenuButtonElementAttribute": if (attribute == null || attribute.GetType() != typeof(MenuButtonElementAttribute)) { attribute = new MenuButtonElementAttribute(Command.NextMenu); } ShowLayout_MenuButtonAttribute(); break; default: break; } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("CloseWindow", buttonStyle, buttonLayoutOptions)) { this.Close(); } GUILayout.Space(this.position.width - 310); if (GUILayout.Button("Add Hex", buttonStyle, buttonLayoutOptions)) { AddHexToLevel(); } GUILayout.EndHorizontal(); GUILayout.Space(40); UpdateAttributeChoices(); // Refreshes the popup window in order to update options if (EditorApplication.isPlaying) { if (prevHexType != hexType) { UpdateAttributeChoices(); Repaint(); } } }
static StateElement CreateInputStateElement(PropertyInfo property, Container parent) { var attr = property.GetCustomAttribute <ElementAttribute>(true); string description = attr?.Description; var displayName = attr?.DisplayName ?? Utils.NameToDisplayName(property.Name); var displayWords = displayName.Split(' '); var t = property.PropertyType; if (t.IsArray || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable <>))) { var itemType = t.IsArray ? t.GetElementType() : t.GetGenericArguments().Single(); return(new TableView(itemType, parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr }); } if (t == typeof(bool) && t.IsPublic) { return(new CheckBox(parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); } if (t.IsEnum) { return(new EnumInput(parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); } // TODO: Add intermediate state support var rangeAttrib = t.GetCustomAttribute <RangeAttribute>(true); if (t.IsNumeric() && ( rangeAttrib != null || displayWords.Contains("Range"))) { double min = rangeAttrib?.Min ?? 0; double max = rangeAttrib?.Max ?? (t == typeof(int) ? 100 : t == typeof(double) ? 1 : t == typeof(float) ? 1 : 10); return(new SlideInput(min, max, parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); } if (attr?.GetType() == typeof(DateInputAttribute) || (t == typeof(DateTime) && property.SetMethod.IsPublic)) { return(new DateInput(parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); } if (attr?.GetType() == typeof(PathAttribute) || (t == typeof(string) && displayWords.Contains("Path") && property.SetMethod.IsPublic)) { if (!property.SetMethod.IsPublic) { throw new NotSupportedException("The setter of a Path property has to be public."); } ElementAttribute elAttr = null; var pa = attr as PathAttribute; var pathType = PathType.Open; if ((pa == null || pa.Type != PathType.Open) && displayWords.Contains("Save")) { pathType = PathType.Save; } else if (pa != null) { pathType = pa.Type; } if (displayWords.Length > 1) { displayName = string.Join(" ", displayWords.Where(x => x != "Path")); } var pathInput = new PathInput(parent, property, property.Name, pathType) { DisplayName = displayName, Description = description }; pathInput.Attribute = attr as ElementAttribute; return(pathInput); } if (attr?.GetType() == typeof(PasswordAttribute) || (t == typeof(string) && displayWords.Contains("Password") && property.SetMethod.IsPublic)) { return(new PasswordInput(parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); } return((StateElement) new TextInput(parent, property, property.Name) { DisplayName = displayName, Description = description, Attribute = attr, }); }
private static void ApplyAttribute(ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high) { ApplyAttribute(attrs, min, max, attr, low, high, 0); }
private static void ApplyAttribute(ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high, int offset) { attrs[attr] = Scale(min, max, low + offset, high + offset); }
/// <summary> /// To extract the object from a XmlNode /// </summary> /// <typeparam name="T"></typeparam> /// <param name="item"></param> /// <param name="xmlNode"></param> public static void Extract <T>(this T item, XmlNode xmlNode) // The generic parameter should be a class where T : class { // checking whether the xml node present if (xmlNode != null) { // Getting the object Type var type = item.GetType(); // Getting the properties of the object var properties = type.GetProperties(); // Iterating through each properties foreach (var property in properties) { #region Value Attribute // Checking wheather the Value Attribute present ValueAttribute valueAttribute = ReflectionHelper.GetCustomeAttribute <ValueAttribute>(property); // If present if (valueAttribute != null) { // Extracting value from Node ExtractValueFromNode(item, xmlNode, property); continue; } #endregion #region Element Attribute // Checking wheather there is any Element Attribute present ElementAttribute elementAttribute = ReflectionHelper.GetCustomeAttribute <ElementAttribute>(property); // If present if (elementAttribute != null) { // Getting the name of node var name = ReflectionHelper.GetName(elementAttribute, property); // Extracting Elemnt from the Node ExtractElementFromNode(item, xmlNode, name, property); continue; } #endregion #region Property Attribute // Getting the property attribute PropertyAttribute propertyAttribute = ReflectionHelper.GetCustomeAttribute <PropertyAttribute>(property); if (propertyAttribute != null) { // Getting the name of property var name = ReflectionHelper.GetName(propertyAttribute, property); // Extract propertry from Node ExtractPropertyFromNode(item, xmlNode, name, property); continue; } #endregion } } }
private static void ApplyAttribute( ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high ) { ApplyAttribute( attrs, min, max, attr, low, high, 0 ); }
/// <summary> Write a Element XML Element from attributes in a member. </summary> public virtual void WriteElement(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ElementAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "element" ); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <type> if(attribute.Type != null) writer.WriteAttributeString("type", GetAttributeValue(attribute.Type, mappedClass)); // Attribute: <length> if(attribute.Length != -1) writer.WriteAttributeString("length", attribute.Length.ToString()); // Attribute: <precision> if(attribute.Precision != -1) writer.WriteAttributeString("precision", attribute.Precision.ToString()); // Attribute: <scale> if(attribute.Scale != -1) writer.WriteAttributeString("scale", attribute.Scale.ToString()); // Attribute: <not-null> if( attribute.NotNullSpecified ) writer.WriteAttributeString("not-null", attribute.NotNull ? "true" : "false"); // Attribute: <unique> if( attribute.UniqueSpecified ) writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ElementAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ElementAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ElementAttribute ) break; // Following attributes are for this Element if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ElementAttribute ) break; // Following attributes are for this Element if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); // Element: <type> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(TypeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ElementAttribute ) break; // Following attributes are for this Element if( memberAttrib is TypeAttribute ) WriteType(writer, member, memberAttrib as TypeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(TypeAttribute), attribute); writer.WriteEndElement(); }
public int this[ElementAttribute attribute] { get { return(GetValue((int)attribute)); } set { SetValue((int)attribute, value); } }