public void Setup() { _experienceType = AttributeEnums.AttributeType.EXPERIENCE; _levelType = AttributeEnums.AttributeType.LEVEL; _a1 = new Attribute(_experienceType, "EXP", "EXP", "", 0, 0, 100); _a2 = new Attribute(_levelType, "LVL", "LVL", "", 0, 1, 10); }
/// <summary> /// Add the specified type and attribute. /// </summary> /// <param name="type">Type.</param> /// <param name="attribute">Attribute.</param> public void Add(AttributeEnums.AttributeType type, Attribute attribute) { if (!_attributes.ContainsKey(type)) { _attributes.Add(type, attribute); } }
/// <summary> /// Remove the specified effect. /// </summary> /// <param name="effect">Effect.</param> public void Remove(AttributeEnums.AttributeType attributeType) { if (_effects.ContainsKey(attributeType)) { _effects.Remove(attributeType); } }
/// <summary> /// Gets the attribute text. /// Only certain attributes are supported. /// </summary> /// <returns>The attribute text.</returns> /// <param name="type">Type.</param> private Text GetAttributeText(AttributeEnums.AttributeType type) { // Look for certain attributes Text attributeText = null; switch (type) { case AttributeEnums.AttributeType.ARMOR: attributeText = armorText; break; case AttributeEnums.AttributeType.DAMAGE: attributeText = damageText; break; case AttributeEnums.AttributeType.DODGE_CHANCE: attributeText = dodgePercentText; break; case AttributeEnums.AttributeType.HIT_PERCENT: attributeText = hitPercentText; break; } return(attributeText); }
/// <summary> /// Get the specified type of attribute. /// </summary> /// <param name="type">Type.</param> public Attribute Get(AttributeEnums.AttributeType type) { if (_attributes.ContainsKey(type)) { return(_attributes [type]); } return(null); }
/// <summary> /// Get the specified attributeType. /// </summary> /// <param name="attributeType">Attribute type.</param> public ModifyAttributeEffect Get(AttributeEnums.AttributeType attributeType) { if (_effects.ContainsKey(attributeType)) { return(_effects [attributeType]); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="ModifyAttributeEffect"/> class. /// </summary> /// <param name="attributeType">Attribute type.</param> /// <param name="value">Value.</param> /// <param name="turns">Turns.</param> /// <param name="incrementalValue">Incremental value.</param> /// <param name="color">Color.</param> /// <param name="effectType">Effect type.</param> public ModifyAttributeEffect(AttributeEnums.AttributeType attributeType, int value, int turns = 0, int incrementalValue = 0, Color color = default(Color), EffectType incomingEffectType = EffectType.INSTANT, string vfxPath = "") { _attributeType = attributeType; _value = value; _turns = turns; _incrementalValue = incrementalValue; _color = color; effectType = incomingEffectType; _vfxPath = vfxPath; }
/// <summary> /// Initializes a new instance of the <see cref="RoseOfEternity.Attribute"/> class. /// </summary> /// <param name="type">Type.</param> /// <param name="name">Name.</param> /// <param name="shortName">Short name.</param> /// <param name="toolTip">Tool tip.</param> /// <param name="currentValue">Current value.</param> /// <param name="minimumValue">Minimum value.</param> /// <param name="maximumValue">Maximum value.</param> public Attribute(AttributeEnums.AttributeType type, string name, string shortName, string toolTip, float currentValue, float minimumValue, float maximumValue) { Type = type; Name = name; ShortName = shortName; ToolTip = toolTip; MinimumValue = minimumValue; MaximumValue = maximumValue; _currentValue = currentValue; }
/// <summary> /// Gets the attribute value. /// </summary> /// <returns>The attribute value.</returns> /// <param name="type">Type.</param> private float GetAttributeValue(AttributeEnums.AttributeType type) { float value = 0.0f; Attribute attribute = _attributeCollection.Get(type); if (attribute != null) { value = attribute.CurrentValue; } return(value); }
public void TestGetAttributeSuccess() { AttributeEnums.AttributeType type = AttributeEnums.AttributeType.ABILITY_POINTS; Attribute a1 = new Attribute(type, "test_get_attribute", "test", "test", 0.0f, 0.0f, 10.0f); AttributeCollection attributes = new AttributeCollection(); attributes.Add(type, a1); Item i1 = new Item(0, Item.ItemType.WEAPON, "weapon", "weapon description", "weapon", attributes, InventorySlots.SlotType.RIGHT_HAND, Item.ItemTier.TIER_5, "weapon.jpg", "swordSFX", "swordVFX"); Assert.NotNull(i1.GetAttribute(type)); }
/// <summary> /// Gets the tool tip color by attribute. /// </summary> /// <returns>The tool tip color by attribute.</returns> /// <param name="item">Item.</param> /// <param name="equippedItem">Equipped item.</param> /// <param name="type">Type.</param> private Color GetToolTipColorByAttribute(Item item, Item equippedItem, AttributeEnums.AttributeType type) { Attribute attribute1 = item.GetAttribute(type); Attribute attribute2 = equippedItem.GetAttribute(type); if (attribute1.CurrentValue < attribute2.CurrentValue) { return(_inventoryController.negativeToolTipAttributeColor); } else if (attribute1.CurrentValue > attribute2.CurrentValue) { return(_inventoryController.positiveToolTipAttributeColor); } return(Color.black); }
/// <summary> /// Sets the attribute. /// </summary> /// <param name="unit">Unit.</param> /// <param name="attributeType">Attribute type.</param> /// <param name="text">Text.</param> private void SetAttribute(Unit unit, AttributeEnums.AttributeType attributeType, Text text) { text.text = unit.GetAttribute(attributeType).CurrentValue.ToString(); text.color = Color.black; // If attribute has been raised, make green, if lowered, red, else, do nothing ModifyAttributeEffect effect = unit.GetModifyAttributeEffect(attributeType); if (effect != null) { int effectValue = effect.GetValue(); if (effectValue < 0) { text.color = Color.red; } else if (effectValue > 0) { text.color = Color.green; } } }
/// <summary> /// Takes in a key/value pair of attribute/values, uses this to pull full Attributes from global collection, and creates new local collection. /// </summary> /// <returns>The from global collection.</returns> /// <param name="attributeDictionary">Attribute dictionary.</param> /// <param name="globalCollection">Global collection.</param> /// <param name="newCollection">New collection.</param> public static AttributeCollection GetFromGlobalCollection(Dictionary <AttributeEnums.AttributeType, float> attributeDictionary, AttributeCollection globalCollection, AttributeCollection newCollection) { // Set attributes in their collection. If attribute already exists, set value, // else, grab from global collection and set new attribute and value foreach (var item in attributeDictionary) { AttributeEnums.AttributeType attributeType = item.Key; Attribute attribute; if (!newCollection.HasType(attributeType)) { attribute = globalCollection.Get(attributeType).DeepCopy(); newCollection.Add(attributeType, attribute); } else { attribute = newCollection.Get(attributeType); } attribute.CurrentValue = item.Value; } return(newCollection); }
/// <summary> /// Determines whether this instance has the specified type. /// </summary> /// <returns><c>true</c> if this instance has the specified type; otherwise, <c>false</c>.</returns> /// <param name="type">Type.</param> private bool HasType(AttributeEnums.AttributeType type) { return(_attributes.ContainsKey(type)); }
/// <summary> /// Adds the modify attribute effect. /// </summary> /// <param name="attributeType">Attribute type.</param> /// <param name="effect">Effect.</param> public void AddModifyAttributeEffect(AttributeEnums.AttributeType attributeType, ModifyAttributeEffect effect) { _modifyAttributeEffectCollection.Add(attributeType, effect); }
/// <summary> /// Sets the maximum value to current value. /// </summary> /// <param name="type">Type.</param> private void SetMaximumValueToCurrentValue(AttributeEnums.AttributeType type) { _attributeCollection.Get(type).MaximumValue = _attributeCollection.Get(type).CurrentValue; }
/// <summary> /// Add the specified effect. /// </summary> /// <param name="effect">Effect.</param> public void Add(AttributeEnums.AttributeType attributeType, ModifyAttributeEffect effect) { _effects.Add(attributeType, effect); }
/// <summary> /// Removes the modify attribute effect. /// </summary> /// <param name="attributeType">Attribute type.</param> public void RemoveModifyAttributeEffect(AttributeEnums.AttributeType attributeType) { _modifyAttributeEffectCollection.Remove(attributeType); }
/// <summary> /// Gets the attribute by type. /// </summary> /// <returns>The attribute.</returns> /// <param name="attributeType">Attribute type.</param> public Attribute GetAttribute(AttributeEnums.AttributeType attributeType) { return(_attributeCollection.Get(attributeType)); }
/// <summary> /// Gets the modify attribute effect. /// </summary> /// <returns>The modify attribute effect.</returns> /// <param name="attributeType">Attribute type.</param> public ModifyAttributeEffect GetModifyAttributeEffect(AttributeEnums.AttributeType attributeType) { return(_modifyAttributeEffectCollection.Get(attributeType)); }