本文整理汇总了C#中Chapter.getLevelByID方法的典型用法代码示例。如果您正苦于以下问题:C# Chapter.getLevelByID方法的具体用法?C# Chapter.getLevelByID怎么用?C# Chapter.getLevelByID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chapter
的用法示例。
在下文中一共展示了Chapter.getLevelByID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parseStaticFromJson
public void parseStaticFromJson(string jsontext)
{
ArrayList allData = MiniJsonExtensions.arrayListFromJson(jsontext);
chapters = new List<Chapter>();
foreach(Hashtable chash in allData){
// Debug.LogError(string.Format("Name: {0}", chash["name"] as string));
Chapter c = new Chapter();
chapters.Add(c);
c.id = (int)(double)chash["chapter"];
c.name = chash["name"] as string;
c.passStars = (int)(double)chash["passStars"];
ArrayList lvList = chash["levels"] as ArrayList;
foreach(Hashtable lvhash in lvList){
Level lv = new Level();
lv.id = (int)(double)lvhash["level"];
lv.preLvIds = Utils.parseCommaSeperatedInt( lvhash["preLevel"] == null? null:lvhash["preLevel"].ToString());
lv.wave = lvhash["wave"] as ArrayList;
lv.chapter = c;
lv.bgMusic = lvhash["bgMusic"] as string;
c.levels.Add(lv);
ReadHazardDefs(lvhash, lv.hazardDefs);
if(lv.preLvIds!=null){
foreach(int prelvid in lv.preLvIds){
Level prelv = c.getLevelByID(prelvid);
if(prelv.postLvIds==null){
prelv.postLvIds = new List<int>();
}
prelv.postLvIds.Add(lv.id);
}
}
}
}
// foreach(Chapter c in chapters){
// Debug.Log(c);
// }
}
示例2: init
public void init(Chapter chapter)
{
this.chapter = chapter;
Debug.Log("chapter = "+chapter.id);
//MusicManager.playBgMusic("AMB_CH"+chapter.id+"_1b");
//MusicManager.playBgMusic("AMB_CH1_1b");
chapterNameText.text = chapter.name;
id2LvCell = new Hashtable ();
int n = -1;
int isUnlockedID = 0;
foreach (Level lv in chapter.levels) {
n++;
if(lv.id>=100){
continue;
}
if(!lv.isUnlocked() && isUnlockedID == 0){
isUnlockedID = lv.id;
}
GameObject go = Instantiate (cellPrefab) as GameObject;
LevelSelectDetailCell levelCell = go.GetComponent<LevelSelectDetailCell> ();
levelCell.init (lv);
go.name = "Level_" + lv.id;
go.transform.parent = this.graphRoot.transform;
go.transform.localScale = Vector3.one;
id2LvCell.Add (lv.id, levelCell);
GameObject preGo = null;
if(lv.preLvIds == null || lv.preLvIds.Count == 0){
preGo = null;
}else{
preGo = (id2LvCell[lv.preLvIds[0]] as LevelSelectDetailCell).gameObject;
}
if(preGo == null){
// absolutly at the center line ( start )
Debug.Log(lv.id + " start");
go.transform.localPosition = new Vector3 (0, yCenter, 0);
}else if (lv.preLvIds.Count != 1) {
// absolutly at the center line ( merge )
Debug.Log(lv.id + " merge");
go.transform.localPosition = new Vector3 (preGo.transform.localPosition.x+hSpan, yCenter, 0);
} else {
Level preLv = chapter.getLevelByID (lv.preLvIds [0]);
if (preLv.postLvIds.Count > 1) { // fork
if (preLv.postLvIds [0] == lv.id) {
Debug.Log(lv.id + " fork up");
go.transform.localPosition = new Vector3 (preGo.transform.localPosition.x+hSpan,yHigh,0);
} else {
Debug.Log(lv.id + " fork down");
go.transform.localPosition = new Vector3 (preGo.transform.localPosition.x+hSpan,yLow,0);
}
} else { // follow the line of pre one
Debug.Log(lv.id + " follow");
go.transform.localPosition = new Vector3 (preGo.transform.localPosition.x+hSpan,preGo.transform.localPosition.y,0);
}
}
//draw lines
if(lv.preLvIds!=null){
foreach(int preid in lv.preLvIds){
preGo = (id2LvCell[preid] as LevelSelectDetailCell).gameObject;
GameObject line = Instantiate(linePrefab) as GameObject;
line.transform.parent = this.graphRoot.transform;
line.transform.localScale = Vector3.one;
line.transform.localPosition = preGo.transform.localPosition;
if(Mathf.Approximately(preGo.transform.localPosition.y,go.transform.localPosition.y)){
//no rotation
}else if(preGo.transform.localPosition.y > go.transform.localPosition.y){
line.transform.localRotation = Quaternion.Euler(new Vector3(0,0,-30));
}else{
line.transform.localRotation = Quaternion.Euler(new Vector3(0,0,+30));
}
}
}
//if(lv.id == 1) levelCell.BgSprite.color = new Color(0.78f,0.27f,1f,1f);
}
playChapterMusic(chapter.id,isUnlockedID);
foreach (LevelSelectDetailCell cell in id2LvCell.Values) {
if (cell.lv.preLvIds == null)
continue;
LevelSelectDetailCell preCell = id2LvCell [cell.lv.preLvIds [0]] as LevelSelectDetailCell;
// Debug.Log (preCell.lv.id + "->" + cell.lv.id);
if (cell.lv.preLvIds.Count >= 2) {
preCell = id2LvCell [cell.lv.preLvIds [1]] as LevelSelectDetailCell;
// Debug.Log (preCell.lv.id + "->" + cell.lv.id);
}
}
// for(int i = 0;i < this.chapter.levels.Count;i++){
// Level lv = this.chapter.levels[i];
// if(!lv.isUnlocked()){
// OnCellClicked(this.chapter.levels[i-1]);
// break;
// }
// }
}