void Start() { viewCurrentValue(); //Delete Previous Slot GameObject content = GameObject.Find("Content").gameObject; foreach (Transform obj in content.transform) { Destroy(obj.gameObject); } //Make Slot Shisya shisya = new Shisya(); Daimyo daimyo = new Daimyo(); bool ClickFlg = false; for (int i = 1; i < 22; i++) { string tmp = "shisya" + i.ToString(); if (PlayerPrefs.HasKey(tmp)) { //Exist string shisyaString = PlayerPrefs.GetString(tmp); List <string> shisyaList = new List <string> (); char[] delimiterChars = { ',' }; if (shisyaString != null && shisyaString != "") { if (shisyaString.Contains(",")) { shisyaList = new List <string> (shisyaString.Split(delimiterChars)); } else { shisyaList.Add(shisyaString); } } for (int j = 0; j < shisyaList.Count; j++) { string shisyaParam = shisyaList [j]; List <string> shisyaParamList = new List <string> (); char[] delimiterChars2 = { ':' }; if (shisyaParam.Contains(":")) { shisyaParamList = new List <string> (shisyaParam.Split(delimiterChars2)); } else { shisyaParamList.Add(shisyaParam); } //Common string slotName = shisya.getSlot(i); string slotPath = "Prefabs/Shisya/Slot/" + slotName; GameObject slotObj = Instantiate(Resources.Load(slotPath)) as GameObject; slotObj.transform.SetParent(content.transform); slotObj.transform.localScale = new Vector2(1, 1); slotObj.transform.localPosition = new Vector3(0, 0, 0); string title = shisya.getName(i); slotObj.transform.FindChild("Title").GetComponent <Text> ().text = title; ShisyaSelect script = slotObj.GetComponent <ShisyaSelect> (); if (slotName == "DaimyoSlot") { string daimyoId = shisyaParamList [0]; string imagePath = "Prefabs/Kamon/" + daimyoId.ToString(); slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Choose Buka int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId)); int busyoId = getRandomBusyo(int.Parse(daimyoId), daimyoBusyoId); string busyoImagePath = "Prefabs/Player/Sprite/unit" + busyoId.ToString(); slotObj.transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(busyoImagePath, typeof(Sprite)) as Sprite; BusyoInfoGet busyo = new BusyoInfoGet(); string busyoName = busyo.getName(busyoId); string daimyoName = daimyo.getName(int.Parse(daimyoId)); if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = daimyoName + "'s retainer :" + busyoName; } else { script.shisyaName = daimyoName + "配下 " + busyoName; } } else if (slotName == "SyogunSlot") { int syogunId = PlayerPrefs.GetInt("syogunDaimyoId"); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); if (seiryokuList.Contains(syogunId.ToString())) { string imagePath = "Prefabs/Kamon/" + syogunId.ToString(); slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; string daimyoName = daimyo.getName(syogunId); if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = " Syogun " + daimyoName + "'s retainer"; } else { script.shisyaName = "将軍" + daimyoName + "配下"; } } else { PlayerPrefs.DeleteKey("shisya" + i.ToString()); } } else { if (i == 13 || i == 15 || i == 16 || i == 17) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Nobleman"; } else { script.shisyaName = "貴族"; } } else if (i == 18) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Merchant"; } else { script.shisyaName = "商人"; } } else if (i == 19) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Westerner"; } else { script.shisyaName = "南蛮人"; } } else if (i == 20) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Monk"; } else { script.shisyaName = "僧"; } } else if (i == 21) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Local Samurai"; } else { script.shisyaName = "国人衆"; } } } //Random Handling string requried1 = shisya.getYesRequried1(i); if (requried1 == "random") { randomMyKahouView(slotObj); } else if (requried1 == "randomKahou") { randomSalesKahouView(slotObj); } //Set Value script.shisyaId = i; script.title = title; script.Content = content; int rdm = UnityEngine.Random.Range(1, 4); //1-3 string serihu = ""; if (rdm == 1) { serihu = shisya.getSerihu1(i); } else if (rdm == 2) { serihu = shisya.getSerihu2(i); } else if (rdm == 3) { serihu = shisya.getSerihu3(i); } serihu = serihuChanger(i, serihu, shisyaParamList, slotObj); script.serihu = serihu; if (!ClickFlg) { ClickFlg = true; firstSlot = slotObj; } } } } if (firstSlot != null) { firstSlot.GetComponent <ShisyaSelect> ().OnClick(); } else { Application.LoadLevel("mainStage"); } }
public void reqruiedItemView(int shisyaId) { Shisya shisya = new Shisya(); bool selectFlg = shisya.getSelectFlg(shisyaId); if (!selectFlg) { //initialization if (GameObject.Find("Required1")) { GameObject.Find("Required1").SetActive(true); if (GameObject.Find("Required2")) { GameObject.Find("Required2").SetActive(true); } GameObject.Find("Circle").SetActive(true); if (GameObject.Find("CyouteiSelectScrollView")) { GameObject.Find("CyouteiSelectScrollView").SetActive(false); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject.Find("SyouninSelectScrollView").SetActive(false); } } else { BackMain script = GameObject.Find("Back").GetComponent <BackMain> (); Required1.gameObject.SetActive(true); Required2.gameObject.SetActive(true); Circle.gameObject.SetActive(true); CyouteiSelectScrollView.gameObject.SetActive(false); SyouninSelectScrollView.gameObject.SetActive(false); } //Item 1 string requried1 = shisya.getYesRequried1(shisyaId); if (requried1 == "no") { baseObj.transform.FindChild("Required1").gameObject.SetActive(false); } else if (requried1 == "random") { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); if (moneyNo != 0) { string item1Path = "Prefabs/Common/Sprite/money"; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x " + moneyNo.ToString(); } else { Kahou kahou = new Kahou(); string rank = kahou.getKahouRank(itemCd, int.Parse(itemId)); string kahouPath = ""; if (rank == "C") { kahouPath = "Prefabs/Kahou/" + itemCd + "C"; } else { kahouPath = "Prefabs/Kahou/" + itemCd + itemId; } baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(kahouPath, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x 1"; } } else if (requried1 == "randomKahou") { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); //Kahou string item1Path = "Prefabs/Common/Sprite/money"; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x " + moneyNo.ToString(); } else { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); List <string> requried1List = new List <string> (); char[] delimiterChars = { ':' }; if (requried1.Contains(":")) { requried1List = new List <string> (requried1.Split(delimiterChars)); } else { requried1List.Add(requried1); } string item1Path = "Prefabs/Common/Sprite/" + requried1List [0]; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text>().text = "x " + requried1List [1]; } //Item 2 string requried2 = shisya.getYesRequried2(shisyaId); if (requried2 == "no") { baseObj.transform.FindChild("Required2").gameObject.SetActive(false); } else { baseObj.transform.FindChild("Required2").gameObject.SetActive(true); List <string> requried2List = new List <string> (); char[] delimiterChars = { ':' }; if (requried2.Contains(":")) { requried2List = new List <string> (requried2.Split(delimiterChars)); } else { requried2List.Add(requried2); } string item2Path = "Prefabs/Common/Sprite/" + requried2List [0]; baseObj.transform.FindChild("Required2").GetComponent <Image> ().sprite = Resources.Load(item2Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required2").transform.FindChild("Value").GetComponent <Text>().text = "x " + requried2List [1]; } } else { //Select if (GameObject.Find("Required1")) { GameObject.Find("Required1").SetActive(false); if (GameObject.Find("Required2")) { GameObject.Find("Required2").SetActive(false); } GameObject.Find("Circle").SetActive(false); } if (shisyaId == 16) { //Cyoutei if (GameObject.Find("CyouteiSelectScrollView")) { GameObject viewObj = GameObject.Find("CyouteiSelectScrollView").gameObject; viewObj.SetActive(true); viewObj.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); viewObj.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } else { CyouteiSelectScrollView.gameObject.SetActive(true); CyouteiSelectScrollView.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); CyouteiSelectScrollView.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject.Find("SyouninSelectScrollView").SetActive(false); } else { SyouninSelectScrollView.gameObject.SetActive(false); } } else if (shisyaId == 18) { //Syounin if (GameObject.Find("CyouteiSelectScrollView")) { GameObject.Find("CyouteiSelectScrollView").SetActive(false); } else { CyouteiSelectScrollView.gameObject.SetActive(false); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject viewObj = GameObject.Find("SyouninSelectScrollView").gameObject; viewObj.SetActive(true); viewObj.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); viewObj.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } else { SyouninSelectScrollView.gameObject.SetActive(true); SyouninSelectScrollView.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); SyouninSelectScrollView.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } } else if (shisyaId == 19) { //Nanban } } }