Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with scripting errors (BurgZergArcade)

Discussion in 'Scripting' started by Gwolf-Studios, Jan 9, 2013.

  1. Gwolf-Studios

    Gwolf-Studios

    Joined:
    Oct 7, 2012
    Posts:
    30
    I've been using the tutorials from BurgZergArcade.com to make scripts for my game but i've run into a error and I can't figure out what's wrong. My game was supposed to be released last year but because of this error I couldn't do that and I still can't continue because until all 20 errors are gone I can't test the game to make sure it works properly. Here is my code:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System;  //used for the Enum class
    4.  
    5. public class CharacterGenerator : MonoBehaviour {
    6.     private PlayerCharacter _toon;
    7.     private const int STARTING_POINTS = 350;
    8.     private const int MIN_STARTING_ATTRIBUTE_VALUE = 10;
    9.     private const int STARTING_VALUE = 50;
    10.     private int pointsleft;
    11.  
    12.     // Use this for initialization
    13.     void Start ()  {
    14.        _toon = new PlayerCharacter();
    15.        _toon.Awake();
    16.        
    17.         pointsleft = STARTING_POINTS;
    18.        
    19.         for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
    20.             _toon.GetPrimaryAttribute(cnt).BaseVaulue = STARTING_VALUE;
    21.             pointsleft -= (STARTING_VALUE - MIN_STARTING_ATTRIBUTE_VALUE);
    22.         }
    23.        
    24.                 _toon.StatUpdate();
    25.     }
    26.  
    27.     // Update is called once per frame
    28.     void Update () {
    29.  
    30.  
    31.     }
    32.  
    33.     void OnGUI() {
    34.         DisplayName();
    35.         DisplayPointsLeft();
    36.         DisplayAttributes();
    37.         DisplayVitals();
    38.         DisplaySkills();
    39.     }
    40.  
    41.  private void DisplayName() {
    42.      GUI.Label(new Rect(10, 10, 50, 25), "Name");
    43.       _toon.Name = GUI.TextField(new Rect(65, 10, 100, 25), _toon.Name);
    44.     }
    45.    
    46.     private void DisplayAttributes() {
    47.         for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) {
    48.             GUI.Label(new Rect(10, 40 + (cnt * 25), 100, 25), ((AttributeName)cnt).ToString());
    49.             GUI.Label(new Rect(115, 40 + (cnt * 25), 30, 25), _toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
    50.                 if(GUI.Button (new Rect(180, 40 + (cnt * 25), 25, 25), "-")) {
    51.                     if(_toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE) {
    52.                         _toon.GetPrimaryAttribute(cnt).BaseValue--;
    53.                         pointsleft++;
    54.                             _toon.StatUpdate();
    55.                 }
    56.                
    57.             }
    58.             if(GUI.Button (new Rect(180, 40 + (cnt * 25), 25, 25), "+")) {
    59.                 if(pointsleft > 0) {
    60.                     _toon.GetPrimaryAttribute(cnt).BaseValue++;
    61.                     pointsleft--;
    62.                             _toon.StatUpdate();
    63.                 }
    64.             }
    65.         }
    66.     }
    67.    
    68.     private void DisplayVitals() {
    69.         for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++) {
    70.             GUI.Label(new Rect(10, 40 + ((cnt + 7) * 25), 100, 25), ((VitalName)cnt).ToString());
    71.             GUI.Label(new Rect(115, 40 + ((cnt + 7) * 25), 30, 25), _toon.GetVital(cnt).AdjustedBaseValue.ToString());
    72.         }
    73.     }
    74.    
    75.     private void DisplaySkills() {
    76.         for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
    77.             GUI.Label(new Rect(250, 40 + (cnt * 25), 100, 25), ((SkillName)cnt).ToString());
    78.             GUI.Label(new Rect(355, 40 + (cnt * 25), 30, 25), _toon.GetSkill(cnt).AdjustedBaseValue.ToString());
    79.         }
    80.     }
    81.    
    82.     private void DisplayPointsLeft() {
    83.         GUI.Label(new Rect(250, 10, 100, 25), "Points Left: " + pointsleft.ToString());
    84.     }
    85. }
    86.  
    Here are the errors:

    Assets/Scripts/Character Classes/CharacterGenerator.cs(20,31): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetPrimaryAttribute' and no extension method `GetPrimaryAttribute' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(24,39): error CS1061: Type `PlayerCharacter' does not contain a definition for `StatUpdate' and no extension method `StatUpdate' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(43,67): error CS1061: Type `PlayerCharacter' does not contain a definition for `Name' and no extension method `Name' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(43,24): error CS1502: The best overloaded method match for `UnityEngine.GUI.TextField(UnityEngine.Rect, string)' has some invalid arguments

    Assets/Scripts/Character Classes/CharacterGenerator.cs(43,24): error CS1503: Argument `#2' cannot convert `object' expression to type `string

    Assets/Scripts/Character Classes/CharacterGenerator.cs(43,13): error CS1061: Type `PlayerCharacter' does not contain a definition for `Name' and no extension method `Name' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(49,69): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetPrimaryAttribute' and no extension method `GetPrimaryAttribute' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(49,17): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string)' has some invalid arguments

    Assets/Scripts/Character Classes/CharacterGenerator.cs(49,17): error CS1503: Argument `#2' cannot convert `object' expression to type `string'

    Assets/Scripts/Character Classes/CharacterGenerator.cs(51,46): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetPrimaryAttribute' and no extension method `GetPrimaryAttribute' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(52,51): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetPrimaryAttribute' and no extension method `GetPrimaryAttribute' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(54,63): error CS1061: Type `PlayerCharacter' does not contain a definition for `StatUpdate' and no extension method `StatUpdate' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(60,47): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetPrimaryAttribute' and no extension method `GetPrimaryAttribute' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(62,63): error CS1061: Type `PlayerCharacter' does not contain a definition for `StatUpdate' and no extension method `StatUpdate' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(71,75): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetVital' and no extension method `GetVital' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(71,17): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string)' has some invalid arguments

    Assets/Scripts/Character Classes/CharacterGenerator.cs(71,17): error CS1503: Argument `#2' cannot convert `object' expression to type `string'

    Assets/Scripts/Character Classes/CharacterGenerator.cs(78,69): error CS1061: Type `PlayerCharacter' does not contain a definition for `GetSkill' and no extension method `GetSkill' of type `PlayerCharacter' could be found (are you missing a using directive or an assembly reference?)

    Assets/Scripts/Character Classes/CharacterGenerator.cs(78,17): error CS1502: The best overloaded method match for `UnityEngine.GUI.Label(UnityEngine.Rect, string)' has some invalid arguments

    Assets/Scripts/Character Classes/CharacterGenerator.cs(78,17): error CS1503: Argument `#2' cannot convert `object' expression to type `string'

    ~~~~~~~~
    And I know pretty much nothing about coding so please don't get super technical on me :(