Exemplo n.º 1
0
	public void OnClick(){
		
		//SE
		if (audioNaisei != null) {
			audioNaisei.PlayOneShot (touch); 
		}

		/*Common Process*/
		string pathOfBoard = "Prefabs/Map/Popup";
		GameObject board = Instantiate (Resources.Load (pathOfBoard)) as GameObject;
		board.transform.parent = GameObject.Find ("Map").transform;
		board.transform.localScale = new Vector2 (1, 0.8f);
		board.transform.localPosition = new Vector2 (0, 0);
		Daimyo daimyo = new Daimyo();

		
		/*Indivisual Process by Kuni*/
		string pathOfKuniMap = "Prefabs/Map/stage/kuniMap";
		GameObject kuniMap = Instantiate (Resources.Load (pathOfKuniMap)) as GameObject;
		board.transform.FindChild ("kuniName").GetComponent<Text> ().text = kuniName;

		string kuniImagePath = "Prefabs/Map/stage/MapSprite/" + kuniId.ToString ();
		kuniMap.GetComponent<Image> ().sprite = 
			Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite;

		
		//kuni
		kuniMap.transform.parent = GameObject.Find ("board").transform;
		kuniMap.transform.localScale = new Vector2 (9, 6);
		kuniMap.transform.localPosition = new Vector3 (-145, 4, 0);
		kuniMap.name = "kuniMap" + kuniId;
		
		
		//Clear Stage Setting
		string clearedStage = "kuni" + kuniId;
		string clearedStageString = PlayerPrefs.GetString (clearedStage);
		List<string> clearedStageList = new List<string> ();
		if (clearedStageString != null && clearedStageString != "") {
			char[] delimiterChars = {','};
			clearedStageList = new List<string> (clearedStageString.Split (delimiterChars));
			
		}
		
		//Default Value
		Entity_stage_mst stageMst = Resources.Load ("Data/stage_mst") as Entity_stage_mst;
		int startline = 10 * kuniId - 10; 
		string stagePath = "Prefabs/Map/stage/stage";
		string clearedPath = "Prefabs/Map/cleared";


		int stageId = 1;
		bool clearedFlg = false;
		int mySenryoku = daimyo.getSenryoku(myDaimyoId);
		int enemySenryoku = daimyo.getSenryoku(daimyoId);
		float senryokuRatio = (float)enemySenryoku / (float)mySenryoku;

		for (int i=startline; i<startline+10; i++) {
			GameObject stage = Instantiate (Resources.Load (stagePath)) as GameObject;
			stage.transform.SetParent (kuniMap.transform);
			stage.transform.localScale = new Vector2 (1, 1);
			stage.name = "stage" + stageId.ToString ();
			
			//Cleared Check
			if (clearedStageList.Contains (stageId.ToString ()) == true) {
				GameObject cleared = Instantiate (Resources.Load (clearedPath)) as GameObject;
				cleared.transform.SetParent (stage.transform);
				cleared.transform.localScale = new Vector2 (3, 5);
				cleared.transform.localPosition = new Vector2 (0, 0);
				clearedFlg = true;
			}
			
			//Get Stage Info
			string stageName = stageMst.param [i].stageName;
			int locationX = stageMst.param [i].LocationX;
			int locationY = stageMst.param [i].LocationY;
			int powerType = stageMst.param [i].powerTyp;

			RectTransform stageTransform = stage.GetComponent<RectTransform> ();
			stageTransform.anchoredPosition = new Vector3 (locationX, locationY, 0);


			//money and exp calculation
			int minExp = getMinExp(powerType,senryokuRatio);
			int maxExp = getMaxExp(powerType,senryokuRatio);
			int exp = UnityEngine.Random.Range (minExp, maxExp + 1);

			int minMoney = minExp * 3;
			int maxMoney = maxExp * 5;
			int money = UnityEngine.Random.Range (minMoney, maxMoney + 1);

			string itemGrp = getRandomItemGrp ();
			string itemTyp = "";
			int itemId = 0;
			int itemQty = 1;

			if (itemGrp == "item") {
				itemTyp = getRandomItemTyp(itemGrp);
				if (itemTyp == "tech") {
					itemId = getItemRank (66, 33);
				} else if (itemTyp == "Tama") {
					itemId = getItemRank (20, 5);
					if (itemId == 3) {
						itemQty = 100;
					} else if (itemId == 2) {
						itemQty = 20;
					} else if (itemId == 1) {
						itemQty = 5;
					}
				} else {
					itemId = getItemRank (20, 5);
				}

			} else if (itemGrp == "kahou") {
				itemTyp = getRandomItemTyp(itemGrp);
				Kahou kahou = new Kahou ();
				string kahouRank = getKahouRank ();
				itemId = kahou.getRamdomKahouId (itemTyp, kahouRank);
			}


			stage.GetComponent<ShowStageDtl> ().kuniId = kuniId;
			stage.GetComponent<ShowStageDtl> ().stageId = stageId;
			stage.GetComponent<ShowStageDtl> ().stageName = stageName;
			stage.GetComponent<ShowStageDtl> ().exp = exp;
			stage.GetComponent<ShowStageDtl> ().showExp = minExp + " - " + maxExp;
			stage.GetComponent<ShowStageDtl> ().money = money;
			stage.GetComponent<ShowStageDtl> ().showMoney = minMoney + " - " + maxMoney;
			stage.GetComponent<ShowStageDtl> ().itemGrp = itemGrp;
			stage.GetComponent<ShowStageDtl> ().itemTyp = itemTyp;
			stage.GetComponent<ShowStageDtl> ().itemId = itemId.ToString ();
			stage.GetComponent<ShowStageDtl> ().itemQty = itemQty;
			stage.GetComponent<ShowStageDtl> ().powerType = powerType;

			if(powerType==2){
				string imagePath = "Prefabs/Map/Stage/shiroIcon_m";
				stage.transform.FindChild("shiroImage").GetComponent<SpriteRenderer> ().sprite = 
					Resources.Load (imagePath, typeof(Sprite)) as Sprite;
			}else if(powerType==3){
				string imagePath = "Prefabs/Map/Stage/shiroIcon_l";
				stage.transform.FindChild("shiroImage").GetComponent<SpriteRenderer> ().sprite = 
					Resources.Load (imagePath, typeof(Sprite)) as Sprite;
			}


			
			stageId = stageId + 1;
		}


		//Line Setting
		Entity_stageLink_mst stageLinkMst = Resources.Load ("Data/stageLink_mst") as Entity_stageLink_mst;
		List<string> myStageLink = new List<string> ();
		for (int i=0; i<stageLinkMst.param.Count; i++) {
			int tempKuniId = stageLinkMst.param[i].kuniId;
			if(tempKuniId ==kuniId){
				myStageLink.Add(stageLinkMst.param[i].Link);
			}
		}
		char[] delimiterChars2 = {'-'};
		string linkPath = "Prefabs/Map/stage/link";
		for (int j=0; j<myStageLink.Count; j++) {

			List<string> linkList = new List<string> (myStageLink[j].Split (delimiterChars2));
			string stage1Name = linkList[0];
			string stage2Name = linkList[1];

			if(!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name)){

				//1st
				string temp1 = "stage" + stage1Name;
				GameObject stage1 = kuniMap.transform.FindChild(temp1).gameObject;
				RectTransform rectStage1 = stage1.GetComponent<RectTransform>();
				Vector3 vect1 = new Vector3(rectStage1.anchoredPosition.x,rectStage1.anchoredPosition.y,0);

				//2nd
				string temp2 = "stage" + stage2Name;
				GameObject stage2 = kuniMap.transform.FindChild(temp2).gameObject;
				RectTransform rectStage2 = stage2.GetComponent<RectTransform>();
				Vector3 vect2 = new Vector3(rectStage2.anchoredPosition.x,rectStage2.anchoredPosition.y,0);



				//Set
				GameObject link = Instantiate (Resources.Load (linkPath)) as GameObject;
				link.transform.SetParent (kuniMap.transform);
				link.transform.localScale = new Vector2 (1, 1);
				RectTransform linkRectTransform =link.GetComponent<RectTransform>();
				linkRectTransform.anchoredPosition = new Vector3 (0, 0, 0);
				link.GetComponent<LineRenderer>().SetPosition(0,vect1);
				link.GetComponent<LineRenderer>().SetPosition(1,vect2);

				//Line No
				stage1.GetComponent<ShowStageDtl>().linkNo = stage1.GetComponent<ShowStageDtl>().linkNo + 1;
				stage2.GetComponent<ShowStageDtl>().linkNo = stage2.GetComponent<ShowStageDtl>().linkNo + 1;


				//Name
				link.name = "link" + stage1Name+ "-" + stage2Name;
			}
		}






		//Battle Initial Setting
		StartKassen sk = GameObject.Find ("BattleButton").GetComponent<StartKassen> ();
		sk.activeBusyoQty = activeBusyoQty;
		sk.activeBusyoLv = activeBusyoLv;
		sk.activeButaiQty = activeButaiQty;
		sk.activeButaiLv = activeButaiLv;
		sk.activeDaimyoId = daimyoId;
		sk.doumeiFlg = doumeiFlg;

		/*Naisei Button*/
		string naiseiPath = "Prefabs/Map/NaiseiButton";
		GameObject naiseiBtn = Instantiate (Resources.Load (naiseiPath)) as GameObject;
		naiseiBtn.transform.parent = GameObject.Find ("Popup(Clone)").transform;
		naiseiBtn.GetComponent<StartNaisei> ().activeKuniId = kuniId;
		naiseiBtn.GetComponent<StartNaisei> ().activeKuniName = kuniName;
		naiseiBtn.GetComponent<StartNaisei> ().clearedFlg = clearedFlg;
		naiseiBtn.transform.localScale = new Vector2 (0.4f, 0.4f);
		naiseiBtn.transform.localPosition = new Vector2 (-490, -300);
		
		//Initial Setting
		GameObject firstStage = GameObject.Find ("stage1");
		firstStage.GetComponent<ShowStageDtl> ().OnClick ();

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

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

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

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

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

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

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

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


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

        MainStageController main = new MainStageController();

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

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

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

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

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

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

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



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

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

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

    //public IEnumerator Start() {
    //
    //assetBundleManager = GameObject.Find("AssetManager").GetComponent<AssetBundleManager>();
    //
    //    yield return StartCoroutine(assetBundleManager.LoadAssetBundleCoroutine());
    //
    //}


    public void OnClick()
    {
        cyouhouSnbRankId = transform.parent.gameObject.transform.FindChild("close").GetComponent <CloseBoard>().cyouhouSnbRankId;

        //SE
        sound = GameObject.Find("SEController").GetComponent <AudioSource> ();
        sound.PlayOneShot(sound.clip);


        /*Common Process*/
        string     pathOfBoard = "Prefabs/Map/Popup";
        GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;

        board.transform.parent        = GameObject.Find("Map").transform;
        board.transform.localScale    = new Vector2(1, 0.8f);
        board.transform.localPosition = new Vector2(0, 0);
        board.name = "AttackStagePopup";
        Daimyo daimyo = new Daimyo();

        char[] delimiterChars = { ',' };

        if (Application.loadedLevelName == "tutorialMain")
        {
            board.transform.FindChild("board").transform.FindChild("close").gameObject.SetActive(false);
        }

        /*Indivisual Process by Kuni*/
        string     pathOfKuniMap = "Prefabs/Map/stage/kuniMap";
        GameObject kuniMap       = Instantiate(Resources.Load(pathOfKuniMap)) as GameObject;

        board.transform.FindChild("kuniName").GetComponent <Text> ().text = kuniName;

        string kuniImagePath   = "Prefabs/Map/stage/MapSprite/stage" + kuniId.ToString();
        string assetBundlePath = "stage" + kuniId.ToString();

        kuniMap.GetComponent <Image> ().sprite =
            Resources.Load(kuniImagePath, typeof(Sprite)) as Sprite;
        //assetBundleManager.GetSpriteFromAssetBundle(assetBundlePath); //Asset
        //assetBundleManager.assetBundleCache.Unload(false);

        //kuni
        GameObject boardObj = board.transform.FindChild("board").gameObject;

        kuniMap.transform.SetParent(boardObj.transform);
        kuniMap.transform.localScale    = new Vector2(9, 6);
        kuniMap.transform.localPosition = new Vector3(-145, 4, 0);
        kuniMap.name = "kuniMap" + kuniId;


        //Clear Stage Setting
        string clearedStage       = "kuni" + kuniId;
        string clearedStageString = "";

        if (Application.loadedLevelName != "tutorialMain")
        {
            clearedStageString = PlayerPrefs.GetString(clearedStage);
        }
        else
        {
            clearedStageString = "1,2,3,4,5,6,7,8,9,10";
        }
        List <string> clearedStageList = new List <string> ();

        if (clearedStageString != null && clearedStageString != "")
        {
            clearedStageList = new List <string> (clearedStageString.Split(delimiterChars));
        }

        //Data adjustment
        if (!clearFlg && clearedStageList.Count == 10)
        {
            clearedStageList   = new List <string>();
            clearedStageString = "";
            PlayerPrefs.DeleteKey(clearedStage);
        }


        //Default Value
        Entity_stage_mst stageMst = Resources.Load("Data/stage_mst") as Entity_stage_mst;
        int    startline          = 10 * kuniId - 10;
        string stagePath          = "Prefabs/Map/stage/stage";
        string clearedPath        = "Prefabs/Map/cleared";


        int   stageId       = 1;
        bool  clearedFlg    = false;
        int   mySenryoku    = daimyo.getSenryoku(myDaimyoId);
        int   enemySenryoku = daimyo.getSenryoku(daimyoId);
        float senryokuRatio = (float)enemySenryoku / (float)mySenryoku;

        for (int i = startline; i < startline + 10; i++)
        {
            GameObject stage = Instantiate(Resources.Load(stagePath)) as GameObject;
            stage.transform.SetParent(kuniMap.transform);
            stage.transform.localScale = new Vector2(1, 1);
            stage.name = "stage" + stageId.ToString();

            //Cleared Check
            if (clearedStageList.Contains(stageId.ToString()) == true)
            {
                GameObject cleared = Instantiate(Resources.Load(clearedPath)) as GameObject;
                cleared.transform.SetParent(stage.transform);
                stage.GetComponent <ShowStageDtl> ().clearedFlg = true;
                cleared.transform.localScale    = new Vector2(3, 5);
                cleared.transform.localPosition = new Vector2(0, 0);
                clearedFlg   = true;
                cleared.name = "cleared";
            }

            //Get Stage Info
            string stageName = "";
            int    locationX = stageMst.param [i].LocationX;
            int    locationY = stageMst.param [i].LocationY;
            int    powerType = stageMst.param [i].powerTyp;
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                stageName = stageMst.param[i].stageNameEng;
            }
            else
            {
                stageName = stageMst.param[i].stageName;
            }
            RectTransform stageTransform = stage.GetComponent <RectTransform> ();
            stageTransform.anchoredPosition = new Vector3(locationX, locationY, 0);


            //money and exp calculation
            int minExp = getMinExp(powerType, senryokuRatio);
            int maxExp = getMaxExp(powerType, senryokuRatio);
            int exp    = UnityEngine.Random.Range(minExp, maxExp + 1);

            int minMoney = minExp * 2;
            int maxMoney = maxExp * 3;
            int money    = UnityEngine.Random.Range(minMoney, maxMoney + 1);

            string itemGrp = getRandomItemGrp();
            string itemTyp = "";
            int    itemId  = 0;
            int    itemQty = 1;

            if (itemGrp == "item")
            {
                itemTyp = getRandomItemTyp(itemGrp);
                if (itemTyp == "tech")
                {
                    itemId = getItemRank(66, 33);
                }
                else if (itemTyp == "Tama")
                {
                    itemId = getItemRank(20, 5);
                    if (itemId == 3)
                    {
                        itemQty = 100;
                    }
                    else if (itemId == 2)
                    {
                        itemQty = 20;
                    }
                    else if (itemId == 1)
                    {
                        itemQty = 5;
                    }
                }
                else
                {
                    itemId = getItemRank(20, 5);
                }
            }
            else if (itemGrp == "kahou")
            {
                itemTyp = getRandomItemTyp(itemGrp);
                Kahou  kahou     = new Kahou();
                string kahouRank = getKahouRank();
                itemId = kahou.getRamdomKahouId(itemTyp, kahouRank);
            }


            stage.GetComponent <ShowStageDtl> ().kuniId    = kuniId;
            stage.GetComponent <ShowStageDtl> ().stageId   = stageId;
            stage.GetComponent <ShowStageDtl> ().stageName = stageName;
            stage.GetComponent <ShowStageDtl> ().exp       = exp;
            stage.GetComponent <ShowStageDtl> ().showExp   = minExp + " - " + maxExp;
            stage.GetComponent <ShowStageDtl> ().money     = money;
            stage.GetComponent <ShowStageDtl> ().showMoney = minMoney + " - " + maxMoney;
            stage.GetComponent <ShowStageDtl> ().itemGrp   = itemGrp;
            stage.GetComponent <ShowStageDtl> ().itemTyp   = itemTyp;
            stage.GetComponent <ShowStageDtl> ().itemId    = itemId.ToString();
            stage.GetComponent <ShowStageDtl> ().itemQty   = itemQty;
            stage.GetComponent <ShowStageDtl> ().powerType = powerType;

            if (powerType == 2)
            {
                string imagePath = "Prefabs/Naisei/Shiro/Sprite/shiro_m";
                stage.transform.FindChild("shiroImage").GetComponent <SpriteRenderer> ().sprite =
                    Resources.Load(imagePath, typeof(Sprite)) as Sprite;
            }
            else if (powerType == 3)
            {
                string imagePath = "Prefabs/Naisei/Shiro/Sprite/shiro_l";
                stage.transform.FindChild("shiroImage").GetComponent <SpriteRenderer> ().sprite =
                    Resources.Load(imagePath, typeof(Sprite)) as Sprite;
            }



            stageId = stageId + 1;
        }


        //Line Setting
        Entity_stageLink_mst stageLinkMst = Resources.Load("Data/stageLink_mst") as Entity_stageLink_mst;
        List <string>        myStageLink  = new List <string> ();

        for (int i = 0; i < stageLinkMst.param.Count; i++)
        {
            int tempKuniId = stageLinkMst.param[i].kuniId;
            if (tempKuniId == kuniId)
            {
                myStageLink.Add(stageLinkMst.param[i].Link);
            }
        }
        List <string> myOriginalStageLink = new List <string>(myStageLink);

        //Reduce Linkcut kousaku
        string        tempLinkuct = "linkcut" + kuniId;
        string        linkcut     = PlayerPrefs.GetString(tempLinkuct);
        List <string> linkcutList = new List <string> ();

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

        myStageLink.RemoveAll(linkcutList.Contains);



        char[] delimiterChars2 = { '-' };
        string linkPath        = "Prefabs/Map/stage/link";

        for (int j = 0; j < myStageLink.Count; j++)
        {
            List <string> linkList   = new List <string> (myStageLink[j].Split(delimiterChars2));
            string        stage1Name = linkList[0];
            string        stage2Name = linkList[1];

            //if(!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name)){

            //1st
            string        temp1      = "stage" + stage1Name;
            GameObject    stage1     = kuniMap.transform.FindChild(temp1).gameObject;
            RectTransform rectStage1 = stage1.GetComponent <RectTransform>();
            Vector3       vect1      = new Vector3(rectStage1.anchoredPosition.x, rectStage1.anchoredPosition.y, 0);

            //2nd
            string        temp2      = "stage" + stage2Name;
            GameObject    stage2     = kuniMap.transform.FindChild(temp2).gameObject;
            RectTransform rectStage2 = stage2.GetComponent <RectTransform>();
            Vector3       vect2      = new Vector3(rectStage2.anchoredPosition.x, rectStage2.anchoredPosition.y, 0);



            //Set
            GameObject link = Instantiate(Resources.Load(linkPath)) as GameObject;
            link.transform.SetParent(kuniMap.transform);
            link.transform.localScale = new Vector2(1, 1);
            RectTransform linkRectTransform = link.GetComponent <RectTransform>();
            linkRectTransform.anchoredPosition = new Vector3(0, 0, 0);
            link.GetComponent <LineRenderer>().SetPosition(0, vect1);
            link.GetComponent <LineRenderer>().SetPosition(1, vect2);

            if (!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name))
            {
                //Line No
                stage1.GetComponent <ShowStageDtl>().linkNo = stage1.GetComponent <ShowStageDtl>().linkNo + 1;
                stage2.GetComponent <ShowStageDtl>().linkNo = stage2.GetComponent <ShowStageDtl>().linkNo + 1;
            }

            //Name
            link.name = "link" + stage1Name + "-" + stage2Name;
        }


        //Battle Initial Setting
        StartKassen sk = GameObject.Find("BattleButton").GetComponent <StartKassen> ();

        sk.activeBusyoQty = activeBusyoQty;
        sk.activeBusyoLv  = activeBusyoLv;
        sk.activeButaiQty = activeButaiQty;
        sk.activeButaiLv  = activeButaiLv;
        sk.activeDaimyoId = daimyoId;
        sk.doumeiFlg      = doumeiFlg;

        /*Naisei Button*/
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string>();

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

        //Only for all clear
        if (clearFlg)
        {
            string     naiseiPath = "Prefabs/Map/NaiseiButton";
            GameObject naiseiBtn  = Instantiate(Resources.Load(naiseiPath)) as GameObject;
            naiseiBtn.transform.SetParent(board.transform);
            naiseiBtn.GetComponent <StartNaisei> ().activeKuniId   = kuniId;
            naiseiBtn.GetComponent <StartNaisei> ().activeKuniName = kuniName;
            naiseiBtn.GetComponent <StartNaisei> ().clearedFlg     = clearedFlg;
            naiseiBtn.transform.localScale    = new Vector2(0.4f, 0.4f);
            naiseiBtn.transform.localPosition = new Vector2(-490, -300);
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").transform.FindChild("Text").GetComponent <Text> ().text = "Training";
            }
            else
            {
                boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").transform.FindChild("Text").GetComponent <Text>().text = "訓練";
            }
            GameObject firstStage = GameObject.Find("stage1");
            firstStage.GetComponent <ShowStageDtl>().OnClick();

            if (Application.loadedLevelName == "tutorialMain")
            {
                GameObject battleBtnObj = boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").gameObject;
                battleBtnObj.GetComponent <Button>().interactable = false;
                battleBtnObj.transform.FindChild("Text").GetComponent <Text>().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f);

                TutorialController tutorialScript = new TutorialController();
                Vector2            vect           = new Vector2(0, 100);
                GameObject         animObj        = tutorialScript.SetPointer(naiseiBtn, vect);
                animObj.transform.localScale = new Vector2(300, 300);
            }
        }
        else
        {
            //enemy attack

            GameObject        closeObj   = boardObj.transform.FindChild("close").gameObject;
            EnemyEventHandler enemyEvent = board.transform.FindChild("board").GetComponent <EnemyEventHandler>();
            enemyEvent.doEnemyEvent(kuniMap, closeObj, kuniId, daimyoId, activeBusyoQty, activeBusyoLv, activeButaiQty, activeButaiLv);

            //open shiro
            List <int> closeStageIdList = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };

            //compare linkKuni with mySeiryoku
            List <int> linkKuniList   = new List <int>();
            List <int> linkMyKuniList = new List <int>();

            KuniInfo kuniScript = new KuniInfo();
            linkKuniList = kuniScript.getMappingKuni(kuniId);
            for (int i = 0; i < linkKuniList.Count; i++)
            {
                int linkKuniId = linkKuniList[i];
                if (seiryokuList[linkKuniId - 1] == myDaimyoId.ToString())
                {
                    linkMyKuniList.Add(linkKuniId);
                }
            }

            //open initial stage
            for (int j = 0; j < linkMyKuniList.Count; j++)
            {
                int    srcKuniId = linkMyKuniList[j];
                string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId);
                linkStage = linkStage.Replace("stage", "");
                List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','),
                                                                           new Converter <string, int>((s) => { return(Convert.ToInt32(s)); })));
                closeStageIdList.RemoveAll(linkStageList.Contains);
            }


            //open cleared kuni & linked stage
            List <int> clearedStageIntList = clearedStageList.ConvertAll(x => int.Parse(x));
            closeStageIdList.RemoveAll(clearedStageIntList.Contains);
            for (int l = 0; l < clearedStageIntList.Count; l++)
            {
                int srcStageId = clearedStageIntList[l];

                for (int m = 0; m < myOriginalStageLink.Count; m++)
                {
                    List <string> linkList = new List <string>(myOriginalStageLink[m].Split(delimiterChars2));
                    int           stage1Id = int.Parse(linkList[0]);
                    int           stage2Id = int.Parse(linkList[1]);
                    if (srcStageId == stage1Id)
                    {
                        if (!getStageGunzeiExistFlg(stage1Id, stage2Id))
                        {
                            closeStageIdList.Remove(stage2Id);
                        }
                    }
                    else if (srcStageId == stage2Id)
                    {
                        if (!getStageGunzeiExistFlg(stage2Id, stage1Id))
                        {
                            closeStageIdList.Remove(stage1Id);
                        }
                    }
                }
            }


            Color closeColor = new Color(60f / 255f, 60f / 255f, 60f / 255f, 255f / 255f); //Black
            for (int k = 0; k < closeStageIdList.Count; k++)
            {
                int        closeStageId  = closeStageIdList[k];
                string     stageName     = "stage" + closeStageId.ToString();
                GameObject closeStageObj = kuniMap.transform.FindChild(stageName).gameObject;
                closeStageObj.GetComponent <Button>().enabled = false;
                closeStageObj.transform.FindChild("shiroImage").GetComponent <SpriteRenderer>().color = closeColor;
            }


            //Initial Setting
            int initStageId = 1;
            for (int i = 1; i <= 10; i++)
            {
                if (!closeStageIdList.Contains(i))
                {
                    initStageId = i;
                }
            }

            string     initStageName = "stage" + initStageId.ToString();
            GameObject firstStage    = GameObject.Find(initStageName);
            firstStage.GetComponent <ShowStageDtl>().OnClick();
        }

        //Kousaku
        if (!clearFlg)
        {
            string     pathOfScroll = "Prefabs/Map/kousaku/BusyoSelectScroll";
            GameObject scroll       = Instantiate(Resources.Load(pathOfScroll)) as GameObject;
            scroll.transform.SetParent(board.transform);
            scroll.transform.localScale = new Vector2(1, 1);
            RectTransform rectScroll = scroll.GetComponent <RectTransform> ();
            rectScroll.anchoredPosition3D = new Vector3(410, 0, 0);
            rectScroll.sizeDelta          = new Vector2(300, 750);
            scroll.name = "BusyoSelectScroll";
            scroll.SetActive(false);

            KousakuConfirm kousakuScript = GameObject.Find("LinkCutButton").GetComponent <KousakuConfirm> ();
            kousakuScript.cyouhouSnbRankId = cyouhouSnbRankId;
            kousakuScript.scrollObj        = scroll;

            KousakuConfirm kousakuScript2 = GameObject.Find("CyouryakuButton").GetComponent <KousakuConfirm> ();
            kousakuScript2.cyouhouSnbRankId = cyouhouSnbRankId;
            kousakuScript2.scrollObj        = scroll;
        }
        else
        {
            GameObject LinkCutButton = GameObject.Find("LinkCutButton").gameObject;
            LinkCutButton.GetComponent <Button> ().interactable = false;
            LinkCutButton.transform.FindChild("Text").GetComponent <Text> ().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f);

            GameObject CyouryakuButton = GameObject.Find("CyouryakuButton").gameObject;
            CyouryakuButton.GetComponent <Button> ().interactable = false;
            CyouryakuButton.transform.FindChild("Text").GetComponent <Text> ().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f);
        }


        /*Kassen Event Controller Start*/
        KassenEvent kEvent = new KassenEvent();

        kEvent.MakeEvent(clearFlg, kuniId, kuniMap, daimyoId);

        viewKuniLink(board, kuniMap, seiryokuList);

        /*Kassen Event Controller End*/
    }