void Awake() { _SM = Score.ScoreManager.GetInstance(); string getdata_string = _SM.GetData_txt(true); SetScore(getdata_string); }
public static ScoreManager GetInstance() { if (!instance) { GameObject get_inst = ((GameObject)GameObject.FindObjectOfType(typeof(ScoreManager))); if (!get_inst){ get_inst = new GameObject("ScoreManager"); instance = get_inst.AddComponent<ScoreManager>(); GameObject.DontDestroyOnLoad(get_inst); } } return instance; }
// Use this for initialization void Start() { _SM = Score.ScoreManager.GetInstance(); //Hide textLables TimerLabel.gameObject.SetActive(false); ScoreLabel.gameObject.SetActive(false); //Load csv data file TextAsset data_text = Resources.Load("Data") as TextAsset; string[] datas; cubeProp_list = new List<Cube.CubeProp>(); //Parse datas if( data_text.text != "" ){ datas = data_text.ToString().Split("\n"[0]); foreach( string data in datas ){ string[] split_data = data.ToString().Split(","[0]); switch(split_data[0]){ case "cude_rand_cnt": initial_cube_count = int.Parse(split_data[1]); break; case "cube": int hex_decimal = int.Parse(split_data[2]); Color hex_ = ToColor(hex_decimal); cubeProp_list.Add ( new Cube.CubeProp() ); cubeProp_list[cubeProp_list.Count-1].type_id = cubeProp_list.Count-1; cubeProp_list[cubeProp_list.Count-1].score = int.Parse(split_data[3]); cubeProp_list[cubeProp_list.Count-1]._color = hex_; break; } } //Set Animation just play once time. // anim_countDown.wrapMode = WrapMode.Once; //As sphere should able to be control when game is start. set as disable. sphere.SetEnable(false); //pre-set the gameState on ready state = GameState.ready; //Do 3 secounds count down before game start timeCountTime = timerTime_ready; //Pre-gen the 10 cubes for(int i = 0 ; i < initial_cube_count ; i++) creat_cude(); }else{ Debug.LogError( "Data file is missing!!" ); } }