//存储message数据 void SaveDate() { if (!File.Exists(messegeFileName)) { IOHelper.CreateDirectory(dirpath); IOHelper.CreateFile(messegeFileName); PanelClass t_date = new PanelClass(); IOHelper.SetData(messegeFileName, t_date); // Debug.Log("save panel correct" + messegeFileName); } }
// Update is called once per frame void Update() { isExist = File.Exists(messageFileName); if (isExist) { PanelClass dt = (PanelClass)IOHelper.GetData(messageFileName, typeof(PanelClass)); targerDate = Convert.ToDateTime(dt.dateNow); today = DateTime.Now; } span = today - targerDate; if (span != TimeSpan.Zero) { double count = Math.Round(span.TotalDays, 1) / 7f; double index = Math.Truncate(count); if (index < 1) { index = 0; } if (index < brickList.Count) { brickList[Convert.ToInt32(index)].SetActive(true); } else { foreach (GameObject gm in brickList) { gm.SetActive(true); } } } }
// Start is called before the first frame update IEnumerator Start() { mapStatus = true; ratingStatus = false; categoryStatus = false; mypageStatus = false; eatStatus = true; seeStatus = false; playStatus = false; star5Status = true; star4Status = false; star3Status = false; //페널 카테고리 이미지 불러오기 Sprite bar = Resources.Load <Sprite>("Textures/EAT-bar_wrap"); Sprite cafe = Resources.Load <Sprite>("Textures/EAT-cafe_wrap"); Sprite res = Resources.Load <Sprite>("Textures/EAT-restaurant_wrap"); Sprite club = Resources.Load <Sprite>("Textures/PLAY-show-club_wrap"); Sprite shop = Resources.Load <Sprite>("Textures/PLAY-shopping_wrap"); Sprite others = Resources.Load <Sprite>("Textures/PLAY-others_wrap"); Sprite att = Resources.Load <Sprite>("Textures/SEE-attraction_wrap"); Sprite mus = Resources.Load <Sprite>("Textures/SEE-museum_wrap"); Sprite park = Resources.Load <Sprite>("Textures/SEE-park_wrap"); //각 메뉴 버튼의 부모객체 소환 mapContents = GameObject.FindWithTag("MapContents"); ratingContents = GameObject.FindWithTag("RatingContents"); categoryContents = GameObject.FindWithTag("CategoryContents").transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform.gameObject; mypageContents = GameObject.FindWithTag("MypageContents"); // 받아온 데이터 객체 정리 JArray jsonData = GetAllList(); for (int i = 0; i < jsonData.Count; i++) { if (((string)jsonData[i]["useYn"]).Equals("Y")) { float positionX = (float)System.Convert.ToDouble(jsonData[i]["positionX"]); float positionY = (float)System.Convert.ToDouble(jsonData[i]["positionY"]); float positionZ = (float)System.Convert.ToDouble(jsonData[i]["positionZ"]); string imgName = (string)jsonData[i]["imgPath"]; Vector3 cubePosition = new Vector3(positionX, positionY, 0f); Quaternion qRotation = Quaternion.Euler(0f, 0f, 0.22f); WWW www; //생성 GameObject go; if (((string)jsonData[i]["category"]).Equals("EAT")) { go = Instantiate(eatPrefab, cubePosition, qRotation); } else if (((string)jsonData[i]["category"]).Equals("PLAY")) { go = Instantiate(playPrefab, cubePosition, qRotation); } else { go = Instantiate(seePrefab, cubePosition, qRotation); } float goScale = 1f / 2.685315f; go.transform.localScale = new Vector3(goScale, goScale, goScale); //부모객체 설정 go.transform.parent = categoryContents.transform; GameObject mainImage = go.transform.Find("GameObject").gameObject; GameObject categoryImage = go.transform.Find("wrap").gameObject; categoryContents.transform.localPosition = new Vector3(-6.103516e-05f, 0f, 0f); int rating = (int)positionY / 10; //객체 변수 적용 PanelClass pc = go.GetComponent <PanelClass>(); pc.rating = rating; pc.selectYn = false; Sprite cateSprite; if (((string)jsonData[i]["category"]).Equals("EAT")) { pc.categoryType = "EAT"; www = new WWW("http://13.209.40.161/images/EAT/" + imgName); if (((string)jsonData[i]["detailCategory"]).Equals("1")) { pc.activeYn = true; cateSprite = res; pc.detailCategoryType = "res"; } else if (((string)jsonData[i]["detailCategory"]).Equals("2")) { cateSprite = cafe; pc.detailCategoryType = "cafe"; } else { cateSprite = bar; pc.detailCategoryType = "bar"; } } else if (((string)jsonData[i]["category"]).Equals("PLAY")) { pc.categoryType = "PLAY"; www = new WWW("http://13.209.40.161/images/PLAY/" + imgName); if (((string)jsonData[i]["detailCategory"]).Equals("1")) { cateSprite = club; pc.detailCategoryType = "con"; } else if (((string)jsonData[i]["detailCategory"]).Equals("2")) { cateSprite = shop; pc.detailCategoryType = "shop"; } else { cateSprite = others; pc.detailCategoryType = "others"; } } else { pc.categoryType = "SEE"; www = new WWW("http://13.209.40.161/images/SEE/" + imgName); if (((string)jsonData[i]["detailCategory"]).Equals("1")) { cateSprite = mus; pc.detailCategoryType = "mus"; } else if (((string)jsonData[i]["detailCategory"]).Equals("2")) { cateSprite = att; pc.detailCategoryType = "att"; } else { cateSprite = park; pc.detailCategoryType = "park"; } } yield return(www); mainImage.GetComponent <Image>().sprite = Sprite.Create(www.texture, new Rect(0f, 0f, www.texture.width, www.texture.height), new Vector2(0.5f, 0.5f)); categoryImage.GetComponent <Image>().sprite = cateSprite; //텍스트 넣기 GameObject placeName_holder = go.transform.Find("Text").gameObject; string text = (string)jsonData[i]["name"]; placeName_holder.transform.GetComponent <Text>().text = text; //panel 상태값이 true일 경우에만 활성화 if (pc.activeYn != true) { go.SetActive(false); } } } }
void OnMouseDown() { if (joystick.Vertical == 0 && joystick.Horizontal == 0) { //创建中转文件 if (!File.Exists(t_filename)) { IOHelper.CreateDirectory(dirpath); IOHelper.CreateFile(t_filename); } //创建 存放message的文件夹 的文件夹名字文件 if (!File.Exists(brickFileName)) { IOHelper.CreateDirectory(dirpath); IOHelper.CreateFile(brickFileName); } //判断是否存在记录点击的文件 if (!File.Exists(clickTimesFileName)) { IOHelper.CreateDirectory(dirpath); IOHelper.CreateFile(clickTimesFileName); } string clickCount = IOHelper.GetRawData(clickTimesFileName); //第一次点击砖块 if (!clickCount.Contains(gameObject.name)) { GameObject Instance = Instantiate(panelPrefab, gameObject.transform.position + offset, Quaternion.identity); Instance.transform.SetParent(parent.transform); Debug.Log("改变砖块的颜色"); //改变砖块的颜色,也就是贴图 gameObject.GetComponent <SpriteRenderer>().sprite = brickImage1; } //第一次之后的点击 else { Debug.Log("判断时间,如果满足条件再显示"); //读取存储的内容和名字 if (File.Exists(messageFileName)) { PanelClass dt = (PanelClass)IOHelper.GetData(messageFileName, typeof(PanelClass)); targerDate = Convert.ToDateTime(dt.dateNow); targetMessage = dt.Messege; targetName = dt.PlayerName; Debug.Log("Date: " + targerDate + "messege: " + targetMessage + " name: " + targetName); } span = DateTime.Now - targerDate; // Debug.Log("span : "+span.TotalSeconds); //判断是否符合时间条件 if (span.TotalDays < 360) { // Debug.Log("span : " + span.TotalSeconds); double time = 365 - span.TotalDays; time = Math.Round(time, 1); string timeString = time.ToString(); GameObject Instance = Instantiate(unFitTimePanelPrefab, gameObject.transform.position + offset, Quaternion.identity); Instance.transform.SetParent(parent.transform); Instance.GetComponentInChildren <Text>().text = "Still need " + timeString + " Days"; } else { // Debug.Log("span : 1234 " + span.TotalSeconds); GameObject Instance = Instantiate(fitTimePanelPrefab, gameObject.transform.position + offset, Quaternion.identity); Instance.transform.SetParent(parent.transform); Instance.GetComponentInChildren <Text>().text = targetMessage + "\n" + targetName; gameObject.GetComponent <SpriteRenderer>().sprite = brickImage2; } } BrickClass bc = new BrickClass(); bc.brickName = gameObject.name; //覆盖 IOHelper.SetData(brickFileName, bc); //中转文件添加 IOHelper.AddData(t_filename, gameObject.name.ToString()); //Debug.Log(IOHelper.GetRawData(clickTimesFileName)); //Debug.Log("save brick correct"); } }