예제 #1
0
        /// <summary>Add trauma with a given source name.</summary>
        /// <param name="sourceName" type="string">Name to use to compare with existing trauma sources</param>
        /// <param name="amount" type="Vector2">Intensity of trauma in two dimensions (always positive)</param>
        /// <param name="mode" type="TraumaMode">How should the new value interact with any existing values?</param>
        public void AddTrauma(string sourceName, Vector2 amount, TraumaMode mode = TraumaMode.KeepMax)
        {
            if (!traumaSources.ContainsKey(sourceName))
            {
                traumaSources.Add(sourceName, Vector2.zero);
            }
            switch (mode)
            {
            case TraumaMode.KeepMax:
                Vector2 v = traumaSources[sourceName];
                if (v.x < amount.x)
                {
                    v.x = amount.x;                     // choose max
                }
                if (v.y < amount.y)
                {
                    v.y = amount.y;
                }
                traumaSources[sourceName] = v;
                break;

            case TraumaMode.Add:
                v  = traumaSources[sourceName];
                v += amount;
                if (v.x > maxTrauma)
                {
                    v.x = maxTrauma;                      // clamp values
                }
                if (v.y > maxTrauma)
                {
                    v.y = maxTrauma;
                }
                traumaSources[sourceName] = v;
                break;

            case TraumaMode.Replace:
                traumaSources[sourceName] = amount;
                break;
            }
        }
예제 #2
0
 /// <summary>Add trauma with a given source name.</summary>
 /// <param name="sourceName" type="string">Name to use to compare with existing trauma sources</param>
 /// <param name="amount" type="float">Intensity of trauma in both dimensions (always positive)</param>
 /// <param name="mode" type="TraumaMode">How should the new value interact with any existing values?</param>
 public void AddTrauma(string sourceName, float amount, TraumaMode mode = TraumaMode.KeepMax)
 {
     AddTrauma(sourceName, Vector2.one * amount, mode);
 }
예제 #3
0
 /// <summary>Add trauma to a "default" trauma source</summary>
 /// <param name="amount" type="float">Intensity of trauma in both dimensions (always positive)</param>
 /// <param name="mode" type="TraumaMode">How should the new value interact with any existing values?</param>
 public void AddTrauma(float amount, TraumaMode mode = TraumaMode.Add)
 {
     AddTrauma("default", amount, mode);
 }
예제 #4
0
 /// <summary>Add trauma to a "default" trauma source</summary>
 /// <param name="amount" type="Vector2">Intensity of trauma in two dimensions (always positive)</param>
 /// <param name="mode" type="TraumaMode">How should the new value interact with any existing values?</param>
 public void AddTrauma(Vector2 amount, TraumaMode mode = TraumaMode.Add)
 {
     AddTrauma("default", amount, mode);
 }