protected void RaiseValueChanged(ValueType type, ValueSubtype subtype, float oldValue) { if (ValueChanged != null) { ValueChanged(this, type, subtype, oldValue); } }
private void Attributes_ValueChanged(Object sender, ValueType type, ValueSubtype subtype, float oldValue) { if (type == ValueType.CharacterLevel) { ShowLevel((int)Attributes[ValueType.CharacterLevel]); } }
private void Attributes_ValueChanged(Object sender, ValueType type, ValueSubtype suybtype, float oldValue) { if (type == ValueType.Health) { Shaking = true; if (Attributes[ValueType.Health] > 0) { StartCoroutine(this.DelayedAction(DurationOnDamage, () => { Shaking = false; })); } } }
private void Attributes_ValueChanged(Object sender, ValueType type, ValueSubtype subtype, float oldValue) { if (type == ValueType.Experience && !Levels.HasMoreLevels && Levels.CurrentXpThreshold <= Levels.CurrentXp) { HandleWinning(); } if (type == ValueType.Health && Attributes[ValueType.Health] <= 0) { HandleLosing(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="type"></param> /// <param name="subtype"></param> /// <param name="old"></param> private void OnPlayerStatsValueChanged(Object sender, ValueType type, ValueSubtype subtype, float old) { switch (type) { case ValueType.Experience: // Ensure CharacterLevel is correct for current accrued Experience DoExperienceGained(); break; case ValueType.CharacterLevel: // Ensure ExperienceThreshold is correct for new current level DoLevelGained(); break; } }
private void Attributes_ValueChanged(Object sender, ValueType type, ValueSubtype subtype, float oldValue) { if (type == ValueSource) { UpdateValue(); } if (type == MaxValueSource) { if (MinChasesMax) { MinValue = MaxValue; } MaxValue = Attributes[type]; UpdateValue(); } }
private void OnStatsValueChanged(UnityEngine.Object sender, ValueType type, ValueSubtype subtype, float old) { if (type == ValueType.Health && Stats[ValueType.Health] <= 0 && !HasSpawned) { HasSpawned = true; foreach (var prefab in MustSpawn) { if (prefab == null) { continue; } var offset2D = Random.insideUnitCircle * SpawnRadius; var offset = OriginOffset + new Vector3(offset2D.x, 0, offset2D.y); // In Local Coords var position = transform.TransformPoint(offset); //Instantiate(prefab, gameObject.transform.position + offset, gameObject.transform.rotation, OptionalParent); Instantiate(prefab, position, gameObject.transform.rotation, OptionalParent); } if (LotterySpawn.Count > 0) { for (int i = 0; i < LotterySpawnCount; i++) { var prefab = RandomLotteryItem; if (prefab == null) { continue; } var offset2D = Random.insideUnitCircle * SpawnRadius; var offset = OriginOffset + new Vector3(offset2D.x, 0, offset2D.y); // In Local Coords var position = transform.TransformPoint(offset); //Instantiate(prefab, gameObject.transform.position + offset, gameObject.transform.rotation, OptionalParent); Instantiate(prefab, position, gameObject.transform.rotation, OptionalParent); } } } }
private void OnStatsValueChanged(UnityEngine.Object sender, ValueType type, ValueSubtype subtype, float old) { if (type == ValueType.Health && Stats[ValueType.Health] <= 0 && !IsFalling) { // Object Died IsFalling = true; // Spawn Rubble tile if (DustCloud != null) { var go = Instantiate(DustCloud, gameObject.transform.position, gameObject.transform.rotation); Destroy(go, TimeToLive); } Destroy(gameObject, TimeToLive); } }
private void OnValueChanged(Object source, ValueType type, ValueSubtype subtype, float oldValue) { if (type == ValueSource) { // Value Changed Widget.value = AttributeSource[ValueSource]; } else if (type == ValueMaxSource) { // MAX Value Changed Widget.maxValue = AttributeSource[ValueMaxSource]; if (MinFollowsMax) { Widget.minValue = oldValue; } Widget.value = AttributeSource[ValueSource]; } }
private void OnPlayerStatsValueChanged(Object source, ValueType type, ValueSubtype subtype, float old) { switch (type) { case ValueType.Experience: // Update XP Bar Value if (Widgets.XpBar != null) { Widgets.XpBar.value = (source as EntityAttributes)[type]; } break; case ValueType.ExperienceThreshold: // Update XP Bar Extents (Min and Max) if (Widgets.XpBar != null) { Widgets.XpBar.minValue = old; Widgets.XpBar.maxValue = (source as EntityAttributes)[type]; } break; case ValueType.Health: if (Widgets.HealthBar != null) { Widgets.HealthBar.value = (source as EntityAttributes)[type]; } break; case ValueType.HealthMax: if (Widgets.HealthBar != null) { Widgets.HealthBar.maxValue = (source as EntityAttributes)[type]; Widgets.HealthBar.value = (source as EntityAttributes)[ValueType.Health]; } break; } }
private void OnStatsValueChanged(object arg1, ValueType arg2, ValueSubtype arg3, float arg4) { RaiseValueChanged(arg2, arg3, arg4); }
public float this[ValueType type, ValueSubtype subtype = ValueSubtype.Derived] { get { return(_Attributes[type, subtype]); } set { _Attributes[type, subtype] = value; } }
/// <summary> /// Indexer. Examples: /// var x = new StatCollection(); /// x[StatType.MaxHealth, StatValueType.Base] = 50; /// x[StatType.MaxHealth, StatValueType.Modifier] = 0.2; // 20% bonus /// Assert( x[StatType.MaxHealth] == 60 ); // 50 + 20% /// </summary> /// <param name="type"></param> /// <param name="subtype"></param> /// <returns></returns> public float this[ValueType type, ValueSubtype subtype = ValueSubtype.Derived] { get { var storedValue = Fetch(type); if (storedValue == null) { return(0); } switch (subtype) { case ValueSubtype.Base: { return(storedValue.Base); } case ValueSubtype.Modifier: { return(storedValue.Modifier); } default: { return(storedValue.Derived); } } } set { //if ( subtype == ValueSubtype.Derived ) throw new System.InvalidOperationException("ValueCollection[].Set: Cannot set EntityStat (" + type.ToString() + ") value directly. MUST set Base or Modifier instead."); // Find list entry: var storedValue = Fetch(type); // If not found, create new if (storedValue == null) { storedValue = new Value { Type = type }; _Values.Add(storedValue); } // For appropriate subtype, remember old value and set new value float old = 0; switch (subtype) { case ValueSubtype.Base: old = storedValue.Base; storedValue.Base = value; break; case ValueSubtype.Modifier: old = storedValue.Modifier; storedValue.Modifier = value; break; default: old = storedValue.Derived; storedValue.Base = value / (1 + storedValue.Modifier); break; } // Raise "ValueChanged" event only if value actually changed if (old != value) { RaiseValueChanged(type, subtype, old); } } }