public int heiryokuCalc(int kuni) { GameObject targetKuni = GameObject.Find("KuniIconView"); int enemyTotalHei = 0; if (targetKuni.transform.FindChild(kuni.ToString())) { SendParam sendParam = targetKuni.transform.FindChild(kuni.ToString()).GetComponent <SendParam> (); int daimyoBusyoId = sendParam.daimyoBusyoId; int busyoLv = sendParam.busyoLv; int busyoQty = sendParam.busyoQty; int butaiLv = sendParam.butaiLv; int butaiQty = sendParam.butaiQty; if (daimyoBusyoId != 0) { StatusGet sts = new StatusGet(); int hp = sts.getHp(daimyoBusyoId, busyoLv); int hpResult = hp * 100 * busyoQty; string type = sts.getHeisyu(daimyoBusyoId); int chHp = sts.getChHp(type, butaiLv, hp); chHp = chHp * butaiQty * busyoQty * 10; enemyTotalHei = hpResult + chHp; } } return(enemyTotalHei); }
public int getEngunHei(string engunSts){ int totalHei = 0; char[] delimiterChars = {'-'}; List<string> engunStsList = new List<string>(); engunStsList = new List<string> (engunSts.Split (delimiterChars)); int busyoId = int.Parse(engunStsList [0]); int busyoLv = int.Parse(engunStsList [1]); int butaiQty = int.Parse(engunStsList [2]); int butaiLv = int.Parse(engunStsList [3]); if (busyoId != 0) { StatusGet sts = new StatusGet (); int hp = sts.getHp (busyoId, busyoLv); int hpResult = hp * 100; string type = sts.getHeisyu (busyoId); int chHp = sts.getChHp (type, butaiLv, hp); chHp = chHp * butaiQty * 10; totalHei = hpResult + chHp; } return totalHei; }
public void OnClick(){ //SE audio.PlayOneShot(touch); /*Common Process*/ string pathOfBack = "Prefabs/Common/TouchBack"; 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/Map/smallBoard"; GameObject board = Instantiate(Resources.Load (pathOfBoard)) as GameObject; board.transform.parent = GameObject.Find ("Panel").transform; board.transform.localScale = new Vector2 (1,1); /*Value Setting*/ //Kuni Name GameObject.Find ("kuniName").GetComponent<Text>().text = kuniName; //Daimyo Name GameObject.Find ("DaimyoNameValue").GetComponent<Text>().text = daimyoName; //Kamon string kamonPath = "Prefabs/Kamon/" + daimyoId.ToString(); GameObject kamon = GameObject.Find ("KamonBack"); kamon.GetComponent<Image> ().sprite = Resources.Load(kamonPath, typeof(Sprite)) as Sprite; //Daimyo Busyo View string busyoPath = "Prefabs/Player/Unit/" + daimyoBusyoId; GameObject busyo = Instantiate(Resources.Load (busyoPath)) as GameObject; busyo.transform.SetParent (kamon.transform); busyo.transform.localScale = new Vector2 (1,1); busyo.GetComponent<DragHandler> ().enabled = false; RectTransform busyoTransform = busyo.GetComponent<RectTransform> (); busyoTransform.anchoredPosition = new Vector3 (90, 100, 0); busyoTransform.sizeDelta = new Vector2 (180, 200); foreach ( Transform n in busyo.transform ){ GameObject.Destroy(n.gameObject); } //Doumei if (doumeiFlg) { string doumeiPath = "Prefabs/Common/Doumei"; GameObject doumei = Instantiate (Resources.Load (doumeiPath)) as GameObject; doumei.transform.SetParent (kamon.transform); doumei.transform.localScale = new Vector2 (1, 1); RectTransform doumeiTransform = doumei.GetComponent<RectTransform> (); doumeiTransform.anchoredPosition = new Vector3 (-50, 80, 0); doumei.name = "Doumei"; } //Heiryoku Calc GameObject yukouValue = GameObject.Find ("YukouValue"); GameObject atkBtn = GameObject.Find ("AttackButton"); GameObject gaikouBtn = GameObject.Find ("GaikouButton"); GameObject bouryakuhouBtn = GameObject.Find ("BouryakuButton"); Color NGClorBtn = new Color (133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f); Color NGClorTxt = new Color (90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f); if (clearFlg == false) { StatusGet sts = new StatusGet (); int hp = sts.getHp (daimyoBusyoId,busyoLv); int hpResult = hp * 100 * busyoQty; string type = sts.getHeisyu (daimyoBusyoId); int chHp = sts.getChHp(type, butaiLv, hp); chHp = chHp * butaiQty * busyoQty * 10; int totalHei = hpResult + chHp; GameObject.Find ("HeiryokuValue").GetComponent<Text> ().text = totalHei.ToString (); //Yukoudo string gaikouTemp = "gaikou" + daimyoId; int myYukouValue = PlayerPrefs.GetInt(gaikouTemp); yukouValue.GetComponent<Text>().text = myYukouValue.ToString(); } else { //Cleard int myHeiryoku = PlayerPrefs.GetInt("jinkeiHeiryoku"); GameObject.Find ("HeiryokuValue").GetComponent<Text> ().text = myHeiryoku.ToString (); //Yukoudo yukouValue.GetComponent<Text>().text = "-"; //Enable Gaiko & Cyouhou gaikouBtn.GetComponent<Image>().color = NGClorBtn; gaikouBtn.GetComponent<Button>().enabled = false; gaikouBtn.transform.FindChild("Text").GetComponent<Text>().color = NGClorTxt; bouryakuhouBtn.GetComponent<Image>().color = NGClorBtn; bouryakuhouBtn.GetComponent<Button>().enabled = false; bouryakuhouBtn.transform.FindChild("Text").GetComponent<Text>().color = NGClorTxt; atkBtn.transform.FindChild("Text").GetComponent<Text>().text = "内政"; } //Enable to Attack if(openFlg == false ){ atkBtn.GetComponent<Image>().color = NGClorBtn; atkBtn.GetComponent<Button>().enabled = false; atkBtn.transform.FindChild("Text").GetComponent<Text>().color = NGClorTxt; } //Doumei Flg if (doumeiFlg) { atkBtn.GetComponent<AttackNaiseiView>().doumeiFlg = doumeiFlg; gaikouBtn.GetComponent<GaikouView>().doumeiFlg = doumeiFlg; atkBtn.GetComponent<Image>().color = NGClorBtn; atkBtn.GetComponent<Button>().enabled = false; atkBtn.transform.FindChild("Text").GetComponent<Text>().color = NGClorTxt; } //Set Hidden Value GameObject close = GameObject.Find ("close").gameObject; close.GetComponent<CloseBoard> ().title = kuniName; close.GetComponent<CloseBoard> ().daimyoId = daimyoId; close.GetComponent<CloseBoard> ().doumeiFlg = doumeiFlg; close.GetComponent<CloseBoard> ().kuniQty = kuniQty; close.GetComponent<CloseBoard> ().kuniId = kuniId; //Set Button Value AttackNaiseiView attkNaiseView = GameObject.Find ("AttackButton").GetComponent<AttackNaiseiView>(); attkNaiseView.kuniId = kuniId; attkNaiseView.kuniName = kuniName; attkNaiseView.daimyoId = daimyoId; attkNaiseView.daimyoName = daimyoName; attkNaiseView.openFlg = openFlg; attkNaiseView.clearFlg = clearFlg; attkNaiseView.activeBusyoQty = busyoQty; attkNaiseView.activeBusyoLv = busyoLv; attkNaiseView.activeButaiQty = butaiQty; attkNaiseView.activeButaiLv = butaiLv; }
public int heiryokuCalc(int kuni){ GameObject targetKuni = GameObject.Find ("KuniIconView"); SendParam sendParam = targetKuni.transform.FindChild (kuni.ToString ()).GetComponent<SendParam> (); int daimyoBusyoId = sendParam.daimyoBusyoId; int busyoLv = sendParam.busyoLv; int busyoQty = sendParam.busyoQty; int butaiLv = sendParam.butaiLv; int butaiQty = sendParam.butaiQty; int enemyTotalHei = 0; if (daimyoBusyoId != 0) { StatusGet sts = new StatusGet (); int hp = sts.getHp (daimyoBusyoId, busyoLv); int hpResult = hp * 100 * busyoQty; string type = sts.getHeisyu (daimyoBusyoId); int chHp = sts.getChHp (type, butaiLv, hp); chHp = chHp * butaiQty * busyoQty * 10; enemyTotalHei = hpResult + chHp; } return enemyTotalHei; }
// 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 (); } /*--------------------*/ /*Game Over*/ /*--------------------*/ bool gameOverFlg = PlayerPrefs.GetBool("gameOverFlg"); if (gameOverFlg) { Application.LoadLevel ("clearOrGameOver"); } else { /*--------------------*/ /*Game Clear*/ /*--------------------*/ bool gameClearFlg = PlayerPrefs.GetBool ("gameClearFlg"); if (gameClearFlg) { Application.LoadLevel ("clearOrGameOver"); } else { 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); kuni.GetComponent<SendParam> ().naiseiItem = kuniMst.param [i].naisei; //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; BusyoInfoGet busyo = new BusyoInfoGet (); if (daimyoBusyoIdTemp != 0) { kuni.GetComponent<SendParam> ().daimyoBusyoAtk = busyo.getMaxAtk (daimyoBusyoIdTemp); kuni.GetComponent<SendParam> ().daimyoBusyoDfc = busyo.getMaxDfc (daimyoBusyoIdTemp); } //Senryoku //Count QTY of Enemy Kuni int enemyKuniQty = 1; //for (int l=0; l<seiryokuList.Count; l++) { // int seiryokuId = int.Parse (seiryokuList [l]); // // if (seiryokuId == daimyoId) { // enemyKuniQty = enemyKuniQty + 1; // } //} List<string> checkedKuniList = new List<string> (); enemyKuniQty = countLinkedKuniQty(1, kuniId, daimyoId, seiryokuList, checkedKuniList); EnemySenryokuCalc calc = new EnemySenryokuCalc (); int busyoQty = 0; int busyoLv = 0; int butaiQty = 0; int butaiLv = 0; busyoQty = calc.EnemyBusyoQtyCalc (myKuniQty, enemyKuniQty); if (busyoQty > 12) { busyoQty = 12; } 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; int myHeiryoku = PlayerPrefs.GetInt ("jinkeiHeiryoku"); kuni.GetComponent<SendParam> ().heiryoku = myHeiryoku; } else { //Not my daimyo //Yukoudo string gaikouTemp = "gaikou" + daimyoId; int myYukouValue = PlayerPrefs.GetInt (gaikouTemp); kuni.GetComponent<SendParam> ().myYukouValue = myYukouValue; if (daimyoBusyoIdTemp != 0) { StatusGet sts = new StatusGet (); int hp = sts.getHp (daimyoBusyoIdTemp, busyoLv); int hpResult = hp * 100 * busyoQty; string type = sts.getHeisyu (daimyoBusyoIdTemp); int chHp = sts.getChHp (type, butaiLv, hp); chHp = chHp * butaiQty * busyoQty * 10; int totalHei = hpResult + chHp; kuni.GetComponent<SendParam> ().heiryoku = totalHei; } //Action Policy Setting(agrresive false or true) if(enemyKuniQty>=3){ kuni.GetComponent<SendParam> ().aggressiveFlg = getAggressiveFlg (0); // big country }else { kuni.GetComponent<SendParam> ().aggressiveFlg = getAggressiveFlg (1); // small country } //Cyouhou Flg string cyouhouTmp = "cyouhou" + kuniId; if (PlayerPrefs.HasKey (cyouhouTmp)) { int cyouhouSnbRankId = PlayerPrefs.GetInt (cyouhouTmp); kuni.GetComponent<SendParam> ().cyouhouSnbRankId = cyouhouSnbRankId; } } } //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 (); GameObject.Find ("AttackButton").GetComponent<AttackNaiseiView> ().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; //経過時間を秒,時間で取得 double spantime = span.TotalSeconds; //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 & Season -Auto Count- Start*/ string lastSeasonChangeTime = PlayerPrefs.GetString ("lastSeasonChangeTime"); if (lastSeasonChangeTime == null || lastSeasonChangeTime == "") { lastSeasonChangeTime = System.DateTime.Now.ToString (); PlayerPrefs.SetString ("lastSeasonChangeTime", lastSeasonChangeTime); PlayerPrefs.Flush (); } System.DateTime SChangeTime = System.DateTime.Parse (lastSeasonChangeTime); System.TimeSpan scSpan = System.DateTime.Now - SChangeTime; double scSpanHour = scSpan.TotalHours; double scSpanSec = scSpan.TotalSeconds; string yearSeason = PlayerPrefs.GetString ("yearSeason"); string[] yearSeasonList = yearSeason.Split (delimiterChars); int nowYear = int.Parse (yearSeasonList [0]); int nowSeason = int.Parse (yearSeasonList [1]); if (scSpanHour >= 12) { int seasonPastCount = (int)scSpanHour / 12; int amari = (int)scSpanSec - (seasonPastCount * 43200); for (int i=1; i<=seasonPastCount; i++) { if (nowSeason == 4) { nowYear = nowYear + 1; nowSeason = 1; } else { nowSeason = nowSeason + 1; } } yearTimer = cyosyuMstTime - amari; string newYearSeason = nowYear.ToString () + "," + nowSeason.ToString (); PlayerPrefs.SetString ("yearSeason", newYearSeason); lastSeasonChangeTime = System.DateTime.Now.ToString (); PlayerPrefs.SetString ("lastSeasonChangeTime", lastSeasonChangeTime); PlayerPrefs.SetBool ("doneCyosyuFlg", false); PlayerPrefs.SetString ("yearSeason", newYearSeason); PlayerPrefs.Flush (); } else { yearTimer = cyosyuMstTime - scSpanSec; } GameObject.Find ("YearValue").GetComponent<Text> ().text = nowYear.ToString (); SetSeason (nowSeason); doneCyosyuFlg = PlayerPrefs.GetBool ("doneCyosyuFlg"); if (!doneCyosyuFlg) { GameObject.Find ("SeiryokuInfo").transform.FindChild ("Ex").GetComponent<Image> ().enabled = true; } else { GameObject.Find ("SeiryokuInfo").transform.FindChild ("Ex").GetComponent<Image> ().enabled = false; } /*Year & Season End*/ /*--------------------*/ /*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); //Metsubou Daimyo Handling string srcMetsubouTemp = "metsubou" + metsubouTextList [0]; string srcMetsubou = PlayerPrefs.GetString (srcMetsubouTemp); string dstMetsubouTemp = "metsubou" + metsubouTextList [1]; string dstMetsubou = PlayerPrefs.GetString (dstMetsubouTemp); string newSrcMetsubou = ""; if (srcMetsubou != null && srcMetsubou != "") { newSrcMetsubou = srcMetsubou + "," + metsubouTextList [1]; } else { newSrcMetsubou = metsubouTextList [1]; } if (dstMetsubou != null && dstMetsubou != "") { newSrcMetsubou = newSrcMetsubou + "," + dstMetsubou; } PlayerPrefs.SetString (srcMetsubouTemp, newSrcMetsubou); } PlayerPrefs.DeleteKey ("metsubou"); PlayerPrefs.Flush (); } /*--------------------*/ /*Enemy Action*/ /*--------------------*/ MainEventHandler gameEvent = new MainEventHandler (); gameEvent.mainHandler (); } } }