- Home /
Error: type could not be resolved because of a cycle.
Hi everyone,
I hope you can help me. I am having a problem with "type could not be resolved because of a cycle".
Specifically it says:
"Definition of 'LevelUpCheck(AvatarData, int)' depends on 'EndBattlePanel()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle."
Explaination:
My thought process was that EndBattlePanel would be the master function and would act like a switch. So it should :
start off on avatar[0]
then run the Experience(0) function
then run the LevelUpCheck function
if avatar did level up, then it would show a popup with a 'continue' button.
When this is pressed, it will play the LevelUpCheck function again until avatar doesn't gain any more levels and will then do the else statement.
When the else statement is run, the Avatar[0] should have a false value and so it would be become false in EndBattlePanel function and continue on with Avatar[1] and run all of the functions again until both Avatar[0] & Avatar[1] are false.
Code:
function EndBattlePanel ()
{
if(avatar[0].hasBattled == true)
{
yield Experience(0);
}
else if(avatar[1].hasBattled == true)
{
yield Experience(1);
}
else
{
scrollbar.SetActive(true);
continueButton.SetActive(true);
}
}
function Experience (number : int)
{
var avatarSelected : AvatarData;
avatarSelected = avatar[number];
ExperienceFormula();
yield SlideExperienceBar();
LevelUpCheck(avatarSelected, number);
}
function LevelUpCheck (avatarSelected : AvatarData, number : int)
{
levelUpPopup.SetActive(false);
if (avatarSelected.curExperience > avatarSelected.experienceMax)
{
LevelUpAvatar(avatarSelected);
levelUpPopup.SetActive(true);
}
else
{
avatar[number].hasBattled = false;
yield WaitForSeconds(0.5);
EndBattlePanel();
}
}
Answer by hulahoolgames · Aug 29, 2015 at 05:36 PM
This has been answered here. Explicitly mention the return type of either one of the functions since they both depend on each other.
Your answer
Follow this Question
Related Questions
Definition of Script.function() depends on Script.function()... 3 Answers
Cycle Through All GameObjects in the Scene 2 Answers
Cycle Through Array of Enemies 1 Answer
Make a Button For Every String in an Array of Level Names 1 Answer
Need tips for optimizing main func that loops through thousands of particles 0 Answers