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 GameObject MakeCommentObj(int enemyDaimyoId, int kuniId)
    {
        //Popup
        string     cmntPath         = "Prefabs/Map/stage/EventComment";
        GameObject commentObj       = Instantiate(Resources.Load(cmntPath)) as GameObject;
        GameObject attackStagePopup = GameObject.Find("AttackStagePopup").gameObject;

        commentObj.transform.SetParent(attackStagePopup.transform);
        commentObj.transform.localScale    = new Vector2(2.0f, 2.5f);
        commentObj.transform.localPosition = new Vector2(-145, 307);
        commentObj.GetComponent <FadeoutSenpou> ().enabled = true;
        commentObj.name = "EventComment";

        //Busyo Image
        GameObject busyoImage    = commentObj.transform.FindChild("Mask").transform.FindChild("BusyoImage").gameObject;
        Daimyo     daimyo        = new Daimyo();
        int        daimyoBusyoId = daimyo.getDaimyoBusyoId(enemyDaimyoId);
        string     imagePath     = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();

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

        return(commentObj);
    }
Exemplo n.º 3
0
	public void OnClick(){


		if (!gameOverFlg) {
			//Clear and Re-srart
			makeDaimyoSeiryoku();


		} else {
			//GameOver and Re-srart
			NewDaimyoDataMaker data = new NewDaimyoDataMaker();

			//Check Once Cleared or Not
			string gameClearDaimyo = PlayerPrefs.GetString ("gameClearDaimyo");
			if(gameClearDaimyo!=null && gameClearDaimyo !=""){
				//Once Cleared >> Can Choose Daimyo
				GameObject kuniMap = GameObject.Find("KuniMap").gameObject;
				GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject;
				Destroy(kuniMap.gameObject);
				Destroy(KuniIconView.gameObject);

				makeDaimyoSeiryoku();

				//Daimyo Busyo Data Clear in the case there is no gacya history
				string gacyaDaimyoHst = PlayerPrefs.GetString ("gacyaDaimyoHst");
				char[] delimiterChars = {','};
				List<string> gacyaDaimyoHstList = new List<string>();
				if(gacyaDaimyoHst!=null && gacyaDaimyoHst !=""){
					if(gacyaDaimyoHst.Contains(",")){
						gacyaDaimyoHstList = new List<string> (gacyaDaimyoHst.Split (delimiterChars));
					}else{
						gacyaDaimyoHstList.Add(gacyaDaimyoHst);
					}
				}
				Daimyo daimyo = new Daimyo();
				int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
				int daimyoBusyoId = daimyo.getDaimyoBusyoId(myDaimyo);

				if(!gacyaDaimyoHstList.Contains(daimyoBusyoId.ToString())){
					//delete daimyo busyo from my busyo
					string myBusyoString = PlayerPrefs.GetString ("myBusyo");
					List<string> myBusyoList = new List<string>();
					if(myBusyoString!=null && myBusyoString !=""){
						if(myBusyoString.Contains(",")){
							myBusyoList = new List<string> (myBusyoString.Split (delimiterChars));
						}else{
							myBusyoList.Add(myBusyoString);
						}
					}


					string newMyBusyo = "";
					for(int i=0; i<myBusyoList.Count; i++){
						int myBusyoId = int.Parse(myBusyoList[i]);

						if(myBusyoId != daimyoBusyoId){
							if(newMyBusyo == ""){
								newMyBusyo = myBusyoId.ToString();
							}else{
								newMyBusyo = newMyBusyo + "," + myBusyoId.ToString();
							}
						}
					}
					PlayerPrefs.SetString ("myBusyo",newMyBusyo);
					PlayerPrefs.Flush();

				}


			}else{
				//Never Cleared >> Start From Oda Nobunaga
				data.dataMake(true, 1, 19, "TP");

			}
		}
	}
Exemplo n.º 4
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [2].Play();

        //Upper
        if (!bottomFlg)
        {
            //Color
            Color Select   = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f);
            Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f);
            foreach (Transform obj in uprContent.transform)
            {
                obj.GetComponent <Image> ().color = unSelect;
            }
            GetComponent <Image> ().color = Select;

            //Reset
            foreach (Transform obj in btnContent.transform)
            {
                Destroy(obj.gameObject);
            }


            string btnSlot = "Prefabs/Bakuhu/CyusaiSlot";
            Daimyo daimyo  = new Daimyo();
            foreach (string dstDaimyoId in checkedDaimyoList)
            {
                if (dstDaimyoId != daimyoId)
                {
                    GameObject btmSlot = Instantiate(Resources.Load(btnSlot)) as GameObject;
                    btmSlot.transform.SetParent(btnContent.transform);
                    btmSlot.transform.localScale = new Vector2(1, 1);

                    int    daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(dstDaimyoId));
                    string daimyoName2   = daimyo.getName(int.Parse(dstDaimyoId));

                    string daimyoBusyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
                    btmSlot.transform.FindChild("Image").transform.FindChild("Image").GetComponent <Image> ().sprite =
                        Resources.Load(daimyoBusyoPath, typeof(Sprite)) as Sprite;
                    btmSlot.transform.FindChild("DaimyoName").GetComponent <Text> ().text = daimyoName2;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().bottomFlg   = true;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().uprContent  = uprContent;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().btnContent  = btnContent;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId    = daimyoId;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId    = daimyoId;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId2   = dstDaimyoId;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName  = daimyoName;
                    btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName2 = daimyoName2;
                }
            }
        }
        else
        {
            //Bottom
            //Color
            Color Select   = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f);
            Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f);
            foreach (Transform obj in btnContent.transform)
            {
                obj.GetComponent <Image> ().color = unSelect;
            }
            GetComponent <Image> ().color = Select;

            //Confirm Button
            //Back Cover
            string     backPath = "Prefabs/Busyo/back";
            GameObject back     = Instantiate(Resources.Load(backPath)) as GameObject;
            back.transform.SetParent(GameObject.Find("Map").transform);
            back.transform.localScale = new Vector2(1, 1);
            RectTransform backTransform = back.GetComponent <RectTransform> ();
            backTransform.anchoredPosition3D = new Vector3(0, 0, 0);

            //Message Box
            string     msgPath = "Prefabs/Bakuhu/CyusaiConfirm";
            GameObject msg     = Instantiate(Resources.Load(msgPath)) as GameObject;
            msg.transform.SetParent(GameObject.Find("Map").transform);
            msg.transform.localScale = new Vector2(1, 1);
            RectTransform msgTransform = msg.GetComponent <RectTransform> ();
            msgTransform.anchoredPosition3D = new Vector3(0, 0, 0);
            msgTransform.name = "CyusaiConfirm";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                msg.transform.FindChild("Text").GetComponent <Text> ().text = "Do you want to mediate between " + daimyoName + " and " + daimyoName2 + "? \n Friendship will increase.";
            }
            else
            {
                msg.transform.FindChild("Text").GetComponent <Text>().text = daimyoName + "と" + daimyoName2 + "を仲裁しますか?\n二大名間の友好度が上がります。";
            }


            GameObject YesBtn = msg.transform.FindChild("YesButton").gameObject;
            GameObject NoBtn  = msg.transform.FindChild("NoButton").gameObject;
            YesBtn.GetComponent <DoCyusai> ().daimyoId    = daimyoId;
            YesBtn.GetComponent <DoCyusai> ().daimyoId2   = daimyoId2;
            YesBtn.GetComponent <DoCyusai> ().daimyoName  = daimyoName;
            YesBtn.GetComponent <DoCyusai> ().daimyoName2 = daimyoName2;
            YesBtn.GetComponent <DoCyusai> ().confirm     = msg;
            YesBtn.GetComponent <DoCyusai> ().back        = back;
            NoBtn.GetComponent <DoCyusai> ().confirm      = msg;
            NoBtn.GetComponent <DoCyusai> ().back         = back;
            NoBtn.GetComponent <DoCyusai> ().btnContent   = btnContent;
            NoBtn.GetComponent <DoCyusai> ().uprContent   = uprContent;
        }
    }
