EyeceScream

Untitled

Oct 8th, 2020
721
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 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.         }
  57.  
  58.     }
  59.    
  60.  
  61.        
  62.    
  63. }
  64. ---------------------------------------------------------------------------------------------------------------------------------------
  65. using System.Collections;
  66. using System.Collections.Generic;
  67. using UnityEngine;
  68.  
  69. public class EnemyController : MonoBehaviour
  70. {
  71.    
  72.  
  73.     public int ATK = 1;
  74.     public int MAG = 5;
  75.     public static int STA = 5;
  76.     public int MaxHealth = 10 + STA;
  77.     public float CurrentHealth;
  78.     public float[] inv;
  79.     int invSlots = 3;
  80.  
  81.  
  82.  
  83.     // Start is called before the first frame update
  84.     void Start()
  85.     {
  86.         //GameController.GetLoot();
  87.         CurrentHealth = MaxHealth;
  88.  
  89.  
  90.  
  91.         inv = new float[invSlots];
  92.     }
  93.  
  94.     // Update is called once per frame
  95.     void Update()
  96.     {
  97.         if(CurrentHealth <= 0){
  98.            
  99.             Destroy(gameObject);
  100.             //GameController.GetLoot();
  101.            
  102.         }
  103.     }
  104.     public void Hurt(int playerDamageCalc){
  105.  
  106.         CurrentHealth -= playerDamageCalc;
  107.  
  108.     }
  109.  
  110. }
  111.  
  112.  
RAW Paste Data