/// <summary> /// Sets the starting rotation of this object /// </summary> /// <param name="Angle"></param> /// <param name="Random">Random Mode</param> /// <param name="RandomAngle"></param> /// <param name="RandomInterval">Constant distance between random numbers</param> public void SetRotation(float Angle, float RandomAngle, RandomMode Random, int RandomInterval = 101) { RotEvents[0].X = Angle; RotEvents[0].RandomX = RandomAngle; RotEvents[0].Random = Random; RotEvents[0].RandomInterval = RandomInterval; }
private void btnApply_Click(object sender, System.EventArgs e) { randomMode = radioBtnRandom.Checked ? RandomMode.PureRandom : RandomMode.LimitedRandom; if (randomMode == RandomMode.PureRandom) { return; } try { interfaceRange = new ValueRange2(textBoxInterface.Text); srcAddressRange = new AddressRange(textBoxSrcAddress.Text); dstAddressRange = new AddressRange(textBoxDstAddress.Text); tosRange = new ValueRange1(textBoxTOS.Text); asRange = new ValueRange2(textBoxAS.Text); bytesRange = new ValueRange4(textBoxBytes.Text); packetsRange = new ValueRange4(textBoxPackets.Text); tcpflagRange = new ValueRange1(textBoxTCPFlags.Text); portRange = new ValueRange2(textBoxPort.Text); protocolRange = new ValueRange1(textBoxProtocols.Text); maskRange = new ValueRange1(textBoxMasks.Text); flowsRange = new ValueRange4(textBoxFlows.Text); } catch (InvalidValueSpecificationException ie) { MessageBox.Show(this, ie.Message, "Invalid Value Specified"); //this.DialogResult = DialogResult.Cancel; return; } DialogResult = DialogResult.OK; }
public IActionResult StartRandomMode() { var mode = new RandomMode(); StoplightModeManager.SetMode(mode); return(Ok()); }
/// <summary> /// Sets the starting scale of this object /// </summary> /// <param name="X">X Scale</param> /// <param name="Y">Y Scale</param> /// <param name="Random">Random Mode</param> /// <param name="RandomX">X Scale</param> /// <param name="RandomY">Y Scale</param> /// <param name="RandomInterval">Constant distance between random numbers</param> public void SetScale(float X, float Y, float RandomX, float RandomY, RandomMode Random, int RandomInterval = 101) { ScaEvents[0].X = X; ScaEvents[0].Y = Y; ScaEvents[0].RandomX = RandomX; ScaEvents[0].RandomY = RandomY; ScaEvents[0].Random = Random; ScaEvents[0].RandomInterval = RandomInterval; }
/// <summary> /// Sets the starting position of this object. /// </summary> /// <param name="X"></param> /// <param name="Y"></param> /// <param name="Random">Random Mode</param> /// <param name="RandomX"></param> /// <param name="RandomY"></param> /// <param name="RandomInterval">Constant distance between random numbers</param> public void SetPosition(float X, float Y, float RandomX, float RandomY, RandomMode Random, int RandomInterval = 101) { PosEvents[0].X = X; PosEvents[0].Y = Y; PosEvents[0].RandomX = RandomX; PosEvents[0].RandomY = RandomY; PosEvents[0].Random = Random; PosEvents[0].RandomInterval = RandomInterval; }
public static string GetRandomMacroString(RandomMode random, VFXAttribute attribute, params string[] parameters) { if (random == RandomMode.Off) { return(parameters[0]); } else { return(string.Format("lerp({0},{1},{2})", parameters)); } }
private void RightMode_Clicked(object sender, EventArgs e) { _testViewModel.SelectedMode = Enums.SelectedMode.Right; RightMode.ScaleTo(1.5, 100); RightMode.FadeTo(1, 100); LeftMode.ScaleTo(1, 100); LeftMode.FadeTo(0.5, 100); RandomMode.ScaleTo(1, 100); RandomMode.FadeTo(0.5, 100); }
public static string GetNameString(RandomMode mode) { switch (mode) { case RandomMode.Off: return(""); case RandomMode.PerComponent: return("Random"); case RandomMode.Uniform: return("Random"); default: throw new ArgumentException(); } }
public Event(Event Base) { Type = Base.Type; Ease = Base.Ease; Random = Base.Random; Time = Base.Time; X = Base.X; Y = Base.Y; RandomX = Base.RandomX; RandomY = Base.RandomY; RandomInterval = Base.RandomInterval; }
public static string GetRandomMacroString(RandomMode mode, int attributeSize, string postfix, params string[] parameters) { switch (mode) { case RandomMode.Off: return(parameters[0] + postfix); case RandomMode.Uniform: return(string.Format("lerp({0},{1},RAND)", parameters.Select(s => s + postfix).ToArray())); case RandomMode.PerComponent: string rand = GetRandStringFromSize(attributeSize); return(string.Format("lerp({0},{1}," + rand + ")", parameters.Select(s => s + postfix).ToArray())); default: throw new System.NotImplementedException("VFXBlockUtility.GetRandomMacroString() does not implement return string for RandomMode : " + mode.ToString()); } }
//Takes a seed and sets up everything for randomization private void ApplyRandomization(int seed) { randomSeed = seed; Log("Randomizing using seed " + randomSeed); CommandLoadPrefabs(); slime_randomMode = (RandomMode)slimeRandomModeInput; produce_randomMode = (RandomMode)produceRandomModeInput; /* For consistent randomization for a given seed, we want to create a new Random object for each element that's being randomized separately */ /* These methods simply *set up* randomization tables. The replacement is done in separate methods that are called from Harlomony patches */ RandomizeSlimeSpawns(new System.Random(seed)); RandomizeSlimeDiets(new System.Random(seed)); RandomizeProduce(new System.Random(seed)); //RandomizeGordos(new System.Random(seed)); //Set up for randomization that needs to be done at runtime runTimeRand = new System.Random(seed); }
/// <summary> /// Takes all objects from a prefab and returns them. /// Note: If the prefab contains a single object it's returned as a GameObject, otherwise it's returned as a GameObject List. /// </summary> /// <param name="PrefabPath">Path to the prefab</param> public dynamic ImportPrefab(string PrefabPath) { using (StreamReader sr = new StreamReader(PrefabPath)) { // Get rid of the junk sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); List <GameObject> objects = new List <GameObject>(); string data = sr.ReadToEnd(); data = data.Insert(0, "{\n"); JObject rss = JObject.Parse(data); JArray objectArray = rss["objects"] as JArray; if (objectArray == null) { throw new NullReferenceException(); } foreach (var Object in objectArray) { JObject Events = Object["events"] as JObject; JArray pos = Events["pos"] as JArray; JArray sca = Events["sca"] as JArray; JArray rot = Events["rot"] as JArray; JArray col = Events["col"] as JArray; byte shape = 99; byte.TryParse((string)Object["so"], out shape); if (shape == 99) { shape = 0; } JObject editor = Object["ed"] as JObject; JObject offset = Object["o"] as JObject; string id = (string)Object["id"], name = (string)Object["name"], parent = (string)Object["p"], text = (string)Object["text"]; int? pt = (int?)Object["pt"], d = (int?)Object["d"], so = (int?)Object["so"]; pt ??= 101; d ??= 15; so ??= 0; Autokill akt = Autokill.LastKFOffset; float ako = 0; ObjectType ot = ObjectType.Normal; try { akt = (Autokill)(int)Object["akt"]; ako = (float)Object["ako"]; ot = (ObjectType)(int)Object["ot"]; } catch { } bool?empty = (bool?)Object["empty"], h = (bool)Object["h"]; empty ??= false; float?st = (float?)Object["st"]; st ??= 0; GameObject obj = new GameObject(id, name, (Shapes)shape, parent, (int)pt); obj.GetEventList(EventType.pos).Clear(); obj.GetEventList(EventType.sca).Clear(); obj.GetEventList(EventType.rot).Clear(); obj.GetEventList(EventType.col).Clear(); if (editor != null) { obj.Bin = (int)editor["bin"]; obj.Layer = (int)editor["layer"]; } if (offset != null) { obj.OffsetX = (float)offset["x"]; obj.OffsetY = (float)offset["y"]; } obj.AutokillMode = (Autokill)akt; obj.AutokillTime = (float)ako; obj.Depth = (int)d; obj.Type = (ObjectType)ot; obj.ShapeVariant = (int)so; obj.StartTime = (float)st; obj.Text = text; foreach (var Event in pos) { Easing ct = Easing.Linear; Easing.TryParse((string)Event["ct"], out ct); float t = (float)Event["t"], x = (float)Event["x"]; float?y = (float?)Event["y"]; y ??= 0; RandomMode r = RandomMode.None; RandomMode.TryParse((string)Event["r"], out r); float?rx = (int?)Event["rx"]; float?ry = (int?)Event["ry"]; float?rz = (int?)Event["rz"]; if (r == RandomMode.None) { obj.AddEvent(EventType.pos, t, x, y, ct); } else { obj.AddEvent(EventType.pos, t, x, y, ct, r, (float)rx, ry, (float)rz); } } foreach (var Event in sca) { Easing ct = Easing.Linear; Easing.TryParse((string)Event["ct"], out ct); float t = (float)Event["t"], x = (float)Event["x"]; float?y = (float?)Event["y"]; y ??= 0; RandomMode r = RandomMode.None; RandomMode.TryParse((string)Event["r"], out r); float?rx = (int?)Event["rx"]; float?ry = (int?)Event["ry"]; float?rz = (int?)Event["rz"]; if (r == RandomMode.None) { obj.AddEvent(EventType.sca, t, x, y, ct); } else { obj.AddEvent(EventType.sca, t, x, y, ct, r, (float)rx, ry, (float)rz); } } foreach (var Event in rot) { Easing ct = Easing.Linear; Easing.TryParse((string)Event["ct"], out ct); float t = (float)Event["t"], x = (float)Event["x"]; float?y = (float?)Event["y"]; y ??= 0; RandomMode r = RandomMode.None; RandomMode.TryParse((string)Event["r"], out r); float?rx = (int?)Event["rx"]; float?rz = (int?)Event["rz"]; if (r == RandomMode.None) { obj.AddEvent(EventType.rot, t, x, y, ct); } else { obj.AddEvent(EventType.rot, t, x, y, ct, r, (float)rx, null, (float)rz); } } foreach (var Event in col) { Easing ct = Easing.Linear; Easing.TryParse((string)Event["ct"], out ct); float t = (float)Event["t"], x = (float)Event["x"]; float?y = (float?)Event["y"]; y ??= 0; obj.AddEvent(EventType.col, t, x, y, ct); } objects.Add(obj); } if (objects.Count > 1) { return(objects); } return(objects[0]); } }
/// <summary> /// Adds an event to this object /// </summary> /// <param name="Type"></param> /// <param name="Time">Event placement on the event timeline</param> /// <param name="X"></param> /// <param name="Y"></param> /// <param name="Ease">Easing mode for this event</param> /// <param name="Random">Random Mode</param> /// <param name="RandomX"></param> /// <param name="RandomY"></param> /// <param name="RandomInterval">Constant distance between random numbers</param> public void AddEvent(EventType Type, float Time, float X, float?Y, Easing Ease, RandomMode Random, float RandomX, float?RandomY, float RandomInterval) { Event e = new Event(Type, Time) { X = X, Random = Random, RandomX = RandomX, RandomInterval = RandomInterval, Ease = Ease }; if (Y != null) { e.Y = (float)Y; } if (RandomY != null) { e.RandomY = (float)RandomY; } switch (Type) { case EventType.pos: PosEvents.Add(e); break; case EventType.sca: ScaEvents.Add(e); break; case EventType.rot: RotEvents.Add(e); break; case EventType.col: ColEvents.Add(e); break; } }
private void GenerateRandom(RandomMode mode) { var tone = new ToneParamPM8(); tone.Extended = mode != RandomMode.Normal; tone.Al = GetRandomValue(0, 7); tone.Fb = GetRandomValue(0, 7, 3.0f); uint output; // al0 fb-0-1-2-3 // al1 [[fb-0]+1]-2-3 // al2 [[fb-0]+[1-2]]-3 // al3 [[fb-0-1]+2]-3 // al4 [fb-0-1]+[2-3] // al5 [fb-0]-[1+2+3] // al6 [fb-0-1]+2+3 // al7 [fb-0]+1+2+3 switch (tone.Al) { case 0: case 1: case 2: case 3: output = 0x8; break; case 4: output = 0xa; break; case 5: case 6: output = 0xe; break; case 7: default: output = 0xf; break; } for (int i = 0; i < 4; i++) { var op = tone.Op[i]; bool o = (output & (1 << i)) != 0; op.WS = (mode != RandomMode.Ex) ? (byte)0 : GetRandomValue(0, 0, 0, 1, 2, 3, 6, 7); op.AE = 0; op.Fx = 0; var env = op.Env; if (mode == RandomMode.Tx) { op.Ml = (byte)((GetRandomValue(0, 15) + 1) & 15); op.MF = 0; op.Dt = GetRandomValue(0, 7); env.TL = GetRandomValue(0, 64); if (o) { env.ExAR = GetRandomValue(32, 127); env.ExDR = GetRandomValue(0, 127); env.ExSL = GetRandomValue(0, 127); env.ExSR = GetRandomValue(0, 127); env.ExRR = GetRandomValue(32, 127); env.VS = 1; env.KS = 0; } else { env.ExAR = GetRandomValue(0, 127); env.ExDR = GetRandomValue(0, 127); env.ExSL = GetRandomValue(0, 127); env.ExSR = GetRandomValue(0, 127); env.ExRR = GetRandomValue(0, 127); env.VS = 0; // normal ? (byte)0 : GetRandomValue(0, 7); env.KS = 0; // normal ? (byte)0 : GetRandomValue(0, 3); } } else { if (o) { op.Ml = (byte)((GetRandomValue(0, 15, 5.0f) + 1) & 15); op.MF = 0; op.Dt = GetRandomValue(0, 7, 2.0f); env.TL = GetRandomValue(0, 64, 2.0f); env.ExAR = GetRandomValue(32, 127, 0.8f); env.ExDR = GetRandomValue(0, 127, 1.5f); env.ExSL = GetRandomValue(0, 127, 1.5f); env.ExSR = GetRandomValue(0, 127, 3.0f); env.ExRR = GetRandomValue(32, 127, 0.8f); env.VS = 1; env.KS = 0; } else { op.Ml = (byte)((GetRandomValue(0, 15, 3.0f) + 1) & 15); op.MF = 0; op.Dt = GetRandomValue(0, 7, 1.0f); env.TL = GetRandomValue(0, 118, 2.0f); env.ExAR = GetRandomValue(0, 127, 0.5f); env.ExDR = GetRandomValue(0, 127, 0.7f); env.ExSL = GetRandomValue(0, 127, 1.0f); env.ExSR = GetRandomValue(0, 127, 3.0f); env.ExRR = GetRandomValue(0, 127, 2.0f); env.VS = 0; // normal ? (byte)0 : GetRandomValue(0, 7); env.KS = 0; // normal ? (byte)0 : GetRandomValue(0, 3); } } } Normalize(tone, output); loadTone(tone); }
public static SKColor GetRandomColor(RandomMode mode = RandomMode.Default) => Color.FromRgb( RandomRgb(mode == RandomMode.LightOnly ? 200 : 0), RandomRgb(mode == RandomMode.LightOnly ? 150 : 0), RandomRgb(mode == RandomMode.LightOnly ? 150 : 0)).ToSKColor();