Exemplo n.º 5
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.º 6
0
    public void OnClick()
    {
        int hyourou = PlayerPrefs.GetInt("hyourou");

        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        if (name == "AtkOrderBtn")
        {
            if (hyourou >= 10)
            {
                audioSources [0].Play();

                //Common
                //Back
                string     returnPath = "Prefabs/Bakuhu/Return";
                GameObject returnObj  = Instantiate(Resources.Load(returnPath)) as GameObject;
                returnObj.transform.SetParent(board.transform);
                returnObj.transform.localScale    = new Vector2(1, 1);
                returnObj.transform.localPosition = new Vector2(-560, 290);
                returnObj.name = "bakuhuReturn";

                //Disabled
                scrollView.SetActive(false);

                //Base Obj
                string     basePath = "Prefabs/Bakuhu/Base";
                GameObject baseObj  = Instantiate(Resources.Load(basePath)) as GameObject;
                baseObj.transform.SetParent(board.transform);
                baseObj.transform.localScale = new Vector2(1, 1);
                baseObj.name = "BakuhuBase";
                returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj  = baseObj;
                returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView;
                returnObj.GetComponent <BakuhuMenuReturn> ().board      = board;
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    board.transform.FindChild("popText").GetComponent <Text> ().text = "Attack Order";
                }
                else
                {
                    board.transform.FindChild("popText").GetComponent <Text>().text = "討伐令";
                }
                string     textPath = "Prefabs/Bakuhu/ToubatsuText";
                GameObject textObj  = Instantiate(Resources.Load(textPath)) as GameObject;
                textObj.transform.SetParent(baseObj.transform);
                textObj.transform.localScale    = new Vector2(0.12f, 0.15f);
                textObj.transform.localPosition = new Vector2(0, 206);
                textObj.name = "ToubatsuText";

                //View daimyo kuni
                string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                List <string> seiryokuList   = new List <string> ();
                char[]        delimiterChars = { ',' };
                seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

                string            kuniPath  = "Prefabs/Map/Kuni/";
                Entity_kuni_mst   kuniMst   = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;
                Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst;
                int myDaimyo = PlayerPrefs.GetInt("myDaimyo");

                string     kuniIconPath = "Prefabs/Bakuhu/BakuhuKuniMap";
                GameObject kuniMapView  = Instantiate(Resources.Load(kuniIconPath)) as GameObject;
                kuniMapView.transform.SetParent(baseObj.transform);
                kuniMapView.transform.localScale = new Vector2(0.8f, 0.65f);

                string     kuniMapPath  = "Prefabs/Bakuhu/BakuhuKuniIconView";
                GameObject kuniIconView = Instantiate(Resources.Load(kuniMapPath)) as GameObject;
                kuniIconView.transform.SetParent(baseObj.transform);
                kuniIconView.transform.localScale = new Vector2(0.8f, 0.65f);
                kuniIconView.name = "BakuhuKuniIconView";

                List <int> kuniQtyByDaimyoId = new List <int> ()
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                };
                int  myKuniQty             = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty;
                bool myKuniQtyIsBiggestFlg = true;

                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.transform.localScale = new Vector2(1, 1);

                    //Seiryoku Handling
                    int daimyoId = int.Parse(seiryokuList [kuniId - 1]);
                    if (daimyoId == myDaimyo)
                    {
                        kuni.SetActive(false);
                        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);

                        kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor;
                    }
                    else
                    {
                        Daimyo daimyoScript = new Daimyo();
                        string daimyoName   = daimyoScript.getName(daimyoId);
                        kuni.GetComponent <SendParam> ().bakuhuFlg  = true;
                        kuni.GetComponent <SendParam> ().kuniId     = kuniId;
                        kuni.GetComponent <SendParam> ().daimyoId   = daimyoId;
                        kuni.GetComponent <SendParam> ().daimyoName = daimyoName;
                        int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId;
                        kuni.GetComponent <SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp;

                        /*Kuni Qty Start*/
                        int kuniQty = 0;
                        if (kuniQtyByDaimyoId [daimyoId - 1] == 0)
                        {
                            kuniQty = getKuniQty(daimyoId, seiryokuList);
                            kuniQtyByDaimyoId [daimyoId - 1] = kuniQty;
                        }
                        else
                        {
                            kuniQty = kuniQtyByDaimyoId [daimyoId - 1];
                        }
                        kuni.GetComponent <SendParam> ().kuniQty = kuniQty;
                        if (kuniQty >= myKuniQty)
                        {
                            myKuniQtyIsBiggestFlg = false;
                        }
                        /*Kuni Qty End*/

                        //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);

                        kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor;

                        //Daimyo Kamon Image
                        string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + 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);
                    }
                }
                returnObj.GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg = myKuniQtyIsBiggestFlg;
            }
            else
            {
                //Hyourou NG
                audioSources [4].Play();

                Message msg = new Message();
                //msg.makeMessageOnBoard (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
        else if (name == "DfcOrderBtn")
        {
            //Boueirei
            if (hyourou >= 10)
            {
                //Gunzei Exist Check
                int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId");

                bool          gunzeiFlg       = false;
                KuniInfo      kuni            = new KuniInfo();
                string        seiryoku        = PlayerPrefs.GetString("seiryoku");
                List <string> seiryokuList    = new List <string> ();
                char[]        delimiterChars  = { ',' };
                char[]        delimiterChars2 = { ':' };
                seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
                int myDaimyo = PlayerPrefs.GetInt("myDaimyo");

                //Used Engun List
                List <string> dstEngunDaimyoIdList = new List <string>();
                foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei"))
                {
                    string        dstEngunDaimyoId        = obs.GetComponent <Gunzei>().dstEngunDaimyoId;
                    List <string> tmpDstEngunDaimyoIdList = new List <string>();
                    if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                    {
                        if (dstEngunDaimyoId.Contains(":"))
                        {
                            tmpDstEngunDaimyoIdList = new List <string>(dstEngunDaimyoId.Split(delimiterChars2));
                        }
                        else
                        {
                            tmpDstEngunDaimyoIdList.Add(dstEngunDaimyoId);
                        }
                    }
                    dstEngunDaimyoIdList.AddRange(tmpDstEngunDaimyoIdList);
                }


                List <string> okGunzeiList = new List <string> (); //key1:engunSrcKuni1:engunSrcKuni2...,key2:engunSrcKuni1:engunSrcKuni2....

                foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei"))
                {
                    int checkDaimyoId = obs.GetComponent <Gunzei> ().dstDaimyoId;
                    if (checkDaimyoId != bakuhuTobatsuDaimyoId)
                    {
                        int        dstKuni      = obs.GetComponent <Gunzei> ().dstKuni;
                        int        srcDaimyoId  = obs.GetComponent <Gunzei> ().srcDaimyoId;
                        int        dstDaimyoId  = obs.GetComponent <Gunzei> ().dstDaimyoId;
                        List <int> openKuniList = new List <int> ();
                        openKuniList = kuni.getMappingKuni(dstKuni);

                        string     tmpString      = "";
                        List <int> usedDaimyoList = new List <int> ();
                        for (int i = 0; i < openKuniList.Count; i++)
                        {
                            int tmpDaimyoId = int.Parse(seiryokuList [openKuniList [i] - 1]);
                            if (tmpDaimyoId != myDaimyo && tmpDaimyoId != srcDaimyoId && tmpDaimyoId != dstDaimyoId)
                            {
                                if (!usedDaimyoList.Contains(tmpDaimyoId))
                                {
                                    if (!dstEngunDaimyoIdList.Contains(tmpDaimyoId.ToString()))
                                    {
                                        gunzeiFlg = true;
                                        usedDaimyoList.Add(tmpDaimyoId);

                                        if (tmpString == "")
                                        {
                                            tmpString = obs.name + ":" + openKuniList [i];
                                        }
                                        else
                                        {
                                            tmpString = tmpString + ":" + openKuniList [i];
                                        }
                                    }
                                }
                            }
                        }
                        if (tmpString != "")
                        {
                            okGunzeiList.Add(tmpString);
                        }
                    }
                }

                if (gunzeiFlg)
                {
                    audioSources [0].Play();

                    //Common
                    //Back
                    string     returnPath = "Prefabs/Bakuhu/Return";
                    GameObject returnObj  = Instantiate(Resources.Load(returnPath)) as GameObject;
                    returnObj.transform.SetParent(board.transform);
                    returnObj.transform.localScale    = new Vector2(1, 1);
                    returnObj.transform.localPosition = new Vector2(-560, 290);
                    returnObj.name = "bakuhuReturn";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order";
                    }
                    else
                    {
                        board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令";
                    }
                    //Disabled
                    scrollView.SetActive(false);

                    //Base Obj
                    string     basePath = "Prefabs/Bakuhu/Base";
                    GameObject baseObj  = Instantiate(Resources.Load(basePath)) as GameObject;
                    baseObj.transform.SetParent(board.transform);
                    baseObj.transform.localScale = new Vector2(1, 1);
                    baseObj.name = "BakuhuBase";
                    returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj  = baseObj;
                    returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView;
                    returnObj.GetComponent <BakuhuMenuReturn> ().board      = board;

                    string     boubiScrollPath = "Prefabs/Bakuhu/BoueiScrollView";
                    GameObject boueiScrollObj  = Instantiate(Resources.Load(boubiScrollPath)) as GameObject;
                    boueiScrollObj.transform.SetParent(baseObj.transform);
                    boueiScrollObj.transform.localScale    = new Vector2(1, 1);
                    boueiScrollObj.transform.localPosition = new Vector2(0, 0);
                    GameObject content = boueiScrollObj.transform.FindChild("Content").gameObject;

                    string uniSlotPath     = "Prefabs/Bakuhu/BoueiSlot";
                    string daimyoBusyoPath = "Prefabs/Player/Sprite/unit";
                    Daimyo daimyo          = new Daimyo();

                    for (int i = 0; i < okGunzeiList.Count; i++)
                    {
                        string        tmp = okGunzeiList [i];
                        List <string> okGunzeiUnitList = new List <string> ();
                        okGunzeiUnitList = new List <string> (tmp.Split(delimiterChars2));

                        string     key              = okGunzeiUnitList [0];
                        GameObject gunzei           = GameObject.Find(key).gameObject;
                        int        dstDaimyoId      = gunzei.GetComponent <Gunzei> ().dstDaimyoId;
                        int        dstDaimyoBusyoId = daimyo.getDaimyoBusyoId(dstDaimyoId);
                        string     dstDaimyoName    = daimyo.getName(dstDaimyoId);
                        int        srcDaimyoId      = gunzei.GetComponent <Gunzei> ().srcDaimyoId;
                        int        srcDaimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyoId);
                        string     srcDaimyoName    = daimyo.getName(srcDaimyoId);
                        int        dstKuniId        = gunzei.GetComponent <Gunzei> ().dstKuni;
                        string     kuniName         = kuni.getKuniName(dstKuniId);

                        for (int j = 1; j < okGunzeiUnitList.Count; j++)
                        {
                            int    engunKuniId        = int.Parse(okGunzeiUnitList [j]);
                            int    engunDaimyoId      = int.Parse(seiryokuList [engunKuniId - 1]);
                            int    engunDaimyoBusyoId = daimyo.getDaimyoBusyoId(engunDaimyoId);
                            string engunDaimyoName    = daimyo.getName(engunDaimyoId);

                            GameObject slot = Instantiate(Resources.Load(uniSlotPath)) as GameObject;
                            slot.transform.SetParent(content.transform);
                            slot.transform.localScale = new Vector2(1, 1);
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                slot.transform.FindChild("Kuni").GetComponent <Text> ().text = kuniName + " Defence";
                            }
                            else
                            {
                                slot.transform.FindChild("Kuni").GetComponent <Text>().text = kuniName + "防衛";
                            }
                            string dfcDaimyoPath = daimyoBusyoPath + dstDaimyoBusyoId.ToString();
                            slot.transform.FindChild("Dfc").transform.FindChild("Image").GetComponent <Image> ().sprite =
                                Resources.Load(dfcDaimyoPath, typeof(Sprite)) as Sprite;
                            string atkDaimyoPath = daimyoBusyoPath + srcDaimyoBusyoId.ToString();
                            slot.transform.FindChild("Atk").transform.FindChild("Image").GetComponent <Image> ().sprite =
                                Resources.Load(atkDaimyoPath, typeof(Sprite)) as Sprite;
                            string engnDaimyoPath = daimyoBusyoPath + engunDaimyoBusyoId.ToString();
                            slot.transform.FindChild("Egn").transform.FindChild("Image").GetComponent <Image> ().sprite =
                                Resources.Load(engnDaimyoPath, typeof(Sprite)) as Sprite;

                            slot.transform.FindChild("DfcName").GetComponent <Text> ().text = dstDaimyoName;
                            slot.transform.FindChild("AtkName").GetComponent <Text> ().text = srcDaimyoName;
                            slot.transform.FindChild("EgnName").GetComponent <Text> ().text = engunDaimyoName;
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                slot.transform.FindChild("Exp").GetComponent <Text>().text = "Request " + engunDaimyoName + " for reinforcement";
                            }
                            else
                            {
                                slot.transform.FindChild("Exp").GetComponent <Text>().text = engunDaimyoName + "に援軍の出兵支持を出す。";
                            }
                            //Param
                            GameObject btn = slot.transform.FindChild("BoueiBtn").gameObject;
                            btn.GetComponent <DoBouei> ().key             = key;
                            btn.GetComponent <DoBouei> ().engunDaimyoId   = engunDaimyoId;
                            btn.GetComponent <DoBouei> ().engunKuniId     = engunKuniId;
                            btn.GetComponent <DoBouei> ().engunDaimyoName = engunDaimyoName;
                            btn.GetComponent <DoBouei> ().dfcDaimyoId     = dstDaimyoId;
                            btn.GetComponent <DoBouei> ().slot            = slot;
                            btn.GetComponent <DoBouei> ().kuniName        = kuniName;
                        }
                    }
                }
                else
                {
                    audioSources [4].Play();

                    Message msg = new Message();
                    msg.makeMessageOnBoard(msg.getMessage(99));
                }
            }
            else
            {
                audioSources [4].Play();

                //Hyourou NG
                Message msg = new Message();
                //msg.makeMessageOnBoard (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
        else if (name == "RelationshipBtn")
        {
            //Boueirei
            if (hyourou >= 5)
            {
                int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId");

                //Not Last Daimyo check
                string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                List <string> seiryokuList   = new List <string> ();
                char[]        delimiterChars = { ',' };
                seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
                int myDaimyo = PlayerPrefs.GetInt("myDaimyo");

                bool          isLastDaimyoFlg   = false;
                List <string> checkedDaimyoList = new List <string> ();
                foreach (string tmp in seiryokuList)
                {
                    if (tmp != myDaimyo.ToString())
                    {
                        if (!checkedDaimyoList.Contains(tmp))
                        {
                            checkedDaimyoList.Add(tmp);
                        }
                    }
                }
                //include other 2 daimyos = 3
                if (checkedDaimyoList.Count >= 2)
                {
                    isLastDaimyoFlg = true;
                }

                if (isLastDaimyoFlg)
                {
                    audioSources [0].Play();

                    //OK
                    //Common
                    //Back
                    string     returnPath = "Prefabs/Bakuhu/Return";
                    GameObject returnObj  = Instantiate(Resources.Load(returnPath)) as GameObject;
                    returnObj.transform.SetParent(board.transform);
                    returnObj.transform.localScale    = new Vector2(1, 1);
                    returnObj.transform.localPosition = new Vector2(-560, 290);
                    returnObj.name = "bakuhuReturn";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order";
                    }
                    else
                    {
                        board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令";
                    }
                    //Disabled
                    scrollView.SetActive(false);

                    //Base Obj
                    string     basePath = "Prefabs/Bakuhu/Base";
                    GameObject baseObj  = Instantiate(Resources.Load(basePath)) as GameObject;
                    baseObj.transform.SetParent(board.transform);
                    baseObj.transform.localScale = new Vector2(1, 1);
                    baseObj.name = "BakuhuBase";
                    returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj  = baseObj;
                    returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView;
                    returnObj.GetComponent <BakuhuMenuReturn> ().board      = board;
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        board.transform.FindChild("popText").GetComponent <Text> ().text = "Mediation";
                    }
                    else
                    {
                        board.transform.FindChild("popText").GetComponent <Text>().text = "仲裁";
                    }
                    //Scroll
                    string     scrollPath = "Prefabs/Bakuhu/CyusaiScrollView";
                    GameObject uprScroll  = Instantiate(Resources.Load(scrollPath)) as GameObject;
                    uprScroll.transform.SetParent(baseObj.transform);
                    uprScroll.transform.localPosition = new Vector2(0, 95);
                    uprScroll.transform.localScale    = new Vector2(1, 1);
                    uprScroll.name = "CyusaiScrollViewUpper";
                    GameObject uprContent = uprScroll.transform.FindChild("Content").gameObject;
                    GameObject btnScroll  = Instantiate(Resources.Load(scrollPath)) as GameObject;
                    btnScroll.transform.SetParent(baseObj.transform);
                    btnScroll.transform.localPosition = new Vector2(0, -170);
                    btnScroll.transform.localScale    = new Vector2(1, 1);
                    btnScroll.name = "CyusaiScrollViewBottom";
                    GameObject btnContent = btnScroll.transform.FindChild("Content").gameObject;

                    //Upper Scroll
                    string slotPath = "Prefabs/Bakuhu/CyusaiSlot";
                    Daimyo daimyo   = new Daimyo();
                    foreach (string daimyoId in checkedDaimyoList)
                    {
                        GameObject uprSlot = Instantiate(Resources.Load(slotPath)) as GameObject;
                        uprSlot.transform.SetParent(uprContent.transform);
                        uprSlot.transform.localScale = new Vector2(1, 1);
                        uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId          = daimyoId;
                        uprSlot.GetComponent <CyusaiDaimyoSelect> ().checkedDaimyoList = checkedDaimyoList;
                        uprSlot.GetComponent <CyusaiDaimyoSelect> ().uprContent        = uprContent;
                        uprSlot.GetComponent <CyusaiDaimyoSelect> ().btnContent        = btnContent;

                        int    daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId));
                        string daimyoName    = daimyo.getName(int.Parse(daimyoId));
                        uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName = daimyoName;
                        string daimyoBusyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
                        uprSlot.transform.FindChild("Image").transform.FindChild("Image").GetComponent <Image> ().sprite =
                            Resources.Load(daimyoBusyoPath, typeof(Sprite)) as Sprite;
                        uprSlot.transform.FindChild("DaimyoName").GetComponent <Text> ().text = daimyoName;
                    }
                    string     cyusaiTxtPath = "Prefabs/Bakuhu/CyusaiText";
                    GameObject cTxt          = Instantiate(Resources.Load(cyusaiTxtPath)) as GameObject;
                    cTxt.transform.SetParent(btnContent.transform);
                    cTxt.transform.localScale = new Vector2(0.12f, 0.15f);
                    cTxt.name = "CyusaiText";
                }
                else
                {
                    audioSources [4].Play();

                    Message msg = new Message();
                    msg.makeMessageOnBoard(msg.getMessage(100));
                }
            }
            else
            {
                audioSources [4].Play();

                //Hyourou NG
                Message msg = new Message();
                //msg.makeMessageOnBoard (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
        else if (name == "SobujiKessenBtn")
        {
            if (hyourou >= 30)
            {
                bool myKuniQtyIsTwiceFlg = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQtyIsTwiceFlg;
                if (myKuniQtyIsTwiceFlg)
                {
                    audioSources [0].Play();

                    //Confirm Button
                    //Back Cover
                    string     backPath = "Prefabs/Busyo/back";
                    GameObject back     = Instantiate(Resources.Load(backPath)) as GameObject;
                    back.transform.SetParent(GameObject.Find("Map").transform);
                    back.transform.localScale = new Vector2(1, 1);
                    RectTransform backTransform = back.GetComponent <RectTransform> ();
                    backTransform.anchoredPosition3D = new Vector3(0, 0, 0);

                    //Message Box
                    GameObject soubujireiConfirmObj = Instantiate(soubujireiConfirm) as GameObject;
                    soubujireiConfirmObj.transform.SetParent(GameObject.Find("Map").transform);
                    soubujireiConfirmObj.transform.localScale = new Vector2(1, 1);
                    RectTransform msgTransform = soubujireiConfirmObj.GetComponent <RectTransform> ();
                    msgTransform.anchoredPosition3D = new Vector3(0, 0, 0);
                    msgTransform.name = "SoubujireiConfirmObj";

                    GameObject YesBtn = soubujireiConfirmObj.transform.FindChild("YesButton").gameObject;
                    GameObject NoBtn  = soubujireiConfirmObj.transform.FindChild("NoButton").gameObject;
                    YesBtn.GetComponent <DoSoubujirei> ().board   = board;
                    YesBtn.GetComponent <DoSoubujirei> ().confirm = soubujireiConfirmObj;
                    YesBtn.GetComponent <DoSoubujirei> ().back    = back;
                    NoBtn.GetComponent <DoSoubujirei> ().confirm  = soubujireiConfirmObj;
                    NoBtn.GetComponent <DoSoubujirei> ().back     = back;
                }
                else
                {
                    audioSources [4].Play();

                    Message msg = new Message();
                    msg.makeMessageOnBoard(msg.getMessage(101));
                }
            }
            else
            {
                audioSources [4].Play();

                //Hyourou NG
                Message msg = new Message();
                //msg.makeMessageOnBoard (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
        else if (name == "KessenBtn")
        {
            if (hyourou >= hyourouNo)
            {
                audioSources [0].Play();

                //Confirm Button

                //Back Cover
                string     backPath = "Prefabs/Busyo/back";
                GameObject back     = Instantiate(Resources.Load(backPath)) as GameObject;
                back.transform.SetParent(GameObject.Find("Map").transform);
                back.transform.localScale = new Vector2(1, 1);
                RectTransform backTransform = back.GetComponent <RectTransform> ();
                backTransform.anchoredPosition3D = new Vector3(0, 0, 0);

                //Message Box
                string     msgPath = "Prefabs/Bakuhu/KessenConfirm";
                GameObject msg     = Instantiate(Resources.Load(msgPath)) as GameObject;
                msg.transform.SetParent(GameObject.Find("Map").transform);
                msg.transform.localScale = new Vector2(1, 1);
                RectTransform msgTransform = msg.GetComponent <RectTransform> ();
                msgTransform.anchoredPosition3D = new Vector3(0, 0, 0);
                msgTransform.name = "KessenConfirm";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    msg.transform.FindChild("Text").GetComponent <Text>().text = "Operate final war with " + daimyoName + ".";
                }
                else
                {
                    msg.transform.FindChild("Text").GetComponent <Text>().text = daimyoName + "に決戦を仕掛けます";
                }
                GameObject YesBtn = msg.transform.FindChild("YesButton").gameObject;
                GameObject NoBtn  = msg.transform.FindChild("NoButton").gameObject;
                YesBtn.GetComponent <DoKessen> ().daimyoId      = daimyoId;
                YesBtn.GetComponent <DoKessen> ().daimyoName    = daimyoName;
                YesBtn.GetComponent <DoKessen> ().kuniId        = kuniId;
                YesBtn.GetComponent <DoKessen> ().needHyourouNo = hyourouNo;
                NoBtn.GetComponent <DoKessen> ().confirm        = msg;
                NoBtn.GetComponent <DoKessen> ().back           = back;

                YesBtn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text> ().text = hyourouNo.ToString();
            }
            else
            {
                audioSources [4].Play();

                //Hyourou NG
                Message msg = new Message();
                //msg.makeMessageOnBoard (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
    }
Exemplo n.º 7
0
    void Start()
    {
        viewCurrentValue();

        //Delete Previous Slot
        GameObject content = GameObject.Find("Content").gameObject;

        foreach (Transform obj in content.transform)
        {
            Destroy(obj.gameObject);
        }

        //Make Slot
        Shisya shisya   = new Shisya();
        Daimyo daimyo   = new Daimyo();
        bool   ClickFlg = false;

        for (int i = 1; i < 22; i++)
        {
            string tmp = "shisya" + i.ToString();
            if (PlayerPrefs.HasKey(tmp))
            {
                //Exist

                string        shisyaString   = PlayerPrefs.GetString(tmp);
                List <string> shisyaList     = new List <string> ();
                char[]        delimiterChars = { ',' };
                if (shisyaString != null && shisyaString != "")
                {
                    if (shisyaString.Contains(","))
                    {
                        shisyaList = new List <string> (shisyaString.Split(delimiterChars));
                    }
                    else
                    {
                        shisyaList.Add(shisyaString);
                    }
                }

                for (int j = 0; j < shisyaList.Count; j++)
                {
                    string shisyaParam = shisyaList [j];

                    List <string> shisyaParamList = new List <string> ();
                    char[]        delimiterChars2 = { ':' };
                    if (shisyaParam.Contains(":"))
                    {
                        shisyaParamList = new List <string> (shisyaParam.Split(delimiterChars2));
                    }
                    else
                    {
                        shisyaParamList.Add(shisyaParam);
                    }

                    //Common
                    string     slotName = shisya.getSlot(i);
                    string     slotPath = "Prefabs/Shisya/Slot/" + slotName;
                    GameObject slotObj  = Instantiate(Resources.Load(slotPath)) as GameObject;
                    slotObj.transform.SetParent(content.transform);
                    slotObj.transform.localScale    = new Vector2(1, 1);
                    slotObj.transform.localPosition = new Vector3(0, 0, 0);
                    string title = shisya.getName(i);
                    slotObj.transform.FindChild("Title").GetComponent <Text> ().text = title;
                    ShisyaSelect script = slotObj.GetComponent <ShisyaSelect> ();

                    if (slotName == "DaimyoSlot")
                    {
                        string daimyoId  = shisyaParamList [0];
                        string imagePath = "Prefabs/Kamon/" + daimyoId.ToString();
                        slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite =
                            Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                        //Choose Buka
                        int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId));
                        int busyoId       = getRandomBusyo(int.Parse(daimyoId), daimyoBusyoId);

                        string busyoImagePath = "Prefabs/Player/Sprite/unit" + busyoId.ToString();
                        slotObj.transform.FindChild("Image").GetComponent <Image> ().sprite =
                            Resources.Load(busyoImagePath, typeof(Sprite)) as Sprite;

                        BusyoInfoGet busyo      = new BusyoInfoGet();
                        string       busyoName  = busyo.getName(busyoId);
                        string       daimyoName = daimyo.getName(int.Parse(daimyoId));
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            script.shisyaName = daimyoName + "'s retainer :" + busyoName;
                        }
                        else
                        {
                            script.shisyaName = daimyoName + "配下 " + busyoName;
                        }
                    }
                    else if (slotName == "SyogunSlot")
                    {
                        int           syogunId     = PlayerPrefs.GetInt("syogunDaimyoId");
                        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
                        List <string> seiryokuList = new List <string> ();
                        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
                        if (seiryokuList.Contains(syogunId.ToString()))
                        {
                            string imagePath = "Prefabs/Kamon/" + syogunId.ToString();
                            slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite =
                                Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                            string daimyoName = daimyo.getName(syogunId);
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = " Syogun " + daimyoName + "'s retainer";
                            }
                            else
                            {
                                script.shisyaName = "将軍" + daimyoName + "配下";
                            }
                        }
                        else
                        {
                            PlayerPrefs.DeleteKey("shisya" + i.ToString());
                        }
                    }
                    else
                    {
                        if (i == 13 || i == 15 || i == 16 || i == 17)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = "Nobleman";
                            }
                            else
                            {
                                script.shisyaName = "貴族";
                            }
                        }
                        else if (i == 18)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = "Merchant";
                            }
                            else
                            {
                                script.shisyaName = "商人";
                            }
                        }
                        else if (i == 19)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = "Westerner";
                            }
                            else
                            {
                                script.shisyaName = "南蛮人";
                            }
                        }
                        else if (i == 20)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = "Monk";
                            }
                            else
                            {
                                script.shisyaName = "僧";
                            }
                        }
                        else if (i == 21)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                script.shisyaName = "Local Samurai";
                            }
                            else
                            {
                                script.shisyaName = "国人衆";
                            }
                        }
                    }


                    //Random Handling
                    string requried1 = shisya.getYesRequried1(i);
                    if (requried1 == "random")
                    {
                        randomMyKahouView(slotObj);
                    }
                    else if (requried1 == "randomKahou")
                    {
                        randomSalesKahouView(slotObj);
                    }


                    //Set Value
                    script.shisyaId = i;
                    script.title    = title;
                    script.Content  = content;

                    int    rdm    = UnityEngine.Random.Range(1, 4);              //1-3
                    string serihu = "";
                    if (rdm == 1)
                    {
                        serihu = shisya.getSerihu1(i);
                    }
                    else if (rdm == 2)
                    {
                        serihu = shisya.getSerihu2(i);
                    }
                    else if (rdm == 3)
                    {
                        serihu = shisya.getSerihu3(i);
                    }

                    serihu        = serihuChanger(i, serihu, shisyaParamList, slotObj);
                    script.serihu = serihu;


                    if (!ClickFlg)
                    {
                        ClickFlg  = true;
                        firstSlot = slotObj;
                    }
                }
            }
        }

        if (firstSlot != null)
        {
            firstSlot.GetComponent <ShisyaSelect> ().OnClick();
        }
        else
        {
            Application.LoadLevel("mainStage");
        }
    }
Exemplo n.º 8
0
	public void FinMaker(GameObject panel){

		string finPath = "Prefabs/clearOrGameOver/Fin";
		GameObject finObj = Instantiate(Resources.Load (finPath)) as GameObject;
		finObj.transform.SetParent(panel.transform);
		finObj.transform.localScale = new Vector2(1,1);
		finObj.transform.FindChild ("ReStartBtn").GetComponent<ShowDaimyoSelect> ().fin = finObj;
		finObj.transform.FindChild ("ReStartBtn").GetComponent<ShowDaimyoSelect> ().panel = panel;

		int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
		Daimyo daimyo = new Daimyo ();
		int busyoId = daimyo.getDaimyoBusyoId (myDaimyo);
		string path = "Prefabs/Player/" + busyoId;
		GameObject prefab = Instantiate(Resources.Load (path)) as GameObject;
		prefab.transform.SetParent (finObj.transform);
		prefab.transform.localScale = new Vector2 (50, 60);
		prefab.transform.localPosition = new Vector2 (-170, 250);
		
		if (prefab.GetComponent<Homing> () != null) {
			prefab.GetComponent<Homing> ().enabled = false;
		} else {
			prefab.GetComponent<HomingLong> ().enabled = false;
		}



	}
Exemplo n.º 9
0
    public void kessen(GameObject contentObj)
    {
        //disable
        contentObj.transform.FindChild("SobujiKessenBtn").gameObject.SetActive(false);
        contentObj.transform.FindChild("AtkOrderBtn").gameObject.SetActive(false);
        contentObj.transform.FindChild("DfcOrderBtn").gameObject.SetActive(false);
        contentObj.transform.FindChild("RelationshipBtn").gameObject.SetActive(false);

        Daimyo        daimyo       = new Daimyo();
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

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

        List <int>    openDaimyoList = new List <int>();
        string        openKuni       = PlayerPrefs.GetString("openKuni");
        List <string> openKuniList   = new List <string>();

        if (openKuni != null && openKuni != "")
        {
            if (openKuni.Contains(","))
            {
                openKuniList = new List <string>(openKuni.Split(delimiterChars));
            }
            else
            {
                openKuniList.Add(openKuni);
            }
        }

        int myDaimyo = PlayerPrefs.GetInt("myDaimyo");

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int daimyoId = int.Parse(seiryokuList [i]);
            kuniQtyByDaimyoId [daimyoId - 1] = kuniQtyByDaimyoId [daimyoId - 1] + 1;

            int kuniId = i + 1;
            if (openKuniList.Contains(kuniId.ToString()))
            {
                if (!openDaimyoList.Contains(daimyoId))
                {
                    openDaimyoList.Add(daimyoId);
                }
            }
        }



        string     kessenBtnPath   = "Prefabs/Bakuhu/KessenBtn";
        List <int> checkedDaimyoId = new List <int> ();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int daimyoId = int.Parse(seiryokuList [i]);
            if (daimyoId != myDaimyo)
            {
                if (!checkedDaimyoId.Contains(daimyoId))
                {
                    //Open Kuni
                    if (openDaimyoList.Contains(daimyoId))
                    {
                        checkedDaimyoId.Add(daimyoId);
                        string daimyoName = daimyo.getName(daimyoId);
                        int    busyoId    = daimyo.getDaimyoBusyoId(daimyoId);
                        int    kuniId     = i + 1;

                        GameObject slotObj = Instantiate(Resources.Load(kessenBtnPath)) as GameObject;
                        slotObj.transform.SetParent(contentObj.transform);
                        slotObj.transform.localScale = new Vector2(1, 1);
                        slotObj.name = "KessenBtn";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            slotObj.transform.FindChild("Title").GetComponent <Text> ().text = daimyoName + "\n Final War";
                        }
                        else
                        {
                            slotObj.transform.FindChild("Title").GetComponent <Text>().text = daimyoName + "\n決戦";
                        }
                        string imagePath = "Prefabs/Player/Sprite/unit" + busyoId.ToString();
                        slotObj.transform.FindChild("Mask").transform.FindChild("Image").GetComponent <Image>().sprite =
                            Resources.Load(imagePath, typeof(Sprite)) as Sprite;
                        slotObj.GetComponent <BakuhuMenu> ().daimyoId   = daimyoId;
                        slotObj.GetComponent <BakuhuMenu> ().daimyoName = daimyoName;
                        slotObj.GetComponent <BakuhuMenu> ().kuniId     = kuniId;
                        int hyourou = kuniQtyByDaimyoId [daimyoId - 1] * 20;
                        if (hyourou > 80)
                        {
                            hyourou = 80;
                        }
                        slotObj.GetComponent <BakuhuMenu> ().hyourouNo = hyourou;
                        slotObj.transform.FindChild("HyourouIcon").transform.FindChild("HyourouValue").GetComponent <Text> ().text = hyourou.ToString();
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
    public void OnClick()
    {
        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [5].Play();

        //Hyourou
        int hyourou    = PlayerPrefs.GetInt("hyourou");
        int newHyourou = hyourou - 10;

        PlayerPrefs.SetInt("hyourou", newHyourou);
        GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

        //Track
        int TrackToubatsuNo = PlayerPrefs.GetInt("TrackToubatsuNo", 0);

        TrackToubatsuNo = TrackToubatsuNo + 1;
        PlayerPrefs.SetInt("TrackToubatsuNo", TrackToubatsuNo);

        MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> ();

        myKuniQty             = script.myKuniQty;
        myDaimyo              = script.myDaimyo;
        myKuniQtyIsBiggestFlg = GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg;
        List <string> messageList = new List <string> ();

        //reduce yukoudo
        Gaikou   gaikou   = new Gaikou();
        DoGaikou doGaikou = new DoGaikou();
        int      myGaikouValueWithTarget = gaikou.getMyGaikou(targetDaimyoId);
        int      newYukoudoWithTarget    = gaikou.downMyGaikou(targetDaimyoId, myGaikouValueWithTarget, 50);
        int      reducedValueWithTarget  = myGaikouValueWithTarget - newYukoudoWithTarget;
        string   firstKassenText         = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            firstKassenText = "Declared " + targetDaimyoName + " attack order. \n Friendship reduced " + reducedValueWithTarget + " point.";
        }
        else
        {
            firstKassenText = targetDaimyoName + "討伐を宣言しました。\n当家との友好度が" + reducedValueWithTarget + "下がります。";
        }
        doGaikou.downYukouOnIcon(targetDaimyoId, newYukoudoWithTarget);
        messageList.Add(firstKassenText);

        //doumei check
        Doumei   doumei         = new Doumei();
        KuniInfo kuni           = new KuniInfo();
        bool     doumeiExistFlg = doumei.myDoumeiExistCheck(targetDaimyoId);

        if (doumeiExistFlg)
        {
            doumei.deleteDoumei(myDaimyo.ToString(), targetDaimyoId.ToString());

            //Change Map & Yukoudo
            kuni.deleteDoumeiKuniIcon(targetDaimyoId);
        }
        PlayerPrefs.Flush();


        //Listup Target kuni Id
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

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

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            if (int.Parse(seiryokuList [i]) == targetDaimyoId)
            {
                int kuniId = i + 1;
                targetKuniList.Add(kuniId);
            }
        }

        //Listup Available Open kuni
        List <string>           srcDstKuniList = new List <string> ();
        Entity_kuni_mapping_mst kuniMapMst     = Resources.Load("Data/kuni_mapping_mst") as Entity_kuni_mapping_mst;

        for (int j = 0; j < targetKuniList.Count; j++)
        {
            int tmpTargetKuniId = targetKuniList [j];

            for (int i = 0; i < kuniMapMst.param.Count; i++)
            {
                int temClearedKuniId = kuniMapMst.param[i].Souce;
                if (temClearedKuniId == tmpTargetKuniId)
                {
                    int openKuniId = kuniMapMst.param [i].Open;

                    if (int.Parse(seiryokuList [openKuniId - 1]) != targetDaimyoId &&
                        int.Parse(seiryokuList [openKuniId - 1]) != myDaimyo)
                    {
                        srcDstKuniList.Add(openKuniId.ToString() + "-" + tmpTargetKuniId.ToString());
                    }
                }
            }
        }

        //Shuffule
        for (int i = 0; i < srcDstKuniList.Count; i++)
        {
            string temp        = srcDstKuniList[i];
            int    randomIndex = Random.Range(i, srcDstKuniList.Count);
            srcDstKuniList[i]           = srcDstKuniList[randomIndex];
            srcDstKuniList[randomIndex] = temp;
        }

        /*Condition of succesful*/
        //1. number of own kuni is more thab twice as number as target ... 20%
        //2. number of own kuni is the largest ... 30%
        //3. relathionship btwn my party and src kuni is 100% ... 20%
        //4. relathionship btwn the other countiries each other is 0% ... 20%
        //5. attacker keep kuni number more than country receiving attack ... 10%

        //1.
        if (myKuniQty > 2 * kuniQty)
        {
            baseRatio = 20;
        }

        //2.
        if (myKuniQtyIsBiggestFlg)
        {
            baseRatio = baseRatio + 30;
        }

        //Make Gunzei
        char[]           delimiterChars2    = { '-' };
        GameObject       BakuhuKuniIconView = GameObject.Find("BakuhuKuniIconView").gameObject;
        string           path              = "Prefabs/Map/Gunzei";
        string           visualizePath     = "Prefabs/Bakuhu/ToubatsuSrcBusyo";
        GameObject       panel             = GameObject.Find("Panel").gameObject;
        Gunzei           gunzei            = new Gunzei();
        Daimyo           daimyo            = new Daimyo();
        MainEventHandler mEvent            = new MainEventHandler();
        List <int>       doneSrcDaimyoList = new List <int> ();

        for (int k = 0; k < srcDstKuniList.Count; k++)
        {
            float indvRatio = 0;

            string        key        = srcDstKuniList[k];
            List <string> srcDstList = new List <string> ();
            srcDstList = new List <string> (key.Split(delimiterChars2));

            //3
            int srcKuniId = int.Parse(srcDstList[0]);
            int srcDaimyo = int.Parse(seiryokuList[srcKuniId - 1]);

            if (!doneSrcDaimyoList.Contains(srcDaimyo))
            {
                doneSrcDaimyoList.Add(srcDaimyo);
                bool ExistFlg = false;
                foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei"))
                {
                    int gunzeiSrcDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId;

                    if (srcDaimyo == gunzeiSrcDaimyoId)
                    {
                        ExistFlg = true;
                    }
                }

                if (!ExistFlg)
                {
                    int myGaikouValue = gaikou.getMyGaikou(srcDaimyo);
                    indvRatio = baseRatio + (float)myGaikouValue / 5;

                    //4.
                    int dstKuniId        = int.Parse(srcDstList [1]);
                    int dstDaimyo        = int.Parse(seiryokuList [dstKuniId - 1]);
                    int otherGaikouValue = gaikou.getOtherGaikouValue(srcDaimyo, dstDaimyo);
                    indvRatio = indvRatio + (float)((100 - otherGaikouValue) / 5);

                    //5.
                    int   srcKuniQty = BakuhuKuniIconView.transform.FindChild(srcDstList [0]).GetComponent <SendParam> ().kuniQty;
                    float addRatio   = 0;
                    if (srcKuniQty >= kuniQty)
                    {
                        addRatio  = 10;
                        indvRatio = indvRatio + addRatio;
                    }

                    //Success Check
                    float percent = UnityEngine.Random.value;
                    percent = percent * 100;
                    if (percent <= indvRatio)
                    {
                        //OK
                        toubatsuFlg = true;
                        GameObject Gunzei = Instantiate(Resources.Load(path)) as GameObject;
                        Gunzei.transform.SetParent(panel.transform);
                        Gunzei.transform.localScale = new Vector2(1, 1);

                        GameObject minGunzei = Instantiate(Resources.Load(visualizePath)) as GameObject;
                        minGunzei.transform.SetParent(BakuhuKuniIconView.transform);
                        int    daimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyo);
                        string daimyoPath    = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
                        minGunzei.GetComponent <SpriteRenderer> ().sprite =
                            Resources.Load(daimyoPath, typeof(Sprite)) as Sprite;

                        //Location
                        int    srcX      = kuni.getKuniLocationX(srcKuniId);
                        int    srcY      = kuni.getKuniLocationY(srcKuniId);
                        int    dstX      = kuni.getKuniLocationX(dstKuniId);
                        int    dstY      = kuni.getKuniLocationY(dstKuniId);
                        string direction = "";

                        if (srcX < dstX)
                        {
                            Gunzei.transform.localScale    = new Vector2(1, 1);
                            minGunzei.transform.localScale = new Vector2(60, 72);
                            direction = "right";
                        }
                        else
                        {
                            Gunzei.transform.localScale    = new Vector2(-1, 1);
                            minGunzei.transform.localScale = new Vector2(-60, 72);
                            direction = "left";
                            Gunzei.GetComponent <Gunzei> ().leftFlg = true;
                        }

                        int           aveX            = (srcX + dstX) / 2;
                        int           aveY            = (srcY + dstY) / 2;
                        RectTransform GunzeiTransform = Gunzei.GetComponent <RectTransform> ();
                        GunzeiTransform.anchoredPosition = new Vector3(aveX, aveY, 0);

                        RectTransform minGunzeiTransform = minGunzei.GetComponent <RectTransform> ();
                        float         minAveX            = (float)aveX * 0.8f;
                        float         minAveY            = (float)aveY * 0.65f;
                        minGunzeiTransform.anchoredPosition = new Vector3((int)minAveX, (int)minAveY, 0);


                        Gunzei.GetComponent <Gunzei> ().key         = key;
                        Gunzei.GetComponent <Gunzei> ().srcKuni     = srcKuniId;
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoId = srcDaimyo;
                        string srcDaimyoName = daimyo.getName(srcDaimyo);
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoName = srcDaimyoName;
                        Gunzei.GetComponent <Gunzei> ().dstKuni       = dstKuniId;
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoId   = dstDaimyo;
                        string dstDaimyoName = daimyo.getName(dstDaimyo);
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoName = dstDaimyoName;
                        int myHei = gunzei.heiryokuCalc(srcKuniId);

                        //random myHei from -50%-myHei
                        List <float> randomPercent = new List <float> {
                            0.8f, 0.9f, 1.0f
                        };
                        int   rmd = UnityEngine.Random.Range(0, randomPercent.Count);
                        float per = randomPercent [rmd];
                        myHei = Mathf.CeilToInt(myHei * per);

                        Gunzei.GetComponent <Gunzei> ().myHei = myHei;
                        Gunzei.name = key;

                        //Engun from Doumei
                        List <string> doumeiDaimyoList = new List <string> ();
                        bool          dstEngunFlg      = false;
                        string        dstEngunDaimyoId = "";             //2:3:5
                        string        dstEngunHei      = "";
                        string        dstEngunSts      = "";             //BusyoId-BusyoLv-ButaiQty-ButaiLv:
                        int           totalEngunHei    = 0;

                        //Doumei Check
                        doumeiDaimyoList = doumei.doumeiExistCheck(dstDaimyo, srcDaimyo.ToString());
                        string doumeiCheck = "doumei" + srcDaimyo;
                        if (PlayerPrefs.HasKey(doumeiCheck))
                        {
                            string        cDoumei     = PlayerPrefs.GetString(doumeiCheck);
                            List <string> cDoumeiList = new List <string>();
                            if (cDoumei.Contains(","))
                            {
                                cDoumeiList = new List <string> (cDoumei.Split(delimiterChars));
                            }
                            else
                            {
                                cDoumeiList.Add(cDoumei);
                            }

                            //If Doumei Daimyo -> Delete
                            if (cDoumeiList.Contains(dstDaimyo.ToString()))
                            {
                                doumei.deleteDoumei(srcDaimyo.ToString(), dstDaimyo.ToString());
                            }
                        }

                        if (doumeiDaimyoList.Count != 0)
                        {
                            //Doumei Exist

                            //Trace Check
                            List <string> okDaimyoList = new List <string> ();
                            List <string> checkList    = new List <string> ();
                            okDaimyoList = doumei.traceNeighborDaimyo(dstKuniId, dstDaimyo, doumeiDaimyoList, seiryokuList, checkList, okDaimyoList);

                            if (okDaimyoList.Count != 0)
                            {
                                //Doumei & Neghbor Daimyo Exist

                                for (int h = 0; h < okDaimyoList.Count; h++)
                                {
                                    string engunDaimyo = okDaimyoList[h];
                                    int    yukoudo     = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), dstDaimyo);

                                    //engun check

                                    dstEngunFlg = mEvent.CheckByProbability(yukoudo);
                                    if (dstEngunFlg)
                                    {
                                        //Engun OK
                                        dstEngunFlg = true;
                                        if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                                        {
                                            dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                                            string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo);
                                            int    tempEngunHei = mEvent.getEngunHei(tempEngunSts);
                                            dstEngunHei   = dstEngunHei + ":" + tempEngunHei.ToString();
                                            totalEngunHei = totalEngunHei + tempEngunHei;
                                            dstEngunSts   = dstEngunSts + ":" + tempEngunSts;
                                        }
                                        else
                                        {
                                            dstEngunDaimyoId = engunDaimyo;
                                            string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo);
                                            int    tempEngunHei = mEvent.getEngunHei(tempEngunSts);
                                            dstEngunHei   = tempEngunHei.ToString();
                                            totalEngunHei = tempEngunHei;
                                            dstEngunSts   = tempEngunSts;
                                        }
                                    }
                                }
                                Gunzei.GetComponent <Gunzei> ().dstEngunFlg      = dstEngunFlg;
                                Gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId;
                                Gunzei.GetComponent <Gunzei> ().dstEngunHei      = dstEngunHei;
                                Gunzei.GetComponent <Gunzei> ().dstEngunSts      = dstEngunSts;
                            }
                        }

                        //Set Value
                        //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts
                        string keyValue   = "";
                        string createTime = System.DateTime.Now.ToString();
                        keyValue = createTime + "," + srcDaimyo + "," + dstDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + "," + dstEngunSts;
                        PlayerPrefs.SetString(key, keyValue);
                        string keyHistory = PlayerPrefs.GetString("keyHistory");
                        if (keyHistory == null || keyHistory == "")
                        {
                            keyHistory = key;
                        }
                        else
                        {
                            keyHistory = keyHistory + "," + key;
                        }
                        PlayerPrefs.SetString("keyHistory", keyHistory);
                        PlayerPrefs.SetInt("bakuhuTobatsuDaimyoId", dstDaimyo);
                        PlayerPrefs.Flush();

                        string kassenText = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            if (!dstEngunFlg)
                            {
                                kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers.";
                            }
                            else
                            {
                                kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers.\n Defender's allianced country sent " + totalEngunHei + " soldiers.";
                            }
                        }
                        else
                        {
                            if (!dstEngunFlg)
                            {
                                kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。";
                            }
                            else
                            {
                                kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。";
                            }
                        }
                        messageList.Add(kassenText);
                    }
                    else
                    {
                        //NG
                        string kassenText    = "";
                        string srcDaimyoName = daimyo.getName(srcDaimyo);
                        int    newYukoudo    = gaikou.downMyGaikou(srcDaimyo, myGaikouValue, 15);
                        int    reducedValue  = myGaikouValue - newYukoudo;
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            kassenText = srcDaimyoName + " rejected our attack order. Friendship reduced " + reducedValue + " point.";
                        }
                        else
                        {
                            kassenText = srcDaimyoName + "が討伐令を黙殺しました。当家との友好度が" + reducedValue + "下がります。";
                        }
                        doGaikou.downYukouOnIcon(srcDaimyo, newYukoudo);
                        messageList.Add(kassenText);
                    }
                }
            }
        }


        //Disabled
        foreach (Transform obj in BakuhuKuniIconView.transform)
        {
            if (obj.GetComponent <Button> ())
            {
                obj.GetComponent <Button> ().enabled = false;
            }
        }

        GameObject toubatsuSelect = GameObject.Find("ToubatsuSelect").gameObject;

        toubatsuSelect.transform.FindChild("ToubatsuBtn").gameObject.SetActive(false);
        if (toubatsuFlg)
        {
            audioSources [3].Play();
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "Declared " + targetDaimyoName + " attack order. Other family responded to it.";
            }
            else
            {
                toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "の討伐令を出しました。諸大名が呼応したようです。";
            }
        }
        else
        {
            audioSources [4].Play();
            if (srcDstKuniList.Count == 0)
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "There is no family who can respond to " + targetDaimyoName + " attack order.";
                }
                else
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = "現在" + targetDaimyoName + "の討伐に呼応可能な大名はおりません。";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "No family responded to our attack order because of fear for " + targetDaimyoName + ".";
                }
                else
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "を恐れてか、討伐令にどの大名も呼応しませんでした。";
                }
            }
        }

        Message msg = new Message();

        msg.makeSlotMessage(messageList);
    }
Exemplo n.º 11
0
    public void FinMaker(GameObject panel)
    {
        string     finPath = "Prefabs/clearOrGameOver/Fin";
        GameObject finObj  = Instantiate(Resources.Load(finPath)) as GameObject;

        finObj.transform.SetParent(panel.transform);
        finObj.transform.localScale = new Vector2(1, 1);
        finObj.transform.FindChild("ReStartBtn").GetComponent <ShowDaimyoSelect> ().fin   = finObj;
        finObj.transform.FindChild("ReStartBtn").GetComponent <ShowDaimyoSelect> ().panel = panel;
        finObj.transform.FindChild("ReStartBtn").transform.FindChild("Question").GetComponent <QA> ().qaId = 12;

        int        myDaimyo = PlayerPrefs.GetInt("myDaimyo");
        Daimyo     daimyo   = new Daimyo();
        int        busyoId  = daimyo.getDaimyoBusyoId(myDaimyo);
        string     path     = "Prefabs/Player/" + busyoId;
        GameObject prefab   = Instantiate(Resources.Load(path)) as GameObject;

        prefab.transform.SetParent(finObj.transform);
        prefab.transform.localScale    = new Vector2(50, 60);
        prefab.transform.localPosition = new Vector2(-170, 340);


        prefab.GetComponent <UnitMover> ().enabled = false;
        Destroy(prefab.GetComponent <PlayerHP>());

        //Value Set
        GameObject eval     = finObj.transform.FindChild("Eval").gameObject;
        GameObject Gunji    = eval.transform.FindChild("Gunji").gameObject;
        GameObject Naisei   = eval.transform.FindChild("Naisei").gameObject;
        GameObject Gaikou   = eval.transform.FindChild("Gaikou").gameObject;
        GameObject Bouryaku = eval.transform.FindChild("Bouryaku").gameObject;

        //Gunji
        int TrackTotalKassenNo    = PlayerPrefs.GetInt("TrackTotalKassenNo");
        int TrackWinNo            = PlayerPrefs.GetInt("TrackWinNo");
        int TrackTettaiNo         = PlayerPrefs.GetInt("TrackTettaiNo");
        int TrackBiggestDaimyoId  = PlayerPrefs.GetInt("TrackBiggestDaimyoId");
        int TrackBiggestDaimyoHei = PlayerPrefs.GetInt("TrackBiggestDaimyoHei");
        int TrackMyBiggestHei     = PlayerPrefs.GetInt("TrackMyBiggestHei");
        int TrackNewBusyoHireNo   = PlayerPrefs.GetInt("TrackNewBusyoHireNo");
        int TrackEarnMoney        = PlayerPrefs.GetInt("TrackEarnMoney");

        Gunji.transform.FindChild("KassenNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackTotalKassenNo.ToString();
        int winRatio = Mathf.CeilToInt((float)TrackWinNo / (float)TrackTotalKassenNo * 100);

        if (TrackWinNo == 0)
        {
            winRatio = 0;
        }
        Gunji.transform.FindChild("WinRatio").transform.FindChild("Text").GetComponent <Text> ().text = winRatio.ToString() + "%";
        Gunji.transform.FindChild("Tettai").transform.FindChild("Text").GetComponent <Text> ().text   = TrackTettaiNo.ToString();
        string daimyoName = daimyo.getName(TrackBiggestDaimyoId);

        Gunji.transform.FindChild("BiggestEnemy").transform.FindChild("Text").GetComponent <Text> ().text     = daimyoName;
        Gunji.transform.FindChild("BiggestEnemyHei").transform.FindChild("Text").GetComponent <Text> ().text  = TrackBiggestDaimyoHei.ToString();
        Gunji.transform.FindChild("BiggestPlayerHei").transform.FindChild("Text").GetComponent <Text> ().text = TrackMyBiggestHei.ToString();
        Gunji.transform.FindChild("NewBusyoHire").transform.FindChild("Text").GetComponent <Text> ().text     = TrackNewBusyoHireNo.ToString();
        Gunji.transform.FindChild("EarnMoney").transform.FindChild("Text").GetComponent <Text> ().text        = TrackEarnMoney.ToString();



        //Naisei
        int TrackGetMoneyNo     = PlayerPrefs.GetInt("TrackGetMoneyNo");
        int TrackGetHyourouNo   = PlayerPrefs.GetInt("TrackGetHyourouNo");
        int TrackGetSozaiNo     = PlayerPrefs.GetInt("TrackGetSozaiNo");
        int TrackBuildMoneyNo   = PlayerPrefs.GetInt("TrackBuildMoneyNo");
        int TrackJyosyuNinmeiNo = PlayerPrefs.GetInt("TrackJyosyuNinmeiNo");
        int TrackTabibitoNo     = PlayerPrefs.GetInt("TrackTabibitoNo");
        int TrackIjinNo         = PlayerPrefs.GetInt("TrackIjinNo");
        int HstNanbansen        = PlayerPrefs.GetInt("HstNanbansen");

        Naisei.transform.FindChild("MoneyProfitQty").transform.FindChild("Text").GetComponent <Text> ().text   = TrackGetMoneyNo.ToString();
        Naisei.transform.FindChild("HyourouProfitQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackGetHyourouNo.ToString();
        Naisei.transform.FindChild("SozaiProfitQty").transform.FindChild("Text").GetComponent <Text> ().text   = TrackGetSozaiNo.ToString();
        Naisei.transform.FindChild("NaiseiInvestment").transform.FindChild("Text").GetComponent <Text> ().text = TrackBuildMoneyNo.ToString();
        Naisei.transform.FindChild("JyosyuNinmeiNo").transform.FindChild("Text").GetComponent <Text> ().text   = TrackJyosyuNinmeiNo.ToString();
        Naisei.transform.FindChild("TabibitoNo").transform.FindChild("Text").GetComponent <Text> ().text       = TrackTabibitoNo.ToString();
        Naisei.transform.FindChild("IjinNo").transform.FindChild("Text").GetComponent <Text> ().text           = TrackIjinNo.ToString();
        Naisei.transform.FindChild("Nanbansen").transform.FindChild("Text").GetComponent <Text> ().text        = HstNanbansen.ToString();



        //Gaikou
        int    TrackGaikouNo      = PlayerPrefs.GetInt("TrackGaikouNo");
        int    TrackGaikouMoneyNo = PlayerPrefs.GetInt("TrackGaikouMoneyNo");
        int    TrackDoumeiNo      = PlayerPrefs.GetInt("TrackDoumeiNo");
        int    TrackCyouteiNo     = PlayerPrefs.GetInt("TrackCyouteiNo");
        int    TrackSyouninNo     = PlayerPrefs.GetInt("TrackSyouninNo");
        int    syogunDaimyoId     = PlayerPrefs.GetInt("syogunDaimyoId");
        string Bakuhu             = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            Bakuhu = "Not Yet";
        }
        else
        {
            Bakuhu = "未開闢";
        }
        if (syogunDaimyoId == myDaimyo)
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                Bakuhu = "Done";
            }
            else
            {
                Bakuhu = "開闢済";
            }
        }
        bool   soubujireiFlg = PlayerPrefs.GetBool("soubujireiFlg");
        string Soubujirei    = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            Soubujirei = "Not Yet";
        }
        else
        {
            Soubujirei = "未施行";
        }
        if (soubujireiFlg)
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                Soubujirei = "Done";
            }
            else
            {
                Soubujirei = "施行済";
            }
        }
        int TrackToubatsuNo = PlayerPrefs.GetInt("TrackToubatsuNo");

        Gaikou.transform.FindChild("GaikouNo").transform.FindChild("Text").GetComponent <Text> ().text    = TrackGaikouNo.ToString();
        Gaikou.transform.FindChild("GaikouMoney").transform.FindChild("Text").GetComponent <Text> ().text = TrackGaikouMoneyNo.ToString();
        Gaikou.transform.FindChild("DoumeiNo").transform.FindChild("Text").GetComponent <Text> ().text    = TrackDoumeiNo.ToString();
        Gaikou.transform.FindChild("CyouteiNo").transform.FindChild("Text").GetComponent <Text> ().text   = TrackCyouteiNo.ToString();
        Gaikou.transform.FindChild("SyouninNo").transform.FindChild("Text").GetComponent <Text> ().text   = TrackSyouninNo.ToString();
        Gaikou.transform.FindChild("Bakuhu").transform.FindChild("Text").GetComponent <Text> ().text      = Bakuhu;
        Gaikou.transform.FindChild("Soubujirei").transform.FindChild("Text").GetComponent <Text> ().text  = Soubujirei;
        Gaikou.transform.FindChild("ToubatsuNo").transform.FindChild("Text").GetComponent <Text> ().text  = TrackToubatsuNo.ToString();



        //Bouryaku
        int TrackBouryakuNo        = PlayerPrefs.GetInt("TrackBouryakuNo");
        int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo");
        int TrackCyouhouNo         = PlayerPrefs.GetInt("TrackCyouhouNo");
        int TrackRyugenNo          = PlayerPrefs.GetInt("TrackRyugenNo");
        int TrackGihouHei          = PlayerPrefs.GetInt("TrackGihouHei");
        int TrackCyouryakuNo       = PlayerPrefs.GetInt("TrackCyouryakuNo");
        int TrackLinkCutNo         = PlayerPrefs.GetInt("TrackLinkCutNo");
        int TrackSyuppeiNo         = PlayerPrefs.GetInt("TrackSyuppeiNo");

        Bouryaku.transform.FindChild("BouryakuQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackBouryakuNo.ToString();
        int successRatio = Mathf.CeilToInt((float)TrackBouryakuSuccessNo / (float)TrackBouryakuNo * 100);

        if (TrackBouryakuSuccessNo == 0)
        {
            successRatio = 0;
        }
        Bouryaku.transform.FindChild("BouryakuRatio").transform.FindChild("Text").GetComponent <Text> ().text = successRatio.ToString() + "%";
        Bouryaku.transform.FindChild("Cyouhou").transform.FindChild("Text").GetComponent <Text> ().text       = TrackCyouhouNo.ToString();
        Bouryaku.transform.FindChild("Ryugen").transform.FindChild("Text").GetComponent <Text> ().text        = TrackRyugenNo.ToString();
        Bouryaku.transform.FindChild("GihouHei").transform.FindChild("Text").GetComponent <Text> ().text      = TrackGihouHei.ToString();
        Bouryaku.transform.FindChild("Cyouryaku").transform.FindChild("Text").GetComponent <Text> ().text     = TrackCyouryakuNo.ToString();
        Bouryaku.transform.FindChild("LinkCut").transform.FindChild("Text").GetComponent <Text> ().text       = TrackLinkCutNo.ToString();
        Bouryaku.transform.FindChild("Syuppei").transform.FindChild("Text").GetComponent <Text> ().text       = TrackSyuppeiNo.ToString();
    }
Exemplo n.º 12
0
    public void OnClick()
    {
        /*Receive Item*/
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [3].Play();

        //Item1
        string        gameClearDaimyo     = PlayerPrefs.GetString("gameClearDaimyo");
        bool          hardFlg             = PlayerPrefs.GetBool("hardFlg");
        List <string> gameClearDaimyoList = new List <string> ();

        char[] delimiterChars = { ',' };
        if (gameClearDaimyo != null && gameClearDaimyo != "")
        {
            if (gameClearDaimyo.Contains(","))
            {
                gameClearDaimyoList = new List <string> (gameClearDaimyo.Split(delimiterChars));
            }
            else
            {
                gameClearDaimyoList.Add(gameClearDaimyo);
            }
        }
        int myDaimyo = PlayerPrefs.GetInt("myDaimyo");

        if (!gameClearDaimyoList.Contains(myDaimyo.ToString()))
        {
            if (gameClearDaimyo != null && gameClearDaimyo != "")
            {
                gameClearDaimyo = gameClearDaimyo + "," + myDaimyo.ToString();
            }
            else
            {
                gameClearDaimyo = myDaimyo.ToString();
            }
            PlayerPrefs.SetString("gameClearDaimyo", gameClearDaimyo);
        }

        //Hard mode
        if (hardFlg)
        {
            string        gameClearDaimyoHard     = PlayerPrefs.GetString("gameClearDaimyoHard");
            List <string> gameClearDaimyoHardList = new List <string>();
            if (gameClearDaimyoHard != null && gameClearDaimyoHard != "")
            {
                if (gameClearDaimyoHard.Contains(","))
                {
                    gameClearDaimyoHardList = new List <string>(gameClearDaimyoHard.Split(delimiterChars));
                }
                else
                {
                    gameClearDaimyoHardList.Add(gameClearDaimyoHard);
                }
            }
            if (!gameClearDaimyoHardList.Contains(myDaimyo.ToString()))
            {
                if (gameClearDaimyoHard != null && gameClearDaimyoHard != "")
                {
                    gameClearDaimyoHard = gameClearDaimyoHard + "," + myDaimyo.ToString();
                }
                else
                {
                    gameClearDaimyoHard = myDaimyo.ToString();
                }
                PlayerPrefs.SetString("gameClearDaimyoHard", gameClearDaimyoHard);
            }
        }


        PlayerPrefs.SetBool("gameClearItemGetFlg", true);


        //Item2
        PlayerPrefs.DeleteKey("gameClearKahouCd");
        PlayerPrefs.DeleteKey("gameClearKahouId");
        Kahou kahou = new Kahou();

        if (kahouCd == "bugu")
        {
            kahou.registerBugu(int.Parse(kahouId));
        }
        else if (kahouCd == "gusoku")
        {
            kahou.registerGusoku(int.Parse(kahouId));
        }
        else if (kahouCd == "kabuto")
        {
            kahou.registerKabuto(int.Parse(kahouId));
        }
        else if (kahouCd == "meiba")
        {
            kahou.registerMeiba(int.Parse(kahouId));
        }
        else if (kahouCd == "cyadougu")
        {
            kahou.registerCyadougu(int.Parse(kahouId));
        }
        else if (kahouCd == "chishikisyo")
        {
            kahou.registerChishikisyo(int.Parse(kahouId));
        }
        else if (kahouCd == "heihousyo")
        {
            kahou.registerHeihousyo(int.Parse(kahouId));
        }

        //Item3
        int busyoDama    = PlayerPrefs.GetInt("busyoDama");
        int newBusyoDama = busyoDama + 1000;

        PlayerPrefs.SetInt("busyoDama", newBusyoDama);



        //Get Daimyo Busyo
        Daimyo daimyoScript  = new Daimyo();
        int    daimyoId      = PlayerPrefs.GetInt("myDaimyo");
        int    daimyoBusyoId = daimyoScript.getDaimyoBusyoId(daimyoId);

        string        zukanBusyoHst     = PlayerPrefs.GetString("zukanBusyoHst");
        List <string> zukanBusyoHstList = new List <string>();

        if (zukanBusyoHst != null && zukanBusyoHst != "")
        {
            if (zukanBusyoHst.Contains(","))
            {
                zukanBusyoHstList = new List <string>(zukanBusyoHst.Split(delimiterChars));
            }
            else
            {
                zukanBusyoHstList.Add(zukanBusyoHst);
            }
        }
        if (!zukanBusyoHstList.Contains(daimyoBusyoId.ToString()))
        {
            if (zukanBusyoHst != null && zukanBusyoHst != "")
            {
                zukanBusyoHst = zukanBusyoHst + "," + daimyoBusyoId.ToString();
            }
            else
            {
                zukanBusyoHst = daimyoBusyoId.ToString();
            }
            PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst);
        }

        if (daimyoScript.daimyoBusyoCheck(daimyoBusyoId))
        {
            string        gacyaDaimyoHst     = PlayerPrefs.GetString("gacyaDaimyoHst");
            List <string> gacyaDaimyoHstList = new List <string>();
            if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
            {
                if (gacyaDaimyoHst.Contains(","))
                {
                    gacyaDaimyoHstList = new List <string>(gacyaDaimyoHst.Split(delimiterChars));
                }
                else
                {
                    gacyaDaimyoHstList.Add(gacyaDaimyoHst);
                }
            }
            if (!gacyaDaimyoHstList.Contains(daimyoBusyoId.ToString()))
            {
                if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
                {
                    gacyaDaimyoHst = gacyaDaimyoHst + "," + daimyoBusyoId.ToString();
                }
                else
                {
                    gacyaDaimyoHst = daimyoBusyoId.ToString();
                }
                PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst);
            }
        }

        PlayerPrefs.Flush();



        //Hide Back
        Destroy(backObj.gameObject);
        Destroy(popObj.gameObject);
        Destroy(particleObj.gameObject);
        GameObject kunimap      = GameObject.Find("KuniMap").gameObject;
        GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject;

        Destroy(kunimap.gameObject);
        Destroy(kuniIconView.gameObject);

        FinMaker(panel);
    }
Exemplo n.º 13
0
    public void showBusyoZukan(GameObject Content)
    {
        //Prepare Master & History
        Entity_busyo_mst tempBusyoMst      = Resources.Load("Data/busyo_mst") as Entity_busyo_mst;
        string           zukanBusyoHst     = PlayerPrefs.GetString("zukanBusyoHst");
        List <string>    zukanBusyoHstList = new List <string> ();

        char[] delimiterChars = { ',' };
        if (zukanBusyoHst != null && zukanBusyoHst != "")
        {
            if (zukanBusyoHst.Contains(","))
            {
                zukanBusyoHstList = new List <string> (zukanBusyoHst.Split(delimiterChars));
            }
            else
            {
                zukanBusyoHstList.Add(zukanBusyoHst);
            }
        }

        //add temporary daimyo busyo
        int    myDaimyo        = PlayerPrefs.GetInt("myDaimyo");
        Daimyo daimyo          = new Daimyo();
        int    myDaimyoBusyoId = daimyo.getDaimyoBusyoId(myDaimyo);

        if (!zukanBusyoHstList.Contains(myDaimyoBusyoId.ToString()))
        {
            zukanBusyoHstList.Add(myDaimyoBusyoId.ToString());
        }

        //Sort Master by daimyo
        Entity_busyo_mst busyoMst = new Entity_busyo_mst();

        busyoMst.param.AddRange(tempBusyoMst.param);
        busyoMst.param.Sort((a, b) => a.daimyoId - b.daimyoId);

        //Show busyo
        string path         = "Prefabs/Zukan/zukanBusyo";
        string nameRankPath = "Prefabs/Zukan/NameRank";

        int NowQty = 0;
        int AllQty = 0;

        for (int i = 0; i < busyoMst.param.Count; i++)
        {
            int daimyoId = busyoMst.param[i].daimyoId;
            if (daimyoId == 0)
            {
                daimyoId = busyoMst.param[i].daimyoHst;
            }

            if (daimyoId != 0)
            {
                AllQty = AllQty + 1;

                BusyoInfoGet busyoScript = new BusyoInfoGet();
                int          busyoId     = busyoMst.param[i].id;
                string       busyoName   = busyoScript.getName(busyoId);
                string       busyoRank   = busyoMst.param[i].rank;

                GameObject back = Instantiate(Resources.Load(path)) as GameObject;
                back.transform.SetParent(Content.transform);
                back.transform.localScale    = new Vector2(1, 1);
                back.transform.localPosition = new Vector3(0, 0, 0);

                GameObject kamon = back.transform.FindChild("kamon").gameObject;

                //Busyo Icon
                string     busyoPath = "Prefabs/Player/Unit/BusyoUnit";
                GameObject busyo     = Instantiate(Resources.Load(busyoPath)) as GameObject;
                busyo.name = busyoId.ToString();
                busyo.transform.SetParent(back.transform);
                busyo.transform.localScale = new Vector2(4, 4);
                busyo.GetComponent <DragHandler>().enabled = false;
                foreach (Transform n in busyo.transform)
                {
                    GameObject.Destroy(n.gameObject);
                }
                RectTransform busyoRect = busyo.GetComponent <RectTransform>();
                busyoRect.anchoredPosition3D = new Vector3(80, 80, 0);
                busyoRect.sizeDelta          = new Vector2(40, 40);

                //Kamon
                string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString();
                kamon.GetComponent <Image> ().sprite =
                    Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                //Name
                GameObject nameRank = Instantiate(Resources.Load(nameRankPath)) as GameObject;
                nameRank.transform.SetParent(back.transform);
                nameRank.transform.localScale    = new Vector2(1, 1);
                nameRank.transform.localPosition = new Vector3(0, 0, 0);


                GameObject rank = nameRank.transform.FindChild("Rank").gameObject;
                rank.GetComponent <Text>().text = busyoRank;


                //Have or not
                if (zukanBusyoHstList.Contains(busyoId.ToString()))
                {
                    NowQty = NowQty + 1;

                    GameObject name = nameRank.transform.FindChild("Name").gameObject;
                    name.GetComponent <Text>().text = busyoName;

                    int    hp        = busyoMst.param[i].hp;
                    int    atk       = busyoMst.param[i].atk;
                    int    dfc       = busyoMst.param[i].dfc;
                    int    spd       = busyoMst.param[i].spd;
                    string heisyu    = busyoMst.param[i].heisyu;
                    int    sendpouId = busyoMst.param[i].senpou_id;

                    PopInfo popScript = back.GetComponent <PopInfo>();
                    popScript.busyoId   = busyoId;
                    popScript.busyoName = busyoName;
                    popScript.hp        = hp;
                    popScript.atk       = atk;
                    popScript.dfc       = dfc;
                    popScript.spd       = spd;
                    popScript.heisyu    = heisyu;
                    popScript.daimyoId  = daimyoId;
                    popScript.senpouId  = sendpouId;
                }
                else
                {
                    Color noBusyoColor = new Color(0f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);                      //Black
                    Color backColor    = new Color(95f / 255f, 95f / 255f, 95f / 255f, 240f / 255f);                   //Black
                    Color kamonColor   = new Color(105f / 255f, 105f / 255f, 105f / 255f, 135f / 255f);                //Black

                    back.GetComponent <Image>().color    = backColor;
                    back.GetComponent <Button>().enabled = false;
                    busyo.GetComponent <Image>().color   = noBusyoColor;
                    kamon.GetComponent <Image>().color   = kamonColor;
                }
            }
        }

        //Qty
        float percent = (float)NowQty / (float)AllQty * 100;

        GameObject.Find("NowQty").GetComponent <Text> ().text = NowQty.ToString();
        GameObject.Find("AllQty").GetComponent <Text> ().text = AllQty.ToString() + "(" + percent.ToString("F1") + "%)";
    }
Exemplo n.º 14
0
    public void SyuppeiKuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn)
    {
        //View kuni which have openkuni

        GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject;

        string seiryoku = PlayerPrefs.GetString("seiryoku");

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

        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

        //my kuni
        int        myDaimyo   = PlayerPrefs.GetInt("myDaimyo");
        string     myKuni     = PlayerPrefs.GetString("clearedKuni");
        List <int> myKuniList = new List <int>();

        if (myKuni.Contains(","))
        {
            List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars));
            myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x));
        }
        else
        {
            myKuniList.Add(int.Parse(myKuni));
        }

        //doumei daimyo's opne kuni
        KuniInfo   kuni = new KuniInfo();
        List <int> doumeiOpenKuniList = new List <int>();
        List <int> doumeiKuniList     = new List <int>();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            string tempDaimyo = seiryokuList[i];
            if (tempDaimyo == targetDaimyo)
            {
                int doumeiKuniId = i + 1;
                doumeiKuniList.Add(doumeiKuniId);
                doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId));
            }
        }

        //"doumei daimyo's doumei check
        string        tempDoumei = "doumei" + targetDaimyo;
        string        doumei     = PlayerPrefs.GetString(tempDoumei);
        List <string> doumeiList = new List <string>();

        if (doumei.Contains(","))
        {
            doumeiList = new List <string> (doumei.Split(delimiterChars));
        }
        else
        {
            doumeiList.Add(doumei);
        }


        //"doumei daimyo's opne kuni" minus "my kuni"  /minus Doumei's doumei
        List <int> doumeiOpenKuniMinusMyKuniList = new List <int>();

        foreach (int n in doumeiOpenKuniList)
        {
            if (!myKuniList.Contains(n))
            {
                if (!doumeiKuniList.Contains(n))
                {
                    if (doumeiList.Count != 0)
                    {
                        string checkDaimyoId = seiryokuList [n - 1];
                        if (!doumeiList.Contains(checkDaimyoId))
                        {
                            doumeiOpenKuniMinusMyKuniList.Add(n);
                        }
                    }
                    else
                    {
                        doumeiOpenKuniMinusMyKuniList.Add(n);
                    }
                }
            }
        }


        //delete duplication
        List <int> finalKuniList = new List <int>();

        for (int i = 0; i < doumeiOpenKuniMinusMyKuniList.Count; i++)
        {
            int tmpKuniId = doumeiOpenKuniMinusMyKuniList [i];

            if (!finalKuniList.Contains(tmpKuniId))
            {
                finalKuniList.Add(tmpKuniId);
            }
        }

        //Src Kuni List
        List <int> srcKuniList = new List <int>();

        for (int j = 0; j < finalKuniList.Count; j++)
        {
            int dstKuniId = finalKuniList [j];

            List <int> targetKuniList = new List <int>();
            targetKuniList.AddRange(kuni.getMappingKuni(dstKuniId));
            for (int k = 0; k < targetKuniList.Count; k++)
            {
                int srcKuniId = targetKuniList [k];
                if (doumeiKuniList.Contains(srcKuniId))
                {
                    srcKuniList.Add(srcKuniId);
                    break;
                }
            }
        }



        /*Slot making*/
        string temp      = "gaikou" + targetDaimyo;
        int    myYukoudo = PlayerPrefs.GetInt(temp);

        //Get Chiryaku
        //Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst;
        Daimyo       daimyoScript    = new Daimyo();
        int          myDaimyoBusyoId = daimyoScript.getDaimyoBusyoId(myDaimyo);
        BusyoInfoGet busyo           = new BusyoInfoGet();
        int          chiryaku        = busyo.getMaxDfc(myDaimyoBusyoId);

        string slotPath = "Prefabs/Map/common/kuniSlot";

        for (int i = 0; i < finalKuniList.Count; i++)
        {
            GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject;
            prefab.transform.SetParent(content.transform);
            prefab.transform.localScale = new Vector3(1, 1, 1);

            int    kuniId        = finalKuniList[i];
            int    daimyoId      = int.Parse(seiryokuList [kuniId - 1]);
            string daimyoName    = daimyoScript.getName(daimyoId);
            int    srcKuniId     = srcKuniList [i];
            int    srcDaimyoId   = int.Parse(seiryokuList [srcKuniId - 1]);
            string srcDaimyoName = daimyoScript.getName(srcDaimyoId);

            string theirYukouTemp = "";
            if (int.Parse(targetDaimyo) < daimyoId)
            {
                theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString();
            }
            else
            {
                theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo;
            }

            int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp);

            string kuniName = kuni.getKuniName(kuniId);
            prefab.transform.FindChild("KuniValue").GetComponent <Text>().text   = kuniName;
            prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName;
            prefab.GetComponent <GaikouKuniSelect>().Content = content;
            prefab.GetComponent <GaikouKuniSelect>().Btn     = btn;

            prefab.GetComponent <GaikouKuniSelect>().myYukoudo        = myYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().chiryaku         = chiryaku;
            prefab.GetComponent <GaikouKuniSelect>().kuniDiff         = kuniDiff;
            prefab.GetComponent <GaikouKuniSelect>().theirYukoudo     = theirYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().kuniName         = kuniName;
            prefab.GetComponent <GaikouKuniSelect>().targetKuniId     = kuniId;
            prefab.GetComponent <GaikouKuniSelect>().targetDaimyoId   = daimyoId;
            prefab.GetComponent <GaikouKuniSelect>().targetDaimyoName = daimyoName;
            prefab.GetComponent <GaikouKuniSelect>().srcKuniId        = srcKuniId;
            prefab.GetComponent <GaikouKuniSelect>().srcDaimyoId      = srcDaimyoId;
            prefab.GetComponent <GaikouKuniSelect>().srcDaimyoName    = srcDaimyoName;

            if (i == 0)
            {
                prefab.GetComponent <GaikouKuniSelect>().OnClick();
            }
        }

        if (finalKuniList.Count == 0)
        {
            string     msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg";
            GameObject msg     = Instantiate(Resources.Load(msgPath)) as GameObject;
            msg.transform.SetParent(GameObject.Find("scroll").transform);
            msg.transform.localScale = new Vector3(0.17f, 0.2f, 1);
            RectTransform msgTransform = msg.GetComponent <RectTransform>();
            msgTransform.anchoredPosition = new Vector3(-260, -115, 0);
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                msg.GetComponent <Text>().text = "There is no available country.\nWe are surranded by allianced party.";
            }
            else
            {
                msg.GetComponent <Text>().text = "出兵可能な国はありませぬ\n周辺国は同盟大名しかおりませぬぞ";
            }

            GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject;
            GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject;
            Destroy(a);
            Destroy(b);

            btn.GetComponent <Button>().enabled = false;
            Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f);
            Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f);
            btn.GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt;

            btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt;
        }
    }
Exemplo n.º 15
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource>();

        if (name == "YesButton")
        {
            audioSources[0].Play();
            RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>();

            //Common
            PlayerPrefs.SetBool("tutorialDoneFlg", true);
            PlayerPrefs.SetInt("kuniLv", RecoveryDataStore.kuniLv);
            Exp expScript   = new Exp();
            int jinkeiLimit = expScript.getJinkeiLimit(RecoveryDataStore.kuniLv);
            int stockLimit  = expScript.getStockLimit(RecoveryDataStore.kuniLv);
            PlayerPrefs.SetInt("jinkeiLimit", jinkeiLimit);
            PlayerPrefs.SetInt("stockLimit", stockLimit);
            PlayerPrefs.SetString("userId", RecoveryDataStore.inputUserId);
            if (RecoveryDataStore.addJinkei1)
            {
                PlayerPrefs.SetBool("addJinkei1", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei1", false);
            }
            if (RecoveryDataStore.addJinkei2)
            {
                PlayerPrefs.SetBool("addJinkei2", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei2", false);
            }
            if (RecoveryDataStore.addJinkei3)
            {
                PlayerPrefs.SetBool("addJinkei3", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei3", false);
            }
            if (RecoveryDataStore.addJinkei4)
            {
                PlayerPrefs.SetBool("addJinkei4", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei4", false);
            }

            if (RecoveryDataStore.dataStore_userId == 0)
            {
                /***dataStore***/
                PlayerPrefs.SetInt("kuniExp", RecoveryDataStore.kuniExp);
                PlayerPrefs.SetString("yearSeason", RecoveryDataStore.yearSeason);
                PlayerPrefs.SetInt("movieCount", RecoveryDataStore.movieCount);
                string seiryoku = RecoveryDataStore.seiryoku;
                if (seiryoku == "")
                {
                    seiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";
                }
                PlayerPrefs.SetString("seiryoku", seiryoku);
                KuniInfo kuniScript = new KuniInfo();
                kuniScript.updateOpenKuni(RecoveryDataStore.myDaimyo, seiryoku);
                kuniScript.updateClearedKuni(RecoveryDataStore.myDaimyo, seiryoku);
                PlayerPrefs.SetInt("money", RecoveryDataStore.money);
                PlayerPrefs.SetInt("busyoDama", RecoveryDataStore.busyoDama);
                PlayerPrefs.SetInt("syogunDaimyoId", RecoveryDataStore.syogunDaimyoId);
                PlayerPrefs.SetString("doumei", RecoveryDataStore.doumei);

                for (int i = 0; i < RecoveryDataStore.questSpecialFlgId.Count; i++)
                {
                    int    questId = RecoveryDataStore.questSpecialFlgId[i];
                    string tmp     = "questSpecialFlg" + questId.ToString();
                    string tmp2    = "questSpecialReceivedFlg" + questId.ToString();
                    PlayerPrefs.SetBool(tmp, true);

                    bool questReceivedFlg = RecoveryDataStore.questSpecialReceivedFlgId[i];
                    if (questReceivedFlg)
                    {
                        PlayerPrefs.SetBool(tmp2, true);
                    }
                    else
                    {
                        PlayerPrefs.SetBool(tmp2, false);
                    }
                }

                Entity_quest_count_mst questCountMst = Resources.Load("Data/quest_count_mst") as Entity_quest_count_mst;
                for (int i = 0; i < questCountMst.param.Count; i++)
                {
                    bool dailyFlg = questCountMst.param[i].daily;
                    if (!dailyFlg)
                    {
                        countSpecialList.Add(i);
                    }
                }
                if (RecoveryDataStore.questSpecialCountReceivedFlg.Count != 0)
                {
                    for (int i = 0; i < countSpecialList.Count; i++)
                    {
                        int    id  = countSpecialList[i];
                        string tmp = "questSpecialCountReceivedFlg" + id.ToString();
                        bool   questReceivedFlg = RecoveryDataStore.questSpecialCountReceivedFlg[i];
                        if (questReceivedFlg)
                        {
                            PlayerPrefs.SetBool(tmp, true);
                        }
                        else
                        {
                            PlayerPrefs.SetBool(tmp, false);
                        }
                    }
                }


                int    count   = 0;
                string myBusyo = "";
                for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++)
                {
                    int busyoId = RecoveryDataStore.busyoList[i];

                    if (busyoId != 0)
                    {
                        //add busyo
                        if (myBusyo == null || myBusyo == "")
                        {
                            myBusyo = busyoId.ToString();
                        }
                        else
                        {
                            myBusyo = myBusyo + "," + busyoId.ToString();
                        }
                        //add parametor
                        int    lv       = RecoveryDataStore.lvList[count];
                        string hei      = RecoveryDataStore.heiList[count];
                        int    senpouLv = RecoveryDataStore.senpouLvList[count];
                        int    sakuLv   = RecoveryDataStore.sakuLvList[count];
                        string kahou    = RecoveryDataStore.kahouList[count];

                        //lv
                        PlayerPrefs.SetInt(busyoId.ToString(), lv);
                        if (lv <= 0)
                        {
                            lv = 1;
                        }

                        //hei
                        string heiTmp = "hei" + busyoId.ToString();
                        PlayerPrefs.SetString(heiTmp, hei);

                        //senpou
                        string senpou = "senpou" + busyoId.ToString();
                        PlayerPrefs.SetInt(senpou, senpouLv); //Lv

                        //saku
                        string saku = "saku" + busyoId.ToString();
                        PlayerPrefs.SetInt(saku, sakuLv); //Lv

                        //kahou
                        string kahouTmp = "kahou" + busyoId.ToString();
                        PlayerPrefs.SetString(kahouTmp, kahou);

                        //exp
                        string exp           = "exp" + busyoId.ToString();
                        int    totalBusyoExp = expScript.getExpforNextLv(lv - 1);
                        PlayerPrefs.SetInt(exp, totalBusyoExp);

                        //addLv
                        string addlvTmp = "addlv" + busyoId.ToString();
                        int    addlv    = RecoveryDataStore.addLvList[count];
                        if (addlv != 0)
                        {
                            PlayerPrefs.SetInt(addlvTmp, addlv);
                        }

                        //gokui
                        string gokuiTmp = "gokui" + busyoId.ToString();
                        int    gokui    = RecoveryDataStore.gokuiList[count];
                        if (gokui != 0)
                        {
                            PlayerPrefs.SetInt(gokuiTmp, gokui);
                        }

                        //gokui
                        string kanniTmp = "kanni" + busyoId.ToString();
                        int    kanni    = RecoveryDataStore.kanniList[count];
                        if (kanni != 0)
                        {
                            PlayerPrefs.SetInt(kanniTmp, kanni);
                        }

                        count = count + 1;
                    }
                }

                PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo);
                Daimyo daimyoScript = new Daimyo();
                PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo));
                PlayerPrefs.SetString("myBusyo", myBusyo);
                PlayerPrefs.SetString("myKanni", RecoveryDataStore.myKanni);
                PlayerPrefs.SetString("availableBugu", RecoveryDataStore.availableBugu);
                PlayerPrefs.SetString("availableKabuto", RecoveryDataStore.availableKabuto);
                PlayerPrefs.SetString("availableGusoku", RecoveryDataStore.availableGusoku);
                PlayerPrefs.SetString("availableMeiba", RecoveryDataStore.availableMeiba);
                PlayerPrefs.SetString("availableCyadougu", RecoveryDataStore.availableCyadougu);
                PlayerPrefs.SetString("availableHeihousyo", RecoveryDataStore.availableHeihousyo);
                PlayerPrefs.SetString("availableChishikisyo", RecoveryDataStore.availableChishikisyo);
                PlayerPrefs.SetString("kanjyo", RecoveryDataStore.kanjyo);
                PlayerPrefs.SetString("cyouheiYR", RecoveryDataStore.cyouheiYR);
                PlayerPrefs.SetString("cyouheiKB", RecoveryDataStore.cyouheiKB);
                PlayerPrefs.SetString("cyouheiTP", RecoveryDataStore.cyouheiTP);
                PlayerPrefs.SetString("cyouheiYM", RecoveryDataStore.cyouheiYM);
                PlayerPrefs.SetInt("hidensyoGe", RecoveryDataStore.hidensyoGe);
                PlayerPrefs.SetInt("hidensyoCyu", RecoveryDataStore.hidensyoCyu);
                PlayerPrefs.SetInt("hidensyoJyo", RecoveryDataStore.hidensyoJyo);
                PlayerPrefs.SetInt("shinobiGe", RecoveryDataStore.shinobiGe);
                PlayerPrefs.SetInt("shinobiCyu", RecoveryDataStore.shinobiCyu);
                PlayerPrefs.SetInt("shinobiJyo", RecoveryDataStore.shinobiJyo);
                PlayerPrefs.SetString("kengouItem", RecoveryDataStore.kengouItem);
                PlayerPrefs.SetString("gokuiItem", RecoveryDataStore.gokuiItem);
                PlayerPrefs.SetString("nanbanItem", RecoveryDataStore.nanbanItem);
                PlayerPrefs.SetInt("transferTP", RecoveryDataStore.transferTP);
                PlayerPrefs.SetInt("transferKB", RecoveryDataStore.transferKB);
                PlayerPrefs.SetInt("meisei", RecoveryDataStore.meisei);
                PlayerPrefs.SetString("shiro", RecoveryDataStore.shiro);
                PlayerPrefs.SetString("koueki", RecoveryDataStore.koueki);
                PlayerPrefs.SetString("cyoutei", RecoveryDataStore.cyoutei);
                PlayerPrefs.SetString("zukanBusyoHst", RecoveryDataStore.zukanBusyoHst);
                PlayerPrefs.SetString("zukanBuguHst", RecoveryDataStore.zukanBuguHst);
                PlayerPrefs.SetString("zukanGusokuHst", RecoveryDataStore.zukanGusokuHst);
                PlayerPrefs.SetString("zukanKabutoHst", RecoveryDataStore.zukanKabutoHst);
                PlayerPrefs.SetString("zukanMeibaHst", RecoveryDataStore.zukanMeibaHst);
                PlayerPrefs.SetString("zukanCyadouguHst", RecoveryDataStore.zukanCyadouguHst);
                PlayerPrefs.SetString("zukanChishikisyoHst", RecoveryDataStore.zukanChishikisyoHst);
                PlayerPrefs.SetString("zukanHeihousyoHst", RecoveryDataStore.zukanHeihousyoHst);
                PlayerPrefs.SetString("gameClearDaimyo", RecoveryDataStore.gameClearDaimyo);
                PlayerPrefs.SetString("gameClearDaimyoHard", RecoveryDataStore.gameClearDaimyoHard);

                //jinkei
                PlayerPrefs.SetInt("jinkei", RecoveryDataStore.jinkeiId);
                PlayerPrefs.SetInt("soudaisyo" + RecoveryDataStore.jinkeiId, RecoveryDataStore.soudaisyo);
                for (int i = 0; i < 25; i++)
                {
                    int busyoId = RecoveryDataStore.busyoMapList[i];
                    int id      = i + 1;
                    if (busyoId == 0)
                    {
                        string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString();
                        PlayerPrefs.DeleteKey(tmp);
                    }
                    else
                    {
                        string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString();
                        PlayerPrefs.SetInt(tmp, busyoId);
                    }
                }

                //naisei
                for (int i = 0; i < RecoveryDataStore.naiseiKuniList.Count; i++)
                {
                    int    kuniId    = RecoveryDataStore.naiseiKuniList[i];
                    string naiseiTmp = "naisei" + kuniId.ToString();
                    PlayerPrefs.SetString(naiseiTmp, RecoveryDataStore.naiseiList[i]);

                    if (RecoveryDataStore.naiseiShiroList[i] != 0)
                    {
                        string shiroTmp = "shiro" + kuniId.ToString();
                        PlayerPrefs.SetInt(shiroTmp, RecoveryDataStore.naiseiShiroList[i]);
                    }
                }

                //Add Qty & PvP Name
                PlayerPrefs.SetInt("myBusyoQty", RecoveryDataStore.busyoList.Count);
                string userName = RecoveryDataStore.userName;
                if (userName == "")
                {
                    userName = "******";
                }
                PlayerPrefs.SetString("PvPName", userName);
            }
            else
            {
                /***userId + pvpJinkei***/
                int totalExp = expScript.getTotalExp(RecoveryDataStore.kuniLv);
                PlayerPrefs.SetInt("kuniExp", totalExp);
                PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo);
                Daimyo daimyoScript = new Daimyo();
                PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo));

                //pvp jinkei
                string        myBusyoString  = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoList    = new List <string>();
                char[]        delimiterChars = { ',' };
                if (myBusyoString != null && myBusyoString != "")
                {
                    if (myBusyoString.Contains(","))
                    {
                        myBusyoList = new List <string>(myBusyoString.Split(delimiterChars));
                    }
                    else
                    {
                        myBusyoList.Add(myBusyoString);
                    }
                }

                //zukan
                string        zukanBusyoHst     = PlayerPrefs.GetString("zukanBusyoHst");
                List <string> zukanBusyoHstList = new List <string>();
                if (zukanBusyoHst != null && zukanBusyoHst != "")
                {
                    if (zukanBusyoHst.Contains(","))
                    {
                        zukanBusyoHstList = new List <string>(zukanBusyoHst.Split(delimiterChars));
                    }
                    else
                    {
                        zukanBusyoHstList.Add(zukanBusyoHst);
                    }
                }

                //Daimyo Busyo History
                Daimyo        daimyo             = new Daimyo();
                string        gacyaDaimyoHst     = PlayerPrefs.GetString("gacyaDaimyoHst");
                List <string> gacyaDaimyoHstList = new List <string>();
                if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
                {
                    if (gacyaDaimyoHst.Contains(","))
                    {
                        gacyaDaimyoHstList = new List <string>(gacyaDaimyoHst.Split(delimiterChars));
                    }
                    else
                    {
                        gacyaDaimyoHstList.Add(gacyaDaimyoHst);
                    }
                }

                int count = 0;
                for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++)
                {
                    int busyoId = RecoveryDataStore.busyoList[i];

                    if (busyoId != 0)
                    {
                        //add busyo
                        if (!myBusyoList.Contains(busyoId.ToString()))
                        {
                            if (myBusyoString == null || myBusyoString == "")
                            {
                                myBusyoString = busyoId.ToString();
                            }
                            else
                            {
                                myBusyoString = myBusyoString + "," + busyoId.ToString();
                            }
                            PlayerPrefs.SetString("myBusyo", myBusyoString);
                        }

                        //add zukan
                        if (!zukanBusyoHstList.Contains(busyoId.ToString()))
                        {
                            if (zukanBusyoHst == null || zukanBusyoHst == "")
                            {
                                zukanBusyoHst = busyoId.ToString();
                            }
                            else
                            {
                                zukanBusyoHst = zukanBusyoHst + "," + busyoId.ToString();
                            }
                            PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst);
                        }

                        //add daimyo busyo
                        if (daimyo.daimyoBusyoCheck(busyoId))
                        {
                            if (!gacyaDaimyoHstList.Contains(busyoId.ToString()))
                            {
                                if (gacyaDaimyoHst == null || gacyaDaimyoHst == "")
                                {
                                    gacyaDaimyoHst = busyoId.ToString();
                                }
                                else
                                {
                                    gacyaDaimyoHst = gacyaDaimyoHst + "," + busyoId.ToString();
                                }
                                PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst);
                            }
                        }

                        //add parametor
                        int    lv       = RecoveryDataStore.lvList[count];
                        string hei      = RecoveryDataStore.heiList[count];
                        int    senpouLv = RecoveryDataStore.senpouLvList[count];
                        int    sakuLv   = RecoveryDataStore.sakuLvList[count];
                        string kahou    = RecoveryDataStore.kahouList[count];

                        //lv
                        PlayerPrefs.SetInt(busyoId.ToString(), lv);

                        //hei
                        string heiTmp = "hei" + busyoId.ToString();
                        PlayerPrefs.SetString(heiTmp, hei);

                        //senpou
                        string senpou = "senpou" + busyoId.ToString();
                        PlayerPrefs.SetInt(senpou, senpouLv); //Lv

                        //saku
                        string saku = "saku" + busyoId.ToString();
                        PlayerPrefs.SetInt(saku, sakuLv); //Lv

                        //kahou
                        string kahouTmp = "kahou" + busyoId.ToString();
                        PlayerPrefs.SetString(kahouTmp, kahou);

                        //exp
                        string exp           = "exp" + busyoId.ToString();
                        int    totalBusyoExp = expScript.getExpforNextLv(lv - 1);
                        PlayerPrefs.SetInt(exp, totalBusyoExp);

                        count = count + 1;
                    }
                }
                PlayerPrefs.Flush();

                //Add Qty & PvP Name
                string        myBusyoStringCount = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoListCount   = new List <string>();
                if (myBusyoStringCount.Contains(","))
                {
                    myBusyoListCount = new List <string>(myBusyoStringCount.Split(delimiterChars));
                }
                else
                {
                    myBusyoListCount.Add(myBusyoStringCount);
                }
                PlayerPrefs.SetInt("myBusyoQty", myBusyoListCount.Count);
                string userName = RecoveryDataStore.userName;
                if (userName == "")
                {
                    userName = "******";
                }
                PlayerPrefs.SetString("PvPName", userName);
            }

            PlayerPrefs.Flush();

            //add data recovery history
            RecoveryDataStore.UpdateDataRecovery(RecoveryDataStore.inputUserId);


            //Final Process
            audioSources[3].Play();
            Destroy(back.gameObject);
            Destroy(msg.gameObject);
            GameObject.Find("Start").GetComponent <Button>().enabled = false;
            Message msgScript = new Message();
            msgScript.makeMessage(msgScript.getMessage(151));
        }
        else
        {
            RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>();
            RecoveryDataStore.ResetValue();

            audioSources[1].Play();
            Destroy(back.gameObject);
            Destroy(msg.gameObject);
        }
    }
Exemplo n.º 16
0
    public void ViewKuniInfo()
    {
        string     kuniPath = "Prefabs/Common/Kakejiku";
        GameObject kakejiku = Instantiate(Resources.Load(kuniPath)) as GameObject;

        kakejiku.transform.SetParent(GameObject.Find("Panel").transform);
        kakejiku.transform.localScale = new Vector2(1, 1);
        kakejiku.name = "Kakejiku";
        GameObject kuni = kakejiku.transform.FindChild("Kakejiku").transform.FindChild("KuniInfo").gameObject;

        //Kanni
        int    syogunDaimyoId = PlayerPrefs.GetInt("syogunDaimyoId");
        int    myDaimyoId     = PlayerPrefs.GetInt("myDaimyo");
        string kanniName      = "";

        if (syogunDaimyoId == myDaimyoId)
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kanniName = "Shogun";
            }
            else
            {
                kanniName = "征夷大将軍";
            }
        }
        else
        {
            int    myDaimyoBusyo = PlayerPrefs.GetInt("myDaimyoBusyo");
            string kanniTmp      = "kanni" + myDaimyoBusyo.ToString();
            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int   kanniId = PlayerPrefs.GetInt(kanniTmp);
                Kanni kanni   = new Kanni();
                kanniName = kanni.getKanniName(kanniId);
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    kanniName = "No Royal Court Rank";
                }
                else
                {
                    kanniName = "官位なし";
                }
            }
        }
        kuni.transform.FindChild("KaniValue").GetComponent <Text> ().text = kanniName;

        //Daimyo Name
        Daimyo daimyoScript = new Daimyo();
        int    myDaimyo     = PlayerPrefs.GetInt("myDaimyo");
        string myDaimyoName = daimyoScript.getName(myDaimyo);

        kuni.transform.FindChild("DaimyoName").GetComponent <Text>().text = myDaimyoName;

        //Daimyo busyo image
        int    daimyoBusyoId = daimyoScript.getDaimyoBusyoId(myDaimyo);
        string daimyoPath    = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();

        kuni.transform.FindChild("Mask").transform.FindChild("BusyoImage").GetComponent <Image>().sprite =
            Resources.Load(daimyoPath, typeof(Sprite)) as Sprite;



        //Current Kokuryoku
        int kuniExp = PlayerPrefs.GetInt("kuniExp");
        //kuni.transform.FindChild ("PopStatusLv").transform.FindChild("PopLvValue").GetComponent<Text> ().text = kuniExp.ToString ();

        //Now Lv
        int nowLv = PlayerPrefs.GetInt("kuniLv");

        kuni.transform.FindChild("PopStatusLv").transform.FindChild("PopLvValue").GetComponent <Text>().text = nowLv.ToString();

        //Exp for Next Lv
        Exp exp      = new Exp();
        int totalExp = exp.getKuniExpforNextLv(nowLv);
        int diff     = totalExp - kuniExp;

        kuni.transform.FindChild("PopStatusLv").transform.FindChild("ExpValue").GetComponent <Text> ().text = diff.ToString();

        //Slider
        Slider sliderScript = kuni.transform.FindChild("PopStatusLv").transform.FindChild("ExpSlider").GetComponent <Slider>();

        sliderScript.maxValue = totalExp;
        int totalExpOfNowLv = 0;

        if (nowLv != 1)
        {
            totalExpOfNowLv = exp.getKuniExpforNextLv(nowLv - 1);
        }
        sliderScript.minValue = totalExpOfNowLv;
        sliderScript.value    = kuniExp;


        //Now Kuni Qty
        string clearedKuni = PlayerPrefs.GetString("clearedKuni");

        if (clearedKuni != null && clearedKuni != "")
        {
            if (clearedKuni.Contains(","))
            {
                char[]   delimiterChars  = { ',' };
                string[] clearedKuniList = clearedKuni.Split(delimiterChars);
                kuni.transform.FindChild("ShiroQtyValue").GetComponent <Text> ().text = clearedKuniList.Length.ToString();
            }
            else
            {
                kuni.transform.FindChild("ShiroQtyValue").GetComponent <Text> ().text = "1";
            }
        }
        else
        {
            kuni.transform.FindChild("ShiroQtyValue").GetComponent <Text> ().text = "0";
        }

        //Syutujin Limit
        int jinkeiLimit = PlayerPrefs.GetInt("jinkeiLimit");

        int  addNo         = 0;
        bool addJinkei1Flg = PlayerPrefs.GetBool("addJinkei1");

        if (addJinkei1Flg)
        {
            addNo = addNo + 1;
        }
        bool addJinkei2Flg = PlayerPrefs.GetBool("addJinkei2");

        if (addJinkei2Flg)
        {
            addNo = addNo + 1;
        }
        bool addJinkei3Flg = PlayerPrefs.GetBool("addJinkei3");

        if (addJinkei3Flg)
        {
            addNo = addNo + 1;
        }
        bool addJinkei4Flg = PlayerPrefs.GetBool("addJinkei4");

        if (addJinkei4Flg)
        {
            addNo = addNo + 1;
        }
        kuni.transform.FindChild("SyutsujinQtyValue").GetComponent <Text> ().text = jinkeiLimit.ToString() + "<Color=#35D74BFF>+" + addNo + "</Color>";

        //Stock Limit
        int    stockLimit = PlayerPrefs.GetInt("stockLimit");
        int    myBusyoQty = PlayerPrefs.GetInt("myBusyoQty");
        string value      = myBusyoQty.ToString() + "/" + stockLimit.ToString();

        kuni.transform.FindChild("TouyouQtyValue").GetComponent <Text> ().text = value;


        //SyutsujinQtyUpLvValue
        kuni.transform.FindChild("SyutsujinQtyUpLvValue").GetComponent <Text>().text = nextAvailableSamuraiUpLv(nowLv).ToString();

        //SyutsujinQtyValue
        int TrackTotalKassenNo = PlayerPrefs.GetInt("TrackTotalKassenNo");
        int TrackWinNo         = PlayerPrefs.GetInt("TrackWinNo");

        kuni.transform.FindChild("BattleNoValue").GetComponent <Text>().text = TrackTotalKassenNo.ToString();

        //WinRatioValue
        int winRatio = Mathf.CeilToInt((float)TrackWinNo / (float)TrackTotalKassenNo * 100);

        if (TrackWinNo == 0)
        {
            winRatio = 0;
        }
        kuni.transform.FindChild("WinRatioValue").GetComponent <Text>().text = winRatio.ToString();

        //DevNo
        int HstNanbansen = PlayerPrefs.GetInt("HstNanbansen");

        kuni.transform.FindChild("ShipNo").GetComponent <Text>().text = HstNanbansen.ToString();
        //VisitorNo
        int TrackTabibitoNo = PlayerPrefs.GetInt("TrackTabibitoNo");

        kuni.transform.FindChild("VisitorNo").GetComponent <Text>().text = TrackTabibitoNo.ToString();
        //BouryakuNo
        int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo");

        kuni.transform.FindChild("BouryakuNo").GetComponent <Text>().text = TrackBouryakuNo.ToString();
        //GaikoNo
        int TrackGaikouNo = PlayerPrefs.GetInt("TrackGaikouNo");

        kuni.transform.FindChild("GaikoNo").GetComponent <Text>().text = TrackGaikouNo.ToString();
    }