Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- float[] currentRecoil = new float[2];
- for (int i = 0; i < 30; i++) {
- Random rnd = new Random();
- currentRecoil = evalRecoil(currentRecoil[0], 0.3f, 0.3f, rnd);
- Console.WriteLine(i + ":\nUp: " + currentRecoil[0] + "\nSides: " + currentRecoil[1] + "\n");
- }
- }
- public static float[] evalRecoil(float currentUp, float upMultiplier, float sideMultiplier, Random rng){
- float[] toReturn = new float[2];
- if (currentUp == 0) {
- currentUp = 0.1f;
- }
- sideMultiplier += (sideMultiplier * currentUp);
- float up = (currentUp * upMultiplier) + currentUp;
- float sideCalc = (currentUp * sideMultiplier);
- Console.WriteLine("Debug sideCalc: " + sideCalc);
- float side = randomFloat(-sideCalc, sideCalc, rng);
- if (up > 20) {
- up = 20; }
- if (side > 10) {
- side = 10; }
- if (side < -10) {
- side = -10;}
- toReturn[0] = up;
- toReturn[1] = side;
- return toReturn;
- }
- public static float randomFloat(float min, float max, Random rng){
- double range = (double) max - (double) min;
- double sample = rng.NextDouble();
- double scaled = (sample * range) + min;
- float f = (float) scaled;
- return f;
- }
- static float NextFloat(float max, float min, Random rand)
- {
- return (float)(max * 2.0 * (rand.NextDouble()-0.5));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement