ronkrt

Untitled

Apr 30th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.91 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4.  
  5. public class BaseCharacter : MonoBehaviour
  6. {
  7.    
  8.     private string _name;
  9.     private int _level;
  10.     private uint _freeExp;
  11.        
  12.     private Attribute[] _primaryAttribute;
  13.     private Vital[] _vital;
  14.     private Skill[] _skill;
  15.    
  16.     public void Awake()
  17.     {
  18.         _name = string.Empty;
  19.         _level = 0;
  20.         _freeExp = 0;
  21.        
  22.         _primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
  23.         _vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
  24.         _skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
  25.        
  26.         SetupPrimaryAttributes();
  27.         SetupVitals();
  28.         SetupSkills();
  29.            
  30.     }
  31.     public string Name
  32.     {
  33.         get
  34.         {
  35.             return _name;
  36.         }
  37.         set
  38.         {
  39.             _name = value;
  40.         }
  41.     }
  42.    
  43.     public int Level
  44.     {
  45.         get
  46.         {
  47.             return _level;
  48.         }
  49.         set
  50.         {
  51.             _level = value;
  52.         }
  53.     }
  54.    
  55.     public uint FreeExp
  56.     {
  57.         get
  58.         {
  59.             return _freeExp;
  60.         }
  61.         set
  62.         {
  63.             _freeExp = value;
  64.         }
  65.     }
  66.    
  67.     public void AddExp(uint exp)
  68.     {
  69.         _freeExp += exp;
  70.        
  71.         CalculateLevel();
  72.     }
  73.    
  74.     //Take Avg of all the players skills and assign that as the player level
  75.     public void CalculateLevel()
  76.     {
  77.        
  78.     }
  79.    
  80.     private void SetupPrimaryAttributes()
  81.     {
  82.         for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++)
  83.         {
  84.             _primaryAttribute[cnt] = new Attribute();
  85.         }
  86.     }
  87.    
  88.     private void SetupVitals()
  89.     {
  90.         for(int cnt = 0; cnt < _vital.Length; cnt++)
  91.         {
  92.         _vital[cnt] = new Vital();
  93.         }
  94.     }
  95.    
  96.     private void SetupSkills()
  97.     {
  98.         for(int cnt = 0; cnt < _skill.Length; cnt++)
  99.         {
  100.             _skill[cnt] = new Skill();
  101.         }  
  102.     }
  103.    
  104.     public Attribute GetPrimaryAttribute(int index)
  105.     {
  106.         return _primaryAttribute[index];
  107.     }
  108.    
  109.     public Vital GetVital(int index)
  110.     {
  111.         return _vital[index];
  112.     }
  113.    
  114.     public Skill GetSkill(int index)
  115.     {
  116.         return _skill[index];
  117.     }
  118.  
  119.  
  120.     private void SetupVitalModifiers()
  121.     {
  122.         // Health
  123.         GetVital ((int)VitalName.Health).AddModifier(new ModifyingAttribute(attribute = GetPrimaryAttribute((int)AttributeName.Constitution), .5f));
  124.         // Energy
  125.         GetVital ((int)VitalName.Energy).AddModifier(new ModifyingAttribute(attribute = GetPrimaryAttribute((int)AttributeName.Constitution), 1f));
  126.         // Mana
  127.         GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(attribute = GetPrimaryAttribute((int)AttributeName.WillPower), 1));
  128.     }
  129.    
  130.     private void SetupSkillModifiers()
  131.     {
  132.         // Melee Offense
  133.         GetSkill((int)SkillName.Melee_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Might), .33f));
  134.         GetSkill((int)SkillName.Melee_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nimbleness), .33f));
  135.        
  136.         // Melee Offense
  137.         GetSkill((int)SkillName.Melee_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
  138.         GetSkill((int)SkillName.Melee_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .33f));
  139.        
  140.         // Magic Offense
  141.         GetSkill((int)SkillName.Magic_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
  142.         GetSkill((int)SkillName.Magic_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.WillPower), .33f));
  143.        
  144.         // Magic Defense
  145.         GetSkill((int)SkillName.Magic_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
  146.         GetSkill((int)SkillName.Magic_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.WillPower), .33f));
  147.        
  148.         // Ranged Offense
  149.         GetSkill((int)SkillName.Ranged_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
  150.         GetSkill((int)SkillName.Ranged_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
  151.        
  152.         //Ranged Defense
  153.         GetSkill((int)SkillName.Ranged_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
  154.         GetSkill((int)SkillName.Ranged_Defense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nimbleness), .33f));
  155.    
  156.     }
  157.    
  158.     public void StatUpdate()
  159.     {
  160.         for(int cnt = 0; cnt < _vital.Length; cnt++)
  161.         {
  162.             _vital[cnt].UpDate();
  163.         }
  164.            
  165.         for(int cnt = 0; cnt < _skill.Length; cnt++)
  166.         {
  167.             _skill[cnt].UpDate();
  168.         }
  169.     }
  170. }
  171.  
  172.  
  173. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(123,85): error CS0103: The name `attribute' does not exist in the current context
  174.  
  175. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(123,155): error CS1502: The best overloaded method match for `ModifyingAttribute.ModifyingAttribute(Attribute, float)' has some invalid arguments
  176.  
  177. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(123,155): error CS1503: Argument `#1' cannot convert `object' expression to type `Attribute'
  178.  
  179. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(123,50): error CS1502: The best overloaded method match for `ModifiedStat.AddModifier(ModifyingAttribute)' has some invalid arguments
  180.  
  181. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(123,50): error CS1503: Argument `#1' cannot convert `object' expression to type `ModifyingAttribute'
  182.  
  183. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(125,85): error CS0103: The name `attribute' does not exist in the current context
  184.  
  185. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(125,154): error CS1502: The best overloaded method match for `ModifyingAttribute.ModifyingAttribute(Attribute, float)' has some invalid arguments
  186.  
  187. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(125,154): error CS1503: Argument `#1' cannot convert `object' expression to type `Attribute'
  188.  
  189. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(125,50): error CS1502: The best overloaded method match for `ModifiedStat.AddModifier(ModifyingAttribute)' has some invalid arguments
  190.  
  191. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(125,50): error CS1503: Argument `#1' cannot convert `object' expression to type `ModifyingAttribute'
  192.  
  193. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(127,82): error CS0103: The name `attribute' does not exist in the current context
  194.  
  195. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(127,147): error CS1502: The best overloaded method match for `ModifyingAttribute.ModifyingAttribute(Attribute, float)' has some invalid arguments
  196.  
  197. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(127,147): error CS1503: Argument `#1' cannot convert `object' expression to type `Attribute'
  198.  
  199. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(127,47): error CS1502: The best overloaded method match for `ModifiedStat.AddModifier(ModifyingAttribute)' has some invalid arguments
  200.  
  201. Assets/Scripts/PlayerScripts/Character-Classes/BaseCharacter.cs(127,47): error CS1503: Argument `#1' cannot convert `object' expression to type `ModifyingAttribute'
Advertisement
Add Comment
Please, Sign In to add comment