Exemplo n.º 1
0
    public void IconMapValueUpdate(int kuniId, int changeDaimyoId, GameObject kuniIconView, GameObject kuniMap, int myKuniQty)
    {
        Daimyo     daimyo         = new Daimyo();
        GameObject targetKuniIcon = kuniIconView.transform.FindChild(kuniId.ToString()).gameObject;

        targetKuniIcon.gameObject.AddComponent <IconFadeChange> ();
        targetKuniIcon.gameObject.AddComponent <IconFadeChange> ().toDaimyoId = changeDaimyoId;

        float colorR   = daimyo.getColorR(changeDaimyoId);
        float colorG   = daimyo.getColorG(changeDaimyoId);
        float colorB   = daimyo.getColorB(changeDaimyoId);
        Color newColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);

        GameObject kuniMapObj = kuniMap.transform.FindChild(kuniId.ToString()).gameObject;

        kuniMapObj.GetComponent <Image> ().color = newColor;

        //Change Name of target Kuni by daimyo info
        SendParam script = targetKuniIcon.GetComponent <SendParam> ();

        script.daimyoId = changeDaimyoId;
        string daimyoName = daimyo.getName(changeDaimyoId);

        script.daimyoName = daimyoName;
        int daimyoBusyoId = daimyo.getDaimyoBusyoId(changeDaimyoId);

        script.daimyoBusyoId = daimyoBusyoId;
        myKuniQty            = myKuniQty + 1;
        script.kuniQty       = myKuniQty;
        script.openFlg       = true;
        script.clearFlg      = true;
        int myHeiryoku = PlayerPrefs.GetInt("jinkeiHeiryoku");

        script.heiryoku = myHeiryoku;
    }
