private void Start() { //Init Data Maker userId = PlayerPrefs.GetString("userId"); //userId = "testtphnii20170323113213"; PlayerPrefs.SetString("userId", userId); initDataDoneFlg = PlayerPrefs.GetBool("initDataFlg"); if (!initDataDoneFlg) { if (userId == "" || userId == null) { InitDataMaker initData = transform.FindChild("InitDataMaker").GetComponent <InitDataMaker>(); initData.makeInitData(); } } //User Data Update DataUserId DataUserId = GetComponent <DataUserId>(); DataJinkei DataJinkei = GetComponent <DataJinkei>(); bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg"); if (tutorialDoneFlg) { if (userId == "" || userId == null) { //New UserId string randomA = StringUtils.GeneratePassword(10); System.DateTime now = System.DateTime.Now; string randomB = now.ToString("yyyyMMddHHmmss"); string userId = randomA + randomB; PlayerPrefs.SetString("userId", userId); PlayerPrefs.Flush(); if (Application.internetReachability != NetworkReachability.NotReachable) { DataUserId.InsertUserId(userId); } } else { //Update UserId if (Application.internetReachability != NetworkReachability.NotReachable) { DataUserId.UpdateUserId(userId); DataJinkei.UpdateJinkei(userId); //Reward DataReward DataReward = GetComponent <DataReward>(); DataReward.GetRewardMaster(userId); //Delete Gunzei Data : Rescue DataDelete DataDelete = GetComponent <DataDelete>(); DataDelete.GunzeiDelete(userId); } } } }
// Use this for initialization public void Start () { Resources.UnloadUnusedAssets (); //Data Initialization //DataMaker data = new DataMaker (); //data.Start (); /*Initial Data*/ bool initDataFlg = PlayerPrefs.GetBool ("initDataFlg"); if (initDataFlg == false) { //my daimyo InitDataMaker initData = new InitDataMaker (); initData.makeInitData (); } Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; Entity_kuni_mapping_mst kuniMappingMst = Resources.Load ("Data/kuni_mapping_mst") as Entity_kuni_mapping_mst; Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; //Base Info. int kuniLv = PlayerPrefs.GetInt ("kuniLv"); int money = PlayerPrefs.GetInt ("money"); int busyoDama = PlayerPrefs.GetInt ("busyoDama"); GameObject.Find ("KuniLvValue").GetComponent<Text> ().text = kuniLv.ToString (); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = money.ToString (); GameObject.Find ("BusyoDamaValue").GetComponent<Text> ().text = busyoDama.ToString (); myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); string myDaimyoName = daimyoMst.param [myDaimyo - 1].daimyoName; GameObject.Find ("DaimyoValue").GetComponent<Text> ().text = myDaimyoName; //Kuni List string openKuni = PlayerPrefs.GetString ("openKuni"); List<string> openKuniList = new List<string> (); char[] delimiterChars = {','}; if (openKuni != null && openKuni != "") { if (openKuni.Contains (",")) { openKuniList = new List<string> (openKuni.Split (delimiterChars)); } else { openKuniList.Add (openKuni); } } GameObject kuniIconView = GameObject.Find ("KuniIconView"); string clearedKuni = PlayerPrefs.GetString ("clearedKuni"); List<string> clearedKuniList = new List<string> (); if (clearedKuni != null && clearedKuni != "") { if (clearedKuni.Contains (",")) { clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars)); } else { clearedKuniList.Add (clearedKuni); } } /*View Every Kuni by Master*/ GameObject KuniMap = GameObject.Find ("KuniMap"); //Seiryoku Default Setting string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); //Count my Kuni QTY for (int m=0; m<seiryokuList.Count; m++) { int seiryokuId = int.Parse (seiryokuList [m]); if (seiryokuId == myDaimyo) { myKuniQty = myKuniQty + 1; } } //My Doumei Color doumeiColor = new Color (100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f); //Blue string myDoumei = PlayerPrefs.GetString ("doumei"); List<string> myDoumeiList = new List<string> (); if (myDoumei != null && myDoumei != "") { if(myDoumei.Contains(",")){ myDoumeiList = new List<string> (myDoumei.Split (delimiterChars)); }else{ myDoumeiList.Add(myDoumei); } } string kuniPath = "Prefabs/Map/Kuni/"; for (int i=0; i<kuniMst.param.Count; i++) { int kuniId = kuniMst.param [i].kunId; string newKuniPath = kuniPath + kuniId.ToString (); int locationX = kuniMst.param [i].locationX; int locationY = kuniMst.param [i].locationY; GameObject kuni = Instantiate (Resources.Load (newKuniPath)) as GameObject; kuni.transform.SetParent (kuniIconView.transform); kuni.name = kuniId.ToString (); kuni.GetComponent<SendParam> ().kuniId = kuniId; kuni.GetComponent<SendParam> ().kuniName = kuniMst.param [i].kuniName; kuni.transform.localScale = new Vector2 (1, 1); //Seiryoku Handling int daimyoId = int.Parse (seiryokuList [kuniId - 1]); string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; kuni.GetComponent<SendParam> ().daimyoId = daimyoId; kuni.GetComponent<SendParam> ().daimyoName = daimyoName; int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; kuni.GetComponent<SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp; //Senryoku //Count QTY of Enemy Kuni int enemyKuniQty = 0; for (int l=0; l<seiryokuList.Count; l++) { int seiryokuId = int.Parse (seiryokuList [l]); if (seiryokuId == daimyoId) { enemyKuniQty = enemyKuniQty + 1; } } EnemySenryokuCalc calc = new EnemySenryokuCalc (); int busyoQty = 0; int busyoLv = 0; int butaiQty = 0; int butaiLv = 0; busyoQty = calc.EnemyBusyoQtyCalc (myKuniQty, enemyKuniQty); int senryokuRatio = daimyoMst.param [daimyoId - 1].senryoku; busyoLv = calc.EnemyBusyoLvCalc (senryokuRatio); butaiQty = calc.EnemyButaiQtyCalc (enemyKuniQty); butaiLv = calc.EnemyButaiLvCalc (senryokuRatio); kuni.GetComponent<SendParam> ().busyoQty = busyoQty; kuni.GetComponent<SendParam> ().busyoLv = busyoLv; kuni.GetComponent<SendParam> ().butaiQty = butaiQty; kuni.GetComponent<SendParam> ().butaiLv = butaiLv; kuni.GetComponent<SendParam>().kuniQty = enemyKuniQty; //Color Handling float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); KuniMap.transform.FindChild (kuni.name).GetComponent<Image> ().color = kuniColor; //Daimyo Kamon Image string imagePath = "Prefabs/Kamon/" + daimyoId.ToString (); kuni.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; RectTransform kuniTransform = kuni.GetComponent<RectTransform> (); kuniTransform.anchoredPosition = new Vector3 (locationX, locationY, 0); //My Doumei Check if (myDoumei != null && myDoumei != "") { if(myDoumeiList.Contains(daimyoId.ToString())){ kuni.GetComponent<SendParam> ().doumeiFlg = true; kuni.GetComponent<Image>().color = doumeiColor; } } //My daimyo Check if(daimyoId==myDaimyo){ string myDaimyoPath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString (); kuni.GetComponent<Image> ().sprite = Resources.Load (myDaimyoPath, typeof(Sprite)) as Sprite; kuni.GetComponent<SendParam> ().clearFlg = true; } } //Color Change for kuni icon "Open but never cleared" Color openKuniColor = new Color (255f / 255f, 255f / 255f, 0f / 255f, 255f / 255f); //Yellow for (int i=0; i<openKuniList.Count; i++) { string openKuniId = openKuniList [i]; //Flg Change GameObject targetOpenKuni = GameObject.Find ("KuniIconView").transform.FindChild (openKuniId).gameObject; targetOpenKuni.GetComponent<SendParam> ().openFlg = true; bool doumeiFlg = targetOpenKuni.GetComponent<SendParam>().doumeiFlg; //Color Change if (!clearedKuniList.Contains (openKuniId)) { if(!doumeiFlg){ targetOpenKuni.GetComponent<Image> ().color = openKuniColor; } } } //Clear Kuni Check bool kuniClearedFlg = PlayerPrefs.GetBool ("kuniClearedFlg"); if (kuniClearedFlg == true) { Message msg = new Message (); string Text = "国盗り、祝着至極に御座りますな。\n民から武将珠100個届いておりますぞ。"; msg.makeMessage (Text); //Add Busyo Dama busyoDama = busyoDama + 100; GameObject.Find ("BusyoDamaValue").GetComponent<Text> ().text = busyoDama.ToString (); PlayerPrefs.SetInt ("busyoDama", busyoDama); PlayerPrefs.SetBool ("kuniClearedFlg", false); PlayerPrefs.Flush (); } //From Naisei Check bool fromNaiseiFlg = PlayerPrefs.GetBool ("fromNaiseiFlg"); if (fromNaiseiFlg == true) { int activeKuniId = PlayerPrefs.GetInt ("activeKuniId"); GameObject.Find ("KuniIconView").transform.FindChild (activeKuniId.ToString ()).GetComponent<SendParam> ().OnClick (); PlayerPrefs.SetBool ("fromNaiseiFlg", false); PlayerPrefs.Flush (); } /*Timer Handling*/ //Last Log-In Time string timestring = PlayerPrefs.GetString ("lasttime"); if (timestring == null || timestring == "") timestring = System.DateTime.Now.ToString (); System.DateTime datetime = System.DateTime.Parse (timestring); System.TimeSpan span = System.DateTime.Now - datetime; //Last Get Time string lastGetTime = PlayerPrefs.GetString ("lastGetTime"); if (lastGetTime == null || lastGetTime == "") { lastGetTime = System.DateTime.Now.ToString (); PlayerPrefs.SetString ("lastGetTime", lastGetTime); PlayerPrefs.Flush (); } System.DateTime getdatetime = System.DateTime.Parse (lastGetTime); System.TimeSpan getspan = System.DateTime.Now - getdatetime; //経過時間を秒,時間で取得 double spantime = span.TotalSeconds; double spanhour = getspan.TotalHours; //spantimeでスタミナの回復分を求める double staminaDouble = spantime / 300; int addHyourou = (int)staminaDouble; int amariSec = (int)spantime - (addHyourou * 300); amariSec = 300 - amariSec; //HyourouMax hyourouMax = PlayerPrefs.GetInt ("hyourouMax"); GameObject.Find ("HyourouMaxValue").GetComponent<Text> ().text = hyourouMax.ToString (); //Now Hyourou int nowHyourou = PlayerPrefs.GetInt ("hyourou"); currentHyourou = GameObject.Find ("HyourouCurrentValue").gameObject; currentHyourou.GetComponent<Text> ().text = nowHyourou.ToString (); //Hyourou Full Check if (hyourouMax <= nowHyourou) { hyourouFull = true; GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = hyourouMax.ToString (); PlayerPrefs.SetInt ("hyourou", hyourouMax); PlayerPrefs.Flush (); } else { if (addHyourou > 0) { int newHyourou = nowHyourou + addHyourou; if (hyourouMax <= newHyourou) { hyourouFull = true; PlayerPrefs.SetInt ("hyourou", hyourouMax); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = hyourouMax.ToString (); } else { hyourouFull = false; PlayerPrefs.SetInt ("hyourou", newHyourou); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = newHyourou.ToString (); //Timer GameObject.Find ("TimerValue").GetComponent<Text> ().text = amariSec.ToString (); timer = (float)amariSec; } //終了時の処理 // 現在の時刻を取得 System.DateTime now = System.DateTime.Now; // 文字列に変換して保存 PlayerPrefs.SetString ("lasttime", now.ToString ()); PlayerPrefs.Flush (); } else { hyourouFull = false; PlayerPrefs.SetInt ("hyourou", nowHyourou); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = nowHyourou.ToString (); //Timer GameObject.Find ("TimerValue").GetComponent<Text> ().text = amariSec.ToString (); timer = (float)amariSec; } } //Year Handling string yearSeason = PlayerPrefs.GetString ("yearSeason"); string[] yearSeasonList = yearSeason.Split (delimiterChars); GameObject.Find ("YearValue").GetComponent<Text> ().text = yearSeasonList [0]; int seasonId = int.Parse (yearSeasonList [1]); if (seasonId == 1) { GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "春"; } else if (seasonId == 2) { GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "夏"; } else if (seasonId == 3) { GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "秋"; } else if (seasonId == 4) { GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "冬"; } //Cyosyu Flg cyosyuFlg = PlayerPrefs.GetBool ("cyosyuFlg"); double spansec = getspan.TotalSeconds; cyosyuTimer = cyosyuMstTime - spansec; if (cyosyuTimer <= 0.0f) { cyosyuFlg = true; } else { cyosyuFlg = false; } if (cyosyuFlg == true) { GameObject.Find ("SeiryokuInfo").transform.FindChild ("Ex").GetComponent<Image> ().enabled = true; } else { GameObject.Find ("SeiryokuInfo").transform.FindChild ("Ex").GetComponent<Image> ().enabled = false; } /*--------------------*/ /*Gunzei*/ /*--------------------*/ string keyHistory = PlayerPrefs.GetString ("keyHistory"); List<string> keyHistoryList = new List<string> (); if (keyHistory != null && keyHistory != "") { if(keyHistory.Contains(",")){ keyHistoryList = new List<string> (keyHistory.Split (delimiterChars)); }else{ keyHistoryList.Add(keyHistory); } } for(int n=0; n<keyHistoryList.Count; n++){ string keyTemp = keyHistoryList[n]; string keyValue = PlayerPrefs.GetString (keyTemp); if(keyValue != null){ List<string> keyValueList = new List<string> (); keyValueList = new List<string> (keyValue.Split (delimiterChars)); string gunzeiTime = keyValueList[0]; System.DateTime gunzeiDatetime = System.DateTime.Parse (gunzeiTime); System.TimeSpan gunzeiSpan = System.DateTime.Now - gunzeiDatetime; double gunzeiSpantime = gunzeiSpan.TotalSeconds; double remainTime = 0; List<string> srcDstKuniList = new List<string> (); char[] keyDelimiterChars = {'-'}; srcDstKuniList = new List<string> (keyTemp.Split (keyDelimiterChars)); int srcDaimyoId = int.Parse(keyValueList[1]); int dstDaimyoId = int.Parse(keyValueList[2]); int srcKuni = int.Parse(srcDstKuniList[0]); int dstKuni = int.Parse(srcDstKuniList[1]); bool dstEngunFlg = bool.Parse(keyValueList[9]); string dstEngunDaimyoId = keyValueList[10]; string dstEngunHei = keyValueList[11]; string dstEngunSts = keyValueList[12]; if(gunzeiSpantime >= 300){ //Has past //Simulation Gunzei gunzei = new Gunzei(); if (dstDaimyoId != myDaimyo) { int enemyHei = gunzei.heiryokuCalc (int.Parse(srcDstKuniList[1])); 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; int myHei = int.Parse(keyValueList[5]); if((myHei + enemyHei)>0){ ratio = 100 * myHei / (myHei + enemyHei); if (ratio < 1) { ratio = 1; } } MainEventHandler kassenEvent = new MainEventHandler (); bool winFlg = kassenEvent.CheckByProbability (ratio); if (winFlg) { bool noGunzeiFlg = true; gunzei.win (keyTemp, int.Parse(keyValueList[1]), int.Parse(keyValueList[2]),noGunzeiFlg); } else { deleteKeyHistory(keyTemp); } }else{ MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked(); atked.wasAttacked(keyTemp, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId,dstEngunSts); } }else{ //View Previous string path = "Prefabs/Map/Gunzei"; GameObject Gunzei = Instantiate (Resources.Load (path)) as GameObject; Gunzei.transform.SetParent (GameObject.Find ("Panel").transform); Gunzei.GetComponent<Gunzei>().key = keyTemp; Gunzei.GetComponent<Gunzei>().srcKuni = int.Parse(srcDstKuniList[0]); Gunzei.GetComponent<Gunzei>().dstKuni = int.Parse(srcDstKuniList[1]); Gunzei.GetComponent<Gunzei>().spantime = gunzeiSpantime; Gunzei.GetComponent<Gunzei>().srcDaimyoId = srcDaimyoId; Gunzei.GetComponent<Gunzei>().dstDaimyoId = dstDaimyoId; Gunzei.GetComponent<Gunzei>().srcDaimyoName = keyValueList[3]; Gunzei.GetComponent<Gunzei>().dstDaimyoName = keyValueList[4]; Gunzei.GetComponent<Gunzei>().myHei = int.Parse(keyValueList[5]); Gunzei.GetComponent<Gunzei>().dstEngunFlg = bool.Parse(keyValueList[9]); Gunzei.GetComponent<Gunzei>().dstEngunDaimyoId = keyValueList[10]; Gunzei.GetComponent<Gunzei>().dstEngunHei = keyValueList[11]; Gunzei.GetComponent<Gunzei>().dstEngunSts = keyValueList[12]; Gunzei.name = keyTemp; RectTransform GunzeiTransform = Gunzei.GetComponent<RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3 (int.Parse(keyValueList[6]), int.Parse(keyValueList[7]), 0); if(keyValueList[8] == "right"){ Gunzei.transform.localScale = new Vector2 (1, 1); }else{ Gunzei.transform.localScale = new Vector2 (-1, 1); Gunzei.GetComponent<Gunzei>().leftFlg = true; } } }else{ PlayerPrefs.DeleteKey(keyTemp); PlayerPrefs.Flush(); } } //Metsubou Flg Check if (PlayerPrefs.HasKey ("metsubou")) { string metsubou = PlayerPrefs.GetString ("metsubou"); List<string> metsubouList = new List<string> (); if (metsubou.Contains (",")) { metsubouList = new List<string> (metsubou.Split (delimiterChars)); } else { metsubouList.Add (metsubou); } //Metsubou Message string pathOfBack = "Prefabs/Common/TouchBack"; GameObject back = Instantiate (Resources.Load (pathOfBack)) as GameObject; back.transform.SetParent (GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1, 1); back.transform.localPosition = new Vector2 (0, 0); //make board string pathOfBoard = "Prefabs/Event/EventBoard"; GameObject board = Instantiate (Resources.Load (pathOfBoard)) as GameObject; board.transform.SetParent (GameObject.Find ("Panel").transform); board.transform.localScale = new Vector2 (1, 1); string pathOfScroll = "Prefabs/Event/Metsubou"; GameObject scroll = Instantiate (Resources.Load (pathOfScroll)) as GameObject; scroll.transform.SetParent (board.transform); scroll.transform.localScale = new Vector2 (1, 1); string pathOfSlot = "Prefabs/Event/MetsubouSlot"; GameObject contents = scroll.transform.FindChild ("MetsubouScrollView/MetsubouContent").gameObject; char[] delimiterChars2 = {':'}; foreach (string text in metsubouList) { GameObject slot = Instantiate (Resources.Load (pathOfSlot)) as GameObject; slot.transform.SetParent (contents.transform); List<string> metsubouTextList = new List<string> (); metsubouTextList = new List<string> (text.Split (delimiterChars2)); string srcDaimyoName = daimyoMst.param [int.Parse (metsubouTextList [0]) - 1].daimyoName; string dstDaimyoName = daimyoMst.param [int.Parse (metsubouTextList [1]) - 1].daimyoName; string metsubouText = dstDaimyoName + "は" + srcDaimyoName + "に滅ぼされました"; slot.transform.FindChild ("MetsubouText").GetComponent<Text> ().text = metsubouText; slot.transform.localScale = new Vector2 (1, 1); } PlayerPrefs.DeleteKey ("metsubou"); PlayerPrefs.Flush (); } /*--------------------*/ /*Enemy Action*/ /*--------------------*/ MainEventHandler gameEvent = new MainEventHandler (); gameEvent.mainHandler (); /*--------------------*/ /*Game Over*/ /*--------------------*/ bool gameOverFlg = PlayerPrefs.GetBool("gameOverFlg"); if (gameOverFlg) { Debug.Log ("gameOver"); } }
// Use this for initialization void Start() { /*Initial Data*/ bool initDataFlg = PlayerPrefs.GetBool ("initDataFlg"); if(initDataFlg == false){ //my daimyo InitDataMaker initData = new InitDataMaker(); initData.makeInitData(); } Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; Entity_kuni_mapping_mst kuniMappingMst = Resources.Load ("Data/kuni_mapping_mst") as Entity_kuni_mapping_mst; Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; //Base Info. int kuniLv = PlayerPrefs.GetInt ("kuniLv"); int money = PlayerPrefs.GetInt("money"); int busyoDama = PlayerPrefs.GetInt("busyoDama"); GameObject.Find ("KuniLvValue").GetComponent<Text> ().text = kuniLv.ToString(); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = money.ToString(); GameObject.Find ("BusyoDamaValue").GetComponent<Text> ().text = busyoDama.ToString(); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); string myDaimyoName = daimyoMst.param[myDaimyo-1].daimyoName; GameObject.Find ("DaimyoValue").GetComponent<Text> ().text = myDaimyoName; //Kuni List string openKuni = PlayerPrefs.GetString ("openKuni"); List<string> openKuniList = new List<string>(); char[] delimiterChars = {','}; if (openKuni.Contains (",")) { openKuniList = new List<string> (openKuni.Split (delimiterChars)); } else { openKuniList.Add(openKuni); } GameObject kuniIconView = GameObject.Find ("KuniIconView"); string kuniPath = "Prefabs/Map/Kuni/"; string newKuniPath = ""; string clearedKuni = PlayerPrefs.GetString ("clearedKuni"); List<string> clearedKuniList = new List<string>(); if (clearedKuni != null && clearedKuni != "") { clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars)); } /*View Every Kuni by Master*/ string linePath = "Prefabs/Map/LineObj"; GameObject KuniMap = GameObject.Find ("KuniMap"); //Seiryoku Default Setting string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); for (int i=0; i<kuniMst.param.Count; i++) { int kuniId = kuniMst.param[i].kunId; newKuniPath = kuniPath + kuniId.ToString(); int locationX = kuniMst.param[i].locationX; int locationY = kuniMst.param[i].locationY; GameObject kuni = Instantiate (Resources.Load (newKuniPath)) as GameObject; kuni.transform.SetParent(kuniIconView.transform); kuni.name = kuniId.ToString(); kuni.GetComponent<SendParam>().kuniId = kuniId; kuni.GetComponent<SendParam>().kuniName = kuniMst.param[i].kuniName; kuni.transform.localScale = new Vector2 (1, 1); //Seiryoku Handling int daimyoId = int.Parse(seiryokuList[kuniId-1]); string daimyoName = daimyoMst.param[daimyoId-1].daimyoName; kuni.GetComponent<SendParam>().daimyoId = daimyoId; kuni.GetComponent<SendParam>().daimyoName = daimyoName; //Color Handling float colorR = (float)daimyoMst.param[daimyoId-1].colorR; float colorG = (float)daimyoMst.param[daimyoId-1].colorG; float colorB = (float)daimyoMst.param[daimyoId-1].colorB; Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); KuniMap.transform.FindChild(kuni.name).GetComponent<Image>().color = kuniColor; //Daimyo Kamon Image string imagePath = "Prefabs/Kamon/" + daimyoId.ToString(); kuni.GetComponent<Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; RectTransform kuniTransform = kuni.GetComponent<RectTransform> (); kuniTransform.anchoredPosition = new Vector3 (locationX, locationY, 0); //Cleared Check if(clearedKuniList.Contains(kuni.name)){ kuni.GetComponent<Image> ().sprite = Resources.Load("Prefabs/Kamon/1", typeof(Sprite)) as Sprite; kuni.GetComponent<SendParam>().clearFlg = true; } } //Color Change for kuni icon "Open but never cleared" Color openKuniColor = new Color (255f / 255f, 255f / 255f, 0f / 255f, 255f / 255f); for(int i=0; i<openKuniList.Count; i++){ string openKuniId = openKuniList[i]; //Flg Change GameObject targetOpenKuni = GameObject.Find ("KuniIconView").transform.FindChild(openKuniId).gameObject; targetOpenKuni.GetComponent<SendParam>().openFlg = true; //Color Change if(!clearedKuniList.Contains(openKuniId)){ targetOpenKuni.GetComponent<Image>().color = openKuniColor; } } /* View Open Kuni for(int i=0; i<openKuniList.Count; i++){ int openKuniId = int.Parse(openKuniList[i]); newKuniPath = kuniPath + openKuniId.ToString(); int locationX = kuniMst.param[i].locationX; int locationY = kuniMst.param[i].locationY; GameObject kuni = Instantiate (Resources.Load (newKuniPath)) as GameObject; kuni.transform.SetParent(kuniIconView.transform); kuni.name = openKuniId.ToString(); kuni.GetComponent<SendParam>().kuniId = openKuniId; kuni.GetComponent<SendParam>().kuniName = kuniMst.param[i].kuniName; kuni.transform.localScale = new Vector2 (1, 1); RectTransform kuniTransform = kuni.GetComponent<RectTransform> (); kuniTransform.anchoredPosition = new Vector3 (locationX, locationY, 0); //Cleared Check if(clearedKuniList.Contains(kuni.name)){ kuni.GetComponent<Image> ().sprite = Resources.Load("Prefabs/Kamon/Oda", typeof(Sprite)) as Sprite; } } */ //Clear Kuni Check bool kuniClearedFlg = PlayerPrefs.GetBool ("kuniClearedFlg"); if(kuniClearedFlg==true){ Message msg = new Message(); string Text = "国盗り、祝着至極に御座りますな。\n民から武将珠100個届いておりますぞ。"; msg.makeMessage(Text); //Add Busyo Dama busyoDama = busyoDama + 100; GameObject.Find ("BusyoDamaValue").GetComponent<Text> ().text = busyoDama.ToString(); PlayerPrefs.SetInt("busyoDama",busyoDama); PlayerPrefs.SetBool("kuniClearedFlg",false); PlayerPrefs.Flush(); } //From Naisei Check bool fromNaiseiFlg = PlayerPrefs.GetBool ("fromNaiseiFlg"); if(fromNaiseiFlg == true){ int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); GameObject.Find ("KuniIconView").transform.FindChild(activeKuniId.ToString()).GetComponent<SendParam>().OnClick(); PlayerPrefs.SetBool ("fromNaiseiFlg",false); PlayerPrefs.Flush(); } /*Timer Handling*/ //Last Log-In Time string timestring = PlayerPrefs.GetString("lasttime"); //初回起動時は取得できないので代わりに現在の時刻を入れる if (timestring == null || timestring == "") timestring = System.DateTime.Now.ToString(); //保存しておいた時刻は文字列なので時刻(DateTime)に変換 System.DateTime datetime = System.DateTime.Parse(timestring); //現在の時刻-保存しておいた時刻で経過時間を求める System.TimeSpan span = System.DateTime.Now - datetime; //Last Get Time string lastGetTime = PlayerPrefs.GetString("lastGetTime"); if (lastGetTime == null || lastGetTime == "") { lastGetTime = System.DateTime.Now.ToString(); PlayerPrefs.SetString("lastGetTime",lastGetTime); PlayerPrefs.Flush(); } System.DateTime getdatetime = System.DateTime.Parse(lastGetTime); System.TimeSpan getspan = System.DateTime.Now - getdatetime; //経過時間を秒,時間で取得 double spantime = span.TotalSeconds; double spanhour = getspan.TotalHours; //spantimeでスタミナの回復分を求める double staminaDouble = spantime / 300; int addHyourou = (int)staminaDouble; int amariSec = (int)spantime - (addHyourou * 300); amariSec = 300 - amariSec; //HyourouMax hyourouMax = PlayerPrefs.GetInt ("hyourouMax"); GameObject.Find ("HyourouMaxValue").GetComponent<Text> ().text = hyourouMax.ToString (); //Now Hyourou int nowHyourou = PlayerPrefs.GetInt ("hyourou"); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = nowHyourou.ToString (); //Hyourou Full Check if (hyourouMax <= nowHyourou) { hyourouFull = true; GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = hyourouMax.ToString(); PlayerPrefs.SetInt ("hyourou", hyourouMax); PlayerPrefs.Flush (); } else { if (addHyourou > 0) { int newHyourou = nowHyourou + addHyourou; if(hyourouMax <= newHyourou ){ hyourouFull = true; PlayerPrefs.SetInt ("hyourou", hyourouMax); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = hyourouMax.ToString(); }else{ hyourouFull = false; PlayerPrefs.SetInt ("hyourou", newHyourou); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = newHyourou.ToString (); //Timer GameObject.Find ("TimerValue").GetComponent<Text> ().text = amariSec.ToString (); timer = (float)amariSec; } //終了時の処理 // 現在の時刻を取得 System.DateTime now = System.DateTime.Now; // 文字列に変換して保存 PlayerPrefs.SetString ("lasttime", now.ToString ()); PlayerPrefs.Flush (); }else{ hyourouFull = false; PlayerPrefs.SetInt ("hyourou", nowHyourou); PlayerPrefs.Flush (); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = nowHyourou.ToString(); //Timer GameObject.Find ("TimerValue").GetComponent<Text> ().text = amariSec.ToString (); timer = (float)amariSec; } } //Year Handling string yearSeason = PlayerPrefs.GetString ("yearSeason"); string[] yearSeasonList = yearSeason.Split (delimiterChars); GameObject.Find ("YearValue").GetComponent<Text> ().text = yearSeasonList[0]; int seasonId = int.Parse(yearSeasonList[1]); if(seasonId == 1){ GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "春"; }else if(seasonId == 2){ GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "夏"; }else if(seasonId == 3){ GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "秋"; }else if(seasonId == 4){ GameObject.Find ("SeasonValue").GetComponent<Text> ().text = "冬"; } //Cyosyu Flg cyosyuFlg = PlayerPrefs.GetBool("cyosyuFlg"); double spansec = getspan.TotalSeconds; cyosyuTimer = cyosyuMstTime - spansec; if (cyosyuTimer <= 0.0f) { cyosyuFlg = true; } else { cyosyuFlg = false; } if (cyosyuFlg == true) { GameObject.Find ("SeiryokuInfo").transform.FindChild("Ex").GetComponent<Image>().enabled = true; } else { GameObject.Find ("SeiryokuInfo").transform.FindChild("Ex").GetComponent<Image>().enabled = false; } /*--------------------*/ /*Enemy Attack*/ /*--------------------*/ }