示例#1
0
    public void registerItemQty(string itemGrp, string itemType, int itemId, int itemQty)
    {
        char[] delimiterChars = { ',' };

        if (itemGrp == "item")
        {
            //Cyouhei
            if (itemType.Contains("Cyouhei") == true)
            {
                string newCyouheiString = "";

                if (itemType.Contains("YR") == true)
                {
                    string   cyouheiString = PlayerPrefs.GetString("cyouheiYR");
                    string[] cyouheiList   = cyouheiString.Split(delimiterChars);
                    if (itemId == 1)
                    {
                        int tempQty = int.Parse(cyouheiList[0]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] + "," + cyouheiList[2];
                    }
                    else if (itemId == 2)
                    {
                        int tempQty = int.Parse(cyouheiList[1]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() + "," + cyouheiList[2];
                    }
                    else if (itemId == 3)
                    {
                        int tempQty = int.Parse(cyouheiList[2]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + cyouheiList[1] + "," + tempQty.ToString();
                    }

                    PlayerPrefs.SetString("cyouheiYR", newCyouheiString);
                }
                else if (itemType.Contains("KB") == true)
                {
                    string   cyouheiString = PlayerPrefs.GetString("cyouheiKB");
                    string[] cyouheiList   = cyouheiString.Split(delimiterChars);
                    if (itemId == 1)
                    {
                        int tempQty = int.Parse(cyouheiList[0]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] + "," + cyouheiList[2];
                    }
                    else if (itemId == 2)
                    {
                        int tempQty = int.Parse(cyouheiList[1]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() + "," + cyouheiList[2];
                    }
                    else if (itemId == 3)
                    {
                        int tempQty = int.Parse(cyouheiList[2]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + cyouheiList[1] + "," + tempQty.ToString();
                    }

                    PlayerPrefs.SetString("cyouheiKB", newCyouheiString);
                }
                else if (itemType.Contains("TP") == true)
                {
                    string   cyouheiString = PlayerPrefs.GetString("cyouheiTP");
                    string[] cyouheiList   = cyouheiString.Split(delimiterChars);
                    if (itemId == 1)
                    {
                        int tempQty = int.Parse(cyouheiList[0]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] + "," + cyouheiList[2];
                    }
                    else if (itemId == 2)
                    {
                        int tempQty = int.Parse(cyouheiList[1]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() + "," + cyouheiList[2];
                    }
                    else if (itemId == 3)
                    {
                        int tempQty = int.Parse(cyouheiList[2]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + cyouheiList[1] + "," + tempQty.ToString();
                    }

                    PlayerPrefs.SetString("cyouheiTP", newCyouheiString);
                }
                else if (itemType.Contains("YM") == true)
                {
                    string   cyouheiString = PlayerPrefs.GetString("cyouheiYM");
                    string[] cyouheiList   = cyouheiString.Split(delimiterChars);
                    if (itemId == 1)
                    {
                        int tempQty = int.Parse(cyouheiList[0]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] + "," + cyouheiList[2];
                    }
                    else if (itemId == 2)
                    {
                        int tempQty = int.Parse(cyouheiList[1]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() + "," + cyouheiList[2];
                    }
                    else if (itemId == 3)
                    {
                        int tempQty = int.Parse(cyouheiList[2]);
                        tempQty          = tempQty + 1;
                        newCyouheiString = cyouheiList[0] + "," + cyouheiList[1] + "," + tempQty.ToString();
                    }

                    PlayerPrefs.SetString("cyouheiYM", newCyouheiString);
                }


                //Kanjyo
            }
            else if (itemType == "Kanjyo")
            {
                string   newKanjyoString = "";
                string   kanjyoString    = PlayerPrefs.GetString("kanjyo");
                string[] kanjyoList      = kanjyoString.Split(delimiterChars);

                if (itemId == 1)
                {
                    int tempQty = int.Parse(kanjyoList[0]);
                    tempQty         = tempQty + 1;
                    newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] + "," + kanjyoList[2];
                }
                else if (itemId == 2)
                {
                    int tempQty = int.Parse(kanjyoList[1]);
                    tempQty         = tempQty + 1;
                    newKanjyoString = kanjyoList[0] + "," + tempQty.ToString() + "," + kanjyoList[2];
                }
                else if (itemId == 3)
                {
                    int tempQty = int.Parse(kanjyoList[2]);
                    tempQty         = tempQty + 1;
                    newKanjyoString = kanjyoList[0] + "," + kanjyoList[1] + "," + tempQty.ToString();
                }
                PlayerPrefs.SetString("kanjyo", newKanjyoString);

                //Hidensyo
            }
            else if (itemType == "Hidensyo")
            {
                if (itemId == 1)
                {
                    int hidensyoQty = PlayerPrefs.GetInt("hidensyoGe");
                    hidensyoQty = hidensyoQty + 1;
                    PlayerPrefs.SetInt("hidensyoGe", hidensyoQty);
                }
                else if (itemId == 2)
                {
                    int hidensyoQty = PlayerPrefs.GetInt("hidensyoCyu");
                    hidensyoQty = hidensyoQty + 1;
                    PlayerPrefs.SetInt("hidensyoCyu", hidensyoQty);
                }
                else if (itemId == 3)
                {
                    int hidensyoQty = PlayerPrefs.GetInt("hidensyoJyo");
                    hidensyoQty = hidensyoQty + 1;
                    PlayerPrefs.SetInt("hidensyoJyo", hidensyoQty);
                }

                //Shinobi
            }
            else if (itemType == "Shinobi")
            {
                if (itemId == 1)
                {
                    int newQty     = 0;
                    int shinobiQty = PlayerPrefs.GetInt("shinobiGe");
                    newQty = shinobiQty + 1;
                    PlayerPrefs.SetInt("shinobiGe", newQty);
                }
                else if (itemId == 2)
                {
                    int newQty     = 0;
                    int shinobiQty = PlayerPrefs.GetInt("shinobiCyu");
                    newQty = shinobiQty + 1;
                    PlayerPrefs.SetInt("shinobiCyu", newQty);
                }
                else if (itemId == 3)
                {
                    int newQty     = 0;
                    int shinobiQty = PlayerPrefs.GetInt("shinobiJyo");
                    newQty = shinobiQty + 1;
                    PlayerPrefs.SetInt("shinobiJyo", newQty);
                }

                //tech
            }
            else if (itemType == "tech")
            {
                if (itemId == 1)
                {
                    //TP
                    int qty    = PlayerPrefs.GetInt("transferTP", 0);
                    int newQty = qty + 1;
                    PlayerPrefs.SetInt("transferTP", newQty);
                }
                else if (itemId == 2)
                {
                    int qty    = PlayerPrefs.GetInt("transferKB", 0);
                    int newQty = qty + 1;
                    PlayerPrefs.SetInt("transferKB", newQty);
                }
                else if (itemId == 3)
                {
                    int qty    = PlayerPrefs.GetInt("transferSNB", 0);
                    int newQty = qty + 1;
                    PlayerPrefs.SetInt("transferSNB", newQty);
                }

                //cyoutei or koueki
            }
            else if (itemType == "cyoutei" || itemType == "koueki")
            {
                TabibitoItemGetter syoukaijyo = new TabibitoItemGetter();
                syoukaijyo.registerKouekiOrCyoutei(itemType, itemId);
            }
            else if (itemType == "Tama")
            {
                int nowQty = PlayerPrefs.GetInt("busyoDama");
                int newQty = nowQty + itemQty;
                PlayerPrefs.SetInt("busyoDama", newQty);
                GameObject.Find("BusyoDamaValue").GetComponent <Text>().text = newQty.ToString();
            }
        }
        else if (itemGrp == "kahou")
        {
            HPCounter addKahouScript = new HPCounter();

            //Register
            addKahouScript.addKahou(itemType, itemId);
        }
        PlayerPrefs.Flush();
    }
示例#2
0
	// 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();
					}
				}
			}
		}
	}
示例#3
0
    public void OnClick()
    {
        onOffTabibitoMove(true);


        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [0].Play();

        string     pathOfBack = "Prefabs/Busyo/Back";
        GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;

        back.transform.parent        = GameObject.Find("Panel").transform;
        back.transform.localScale    = new Vector2(1, 1);
        back.transform.localPosition = new Vector2(0, 0);

        string     pathOfBoard = "Prefabs/Naisei/Tabibito/TabibitoBoard";
        GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;

        board.transform.parent        = GameObject.Find("Panel").transform;
        board.transform.localScale    = new Vector2(1, 1);
        board.transform.localPosition = new Vector3(0, 0, 0);

        board.transform.FindChild("GrpValue").GetComponent <Text> ().text = targetGrp;
        board.transform.FindChild("Name").transform.FindChild("NameValue").GetComponent <Text> ().text     = targetName;
        board.transform.FindChild("Rank").transform.FindChild("RankValue").GetComponent <Text> ().text     = targetRank;
        board.transform.FindChild("Serihu").transform.FindChild("SerihuValue").GetComponent <Text> ().text = targetExp;

        board.transform.FindChild("Image").GetComponent <Image> ().sprite = gameObject.transform.parent.gameObject.GetComponent <Image> ().sprite;
        board.transform.FindChild("close").GetComponent <CloseBoard>().tabibitoNoticeBtnFlg = true;
        GameObject.Find("NaiseiController").GetComponent <NaiseiController>().stopFlg       = true;


        //Find Item Icon
        string addPath = itemCd;

        if (itemCd == "nanban")
        {
            itemCd  = itemCd + itemId;
            addPath = itemCd;
        }

        bool kahouFlg = false;

        if (itemCd == "bugu" || itemCd == "kabuto" || itemCd == "gusoku" || itemCd == "meiba" || itemCd == "cyadougu" || itemCd == "chishikisyo" || itemCd == "heihousyo")
        {
            //kahou item
            addPath  = "Kahou/" + itemCd + itemId;
            kahouFlg = true;
        }

        string     pathOfItem = "Prefabs/Item/" + addPath;
        GameObject item       = Instantiate(Resources.Load(pathOfItem)) as GameObject;

        item.transform.SetParent(board.transform);
        if (!kahouFlg)
        {
            item.transform.localScale = new Vector2(1, 1);
        }
        else
        {
            item.transform.localScale            = new Vector2(0.65f, 0.65f);
            item.GetComponent <Button>().enabled = false;
        }
        item.transform.localPosition = new Vector3(-60, -100, 0);

        board.transform.FindChild("Qty").GetComponent <Text> ().text = "x " + itemQty.ToString();


        /*Adjustment*/
        if (itemCd == "CyouheiTP")
        {
            Color lowColor  = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f);
            Color midColor  = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
            Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f);
            if (itemId == 1)
            {
                //Ge
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "Low";
                }
                else
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "下";
                }
                item.GetComponent <Image>().color = lowColor;
            }
            else if (itemId == 2)
            {
                //Cyu
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "Mid";
                }
                else
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "中";
                }
                item.GetComponent <Image>().color = midColor;
            }
            else if (itemId == 3)
            {
                //Jyo
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "High";
                }
                else
                {
                    item.transform.FindChild("CyouheiRank").GetComponent <Text>().text = "上";
                }
                item.GetComponent <Image>().color = highColor;
            }
        }
        //Syoukaijyo
        if (itemCd == "cyoutei" || itemCd == "koueki")
        {
            item.transform.FindChild("Name").GetComponent <Text>().text = targetName;

            if (itemCd == "cyoutei")
            {
                if (targetRank == "S")
                {
                    itemId = 3;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "High";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "上";
                    }
                }
                else if (targetRank == "A")
                {
                    itemId = 2;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "Mid";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "中";
                    }
                }
                else if (targetRank == "B")
                {
                    itemId = 1;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "Low";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "下";
                    }
                }
            }
            else if (itemCd == "koueki")
            {
                if (targetRank == "A")
                {
                    itemId = 3;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "High";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "上";
                    }
                }
                else if (targetRank == "B")
                {
                    itemId = 2;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "Mid";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "中";
                    }
                }
                else if (targetRank == "C")
                {
                    itemId = 1;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "Low";
                    }
                    else
                    {
                        item.transform.FindChild("Rank").GetComponent <Text>().text = "下";
                    }
                }
            }
        }

        //Kengou
        if (itemCd == "kengou")
        {
            if (targetRank == "A")
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "High";
                }
                else
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "上";
                }
            }
            else if (targetRank == "B")
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "Mid";
                }
                else
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "中";
                }
            }
            else if (targetRank == "C")
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "Low";
                }
                else
                {
                    item.transform.FindChild("Rank").GetComponent <Text>().text = "下";
                }
            }
        }


        //Btn Parametor Setting
        TabibitoItemGetter script = board.transform.FindChild("GetButton").GetComponent <TabibitoItemGetter> ();

        script.itemCd    = itemCd;
        script.itemId    = itemId;
        script.itemQty   = itemQty;
        script.popButton = gameObject;
    }