Exemplo n.º 2
0
    public void changeKuniIconAndParam(int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId)
    {
        //Change Icon
        string     imagePath    = "Prefabs/Kamon/" + srcDaimyoId.ToString();
        GameObject kuniIconView = GameObject.Find("KuniIconView");
        GameObject targetKuni   = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject;

        targetKuni.GetComponent <Image> ().sprite =
            Resources.Load(imagePath, typeof(Sprite)) as Sprite;

        //Change Tochi Color
        GameObject KuniMap      = GameObject.Find("KuniMap");
        Daimyo     daimyoScript = new Daimyo();
        float      colorR       = daimyoScript.getColorR(srcDaimyoId);
        float      colorG       = daimyoScript.getColorG(srcDaimyoId);
        float      colorB       = daimyoScript.getColorB(srcDaimyoId);
        Color      kuniColor    = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);

        KuniMap.transform.FindChild(dstKuni.ToString()).GetComponent <Image> ().color = kuniColor;

        //Change Yukoudo
        string tmp     = "gaikou" + srcDaimyoId;
        int    yukoudo = PlayerPrefs.GetInt(tmp);

        targetKuni.GetComponent <SendParam> ().myYukouValue = yukoudo;

        /*Change Param*/
        //Set Senryoku
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

        char[] delimiterChars = { ',' };
        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));


        /*Get Winner Kuni Qty*/
        EnemySenryokuCalc calc = new EnemySenryokuCalc();
        int myKuniQty          = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty;
        //int enemyKuniQty = kuniIconView.transform.FindChild (srcKuni.ToString ()).GetComponent<SendParam> ().kuniQty;
        //int newEnemyKuniQty = enemyKuniQty + 1;

        MainStageController main = new MainStageController();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int tmpDaimyoId = int.Parse(seiryokuList [i]);

            if (tmpDaimyoId == srcDaimyoId)
            {
                List <string> checkedKuniList  = new List <string> ();
                int           tmpKuniId        = i + 1;
                int           newWinnerKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

                //Get New Senryoku
                int busyoQty      = calc.EnemyBusyoQtyCalc(myKuniQty, newWinnerKuniQty, 0);
                int senryokuRatio = daimyoScript.getSenryoku(srcDaimyoId);
                int busyoLv       = calc.EnemyBusyoLvCalc(senryokuRatio);
                int butaiQty      = calc.EnemyButaiQtyCalc(newWinnerKuniQty, myKuniQty);
                int butaiLv       = calc.EnemyButaiLvCalc(senryokuRatio);

                //Change Name of target Kuni by daimyo info
                targetKuni.GetComponent <SendParam> ().daimyoId     = srcDaimyoId;
                targetKuni.GetComponent <SendParam>().daimyoName    = daimyoScript.getName(srcDaimyoId);          //daimyoMst.param [srcDaimyoId - 1].daimyoName;
                targetKuni.GetComponent <SendParam>().daimyoBusyoId = daimyoScript.getDaimyoBusyoId(srcDaimyoId); //daimyoMst.param [srcDaimyoId - 1].busyoId;

                SendParam winnerParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> ();
                winnerParam.busyoQty = busyoQty;
                winnerParam.busyoLv  = busyoLv;
                winnerParam.butaiQty = butaiQty;
                winnerParam.butaiLv  = butaiLv;
                winnerParam.kuniQty  = newWinnerKuniQty;
            }
            else if (tmpDaimyoId == dstDaimyoId)
            {
                List <string> checkedKuniList = new List <string> ();
                int           tmpKuniId       = i + 1;
                int           newLoserKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

                //Get New Senryoku
                int busyoQty      = calc.EnemyBusyoQtyCalc(myKuniQty, newLoserKuniQty, 0);
                int senryokuRatio = daimyoScript.getSenryoku(dstDaimyoId);//daimyoMst.param [dstDaimyoId - 1].senryoku;
                int busyoLv       = calc.EnemyBusyoLvCalc(senryokuRatio);
                int butaiQty      = calc.EnemyButaiQtyCalc(newLoserKuniQty, myKuniQty);
                int butaiLv       = calc.EnemyButaiLvCalc(senryokuRatio);

                SendParam loserParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> ();
                loserParam.busyoQty = busyoQty;
                loserParam.busyoLv  = busyoLv;
                loserParam.butaiQty = butaiQty;
                loserParam.butaiLv  = butaiLv;
                loserParam.kuniQty  = newLoserKuniQty;
            }
        }



        //Icon Color Change by Doumei Situation
        List <string> myDoumeiList = new List <string> ();
        string        doumeiString = PlayerPrefs.GetString("doumei");

        if (doumeiString != null && doumeiString != "")
        {
            if (doumeiString.Contains(","))
            {
                myDoumeiList = new List <string> (doumeiString.Split(delimiterChars));
            }
            else
            {
                myDoumeiList.Add(doumeiString);
            }
        }
        if (myDoumeiList.Contains(srcDaimyoId.ToString()))
        {
            Color doumeiColor = new Color(100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f);
            targetKuni.GetComponent <SendParam> ().doumeiFlg = true;
            targetKuni.GetComponent <Image>().color          = doumeiColor;
        }

        if (!myDoumeiList.Contains(srcDaimyoId.ToString()) && myDoumeiList.Contains(dstDaimyoId.ToString()))
        {
            Color unDoumeiColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
            targetKuni.GetComponent <SendParam> ().doumeiFlg = false;
            targetKuni.GetComponent <Image>().color          = unDoumeiColor;
        }
    }
