//public static ArrayList ContentList = new ArrayList() ; public void setContent(string selected) { Toggle Content_Ele = GameObject.Find("Content_" + selected).transform.GetComponentsInChildren <Toggle>()[0]; Debug_Log.Call_WriteLog(Content_Ele.isOn, "点击" + selected.toString(), "Unity"); ArrayList ContentList = new ArrayList(); Assets.Script.ReadIniPar ReadIniPargetParme = Assets.Script.getPar.getParme(); ArrayList bContent = new ArrayList(ReadIniPargetParme.Content.Split(',')); if (!System.String.IsNullOrEmpty(ReadIniPargetParme.Content))///如果读取到值了就赋值 { ContentList = bContent; } // TrainTime = selected; if (ContentList.Contains(selected) && !Content_Ele.isOn) { ContentList.Remove(selected); } else if (!ContentList.Contains(selected) && Content_Ele.isOn) { ContentList.Add(selected); } string str = string.Join(",", (string[])ContentList.ToArray(typeof(string))); Assets.Script.MyIni ini = new Assets.Script.MyIni(); ini.WriteIniContent("GameContent", "Content", str); //转换成数组 //string strdddd = string.Join(",", (string[])ContentList.ToArray(typeof(string))); Debug_Log.Call_WriteLog("setContent=" + str, selected.toString(), "Unity"); Debug.Log(selected); //if (selected) //{ //} //else { //} }
public static ReadIniPar getParme() { ReadIniPar ddReadIniPardd = new ReadIniPar(); #region 获取参数 //获取ini文件 int LengthofTime = 0; int speed = 0; MyIni ini = new MyIni(); //获取Ini文件Time类型下的time对应的数值 LengthofTime = ini.ReadIniContent("GameContent", "LengthofTime").toInt32(); ///SelectTrainTime speed = ini.ReadIniContent("GameContent", "Speed").toInt32(); ///SelectTrainDifficulty string strContent = ini.ReadIniContent("GameContent", "Content"); #endregion 获取参数 ddReadIniPardd.LengthofTime = LengthofTime; ddReadIniPardd.speed = speed; ddReadIniPardd.Content = strContent; Debug_Log.Call_WriteLog(ddReadIniPardd, "读取的strpersistentDataPath", "Unity"); return(ddReadIniPardd); }
// Use this for initialization void Start() { try { Cursor.visible = false; Assets.Script.ReadIniPar ReadIniPargetParme = Assets.Script.getPar.getParme(); int intAllNum = 200; switch (ReadIniPargetParme.LengthofTime) { case 0: intAllNum = 50; break; case 1: intAllNum = 100; break; case 2: intAllNum = 200; break; /* 您可以有任意数量的 case 语句 */ default: /* 可选的 */ intAllNum = 200; break; } switch (ReadIniPargetParme.speed) { case 0: floatMoveMi = 60; break; case 1: floatMoveMi = 30; break; case 2: floatMoveMi = 15; break; /* 您可以有任意数量的 case 语句 */ default: /* 可选的 */ floatMoveMi = 200; break; } string strContent = ReadIniPargetParme.Content; if (String.IsNullOrEmpty(strContent)) { strContent = "A"; } ArrayList bContentArrayList = new ArrayList(strContent.Split(',')); GameObject canvas = GameObject.Find("GameEnemyObject"); ArrayList cShiftArrayList = Common.getShiftArrayList(intAllNum, bContentArrayList); Debug_Log.Call_WriteLog(string.Join(",", (string[])cShiftArrayList.ToArray(typeof(string))), "随机图形表示"); for (int i = 0; i < intAllNum; i++) { GameObject gameObjectEnemyGame = (GameObject)Resources.Load("Pref/EnemyGame"); gameObjectEnemyGame = Instantiate(gameObjectEnemyGame); gameObjectEnemyGame.name = "myCube" + i.toString(); /// 查找子物体,并且将得到的物体转换成gameobject GameObject objnameFindChild = gameObjectEnemyGame.transform.Find("Cube").gameObject; #region 动态材质球 //System.Random ran = new System.Random(); //int RandKey = ran.Next(0, bContentArrayList.Count); string strLoad = "OuterDATA/GameEnemy_" + cShiftArrayList[i]; //Material mddddMaterial = Instantiate(lastMat) as Material; Texture mat = Resources.Load(strLoad) as Texture; objnameFindChild.GetComponent <Renderer>().material.mainTexture = mat; // mddddMaterial.mainTexture = mat; #endregion gameObjectEnemyGame.transform.parent = canvas.transform; Quaternion rotation = Quaternion.Euler(new Vector3(0, 180, 0)); gameObjectEnemyGame.transform.rotation = rotation; #region 对左右位置进行随机 int intddd = UnityEngine.Random.Range(-10, 10);///左右随机摆动的 Vector3 unitVector = new Vector3(56.72f + intddd, 2, 10.15f + i * 3); gameObjectEnemyGame.transform.position = unitVector; #endregion // 用 slerp 进行插值平滑的旋转 //transform.rotation = Quaternion.Slerp(transform.rotation, targetAngels, rotateSpeed * Time.deltaTime); //transform.rotation = targetAngels; } Score.iniSucessPercent(intAllNum); Debug_Log.Call_WriteLog(intAllNum.toString(), "class move"); ///屏幕1记录时间 DateTimeStart = DateTime.Now; } catch (Exception ex) { ////LogController.writeErrorLog(ex, "ObjectExtended toInt32"); Debug_Log.Call_WriteLog(ex, "move初始化推球界面"); } }