protected override async Task OnCastE() { await Task.Delay(1000); if (!rCastInProgress) { Animator.ColorBurst(HSVColor.FromRGB(229, 115, 255), LightZone.Desk, 0.8f); } }
protected override async Task OnCastW() { RunAnimationOnce("w_cast", LightZone.Desk); Animator.HoldLastFrame(LightZone.Desk, 1.8f); if (!rCastInProgress) { Animator.ColorBurst(HSVColor.FromRGB(229, 115, 255), LightZone.Desk, 0.8f, false); } }
private void OnCastE() { Task.Run(async() => { await Task.Delay(1000); if (!rCastInProgress) { _ = animator.ColorBurst(HSVColor.FromRGB(229, 115, 255), 0.15f); } }); }
public static Animation LoadFromFile(string path) { string text = ""; try { text = File.ReadAllText(path); } catch (Exception e) { Debug.WriteLine(e.StackTrace); throw new ArgumentException("File does not exist.", e); } try { string[] lines = text.Split('\n'); string[] data = lines[0].Split(','); int numLeds = int.Parse(data[0]); int numFrames = int.Parse(data[1]); string animationData = ""; if (lines.Length > 2) { // multiline format for (int i = 1; i <= numFrames; i++) { lines[i] = lines[i].Replace("\r", ""); lines[i] = lines[i].Replace("\n", ","); animationData += lines[i]; } } else { animationData = lines[1]; } string[] bytes = animationData.Split(','); List <HSVColor[]> animation = new List <HSVColor[]>(); for (int i = 0; i < numFrames; i++) { animation.Add(new HSVColor[numLeds]); for (int j = 0; j < numLeds; j++) { Color rgb = Color.FromArgb(int.Parse(bytes[i * numLeds * 3 + j * 3 + 0]), int.Parse(bytes[i * numLeds * 3 + j * 3 + 1]), int.Parse(bytes[i * numLeds * 3 + j * 3 + 2])); HSVColor c = HSVColor.FromRGB(rgb); animation[i][j] = c; } } return(new Animation(animation)); } catch (Exception e) { Debug.WriteLine("Error reading animation"); Debug.WriteLine(e.StackTrace); throw e; } }
void UpdateRGBAControls(ColorValue value, object ignoreControl) { HSVColor hsvColor = HSVColor.FromRGB(value); if (ignoreControl != colorWheel) { colorWheel.HsvColor = hsvColor; } if (ignoreControl != colorGradientControl) { colorGradientControl.Value = (int)(hsvColor.Value * 255); colorGradientControl.TopColor = new HSVColor(hsvColor.Hue, hsvColor.Saturation, 1).ToColor(); colorGradientControl.BottomColor = Color.Black; } if (ignoreControl != numericUpDownRed) { numericUpDownRed.Value = (decimal)MathEx.Saturate(value.Red) * 255; } if (ignoreControl != numericUpDownGreen) { numericUpDownGreen.Value = (decimal)MathEx.Saturate(value.Green) * 255; } if (ignoreControl != numericUpDownBlue) { numericUpDownBlue.Value = (decimal)MathEx.Saturate(value.Blue) * 255; } if (ignoreControl != numericUpDownAlpha) { numericUpDownAlpha.Value = (decimal)(MathEx.Saturate(noAlpha ? 1 : value.Alpha) * 255); } if (ignoreControl != trackBarRed) { trackBarRed.Value = (int)(MathEx.Saturate(value.Red) * 1000); } if (ignoreControl != trackBarGreen) { trackBarGreen.Value = (int)(MathEx.Saturate(value.Green) * 1000); } if (ignoreControl != trackBarBlue) { trackBarBlue.Value = (int)(MathEx.Saturate(value.Blue) * 1000); } if (ignoreControl != trackBarAlpha) { trackBarAlpha.Value = (int)(MathEx.Saturate(noAlpha ? 1 : value.Alpha) * 1000); } }
/// <summary> /// Called when the mouse is clicked. /// </summary> private void OnMouseClick(object sender, MouseEventArgs m) { // TODO: Quick cast support if (m.Button == MouseButtons.Right) { SelectedAbility = AbilityKey.None; } else if (m.Button == MouseButtons.Left) { // CODE FOR Q if (SelectedAbility == AbilityKey.Q && !qCastInProgress) { // Here you should write code to trigger the appropiate animations to play when the user casts Q. // The code will slightly change depending on the champion, since not all champion abilities are cast in the same "Q + Left Click" fashion, // plus you might want to implement custom animation logic for the different champion abilities. // Trigger the start animation. Task.Run(async() => { await Task.Delay(100); if (!rCastInProgress) { animator.RunAnimationOnce(@"Animations/Vel'Koz/q_start.txt", true); } }); // The Q cast is in progress. qCastInProgress = true; // After 1.15s, if user didn't press Q again already, the Q split animation plays. Task.Run(async() => { await Task.Delay(1150); if (CanCastAbility(AbilityKey.Q) && !rCastInProgress && qCastInProgress) { animator.RunAnimationOnce(@"Animations/Vel'Koz/q_recast.txt"); // Since the ability was cast, start the cooldown timer. StartCooldownTimer(AbilityKey.Q); } qCastInProgress = false; }); // Q was cast, so now there is no ability selected. // Note that this doesn't get triggered after 1.15s (it doesn't wait for the above task to finish). SelectedAbility = AbilityKey.None; } // CODE FOR W if (SelectedAbility == AbilityKey.W) { Task.Run(async() => { animator.RunAnimationOnce(@"Animations/Vel'Koz/w_cast.txt", true); await Task.Delay(1800); if (!rCastInProgress) { animator.RunAnimationOnce(@"Animations/Vel'Koz/w_close.txt", false, 0.15f); } }); StartCooldownTimer(AbilityKey.W); SelectedAbility = AbilityKey.None; } // CODE FOR E if (SelectedAbility == AbilityKey.E) { Task.Run(async() => { await Task.Delay(1000); if (!rCastInProgress) { _ = animator.ColorBurst(HSVColor.FromRGB(229, 115, 255), 0.15f); } }); StartCooldownTimer(AbilityKey.E); SelectedAbility = AbilityKey.None; } // if (SelectedAbility == AbilityKey.R) { } --- Not needed for vel'koz because vel'koz ult is instant cast and doesn't need a mouse click. } }
/// <summary> /// Called when a key is pressed; /// </summary> private void OnKeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'q') { if (qCastInProgress) { qCastInProgress = false; if (!rCastInProgress) { animator.RunAnimationOnce(@"Animations/Vel'Koz/q_recast.txt"); } StartCooldownTimer(AbilityKey.Q); } else if (CanCastAbility(AbilityKey.Q)) { SelectedAbility = AbilityKey.Q; } } if (e.KeyChar == 'w') { if (CanCastAbility(AbilityKey.W)) { SelectedAbility = AbilityKey.W; } } if (e.KeyChar == 'e') { if (CanCastAbility(AbilityKey.E)) { SelectedAbility = AbilityKey.E; } } if (e.KeyChar == 'r') { if (rCastInProgress) { animator.StopCurrentAnimation(); rCastInProgress = false; StartCooldownTimer(AbilityKey.R); } else { if (CanCastAbility(AbilityKey.R)) { animator.StopCurrentAnimation(); animator.RunAnimationInLoop(@"Animations/Vel'Koz/r_loop.txt", 2300, 0.15f); rCastInProgress = true; Task.Run(async() => { await Task.Delay(2300); if (rCastInProgress) { StartCooldownTimer(AbilityKey.R); rCastInProgress = false; } }); } } } if (e.KeyChar == 'f') // TODO: Refactor this into LeagueOfLegendsModule, or a new SummonerSpells module. Also take cooldown into consideration. { animator.ColorBurst(HSVColor.FromRGB(255, 237, 41), 0.1f); } }
/*public static Animation LoadFromFileLegacy(string path) * { * string text = ""; * try * { * text = File.ReadAllText(path); * } * catch (Exception e) * { * Debug.WriteLine(e.StackTrace); * throw new ArgumentException("File does not exist.", e); * } * * string[] lines = text.Split('\n'); * string[] data = lines[0].Split(','); * int = int.Parse(data[0]); * int numFrames = int.Parse(data[1]); * * string animationData = lines[1]; * if (lines.Length > 2) * { * var animationDataBuilder = new StringBuilder(); * // multiline format * for (int i = 1; i <= numFrames; i++) * { * lines[i] = lines[i].Replace("\r", "").Replace('\n', ','); * animationDataBuilder.Append(lines[i]); * } * animationData = animationDataBuilder.ToString(); * } * string[] bytes = animationData.Split(','); * List<HSVColor[]> animation = new List<HSVColor[]>(); * for (int i = 0; i < numFrames; i++) * { * animation.Add(new HSVColor[numLeds]); * for (int j = 0; j < numLeds; j++) * { * int baseIndex = i * numLeds * 3 + j * 3; * Color rgb = Color.FromArgb(int.Parse(bytes[baseIndex]), int.Parse(bytes[baseIndex + 1]), int.Parse(bytes[baseIndex + 2])); * HSVColor c = HSVColor.FromRGB(rgb); * animation[i][j] = c; * } * } * return new Animation(animation); * }*/ public static Animation LoadFromFile(string path) { string text = ""; try { text = File.ReadAllText(path); } catch (Exception e) { Debug.WriteLine(e.StackTrace); Debug.WriteLine("Error loading animation: File does not exist."); return(Animation.Empty); //throw new ArgumentException("File does not exist.", e); } string[] lines = text.Split('\n'); string[] data = lines[0].Split(','); int version = int.Parse(data[0]); int numFrames = int.Parse(data[1]); if (version != 2) { Debug.WriteLine("Error parsing: Unsupported animation format version"); return(Animation.Empty); //throw new FileFormatException("Error parsing: Unsupported animation format version"); } List <string> animLines = new List <string>(); for (int i = 1; i < lines.Length - 1; i++) { animLines.Add(lines[i]); } LEDColorData[] frames = new LEDColorData[numFrames]; for (int f = 0; f < numFrames; f++) { string[] zones = animLines[f].Split(";"); if (zones.Length != 7) { throw new FileFormatException("Error parsing: Zone length != 7"); } LEDColorData frameData = LEDColorData.Empty; for (int i = 0; i < 7; i++) { string zone = zones[i]; string[] bytes = zone.Split(','); HSVColor[] colArray = new HSVColor[LEDData.LEDCounts[i]]; if (bytes.Length != LEDData.LEDCounts[i] * 3) { throw new FileFormatException("Error parsing: Unexpected length of light zone array"); } for (int j = 0; j < LEDData.LEDCounts[i]; j++) { int baseIndex = j * 3; Color rgb = Color.FromArgb(int.Parse(bytes[baseIndex]), int.Parse(bytes[baseIndex + 1]), int.Parse(bytes[baseIndex + 2])); HSVColor c = HSVColor.FromRGB(rgb); colArray[j] = c; } switch (i) { case 0: frameData.Keyboard = colArray; break; case 1: frameData.Strip = colArray; break; case 2: frameData.Mouse = colArray; break; case 3: frameData.Mousepad = colArray; break; case 4: frameData.Headset = colArray; break; case 5: frameData.Keypad = colArray; break; case 6: frameData.General = colArray; break; } } frames[f] = frameData; } return(new Animation(frames)); }