- Home /
This question was
closed Mar 28, 2015 at 05:12 PM by
Graham-Dunnett for the following reason:
Duplicate Question - try reading the questions on this site about CS0029. I retagged your question for you.
rror CS0029: Cannot implicitly convert type `BaseWarriorClass' to `string'
here is my code, and i am not quiet sure what i am missing here... any help would be awesome, thanks!
using UnityEngine;
using System.Collections;
public class DisplayCreatePlayerFunctions {
private StatAllocationModule statAllocationModule = new StatAllocationModule ();
private int classSelection;
private string[] classSelectionNames = new string[4]{"Mage", "Warrior", "Hunter", "Cleric"};
public void DisplayClassSelections(){
//a list of toggle buttons and each button will be a different class.
//selection grid
classSelection = GUI.SelectionGrid(new Rect(50,50,250,300),classSelection, classSelectionNames, 2);
GUI.Label (new Rect(450, 50, 300, 300), FindClassDescription(classSelection));
GUI.Label (new Rect(450, 100, 300, 300), FindClassStatValues(classSelection));
}
private string FindClassDescription(int classSelection){
if(classSelection == 0){
BaseCharacterClass tempClass = new BaseMageClass();
return tempClass.CharacterClassDescription;
}else if(classSelection == 1){
BaseCharacterClass tempClass = new BaseWarriorClass();
return tempClass.CharacterClassDescription;
}
return "NO CLASS FOUND";
}
private string FindClassStatValues(int classSelection){
if (classSelection == 0) {
BaseCharacterClass tempClass = new BaseMageClass ();
string tempStats = "Strength " + tempClass.Strength + "\n" + "dextarity" + tempClass.Dextarity;
return tempStats;
} else if (classSelection == 1) {
BaseCharacterClass tempClass = new BaseWarriorClass ();
string tempStats = "Strength " + tempClass.Strength + "\n" + "dextarity" + tempClass.Dextarity;
return tempStats;
}
return "NO STATS FOUND";
}
public void DisplayStatAllocations(){
//a list of stats with plus and minus buttons to add stats
//logic to make sure the player cannot add more than stats given
statAllocationModule.DisplayStatAllocationModule();
}
public void DisplayFinalSetup(){
//name
//gender
//add a description to your character, a short bio
}
private void ChooseClass(int classSelection){
if (classSelection == 0) {
GameInformation.PlayerClass = new BaseMageClass ();
} else if (classSelection == 1) {
GameInformation.PlayerClass = new BaseWarriorClass();
}
}
public void DisplayMainItems(){
Transform player = GameObject.FindGameObjectWithTag("Player").transform;
GUI.Label(new Rect(Screen.width/2, 20, 250, 250), "CREATE NEW PLAYER");
if(GUI.Button(new Rect(340,370,50,50), "<<<")){
//turn transform tagged as player to the left
player.Rotate(Vector3.up * 10);
}
if(GUI.Button(new Rect(470,370,50,50), ">>>")){
//turn transform tagged as player to the right
player.Rotate(Vector3.down * 10);
}
if (CreateAPlayerGUI.currentState != CreateAPlayerGUI.CreateAPlayerStates.FINALSETUP){ //if we are not in the final setup then show a next button
if(GUI.Button(new Rect(525,370,50,50), "New")){
if(CreateAPlayerGUI.currentState == CreateAPlayerGUI.CreateAPlayerStates.CLASSSELECTION){
ChooseClass(classSelection);
CreateAPlayerGUI.currentState = CreateAPlayerGUI.CreateAPlayerStates.STATALLOCATION;
}else if(CreateAPlayerGUI.currentState == CreateAPlayerGUI.CreateAPlayerStates.STATALLOCATION){
CreateAPlayerGUI.currentState = CreateAPlayerGUI.CreateAPlayerStates.FINALSETUP;
}
}
}else if(CreateAPlayerGUI.currentState == CreateAPlayerGUI.CreateAPlayerStates.FINALSETUP){
if(GUI.Button(new Rect(525,370,50,50), "Finish")){
//FINAL SAVE
}
}
}
}
it says the error is on line 62, im not quiet sure what im missing here on that line, thanks for the help! been stuck for a couple days on this.
Comment
Follow this Question
Related Questions
Converting a string to an int 2 Answers
Convert Array to String 3 Answers
Convert string to guitext, in a guitext array. 0 Answers