Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using UnityEngine;
- public class GameController : MonoBehaviour
- {
- public GameObject sword;
- //Inventory Sys.
- public List<GameObject> generatedLoot;
- public int[] lootTable = {
- 60,
- 90,
- 100
- };
- public int total;
- public int randomNumber;
- public float playerDamageCalc;
- public float enemyDamageCalc;
- // Start is called before the first frame update
- void Start()
- {
- GetLoot();
- playerDamageCalc = CharController.playerDamage;
- }
- // Update is called once per frame
- void Update()
- {
- }
- public static void GetLoot(){
- //tally the total weight
- foreach(var item in lootTable){
- total += item;
- }
- //Pick a random # from 0 - total weight.
- randomNumber = Random.Range(0,total);
- foreach (var weight in lootTable)
- {
- if(randomNumber <= weight){
- generatedLoot.Add(Instantiate(sword) as GameObject);
- return;
- }
- else{
- randomNumber -= weight;
- }
- lootTable lootT = new lootTable();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CharController : MonoBehaviour
- {
- //Inventory
- public List<GameObject> inv;
- //Stats
- public static int STR = 1;
- public static int MAG = 5;
- public static int STA = 5;
- //Health
- public int playerMaxHealth = 10 + STA;
- public float playerCurrentHealth;
- public static int addedSTR = 0;
- public static float playerDamage = STR + addedSTR;
- // Start is called before the first frame update
- void Start()
- {
- playerCurrentHealth = playerMaxHealth;
- //equipment = new List<Equipment>();
- //inv.Add(sword()); -List needs to support Methods/Functions
- //equipment.Add(sword);
- }
- // Update is called once per frame
- void Update()
- {
- if(playerCurrentHealth <= 0){
- Destroy(GameObject.FindWithTag("Player"));
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyController : MonoBehaviour
- {
- public int ATK = 1;
- public int MAG = 5;
- public static int STA = 5;
- public int MaxHealth = 10 + STA;
- public float CurrentHealth;
- public float[] inv;
- int invSlots = 3;
- // Start is called before the first frame update
- void Start()
- {
- GameController.GetLoot();
- CurrentHealth = MaxHealth;
- inv = new float[invSlots];
- }
- // Update is called once per frame
- void Update()
- {
- if(CurrentHealth <= 0){
- Destroy(gameObject);
- GameController.GetLoot();
- }
- }
- public void Hurt(int playerDamageCalc){
- CurrentHealth -= playerDamageCalc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement