void back() { if (UnityEngine.Random.Range(1, 100) <= BackProbability) { switch (myPos) { case ("bed1"): if (crocobed.activeSelf) { crocobed.SetActive(false); player.RoomBed.SetActive(true); } FriendList.bed1 = false; disableImage(); break; case ("floor1"): if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { cushion.GetComponent <Image>().enabled = false; } FriendList.floor1 = false; disableImage(); break; case ("floor2"): if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { cushion.GetComponent <Image>().enabled = false; } FriendList.floor2 = false; disableImage(); break; case ("desk"): if (crocodesk.activeSelf) { crocodesk.SetActive(false); } if (crocohagen.GetComponent <Image> ().enabled) { crocohagen.GetComponent <Image> ().enabled = false; } FriendList.desk = false; disableImage(); break; case ("laundry"): if (ShopLaundry.GetComponent <Item>().BoughtNumber > 0) { Laundry.SetActive(true); LaundryFold.SetActive(false); } FriendList.laundry = false; disableImage(); break; case (""): //bug!! if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { cushion.GetComponent <Image> ().enabled = false; } if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "crocodileVisit") { crocodesk.SetActive(false); crocohagen.GetComponent <Image> ().enabled = false; } disableImage(); break; } } save(); }
void Start() { AmmoOpened = (PlayerPrefs.GetString("AmmoOpened") == "True"); if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit" && !AmmoOpened) { AmmoOpened = true; PlayerPrefs.SetString("AmmoOpened", "True"); int month = PlayerPrefs.GetInt("Month"); int day = PlayerPrefs.GetInt("Day"); PlayerPrefs.SetInt("AmmoMonth", month); PlayerPrefs.SetInt("AmmoDay", day); } load(); if (!isShown) { Invoke("visit", 3.0f); } if (!FriendList.Sleeping) { //default: 0,0,7 Delta = new TimeSpan(0, 0, 20); // friends visit,back per 20 second Delta2 = new TimeSpan(0, 0, 20); // save during 1 minute. SysTime = System.DateTime.Now; UpdatedTime = SysTime; switch (myPos) { case ("bed1"): if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "crocodileVisit") { ThisObject.transform.position = posCrocoBed; crocobed.SetActive(true); player.RoomBed.SetActive(false); } else { //FriendImage.sprite = SeatImage [posNumber].sprite; sprite(); ThisObject.transform.position = posBed1; } break; case ("floor1"): //FriendImage.sprite = SeatImage [posNumber].sprite; sprite(); ThisObject.transform.position = posFloor1; if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { ThisObject.transform.position = posAmmoFloor1; cushion.GetComponent <Image>().enabled = true; } break; case ("floor2"): //FriendImage.sprite = SeatImage [posNumber].sprite; sprite(); ThisObject.transform.position = posFloor2; if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { ThisObject.transform.position = posAmmoFloor2; cushion.GetComponent <Image>().enabled = true; } break; case ("desk"): if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "crocodileVisit") { ThisObject.transform.position = posCrocoDesk; if (PlayerPrefs.GetInt("hagendazBoughtNumber") == 0) { crocodesk.SetActive(true); } else { crocohagen.GetComponent <Image> ().enabled = true; } } else { //FriendImage.sprite = SeatImage [posNumber].sprite; sprite(); ThisObject.transform.position = posDesk; } break; case ("laundry"): Laundry.SetActive(false); if (ShopLaundry.GetComponent <Item>().BoughtNumber > 0) { LaundryFold.SetActive(true); } //FriendImage.sprite = SeatImage [posNumber].sprite; sprite(); ThisObject.transform.position = posLaundry; break; } if (TimeCheck.TimeOver(Delta2)) { if (FriendImage.GetComponent <Image> ().enabled == false && ItemCheck()) { visit(); } else if (FriendImage.GetComponent <Image> ().enabled) { back(); } } } if (PlayerPrefs.HasKey(FriendNameVisit)) { VisitCounter.text = PlayerPrefs.GetString(FriendNameVisit); VisitNumber = IntParseFast(VisitCounter.text); } }
void visit() { if (snakeOK()) { if (UnityEngine.Random.Range(1, 100) <= VisitProbability) { int i = UnityEngine.Random.Range(0, Seat.Length); if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "lionVisit" && IsPartyTime()) { i = 1; } else if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "lionVisit") { i = 0; } switch (Seat[i]) { case ("bed1"): if (!FriendList.bed1) { // !bed2 option.. if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "crocodileVisit") { ThisObject.transform.position = posCrocoBed; FriendList.bed1 = true; myPos = "bed1"; posNumber = i; EnableImage(); crocobed.SetActive(true); player.RoomBed.SetActive(false); player.playerPos(); isShown = true; } else { ThisObject.transform.position = posBed1; FriendList.bed1 = true; myPos = "bed1"; FriendImage.sprite = SeatImage [i].sprite; posNumber = i; EnableImage(); player.playerPos(); isShown = true; } } break; case ("floor1"): if (!FriendList.floor1) { FriendList.floor1 = true; ThisObject.transform.position = posFloor1; if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { ThisObject.transform.position = posAmmoFloor1; cushion.GetComponent <Image>().enabled = true; } myPos = "floor1"; FriendImage.sprite = SeatImage [i].sprite; posNumber = i; EnableImage(); player.playerPos(); isShown = true; } break; case ("floor2"): if (!FriendList.floor2) { ThisObject.transform.position = posFloor2; if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "ammoniteVisit") { ThisObject.transform.position = posAmmoFloor2; cushion.GetComponent <Image>().enabled = true; } FriendList.floor2 = true; myPos = "floor2"; FriendImage.sprite = SeatImage [i].sprite; posNumber = i; EnableImage(); player.playerPos(); isShown = true; } break; case ("desk"): if (!FriendList.desk) { if (ThisObject.GetComponent <VisitFriend> ().FriendNameVisit == "crocodileVisit") { ThisObject.transform.position = posCrocoDesk; FriendList.desk = true; myPos = "desk"; posNumber = i; EnableImage(); //crocodesk.SetActive (true); if (hagendaz.GetComponent <Item> ().BoughtNumber == 0) { crocodesk.SetActive(true); } else { crocohagen.GetComponent <Image> ().enabled = true; } player.playerPos(); isShown = true; } else { ThisObject.transform.position = posDesk; FriendList.desk = true; myPos = "desk"; FriendImage.sprite = SeatImage [i].sprite; posNumber = i; EnableImage(); player.playerPos(); isShown = true; } } break; case ("laundry"): // only lion! if (!FriendList.laundry) { ThisObject.transform.position = posLaundry; Laundry.SetActive(false); if (ShopLaundry.GetComponent <Item>().BoughtNumber > 0) { LaundryFold.SetActive(true); } FriendList.laundry = true; myPos = "laundry"; FriendImage.sprite = SeatImage [i].sprite; posNumber = i; EnableImage(); player.playerPos(); isShown = true; } break; default: // Debug.Log ("NULL!"); break; } } } save(); }