hi all,
i try to make a candy-crush-like game.
i have make some sprites and design them in 5x5. i have attach them a script that show the sprite name and their “game value” in script property.
when i run, i notice that not all my 5x5 sprites have done the script, they just show 0 value.
anyone can help me?
here is the code snippet:
public float posisibaris=0;
public float posisikolom=0;
public int jenisunit=0;
public int nilai=0;
// Use this for initialization
void Start () {
BlocksUnitScript gameobj = GetComponent<BlocksUnitScript>();
posisibaris = gameobj.transform.position.x;
posisikolom = gameobj.transform.position.y;
jenisunit = get_jenisunit ();
nilai = get_nilai ();
}
private int get_nilai(){
int returnvalue = 0;
switch (jenisunit) {
case 0 :
returnvalue=0;
break;
case 1 : //berry
returnvalue=50;
break;
case 2 : //grape
returnvalue=30;
break;
case 3 : //orange
returnvalue=45;
break;
case 4 : //strawberry
returnvalue=100;
break;
case 5 : //apple
returnvalue=75;
break;
case 6 : //melon
returnvalue=300;
break;
case 7 : //pear
returnvalue=500;
break;
default :
returnvalue=0;
break;
}
return returnvalue;
}
private int get_jenisunit(){
int returnindex = 0;
SpriteRenderer gameobj_sprite = GetComponentInChildren<SpriteRenderer> ();
if (GlobalVarScript.mySprites != null ) {
for (int i=0;i<GlobalVarScript.mySprites.Length; i++){
if (gameobj_sprite.sprite==GlobalVarScript.mySprites*) {*
* returnindex=i+1;*
* break;*
* }*
* }*
* }*
* gameobj_sprite = null;*
* return returnindex ;*
* }*
*[37123-trouble+in+unity+resized.png*|37123]*
*```*
*