Search code examples
c#androidactionscript-3unity-game-engine

Actionscript To C#(UNITY)


Can someone please help me translate this actionscript code to c# code

public function SetRoadmap( strData : Array ) : void
{
    var arrPart : Array = strData;  //An array of histogram values
    var arrTmp1 : Array = [];

    intTmp_Ori = int(arrPart[0]);
    intTmp = int(intTmp_Ori/100);

    if ( int(int(arrPart[i])/100) == 3 )//Tie
    {
        bNextMove = false;
    }
}

Here's my attempt

public void SetRoadMap(string strData){
    string arrPart = strData;
    string[] arrTmp1 = new string[]{};

    int intTmp_Ori = arrPart[0];
    int intTmp = intTmp_Ori/100;

    if(//this line is i don't know){

    }
}

Could someone please help me out figure out this please. Thank you in advance guys. I need to convert this to c# because it has the same scoreboard rules that i am making in unity.


Solution

  • It seems this is the translation. As you can see there are some variables undefined, possibly they are class members.

    public void SetRoadmap(string[] strData)
    {
        string[] arrPart = strData;  //An array of histogram values
        string[] arrTmp1 = { };
    
        int intTmp_Ori = Convert.ToInt32(arrPart[0]);
        int intTmp = intTmp_Ori / 100;
    
        if (Convert.ToInt32(arrPart[i]) / 100 == 3)//Tie
        {
            bNextMove = false;
        }
    }
    

    The problem statement containing int(int()) seems to be a conversion operation. That is necessary since the input is an array of strings. There are several ways to do such conversion, for example to provide integers instead of strings when you can. This code however would do.