public void attack() { audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //Same Daimyo Check int latestDaimyoId = kuniIconView.transform.FindChild(dstKuni.ToString()).GetComponent <SendParam> ().daimyoId; GameObject MsgBack = this.transform.FindChild("MsgBack").gameObject; GameObject MsgText = MsgBack.transform.FindChild("MsgText").gameObject; if (dstDaimyoId == latestDaimyoId) { if (dstDaimyoId != myDaimyoId) { audioSources [7].Play(); int enemyHei = heiryokuCalc(dstKuni); //Engun int engunTotalHei = 0; if (dstEngunFlg) { char[] delimiterChars2 = { ':' }; List <string> engunHeiList = new List <string>(); engunHeiList = new List <string> (dstEngunHei.Split(delimiterChars2)); for (int k = 0; k < engunHeiList.Count; k++) { engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]); } } enemyHei = enemyHei + engunTotalHei; int ratio = 0; if ((myHei + enemyHei) != 0) { ratio = 100 * myHei / (myHei + enemyHei); if (ratio < 1) { ratio = 1; } } MainEventHandler kassenEvent = new MainEventHandler(); bool winFlg = kassenEvent.CheckByProbability(ratio); //Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; KuniInfo kuniScript = new KuniInfo(); string dstKuniName = kuniScript.getKuniName(dstKuni); //Gaikou Gaikou gaikou = new Gaikou(); gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId); if (winFlg) { bool noGunzeiFlg = false; string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = srcDaimyoName + "\n" + "Conquered " + dstKuniName; } else { syouhai = srcDaimyoName + "\n" + dstKuniName + "を攻略"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; win(key, srcDaimyoId, dstDaimyoId, noGunzeiFlg, dstKuni); fire(dstKuni); } else { string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = dstDaimyoName + "\n" + "Defended " + dstKuniName; } else { syouhai = dstDaimyoName + "\n" + dstKuniName + "を防衛"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; gameObject.GetComponent <GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController(); main.deleteKeyHistory(key); } } else { MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked(); atked.wasAttacked(key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts); } } else { audioSources [1].Play(); string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = srcDaimyoName + " withdrawed"; } else { syouhai = srcDaimyoName + "撤退"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; gameObject.GetComponent <GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController(); main.deleteKeyHistory(key); } }
public void attack(){ //Same Daimyo Check int latestDaimyoId = kuniIconView.transform.FindChild (dstKuni.ToString ()).GetComponent<SendParam> ().daimyoId; GameObject MsgBack = this.transform.FindChild ("MsgBack").gameObject; GameObject MsgText = MsgBack.transform.FindChild ("MsgText").gameObject; if (dstDaimyoId == latestDaimyoId) { if (dstDaimyoId != myDaimyoId) { int enemyHei = heiryokuCalc (dstKuni); //Engun int engunTotalHei = 0; if(dstEngunFlg){ char[] delimiterChars2 = {':'}; List<string> engunHeiList = new List<string>(); engunHeiList = new List<string> (dstEngunHei.Split (delimiterChars2)); for(int k=0; k<engunHeiList.Count; k++){ engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]); } } enemyHei = enemyHei + engunTotalHei; int ratio = 0; if ((myHei + enemyHei) != 0) { ratio = 100 * myHei / (myHei + enemyHei); if (ratio < 1) { ratio = 1; } } MainEventHandler kassenEvent = new MainEventHandler (); bool winFlg = kassenEvent.CheckByProbability (ratio); Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; string dstKuniName = kuniMst.param [dstKuni - 1].kuniName; //Gaikou Gaikou gaikou = new Gaikou(); gaikou.downGaikouByAttack(srcDaimyoId,dstDaimyoId); if (winFlg) { bool noGunzeiFlg = false; string syouhai = srcDaimyoName + "\t" + dstKuniName + "を攻略"; MsgBack.GetComponent<Image> ().enabled = true; MsgText.GetComponent<Text> ().enabled = true; MsgText.GetComponent<Text> ().text = syouhai; if (leftFlg == true) { MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f); } win (key, srcDaimyoId, dstDaimyoId, noGunzeiFlg); } else { string syouhai = dstDaimyoName + "\t" + dstKuniName + "を防衛"; MsgBack.GetComponent<Image> ().enabled = true; MsgText.GetComponent<Text> ().enabled = true; MsgText.GetComponent<Text> ().text = syouhai; if (leftFlg == true) { MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f); } gameObject.GetComponent<GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController (); main.deleteKeyHistory (key); } } else { MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked (); atked.wasAttacked (key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts); } } else { string syouhai = srcDaimyoName + "撤退"; MsgBack.GetComponent<Image> ().enabled = true; MsgText.GetComponent<Text> ().enabled = true; MsgText.GetComponent<Text> ().text = syouhai; if (leftFlg == true) { MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f); } gameObject.GetComponent<GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController (); main.deleteKeyHistory (key); } }
// Update is called once per frame void Update () { life = getTotalHp (targetTag); //Show Heiryoku if (life >= 0) { gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString(); } if (!flag) { if (life == 0) { flag = true; GameObject.Find ("ScrollView").SetActive (false); GameObject canvas = GameObject.Find ("Canvas").gameObject; if (targetTag == "Player") { //Game Over string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent (canvas.transform); backObj.transform.localScale = new Vector2(70,63); backObj.transform.localPosition = new Vector2 (0,0); //Chane word Color color = Color.blue; GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北"; GameObject.Find ("winlose").GetComponent<TextMesh>().color = color; string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.SetParent (canvas.transform); blackObj.transform.localScale = new Vector2(330,300); blackObj.transform.localPosition = new Vector2 (0,0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.SetParent (canvas.transform); makimonoObj.transform.localScale = new Vector2(1,1); makimonoObj.transform.localPosition = new Vector2(0,-135); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.SetParent (canvas.transform); bttnListObj.transform.localScale = new Vector2(1,1); bttnListObj.transform.localPosition = new Vector2 (0,0); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //lose Stage Name string stageNamePath = "Prefabs/PostKassen/loseStageName"; GameObject stageNameObj = Instantiate(Resources.Load (stageNamePath)) as GameObject; stageNameObj.transform.SetParent (canvas.transform); stageNameObj.transform.localScale = new Vector2(1,1); stageNameObj.transform.localPosition = new Vector2 (0,-102); string stageName = PlayerPrefs.GetString("activeStageName"); //Check is attacked flag if (isAttackedFlg == true) { stageNameObj.transform.FindChild ("stageNameValue").GetComponent<Text> ().text = stageName + "失敗"; //My Daimyo Lose Gunzei lose = new Gunzei (); string tKey = PlayerPrefs.GetString ("activeKey"); int tSrcDaimyoId = PlayerPrefs.GetInt ("activeSrcDaimyoId"); int tDstDaimyoId = PlayerPrefs.GetInt ("activeDstDaimyoId"); bool noGunzeiFlg = true; PlayerPrefs.DeleteKey ("isAttacked"); lose.win (tKey, tSrcDaimyoId, tDstDaimyoId, noGunzeiFlg); //Delete Cleared Kuni int activeKuniId = PlayerPrefs.GetInt ("activeKuniId"); string clearedKuni = PlayerPrefs.GetString ("clearedKuni"); char[] delimiterChars = { ',' }; List<string> clearedKuniList = new List<string> (); if (clearedKuni != null && clearedKuni != "") { if (clearedKuni.Contains (",")) { clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars)); } else { clearedKuniList.Add (clearedKuni); } } string tempActiveKuni = activeKuniId.ToString (); clearedKuniList.Remove (tempActiveKuni); string newClearedKuni = ""; for (int i = 0; i < clearedKuniList.Count; i++) { if (i == 0) { newClearedKuni = clearedKuniList [i]; } else { newClearedKuni = newClearedKuni + "," + clearedKuniList [i]; } } PlayerPrefs.SetString ("clearedKuni", newClearedKuni); if (newClearedKuni == null || newClearedKuni == "") { PlayerPrefs.SetBool ("gameOverFlg", true); } //Delete Naisei //string tempNaisei = "naisei" + activeKuniId.ToString(); //PlayerPrefs.DeleteKey(tempNaisei); //Delete Jyosyu string tempJyosyu = "jyosyu" + activeKuniId.ToString (); PlayerPrefs.DeleteKey (tempJyosyu); //Delete Stage Clear string tempKuni = "kuni" + activeKuniId.ToString (); PlayerPrefs.DeleteKey (tempKuni); //Delete open KuniInfo kuni = new KuniInfo (); kuni.updateOpenKuni (); PlayerPrefs.Flush (); } else { stageNameObj.transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略失敗"; } } else if (targetTag == "Enemy") { //Win if(isAttackedFlg == true){ //history string tKey = PlayerPrefs.GetString("activeKey"); MainStageController main = new MainStageController(); main.deleteKeyHistory(tKey); PlayerPrefs.DeleteKey("isAttacked"); PlayerPrefs.Flush(); } string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent (canvas.transform); backObj.transform.localScale = new Vector2(70,63); backObj.transform.localPosition = new Vector2 (0,0); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject; particleObj.transform.SetParent (canvas.transform); particleObj.transform.localPosition = new Vector2(0,60); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.SetParent (canvas.transform); blackObj.transform.localScale = new Vector2(330,300); blackObj.transform.localPosition = new Vector2 (0,0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.SetParent (canvas.transform); makimonoObj.transform.localScale = new Vector2(1,1); makimonoObj.transform.localPosition = new Vector2(0,-135); string stageName = PlayerPrefs.GetString("activeStageName"); //Item List string itemListPath = "Prefabs/PostKassen/itemList"; GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject; itemListObj.transform.SetParent (canvas.transform); itemListObj.transform.localScale = new Vector2(1,1); itemListObj.transform.localPosition = new Vector2 (0,-136); if (!isAttackedFlg) { itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略"; /*Item or Kahou*/ string activeItemGrp = PlayerPrefs.GetString ("activeItemGrp"); if (activeItemGrp != "no") { string activeItemType = PlayerPrefs.GetString ("activeItemType"); Debug.Log (activeItemType); int activeItemId = PlayerPrefs.GetInt ("activeItemId"); Debug.Log (activeItemId); int activeItemQty = PlayerPrefs.GetInt ("activeItemQty"); Debug.Log (activeItemQty); //Get Item string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType; string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo"; string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo"; string shinobiPath = "Prefabs/Item/Shinobi/Shinobi"; char[] delimiterChars = { ',' }; if (activeItemGrp == "item") { //Cyouhei if (activeItemType.Contains ("Cyouhei") == true) { string newCyouheiString = ""; makeItemIcon (cyouheiPath, activeItemId.ToString (), itemListObj); if (activeItemType.Contains ("YR") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiYR"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiYR", newCyouheiString); } else if (activeItemType.Contains ("KB") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiKB"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiKB", newCyouheiString); } else if (activeItemType.Contains ("TP") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiTP"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiTP", newCyouheiString); } else if (activeItemType.Contains ("YM") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiYM"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiYM", newCyouheiString); } //Kanjyo } else if (activeItemType == "Kanjyo") { makeItemIcon (kanjyoPath, activeItemId.ToString (), itemListObj); string newKanjyoString = ""; string kanjyoString = PlayerPrefs.GetString ("kanjyo"); string[] kanjyoList = kanjyoString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (kanjyoList [0]); tempQty = tempQty + activeItemQty; newKanjyoString = tempQty.ToString () + "," + kanjyoList [1] + "," + kanjyoList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (kanjyoList [1]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList [0] + "," + tempQty.ToString () + "," + kanjyoList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (kanjyoList [2]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList [0] + "," + kanjyoList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("kanjyo", newKanjyoString); //Hidensyo } else if (activeItemType == "Hidensyo") { makeItemIcon (hidensyoPath, activeItemId.ToString (), itemListObj); if (activeItemId == 1) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoGe"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoGe", hidensyoQty); } else if (activeItemId == 2) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoCyu"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoCyu", hidensyoQty); } else if (activeItemId == 3) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoJyo"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoJyo", hidensyoQty); } //Shinobi } else if (activeItemType == "Shinobi") { makeItemIcon (shinobiPath, activeItemId.ToString (), itemListObj); RectTransform rect = itemListObj.transform.FindChild ("itemIcon").transform.FindChild ("Shinobi").GetComponent<RectTransform> (); rect.sizeDelta = new Vector2 (100, 100); if (activeItemId == 1) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiGe"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiGe", newQty); } else if (activeItemId == 2) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiCyu"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiCyu", newQty); } else if (activeItemId == 3) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiJyo"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiJyo", newQty); } //tech } else if (activeItemType == "tech") { string path = "Prefabs/Item/Tech/Tech"; GameObject tech = Instantiate (Resources.Load (path)) as GameObject; tech.transform.SetParent (itemListObj.transform); tech.transform.localScale = new Vector2 (0.4f, 0.4f); RectTransform techTransform = tech.GetComponent<RectTransform> (); techTransform.sizeDelta = new Vector2 (100, 100); techTransform.anchoredPosition3D = new Vector3 (650, 110, 0); tech.GetComponent<Button> ().enabled = false; string spritePath = ""; if (activeItemId == 1) { //TP int qty = PlayerPrefs.GetInt ("transferTP", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferTP", newQty); spritePath = "Prefabs/Item/Tech/Sprite/tp"; } else if (activeItemId == 2) { int qty = PlayerPrefs.GetInt ("transferKB", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferKB", newQty); spritePath = "Prefabs/Item/Tech/Sprite/kb"; } else if (activeItemId == 3) { int qty = PlayerPrefs.GetInt ("transferSNB", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferSNB", newQty); spritePath = "Prefabs/Item/Tech/Sprite/snb"; } tech.GetComponent<Image> ().sprite = Resources.Load (spritePath, typeof(Sprite)) as Sprite; //cyoutei or koueki } else if (activeItemType == "cyoutei" || activeItemType == "koueki") { if (activeItemType == "cyoutei") { string syoukaijyoPath = "Prefabs/Item/cyoutei"; GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; if (activeItemId == 1) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "山科言継"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下"; } else if (activeItemId == 2) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "三条西実枝"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中"; } else if (activeItemId == 3) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "近衛前久"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上"; } } else if (activeItemType == "koueki") { string syoukaijyoPath = "Prefabs/Item/koueki"; GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; if (activeItemId == 1) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "加藤浄与"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下"; } else if (activeItemId == 2) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "島井宗室"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中"; } else if (activeItemId == 3) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "茶屋四郎次郎"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上"; } } TabibitoItemGetter syoukaijyo = new TabibitoItemGetter (); syoukaijyo.registerKouekiOrCyoutei (activeItemType, activeItemId); } else if (activeItemType == "Tama") { string path = "Prefabs/Item/Tama"; GameObject icon = Instantiate (Resources.Load (path)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; int nowQty = PlayerPrefs.GetInt ("busyoDama"); int newQty = nowQty + activeItemQty; PlayerPrefs.SetInt ("busyoDama", newQty); } } else if (activeItemGrp == "kahou") { //Kahou string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId; GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject; kahouIcon.transform.SetParent (itemListObj.transform); kahouIcon.name = "itemIcon"; kahouIcon.transform.localPosition = new Vector3 (250, 35, 0); kahouIcon.transform.localScale = new Vector2 (0.4f, 0.4f); RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> (); kahouTransform.sizeDelta = new Vector2 (100, 100); GameObject rank = kahouIcon.transform.FindChild ("Rank").gameObject; rank.transform.localScale = new Vector2 (0.3f, 0.3f); rank.transform.localPosition = new Vector2 (20, -20); //Register addKahou (activeItemType, activeItemId); } //Qty string itemQtyPath = "Prefabs/PostKassen/itemQty"; GameObject itemQtyObj = Instantiate (Resources.Load (itemQtyPath)) as GameObject; itemQtyObj.transform.SetParent (itemListObj.transform); itemQtyObj.transform.localScale = new Vector2 (0.09f, 0.09f); itemQtyObj.transform.localPosition = new Vector2 (290, 35); itemQtyObj.GetComponent<Text> ().text = "x " + activeItemQty.ToString (); PlayerPrefs.Flush (); } } else { itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "成功"; } //Money int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0); GameObject.Find ("moneyAmt").GetComponent<Text>().text = activeStageMoney.ToString(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + activeStageMoney; PlayerPrefs.SetInt("money",currentMoney); //kuniExp int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0); GameObject.Find ("expAmt").GetComponent<Text>().text = activeStageExp.ToString(); int currentKuniExp = PlayerPrefs.GetInt ("kuniExp"); currentKuniExp = currentKuniExp + activeStageExp; int kuniLv = PlayerPrefs.GetInt ("kuniLv"); Exp kuniExp = new Exp(); int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp); if(newKuniLv>kuniLv){ //lv up int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv); int stockLimit = kuniExp.getStockLimit(newKuniLv); PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit); PlayerPrefs.SetInt("stockLimit",stockLimit); }else{ Debug.Log ("No level up"); } /*Cleared Flag*/ if(!isAttackedFlg){ int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); int activeStageId = PlayerPrefs.GetInt("activeStageId"); string temp = "kuni" + activeKuniId.ToString(); List<string> clearedStageList = new List<string>(); string clearedStageString = PlayerPrefs.GetString(temp); if(clearedStageString !=null && clearedStageString !=""){ //after 1st time char[] delimiterChars = {','}; clearedStageList = new List<string>(clearedStageString.Split (delimiterChars)); if(clearedStageList.Contains(activeStageId.ToString()) == false){ clearedStageString = clearedStageString + "," + activeStageId.ToString(); //1st Kuni Clear Check string[] commaCounter = clearedStageString.Split(delimiterChars); int counter = commaCounter.Length; if(counter == 10){ //1st time string clearedKuni = PlayerPrefs.GetString("clearedKuni"); if(clearedKuni !=null && clearedKuni !=""){ clearedKuni = clearedKuni + "," + activeKuniId.ToString(); }else{ clearedKuni = activeKuniId.ToString(); } PlayerPrefs.SetString("clearedKuni",clearedKuni); //Give 1st cleared revenue PlayerPrefs.SetBool("kuniClearedFlg",true); //Open Kuni KuniInfo kuni = new KuniInfo(); kuni.registerOpenKuni(activeKuniId); //Seiryoku Change string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); seiryokuList[activeKuniId-1] = myDaimyo.ToString(); string newSeiryoku = ""; bool gameClearFlg = true; for(int i=0; i<seiryokuList.Count; i++){ if(i==0){ newSeiryoku = seiryokuList[i]; }else{ newSeiryoku = newSeiryoku + "," + seiryokuList[i]; } //game clear check if(gameClearFlg){ if(seiryokuList[i] != myDaimyo.ToString()){ gameClearFlg = false; } } } PlayerPrefs.SetBool("gameClearFlg",gameClearFlg); PlayerPrefs.SetString("seiryoku",newSeiryoku); //Cyouhou Delete string cyouhouTmp = "cyouhou" + activeKuniId; if (PlayerPrefs.HasKey (cyouhouTmp)) { PlayerPrefs.DeleteKey(cyouhouTmp); string cyouhou = PlayerPrefs.GetString("cyouhou"); List<string> cyouhouList = new List<string> (); if (cyouhou != null && cyouhou != "") { if(cyouhou.Contains(",")){ cyouhouList = new List<string> (cyouhou.Split (delimiterChars)); }else{ cyouhouList.Add(cyouhou); } } cyouhouList.Remove (activeKuniId.ToString()); string newCyouhou = ""; for(int j=0;j<cyouhouList.Count;j++){ if (j == 0) { newCyouhou = cyouhouList[j]; } else { newCyouhou = newCyouhou + "," + cyouhouList[j]; } } PlayerPrefs.SetString ("cyouhou",newCyouhou); } } } }else{ //1st time clearedStageString = activeStageId.ToString(); } PlayerPrefs.SetString(temp,clearedStageString); PlayerPrefs.SetInt("kuniLv",newKuniLv); PlayerPrefs.SetInt("kuniExp",currentKuniExp); PlayerPrefs.Flush(); } //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.SetParent (canvas.transform); bttnListObj.transform.localScale = new Vector2(1,1); bttnListObj.transform.localPosition = new Vector2 (0,0); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //Get Exp SenkouButton senkou = new SenkouButton(); List<BusyoSenkou> senkouList = new List<BusyoSenkou>(); senkouList=senkou.getSenkou (); for(int i=0;i<senkouList.Count;i++){ int busyoId = senkouList[i].id; int senkouAmt = senkouList[i].senkou; Exp exp = new Exp(); //Modify by Cyadougu Kahou senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt); //Busyo Exp string tempExp = "exp" + busyoId; int nowExp = PlayerPrefs.GetInt(tempExp); int newExp = nowExp + senkouAmt; PlayerPrefs.SetInt(tempExp, newExp); //Busyo Lv int nowLv = PlayerPrefs.GetInt(busyoId.ToString()); int newLv = exp.getLvbyTotalExp(nowLv,newExp); PlayerPrefs.SetInt(busyoId.ToString(), newLv); PlayerPrefs.Flush(); } } } } }
private void Update() { if (!paused) { timer -= Time.deltaTime; if (timer > 0.0f) { //On Play gameObject.transform.FindChild("timerText").GetComponent <Text>().text = ((int)timer).ToString(); //Engun Time if (!engunTimerflg) { if (timer < engunTime) { engunTimerflg = true; if (playerEngunFlg) { playerEngunInstance(playerEngunList, mntMinusRatio, seaMinusRatio, rainMinusRatio, snowMinusRatio); } if (enemyEngunFlg) { enemyEngunInstance(enemyEngunList, mntMinusRatio, seaMinusRatio, rainMinusRatio, snowMinusRatio); } } } //cyouryaku if (!cyouryakuFlg) { if (timer < cyouryakuTime) { cyouryakuFlg = true; cyouryaku(cyouryakuHeiQty, cyouryakuTmp); } } } else { if (!flag) { Time.timeScale = 1; audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [5].Play(); GameObject canvas = GameObject.Find("Canvas").gameObject; //Player battle stop canvas.transform.FindChild("playerHp").GetComponent <HPCounter> ().flag = true; canvas.transform.FindChild("enemyHp").GetComponent <HPCounter> ().flag = true; //Enable Button if (GameObject.Find("ScrollView")) { GameObject.Find("ScrollView").SetActive(false); } if (GameObject.Find("GiveupBtn")) { GameObject.Find("GiveupBtn").SetActive(false); } if (!isAttackedFlg) { //Player Attacked //Game Over string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load(backPath)) as GameObject; backObj.transform.SetParent(canvas.transform); backObj.transform.localScale = new Vector2(70, 63); backObj.transform.localPosition = new Vector2(0, 0); //Chane word Color color = Color.blue; if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("winlose").GetComponent <TextMesh> ().text = "Timeup"; } else { GameObject.Find("winlose").GetComponent <TextMesh>().text = "時間切れ"; } GameObject.Find("winlose").GetComponent <TextMesh> ().color = color; audioSources [4].Play(); busouKaijyo(); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load(blackPath)) as GameObject; blackObj.transform.SetParent(canvas.transform); blackObj.transform.localScale = new Vector2(330, 300); blackObj.transform.localPosition = new Vector2(0, 0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load(makimonoPath)) as GameObject; makimonoObj.transform.SetParent(canvas.transform); makimonoObj.transform.localScale = new Vector2(1, 1); makimonoObj.transform.localPosition = new Vector2(0, -135); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject; bttnListObj.transform.SetParent(canvas.transform); bttnListObj.transform.localScale = new Vector2(1, 1); bttnListObj.transform.localPosition = new Vector2(0, 0); bool isKessenFlg = PlayerPrefs.GetBool("isKessenFlg"); if (isKessenFlg) { HPCounter kessen = new HPCounter(); kessen.kessenResult(false); } } else { //Enemy Attacked //history if (Application.loadedLevelName != "tutorialKassen") { string tKey = PlayerPrefs.GetString("activeKey"); MainStageController main = new MainStageController(); main.deleteKeyHistory(tKey); PlayerPrefs.DeleteKey("isAttacked"); PlayerPrefs.Flush(); bool twiceHeiFlg = PlayerPrefs.GetBool("twiceHeiFlg"); if (twiceHeiFlg) { PlayerPrefs.SetBool("questDailyFlg15", true); PlayerPrefs.DeleteKey("twiceHeiFlg"); PlayerPrefs.Flush(); } //View string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load(backPath)) as GameObject; backObj.transform.SetParent(canvas.transform); backObj.transform.localScale = new Vector2(70, 63); backObj.transform.localPosition = new Vector2(0, 0); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load(particlePath)) as GameObject; particleObj.transform.SetParent(canvas.transform); particleObj.transform.localPosition = new Vector2(0, 60); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load(blackPath)) as GameObject; blackObj.transform.SetParent(canvas.transform); blackObj.transform.localScale = new Vector2(330, 300); blackObj.transform.localPosition = new Vector2(0, 0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load(makimonoPath)) as GameObject; makimonoObj.transform.SetParent(canvas.transform); makimonoObj.transform.localScale = new Vector2(1, 1); makimonoObj.transform.localPosition = new Vector2(0, -135); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("winlose").GetComponent <TextMesh> ().text = "Timeup"; } else { GameObject.Find("winlose").GetComponent <TextMesh>().text = "時勝切れ"; } string stageName = PlayerPrefs.GetString("activeStageName"); audioSources [3].Play(); audioSources [7].Play(); busouKaijyo(); //Item List string itemListPath = "Prefabs/PostKassen/itemList"; GameObject itemListObj = Instantiate(Resources.Load(itemListPath)) as GameObject; itemListObj.transform.SetParent(canvas.transform); itemListObj.transform.localScale = new Vector2(1, 1); itemListObj.transform.localPosition = new Vector2(0, -136); //Money int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney", 0); GameObject.Find("moneyAmt").GetComponent <Text>().text = activeStageMoney.ToString(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + activeStageMoney; if (currentMoney < 0) { currentMoney = int.MaxValue; } PlayerPrefs.SetInt("money", currentMoney); //kuniExp int activeStageExp = PlayerPrefs.GetInt("activeStageExp", 0); GameObject.Find("expAmt").GetComponent <Text>().text = activeStageExp.ToString(); int currentKuniExp = PlayerPrefs.GetInt("kuniExp"); currentKuniExp = currentKuniExp + activeStageExp; int kuniLv = PlayerPrefs.GetInt("kuniLv"); Exp kuniExp = new Exp(); int newKuniLv = kuniExp.getKuniLv(kuniLv, currentKuniExp); if (newKuniLv > kuniLv) { //lv up int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv); int stockLimit = kuniExp.getStockLimit(newKuniLv); PlayerPrefs.SetInt("jinkeiLimit", jinkeiLimit); PlayerPrefs.SetInt("stockLimit", stockLimit); } else { Debug.Log("No level up"); } //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject; bttnListObj.transform.SetParent(canvas.transform); bttnListObj.transform.localScale = new Vector2(1, 1); bttnListObj.transform.localPosition = new Vector2(0, 0); if (Application.systemLanguage != SystemLanguage.Japanese) { itemListObj.transform.FindChild("stageName").transform.FindChild("stageNameValue").GetComponent <Text> ().text = stageName + " Succeed"; } else { itemListObj.transform.FindChild("stageName").transform.FindChild("stageNameValue").GetComponent <Text>().text = stageName + "成功"; } //Get Exp SenkouButton senkou = new SenkouButton(); List <BusyoSenkou> senkouList = new List <BusyoSenkou>(); senkouList = senkou.getSenkou(); for (int i = 0; i < senkouList.Count; i++) { int busyoId = senkouList[i].id; int senkouAmt = senkouList[i].senkou; Exp exp = new Exp(); //Modify by Cyadougu Kahou senkouAmt = exp.getExpbyCyadougu(busyoId, senkouAmt); //Busyo Exp string tempExp = "exp" + busyoId; int nowExp = PlayerPrefs.GetInt(tempExp); int newExp = nowExp + senkouAmt; PlayerPrefs.SetInt(tempExp, newExp); //Busyo Lv int nowLv = PlayerPrefs.GetInt(busyoId.ToString()); string addLvTmp = "addlv" + busyoId.ToString(); int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp); if (maxLv > 200) { maxLv = 200; } int newLv = exp.getLvbyTotalExp(nowLv, newExp, maxLv); PlayerPrefs.SetInt(busyoId.ToString(), newLv); PlayerPrefs.Flush(); } } else { busouKaijyo(); string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load(backPath)) as GameObject; backObj.transform.SetParent(canvas.transform); backObj.transform.localScale = new Vector2(70, 63); backObj.transform.localPosition = new Vector2(0, 0); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load(blackPath)) as GameObject; blackObj.transform.SetParent(canvas.transform); blackObj.transform.localScale = new Vector2(330, 300); blackObj.transform.localPosition = new Vector2(0, 0); string nextbtnPath = "Prefabs/Tutorial/tutorialBttnList"; GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject; bttnListObj.transform.SetParent(canvas.transform); bttnListObj.transform.localScale = new Vector2(1, 1); bttnListObj.transform.localPosition = new Vector2(0, 20); //Win audioSources[3].Play(); audioSources[7].Play(); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load(particlePath)) as GameObject; particleObj.transform.SetParent(canvas.transform); particleObj.transform.localPosition = new Vector2(0, 60); } } //Time Stop GameObject.Find("timer").GetComponent <Timer> ().enabled = false; flag = true; PlayerPrefs.Flush(); } } } }
// Update is called once per frame void Update () { life = getTotalHp (targetTag); gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString(); if (!flag) { if (life == 0) { flag = true; if (targetTag == "Player") { //Game Over string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.parent = GameObject.Find ("Canvas").transform; backObj.transform.localScale = new Vector2(70,63); //Chane word Color color = Color.blue; GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北"; GameObject.Find ("winlose").GetComponent<TextMesh>().color = color; string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.parent = GameObject.Find ("Canvas").transform; blackObj.transform.localScale = new Vector2(330,300); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.parent = GameObject.Find ("Canvas").transform; makimonoObj.transform.localScale = new Vector2(60,80); makimonoObj.transform.localPosition = new Vector2(0,-130); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.parent = GameObject.Find ("Canvas").transform; bttnListObj.transform.localScale = new Vector2(1,1); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; Debug.Log (isAttackedFlg); //Check is attacked flag if(isAttackedFlg == true){ //My Daimyo Lose Gunzei lose = new Gunzei(); string tKey = PlayerPrefs.GetString("activeKey"); int tSrcDaimyoId = PlayerPrefs.GetInt("activeSrcDaimyoId"); int tDstDaimyoId = PlayerPrefs.GetInt("activeDstDaimyoId"); bool noGunzeiFlg = true; PlayerPrefs.DeleteKey("isAttacked"); lose.win(tKey, tSrcDaimyoId, tDstDaimyoId,noGunzeiFlg); //Delete Cleared Kuni int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); string clearedKuni = PlayerPrefs.GetString("clearedKuni"); char[] delimiterChars = {','}; List<string> clearedKuniList = new List<string>(); if (clearedKuni != null && clearedKuni != "") { if(clearedKuni.Contains(",")){ clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars)); }else{ clearedKuniList.Add(clearedKuni); } } Debug.Log ("before:"+clearedKuniList.Count); string tempActiveKuni = activeKuniId.ToString(); clearedKuniList.Remove(tempActiveKuni); Debug.Log ("after:"+clearedKuniList.Count); string newClearedKuni = ""; for(int i=0; i<clearedKuniList.Count; i++){ if(i==0){ newClearedKuni = clearedKuniList[i]; }else{ newClearedKuni = newClearedKuni + "," + clearedKuniList[i]; } } PlayerPrefs.SetString("clearedKuni",newClearedKuni); Debug.Log ("NewClearedKuni:"+newClearedKuni); if(newClearedKuni==null || newClearedKuni == ""){ PlayerPrefs.SetBool("gameOverFlg",true); Debug.Log ("gameOverFlg"); } //Delete Naisei string tempNaisei = "naisei" + activeKuniId.ToString(); PlayerPrefs.DeleteKey(tempNaisei); //Delete Jyosyu string tempJyosyu = "jyosyu" + activeKuniId.ToString(); PlayerPrefs.DeleteKey(tempJyosyu); //Delete Stage Clear string tempKuni = "kuni" + activeKuniId.ToString(); PlayerPrefs.DeleteKey(tempKuni); //Delete open KuniInfo kuni = new KuniInfo(); kuni.updateOpenKuni(); PlayerPrefs.Flush(); } } else if (targetTag == "Enemy") { //Win if(isAttackedFlg == true){ //history string tKey = PlayerPrefs.GetString("activeKey"); MainStageController main = new MainStageController(); main.deleteKeyHistory(tKey); PlayerPrefs.DeleteKey("isAttacked"); PlayerPrefs.Flush(); } string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.parent = GameObject.Find ("Canvas").transform; backObj.transform.localScale = new Vector2(70,63); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject; particleObj.transform.parent = GameObject.Find ("Canvas").transform; particleObj.transform.localPosition = new Vector2(0,60); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.parent = GameObject.Find ("Canvas").transform; blackObj.transform.localScale = new Vector2(330,300); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.parent = GameObject.Find ("Canvas").transform; makimonoObj.transform.localScale = new Vector2(60,80); makimonoObj.transform.localPosition = new Vector2(0,-130); //Item List string itemListPath = "Prefabs/PostKassen/itemList"; GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject; itemListObj.transform.parent = GameObject.Find ("Canvas").transform; itemListObj.transform.localScale = new Vector2(1,1); if(!isAttackedFlg){ /*Item or Kahou*/ string activeItemType = PlayerPrefs.GetString("activeItemType"); int activeItemId = PlayerPrefs.GetInt("activeItemId"); float activeItemRatio = PlayerPrefs.GetFloat("activeItemRatio"); int activeItemQty = PlayerPrefs.GetInt("activeItemQty"); float percent = Random.value; percent = percent * 100; if(percent <= activeItemRatio){ //if(0 <= activeItemRatio){ //Test //Get Item string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType; string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo"; string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo"; char[] delimiterChars = {','}; ShowStageDtl itemIcon = new ShowStageDtl(); if(activeItemType.Contains("Cyouhei")==true){ string newCyouheiString = ""; itemIcon.makeItemIcon(cyouheiPath, activeItemId.ToString(), itemListObj); if(activeItemType.Contains("YR")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiYR"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiYR", newCyouheiString); }else if(activeItemType.Contains("KB")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiKB"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiKB", newCyouheiString); }else if(activeItemType.Contains("TP")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiTP"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiTP", newCyouheiString); }else if(activeItemType.Contains("YM")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiYM"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiYM", newCyouheiString); } }else if(activeItemType == "Kanjyo"){ itemIcon.makeItemIcon(kanjyoPath, activeItemId.ToString(), itemListObj); string newKanjyoString = ""; string kanjyoString = PlayerPrefs.GetString("kanjyo"); string[] kanjyoList = kanjyoString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(kanjyoList[0]); tempQty = tempQty + activeItemQty; newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] +","+ kanjyoList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(kanjyoList[1]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList[0] + "," + tempQty.ToString() +","+ kanjyoList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(kanjyoList[2]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList[0] +","+ kanjyoList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("kanjyo", newKanjyoString); }else if(activeItemType == "Hidensyo"){ itemIcon.makeItemIcon(hidensyoPath, activeItemId.ToString(), itemListObj); if(activeItemId == 1){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoGe"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoGe", hidensyoQty); }else if(activeItemId == 2){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoCyu"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoCyu", hidensyoQty); }else if(activeItemId == 3){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoJyo"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoJyo", hidensyoQty); } }else{ //Kahou string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId; GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject; kahouIcon.transform.SetParent(itemListObj.transform); kahouIcon.name = "itemIcon"; RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> (); kahouTransform.sizeDelta = new Vector2 (100, 100); GameObject rank = kahouIcon.transform.FindChild("Rank").gameObject; rank.transform.localScale = new Vector2(0.3f,0.3f); rank.transform.localPosition = new Vector2(20,-20); //Register addKahou(activeItemType, activeItemId); } //Modfication Size & Location GameObject item = GameObject.Find ("itemIcon"); item.transform.localScale = new Vector2 (0.4f, 0.42f); item.transform.localPosition = new Vector2(80,-105); item.GetComponent<Button>().enabled = false; //Qty string itemQtyPath = "Prefabs/PostKassen/itemQty"; GameObject itemQtyObj = Instantiate(Resources.Load (itemQtyPath)) as GameObject; itemQtyObj.transform.SetParent(itemListObj.transform); itemQtyObj.transform.localScale = new Vector2(0.09f,0.09f); itemQtyObj.transform.localPosition = new Vector2(130,-105); itemQtyObj.GetComponent<Text>().text = "x " + activeItemQty.ToString(); // PlayerPrefs.Flush(); } } //Money int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0); GameObject.Find ("moneyAmt").GetComponent<TextMesh>().text = activeStageMoney.ToString(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + activeStageMoney; PlayerPrefs.SetInt("money",currentMoney); //kuniExp int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0); GameObject.Find ("expAmt").GetComponent<TextMesh>().text = activeStageExp.ToString(); int currentKuniExp = PlayerPrefs.GetInt ("kuniExp"); currentKuniExp = currentKuniExp + activeStageExp; int kuniLv = PlayerPrefs.GetInt ("kuniLv"); Exp kuniExp = new Exp(); int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp); if(newKuniLv>kuniLv){ //lv up int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv); int stockLimit = kuniExp.getStockLimit(newKuniLv); PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit); PlayerPrefs.SetInt("stockLimit",stockLimit); }else{ Debug.Log ("No level up"); } /*Cleared Flag*/ if(!isAttackedFlg){ int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); int activeStageId = PlayerPrefs.GetInt("activeStageId"); string temp = "kuni" + activeKuniId.ToString(); List<string> clearedStageList = new List<string>(); string clearedStageString = PlayerPrefs.GetString(temp); if(clearedStageString !=null && clearedStageString !=""){ //after 1st time char[] delimiterChars = {','}; clearedStageList = new List<string>(clearedStageString.Split (delimiterChars)); if(clearedStageList.Contains(activeStageId.ToString()) == false){ clearedStageString = clearedStageString + "," + activeStageId.ToString(); //1st Kuni Clear Check string[] commaCounter = clearedStageString.Split(delimiterChars); int counter = commaCounter.Length; if(counter == 10){ //1st time string clearedKuni = PlayerPrefs.GetString("clearedKuni"); if(clearedKuni !=null && clearedKuni !=""){ clearedKuni = clearedKuni + "," + activeKuniId.ToString(); }else{ clearedKuni = activeKuniId.ToString(); } PlayerPrefs.SetString("clearedKuni",clearedKuni); //Give 1st cleared revenue PlayerPrefs.SetBool("kuniClearedFlg",true); //Open Kuni KuniInfo kuni = new KuniInfo(); kuni.registerOpenKuni(activeKuniId); //Seiryoku Change string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); seiryokuList[activeKuniId-1] = myDaimyo.ToString(); string newSeiryoku = ""; for(int i=0; i<seiryokuList.Count; i++){ if(i==0){ newSeiryoku = seiryokuList[i]; }else{ newSeiryoku = newSeiryoku + "," + seiryokuList[i]; } } PlayerPrefs.SetString("seiryoku",newSeiryoku); } } }else{ //1st time clearedStageString = activeStageId.ToString(); Debug.Log (clearedStageString); } PlayerPrefs.SetString(temp,clearedStageString); PlayerPrefs.SetInt("kuniLv",newKuniLv); PlayerPrefs.SetInt("kuniExp",currentKuniExp); PlayerPrefs.Flush(); } //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.parent = GameObject.Find ("Canvas").transform; bttnListObj.transform.localScale = new Vector2(1,1); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //Get Exp SenkouButton senkou = new SenkouButton(); List<BusyoSenkou> senkouList = new List<BusyoSenkou>(); senkouList=senkou.getSenkou (); for(int i=0;i<senkouList.Count;i++){ int busyoId = senkouList[i].id; int senkouAmt = senkouList[i].senkou; Exp exp = new Exp(); //Modify by Cyadougu Kahou senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt); //Busyo Exp string tempExp = "exp" + busyoId; int nowExp = PlayerPrefs.GetInt(tempExp); int newExp = nowExp + senkouAmt; PlayerPrefs.SetInt(tempExp, newExp); //Busyo Lv int nowLv = PlayerPrefs.GetInt(busyoId.ToString()); int newLv = exp.getLvbyTotalExp(nowLv,newExp); PlayerPrefs.SetInt(busyoId.ToString(), newLv); PlayerPrefs.Flush(); } } } } }