Guest User

Untitled

a guest
Oct 21st, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.38 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3.  
  4. public class Wizard : MonoBehaviour {
  5.     #region variables
  6.     public int playerActualLevel;
  7.     public static int playerExperience;
  8.     public int expNeededToLevelUp;
  9.     public float skillCooldown = 0f;
  10.     public float attackCooldown = 0f;
  11.     public int outputdamage;
  12.     public int coins_collected;
  13.     [Header("Class Settings")]
  14.     public bool fireMage;
  15.     public bool iceMage;
  16.     public bool xMage;
  17.     public bool yMage;
  18.    
  19.     [Header("Health Settings")]
  20.     public int StartingHealth = 10;
  21.     public int currentPlayerHealth;
  22.     [Header("Mana Settings")]
  23.     public int StartingMana = 5;
  24.     public int actuallMana;
  25.     [Header("Skills of fire mage")]
  26.     public GameObject fireball;
  27.     public GameObject firebolt;
  28.     public GameObject fireExplosion;
  29.     public GameObject meteors;
  30.     [Header("Skills of ice mage")]
  31.     public GameObject iceball;
  32.  
  33.     [Header("Skills of heal mage")]
  34.    
  35.     //add later
  36.     [Header("Skills of demonic mage")]
  37.     //add later
  38.     public GameObject healingAura;
  39.     public GameObject ringOfDeath;
  40.     [Header("Character Stats")]
  41.     public int attackDamage=20;
  42.     public int defense;
  43.     public int skillDamage;
  44.    
  45.     #endregion
  46.  
  47.     void Start () {
  48.         if (fireMage)
  49.         {
  50.  
  51.         }
  52.         else if (iceMage)
  53.         {
  54.  
  55.         }
  56.         else if (xMage){
  57.  
  58.         }
  59.         else if (yMage)
  60.         {
  61.  
  62.         }
  63.         currentPlayerHealth = StartingHealth;
  64.      
  65.      
  66.         GameObject  Enemy = GameObject.Find("Enemy");
  67.         Enemy enemy = Enemy.GetComponent<Enemy>();
  68.         outputdamage=enemy.enemyAttack;
  69.     }
  70.  
  71.    
  72.     void Update() {
  73.         skillCooldown -= Time.deltaTime;
  74.         attackCooldown -= Time.deltaTime;
  75.         print("player experience"+playerExperience);
  76.  
  77.         if (playerExperience >= expNeededToLevelUp)
  78.         {
  79.             playerActualLevel++;
  80.             print("lvl up, player level: "+playerActualLevel);
  81.             PlayerLevelUp();
  82.             expNeededToLevelUp += 2*expNeededToLevelUp*playerActualLevel;
  83.             print("exp required for level: " + (playerActualLevel + 1) + " is: "+expNeededToLevelUp);
  84.         }
  85.  
  86.         PlayerSpellInput();
  87.  
  88.  
  89.      
  90.     }
  91.     public void PlayerSpellInput()
  92.     {
  93.  
  94.         if (Input.GetMouseButtonDown(0))
  95.         {
  96.  
  97.             Attack();
  98.         }
  99.         if (Input.GetKeyDown(KeyCode.Alpha1))
  100.         {
  101.  
  102.             Fire();
  103.         }
  104.         if (Input.GetKeyDown(KeyCode.Alpha2))
  105.         {
  106.             Ice();
  107.         }
  108.         if (Input.GetKeyDown(KeyCode.Alpha3))
  109.         {
  110.             Heal();
  111.         }
  112.         if (Input.GetKeyDown(KeyCode.Alpha4))
  113.         {
  114.             Ring();
  115.         }
  116.     }
  117.  
  118.     #region spells
  119.     public void Attack()
  120.     {
  121.        
  122.         if (attackCooldown <= 0f)
  123.         {
  124.             Instantiate(firebolt, gameObject.transform.position, gameObject.transform.rotation);
  125.             attackCooldown = 0.75f;
  126.         }
  127.         else
  128.             return;      
  129.     }
  130.     public void Fire()
  131.     {
  132.        
  133.         if (skillCooldown <= 0)
  134.         {
  135.             Instantiate(fireball, gameObject.transform.position, gameObject.transform.rotation);
  136.             skillCooldown = 2f;
  137.         }
  138.         else
  139.             return;  
  140.     }
  141.     public void Ice()
  142.     {
  143.         if (skillCooldown <= 0)
  144.         {
  145.             Instantiate(fireball, gameObject.transform.position, gameObject.transform.rotation);
  146.             skillCooldown = 2f;
  147.         }
  148.         else
  149.             return;
  150.     }
  151.     public void Heal()
  152.     {
  153.         if (skillCooldown <= 0)
  154.         {
  155.             Instantiate(fireExplosion, gameObject.transform.position, gameObject.transform.rotation);
  156.             skillCooldown = 2f;
  157.         }
  158.         else
  159.             return;
  160.     }
  161.     public void Ring()
  162.     {
  163.         if (skillCooldown <= 0)
  164.         {
  165.             Instantiate(meteors, gameObject.transform.position, gameObject.transform.rotation);
  166.             skillCooldown = 2f;
  167.         }
  168.         else
  169.             return;
  170.     }
  171.     #endregion
  172.     public void OnCollisionEnter(Collision  col)
  173.     {
  174.    
  175.        
  176.         if (col.transform.CompareTag("Enemy"))
  177.         {
  178.            
  179.             currentPlayerHealth -= outputdamage;
  180.            
  181.             if (currentPlayerHealth <= 0)
  182.             {
  183.                 Debug.Log("health<0");
  184.                 //death animation +sound
  185.             }
  186.          
  187.            
  188.         }
  189.         if (col.transform.CompareTag("Coin"))
  190.         {
  191.             Level_Manager.coins++;
  192.             Destroy(col.gameObject);
  193.             //put sound
  194.            
  195.         }
  196.        
  197.         }
  198.  
  199.     public void PlayerLevelUp()
  200.     {
  201.        
  202.    
  203.         StartingHealth += 20;
  204.        print("startinghealth after lvl up" + StartingHealth);
  205.         currentPlayerHealth = StartingHealth;
  206.        print("actualhealth after lvl up" + currentPlayerHealth);
  207.         StartingMana += 25;
  208.         actuallMana = StartingMana;
  209.         attackDamage += 10;
  210.        print("attack damage after lvl" + attackDamage);
  211.      
  212.     }
  213.     public void IncreaseStats(int id,int buff_amount,int buff_duration)
  214.     {
  215.         print("attackdamage" + attackDamage);
  216.         attackDamage+= buff_amount;
  217.         currentPlayerHealth += buff_amount;
  218.         //STAT ID, BUFF amount, BUFF DURATION
  219.         print("attackdamage after increase" + attackDamage);
  220.     }
  221. }
Add Comment
Please, Sign In to add comment