bianpao.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class bianpao : MonoBehaviour
  5. {
  6. public float benjin = 100000;
  7. public float gailv = 50;
  8. public float zhouqi = 10000;
  9. public float zongtouru = 0;
  10. public float yinkui = 0;
  11. public int xunhuan = 0;
  12. public void Start()
  13. {
  14. zongtouru = benjin;
  15. }
  16. public void nextzhou()
  17. {
  18. for (int i = 0; i < xunhuan; i++)
  19. {
  20. bool zf = false;
  21. int gl = Random.Range(-1, 100);
  22. if (gailv >= gl)
  23. {
  24. zf = true;
  25. }
  26. float gl2 = Random.Range(-1f, 10f);
  27. gl2 = zf ? gl2 / 100 : -gl2 / 100;
  28. benjin = benjin + benjin * gl2;
  29. if (!zf)
  30. {
  31. zongtouru = zongtouru + zhouqi;
  32. benjin = benjin + zhouqi;
  33. }
  34. else
  35. {
  36. zongtouru = zongtouru - zhouqi;
  37. benjin = benjin - zhouqi;
  38. }
  39. yinkui = (benjin - zongtouru) / benjin;
  40. }
  41. }
  42. }