Advertisement
EyeceScream

Untitled

Oct 8th, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using UnityEngine;
  5.  
  6. public class GameController : MonoBehaviour
  7. {
  8. public GameObject sword;
  9.  
  10. //Inventory Sys.
  11.  
  12.  
  13. public List<GameObject> generatedLoot;
  14.  
  15. public int[] lootTable = {
  16. 60,
  17. 90,
  18. 100
  19. };
  20. public int total;
  21. public int randomNumber;
  22. public float playerDamageCalc;
  23. public float enemyDamageCalc;
  24. // Start is called before the first frame update
  25. void Start()
  26. {
  27.  
  28. GetLoot();
  29.  
  30. playerDamageCalc = CharController.playerDamage;
  31.  
  32. }
  33.  
  34. // Update is called once per frame
  35. void Update()
  36. {
  37.  
  38. }
  39. public static void GetLoot(){
  40. //tally the total weight
  41. foreach(var item in lootTable){
  42. total += item;
  43. }
  44. //Pick a random # from 0 - total weight.
  45. randomNumber = Random.Range(0,total);
  46.  
  47. foreach (var weight in lootTable)
  48. {
  49. if(randomNumber <= weight){
  50. generatedLoot.Add(Instantiate(sword) as GameObject);
  51. return;
  52. }
  53. else{
  54. randomNumber -= weight;
  55. }
  56. lootTable lootT = new lootTable();
  57. }
  58.  
  59. }
  60.  
  61.  
  62.  
  63.  
  64. }
  65. ---------------------------------------------------------------------------------------------------------------------------------------
  66. using System.Collections;
  67. using System.Collections.Generic;
  68. using UnityEngine;
  69.  
  70. public class CharController : MonoBehaviour
  71. {
  72. //Inventory
  73. public List<GameObject> inv;
  74. //Stats
  75. public static int STR = 1;
  76. public static int MAG = 5;
  77. public static int STA = 5;
  78.  
  79. //Health
  80. public int playerMaxHealth = 10 + STA;
  81. public float playerCurrentHealth;
  82.  
  83. public static int addedSTR = 0;
  84.  
  85.  
  86. public static float playerDamage = STR + addedSTR;
  87.  
  88.  
  89. // Start is called before the first frame update
  90. void Start()
  91. {
  92. playerCurrentHealth = playerMaxHealth;
  93. //equipment = new List<Equipment>();
  94. //inv.Add(sword()); -List needs to support Methods/Functions
  95. //equipment.Add(sword);
  96.  
  97. }
  98.  
  99. // Update is called once per frame
  100. void Update()
  101. {
  102. if(playerCurrentHealth <= 0){
  103.  
  104. Destroy(GameObject.FindWithTag("Player"));
  105.  
  106. }
  107. }
  108.  
  109. }
  110. ---------------------------------------------------------------------------------------------------------------------------------------
  111. using System.Collections;
  112. using System.Collections.Generic;
  113. using UnityEngine;
  114.  
  115. public class EnemyController : MonoBehaviour
  116. {
  117.  
  118.  
  119. public int ATK = 1;
  120. public int MAG = 5;
  121. public static int STA = 5;
  122. public int MaxHealth = 10 + STA;
  123. public float CurrentHealth;
  124. public float[] inv;
  125. int invSlots = 3;
  126.  
  127.  
  128.  
  129. // Start is called before the first frame update
  130. void Start()
  131. {
  132. GameController.GetLoot();
  133. CurrentHealth = MaxHealth;
  134.  
  135.  
  136.  
  137. inv = new float[invSlots];
  138. }
  139.  
  140. // Update is called once per frame
  141. void Update()
  142. {
  143. if(CurrentHealth <= 0){
  144.  
  145. Destroy(gameObject);
  146. GameController.GetLoot();
  147.  
  148. }
  149. }
  150. public void Hurt(int playerDamageCalc){
  151.  
  152. CurrentHealth -= playerDamageCalc;
  153.  
  154. }
  155.  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement