heyho! i need some help with an array… i´m never sure how to implement it
for example PlayerExperience += XPreward; if(PlayerExperience > 10//which is element 0) LevelUp(); !
at th moment i´m checking it with some if conditions… but i think there is always a short way
…but using arrays is a lack of knowledge to me ![]()
so how to combine the array with CheckXp() coroutine? …if elemnt 0 → lvlup…if element 1 → lvlup…you know?
the lvlup system works so far but i need to avoid lots of
if (PlayerExperience > 100 PlayerLevel == 1){
LevelUp();
connect.UpdateLevelStats();
}
so here we go ![]()
var PlayerName: String;
private var PlayerLevel: int = 1;
private var PlayerExperience :int = 1;
//private var PlayerExperience : Array = new Array(10,20,30);
//private var count: boolean = true;
private var levelFactor: float = 1;
private var connect;
var ConnectTo: GameObject;
function Update () {
connect = ConnectTo.GetComponent("player_EnerCal");
////////////////////////
//if (count){
//CountUpXp(); // XP TEST COUNTER
//}
//////////////////////////////////////////////
Debug.Log(PlayerExperience+" "+PlayerLevel);
}
function CountUpXp(XPreward : int){ // is a sendmessage by the enemy
//count = false;
PlayerExperience += XPreward;
CheckXp();
//yield WaitForSeconds(2);
//count = true;
}
function CheckXp(){
if (PlayerExperience > 100 PlayerLevel == 1){
LevelUp();
connect.UpdateLevelStats();
}
if (PlayerExperience > 240 &PlayerLevel == 2){
LevelUp();
connect.UpdateLevelStats();
}
}
function LevelUp(){
PlayerLevel += 1;
levelFactor = 1 + (PlayerLevel *0.03); // used as a factor for maxenergy and all that stuff
CheckXp();
}
thx 4 help:)