protected virtual bool LoadMoveScript(TextAsset file) { bool hr = true; bool uniFlag = false; //string line = ""; string lPc = ""; int splitInd = 0; int atInd = -1; int cInd = 0; int[] instructNum = new int[MOVENUM]; int[] uniqueNum = new int[UNIQUE_LMT]; MoveInstruct uniMove = new MoveInstruct(); int uInd = 0; moveCont = new MoveInstruct[MOVENUM]; string[] lines = file.text.Split('\n'); string line; foreach (string rline in lines){ line = rline.Trim(); if(FirstNCharChk(line, "<ATTACK")){ splitInd = line.IndexOf(":")+1; atInd = AttStringToIndex(line.Substring(splitInd, line.IndexOf(">")-8)); if(atInd>=0) instructNum[atInd]=0; } if(FirstNCharChk(line, "<UNIQUE")){ splitInd = line.IndexOf(":")+1; uniFlag=true; //atInd = AttStringToIndex(line.Substring(splitInd, line.IndexOf(">")-8)); if(atInd>=0) atInd=-1; } if(FirstNCharChk(line, "time")){ if(atInd>=0) instructNum[atInd]++; else if(uniFlag) uniqueNum[uInd]++; } if(FirstNCharChk(line, "</ATTACK>")){ atInd=-1; } if(FirstNCharChk(line, "</UNIQUE>")){ uInd++; } } //infile.DiscardBufferedData(); //infile.BaseStream.Seek(0, SeekOrigin.Begin); //infile.BaseStream.Position = 0; cInd=0; uInd=0; string uniName = ""; foreach (string rline in lines){ line = rline.Trim(); if(FirstNCharChk(line, "<ATTACK")){ splitInd = line.IndexOf(":")+1; atInd = AttStringToIndex(line.Substring(splitInd, line.IndexOf(">")-8)); moveCont[atInd]=new MoveInstruct(instructNum[atInd]); uniFlag=false; //instantiate moveset instructions }if(FirstNCharChk(line, "<UNIQUE")){ splitInd = line.IndexOf(":")+1; uniName = line.Substring(splitInd, line.IndexOf(">")-8); uniMove=new MoveInstruct(uniqueNum[uInd]); uniFlag=true; atInd=-1; //moveCont[atInd]=new MoveInstruct(instructNum[atInd]); //instantiate moveset instructions } if (FirstNCharChk(line, "time")) { //moveCont. lPc = line.Substring(5); float time = float.Parse(lPc.Substring(0, lPc.IndexOf(" "))); lPc = lPc.Substring(lPc.IndexOf(" ") + 1); if (FirstNCharChk(lPc, "wait")) { if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "WAIT", 0); else if (uniFlag) uniMove.SetInstruct(cInd, time, "WAIT", 0); } if (FirstNCharChk(lPc, "burst")) { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float val = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "BURST", val); else if (uniFlag) uniMove.SetInstruct(cInd, time, "BURST", val); } else if (FirstNCharChk(lPc, "airburst")) { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float xV = float.Parse(lPc.Substring(0, lPc.IndexOf(" "))); lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float yV = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "AIRBURST", new SPoint(xV, yV)); else if (uniFlag) uniMove.SetInstruct(cInd, time, "AIRBURST", new SPoint(xV, yV)); } else if (FirstNCharChk(lPc, "slide")) { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float val = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "SLIDE", val); else if (uniFlag) uniMove.SetInstruct(cInd, time, "SLIDE", val); } else if (FirstNCharChk(lPc, "brake")) { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float val = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "BRAKE", val); else if (uniFlag) uniMove.SetInstruct(cInd, time, "BRAKE", val); } else if (FirstNCharChk(lPc, "airhover")) { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float xV = float.Parse(lPc.Substring(0, lPc.IndexOf(" "))); lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float yV = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "AIRHOVER", new SPoint(xV, yV)); else if (uniFlag) uniMove.SetInstruct(cInd, time, "AIRHOVER", new SPoint(xV, yV)); } else if (FirstNCharChk(lPc, "airbrake")){ lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float xV = float.Parse(lPc.Substring(0, lPc.IndexOf(" "))); lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float yV = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstruct(cInd, time, "AIRBRAKE", new SPoint(xV, yV)); else if (uniFlag) uniMove.SetInstruct(cInd, time, "AIRBRAKE", new SPoint(xV, yV)); } cInd++; } else if (FirstNCharChk(line, "cons")) { lPc = line.Substring(5); if (FirstNCharChk(lPc, "end_pt"))//end velocity (SPoint) for anything { lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float xV = float.Parse(lPc.Substring(0, lPc.IndexOf(" "))); lPc = lPc.Substring(lPc.IndexOf(" ") + 1); float yV = float.Parse(lPc); if (atInd >= 0) moveCont[atInd].SetInstructEnd(cInd-1, new SPoint(xV, yV)); else if (uniFlag) uniMove.SetInstructEnd(cInd-1, new SPoint(xV, yV)); } } if(FirstNCharChk(line, "</ATTACK>")){ atInd=-1; cInd=0; } if(FirstNCharChk(line, "</UNIQUE>")){ SetUniqueMove (uniName, uniMove); atInd=-1; uInd++; cInd=0; } } return hr; }
protected virtual void SetUniqueMove(string uName, MoveInstruct uMove) { //should not be called here }
protected override void SetUniqueMove(string uName, MoveInstruct uMove) { if(uName.CompareTo("SPB_L")==0) specInst[SPB_L]=uMove; if(uName.CompareTo("SPB_M")==0) specInst[SPB_M]=uMove; if(uName.CompareTo("SPB_H")==0) specInst[SPB_H]=uMove; if(uName.CompareTo("SPC_L")==0) specInst[SPC_L]=uMove; if(uName.CompareTo("SPC_M")==0) specInst[SPC_M]=uMove; if(uName.CompareTo("SPC_H")==0) specInst[SPC_H]=uMove; }