Exemplo n.º 3
0
	public void OnClick(){

		if (close.GetComponent<CloseBoard> ().kuniId != kuniId) {
			close.GetComponent<CloseBoard> ().kuniId = kuniId;

			/*Status*/
			//Common
			GameObject kuniIconView = GameObject.Find ("KuniIconView").gameObject;
			SendParam script = kuniIconView.transform.FindChild (kuniId.ToString ()).GetComponent<SendParam> ();
			KuniInfo kuni = new KuniInfo ();
			Daimyo daimyo = new Daimyo ();
			Gaikou gaikou = new Gaikou ();
			List<int> targetKuniList = new List<int> ();
			targetKuniList = kuni.getMappingKuni (kuniId);
			char[] delimiterChars = { ',' };

			//Kamon
			GameObject daimyoNameObj = status.transform.FindChild ("DaimyoName").gameObject;
			string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString ();
			daimyoNameObj.transform.FindChild ("Kamon").GetComponent<Image> ().sprite = 
			Resources.Load (imagePath, typeof(Sprite)) as Sprite;

			//Daimyo Name
			daimyoNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = daimyoName;

			//Kuni Name
			GameObject kuniNameObj = status.transform.FindChild ("KuniName").gameObject;
			kuniNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = kuniName;

			//Heiryoku
			status.transform.FindChild ("Heiryoku").transform.FindChild ("Value").GetComponent<Text> ().text = script.heiryoku.ToString ();

			//Yukou
			status.transform.FindChild ("Yukoudo").transform.FindChild ("Value").GetComponent<Text> ().text = script.myYukouValue.ToString ();

			//Attack Target
			bool aggressiveFlg = script.aggressiveFlg;
			int myDaimyoId = PlayerPrefs.GetInt ("myDaimyo");

			int targetKuniId = getKassenTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
			if (targetKuniId != 0) {
				string targetKuniName = kuni.getKuniName (targetKuniId);
				int targetDaimyoId = int.Parse (seiryokuList [targetKuniId - 1]);
				string targetDaimyoName = daimyo.getName (targetDaimyoId);
				status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = targetKuniName + "(" + targetDaimyoName + ")";
			} else {
				status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = "無し";
			}


			int targetGaikouKuniId = 0;
			if (snbRank > 1) { //Jyo or Cyu

				//Gaikou
				targetGaikouKuniId = getGaikouTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
				if (targetGaikouKuniId != 0) {
					string targetGaikouKuniName = kuni.getKuniName (targetGaikouKuniId);
					int targetGaikouDaimyoId = int.Parse (seiryokuList [targetGaikouKuniId - 1]);
					string targetGaikouDaimyoName = daimyo.getName (targetGaikouDaimyoId);
		
					status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")";
				} else {
					status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "無し";
				}

				//Doumei
				string doumeiTmp = "doumei" + daimyoId.ToString ();
				string doumeiString = PlayerPrefs.GetString (doumeiTmp);
				List<string> doumeiList = new List<string> ();
				if (doumeiString != null && doumeiString != "") {
					if (doumeiString.Contains (",")) {
						doumeiList = new List<string> (doumeiString.Split (delimiterChars));
					} else {
						doumeiList.Add (doumeiString);
					}
				}

				string doumeiNameList = "無し";
				for (int j = 0; j < doumeiList.Count; j++) {
					if (j == 0) {
						doumeiNameList = daimyo.getName (int.Parse (doumeiList [j]));
					} else {
						doumeiNameList = doumeiNameList + "," + daimyo.getName (int.Parse (doumeiList [j]));
					}
				}

				status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = doumeiNameList;
			
			} else {
				//Ge
				status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "?";
				status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = "?";

			}


			if (snbRank > 2) { //Jyo
				BusyoInfoGet busyo = new BusyoInfoGet();

				string qtyAndHeisyu = busyo.getDaimyoBusyoQtyHeisyu(daimyoId);
				List<string> qtyAndHeisyuiList = new List<string> ();
				qtyAndHeisyuiList = new List<string> (qtyAndHeisyu.Split (delimiterChars));

				//BusyoQty
				//Heisyu
				status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[0];
				status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[1];
			
			} else {
				//Cyu or Ge
				status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = "?";
				status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = "?";

			}


			//Main Map
			foreach(Transform obj in board.transform){
				if (obj.name != "Explanation") {
					Destroy (obj.gameObject);
				}
			}

			string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage";
			GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
			mainMap.transform.SetParent(board.transform);
			mainMap.transform.localScale = new Vector2 (13, 9);
			mainMap.name = "kuniMap" + kuniId;
			string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString ();
			mainMap.GetComponent<Image> ().sprite = 
				Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite;

			int baseX = kuni.getKuniLocationX (kuniId);
			int baseY = kuni.getKuniLocationY (kuniId);
			int adjstX = baseX * -1;
			int adjustY = baseY * -1;

			float colorR = daimyo.getColorR (daimyoId);
			float colorG = daimyo.getColorG (daimyoId);
			float colorB = daimyo.getColorB (daimyoId);
			Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);
			mainMap.GetComponent<Image> ().color = kuniColor;

			RectTransform mapRect = mainMap.GetComponent<RectTransform> ();
			mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0);

			//My Kuni Kamon Icon
			string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack";
			GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject;
			kamonBack.transform.SetParent (board.transform);
			kamonBack.transform.localScale = new Vector2 (1, 1);
			kamonBack.transform.localPosition = new Vector2(0,0);

			string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString();
			GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject;
			kamonObj.transform.SetParent (kamonBack.transform);
			kamonObj.transform.localScale = new Vector2 (1, 0.8f);
			kamonObj.transform.localPosition = new Vector2(0,0);
			kamonObj.GetComponent<Image> ().sprite = 
				Resources.Load (imagePath, typeof(Sprite)) as Sprite;
			kamonObj.GetComponent<Button> ().enabled = false;


			//Mapping Kuni
			Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
			for (int i=0; i < kuniMst.param.Count; i++) {
			//for (int i=0; i < targetKuniList.Count; i++) {
				int subKuniId = i + 1;

				GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
				subMap.transform.SetParent(mainMap.transform);
				subMap.transform.localScale = new Vector2 (1, 1);
				subMap.transform.localPosition = new Vector2 (0, 0);

				subMap.name = "kuniMap" + subKuniId;
				string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId;
				subMap.GetComponent<Image> ().sprite = 
					Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite;


				if (targetKuniList.Contains (subKuniId)) {
					//color
					int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]);
					float subColorR = daimyo.getColorR (subDaimyoId);
					float subColorG = daimyo.getColorG (subDaimyoId);
					float subColorB = daimyo.getColorB (subDaimyoId);
					Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f);
					subMap.GetComponent<Image> ().color = subKuniColor;

					//Kamon
					string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString ();
					GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject;
					subKamonObj.transform.SetParent (board.transform);
					subKamonObj.transform.localScale = new Vector2 (1, 0.8f);
					if (daimyoId != subDaimyoId) {
						string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString ();
						subKamonObj.GetComponent<Image> ().sprite = 
							Resources.Load (subImagePath, typeof(Sprite)) as Sprite;

						//yukoudo
						int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId);
						string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
						GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject;
						yukoudoObj.transform.SetParent (subKamonObj.transform);
						yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString ();
						yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f);
						yukoudoObj.transform.localPosition = new Vector2 (0, 26);

					} else {
						subKamonObj.GetComponent<Image> ().sprite = 
							Resources.Load (imagePath, typeof(Sprite)) as Sprite;
					}
					subKamonObj.GetComponent<Button> ().enabled = false;

					//Kamon adjustment
					int subBaseX = kuni.getKuniLocationX (subKuniId);
					int subBaseY = kuni.getKuniLocationY (subKuniId);
					int subAdjstX = subBaseX - baseX;
					int subAdjstY = subBaseY - baseY;

					RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> ();
					subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0);

					if (targetKuniId != 0) {
						if (targetKuniId == subKuniId) {
							//kassen target
							Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
							subKamonObj.GetComponent<Image> ().color = atkColor;
						}
					}

					if (snbRank > 1) {
						if (targetGaikouKuniId != 0) {
							if (targetGaikouKuniId == subKuniId) {
								//kassen target
								Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
								subKamonObj.GetComponent<Image> ().color = gaikouColor;
							}
						}
					}
				} else {
					Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
					subMap.GetComponent<Image> ().color = noSubKuniColor;
				}

			}






		}


	}