Exemple #1
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();
            }
        }
    }
Exemple #2
0
    public void OnClick()
    {
        MainStageController MainStageController = GameObject.Find("GameController").GetComponent <MainStageController>();

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

        sound.PlayOneShot(sound.clip);

        //Initialization
        totalMoney   = 0;
        kozanMoney   = 0;
        totalHyourou = 0;
        totalYRL     = 0;
        totalKBL     = 0;
        totalYML     = 0;
        totalTPL     = 0;
        totalYRM     = 0;
        totalKBM     = 0;
        totalYMM     = 0;
        totalTPM     = 0;
        totalYRH     = 0;
        totalKBH     = 0;
        totalYMH     = 0;
        totalTPH     = 0;
        totalSNBL    = 0;
        totalSNBM    = 0;
        totalSNBH    = 0;

        /*Popup*/
        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.anchoredPosition = new Vector3(0, 0, 0);

        //Popup Screen
        string     popupPath = "Prefabs/Busyo/board";
        GameObject popup     = Instantiate(Resources.Load(popupPath)) as GameObject;

        popup.transform.SetParent(GameObject.Find("Map").transform);
        popup.transform.localScale = new Vector2(1, 1);
        RectTransform popupTransform = popup.GetComponent <RectTransform> ();

        popupTransform.anchoredPosition = new Vector3(0, 0, 0);
        popup.name = "board";

        //qa
        string     qaPath = "Prefabs/Common/Question";
        GameObject qa     = Instantiate(Resources.Load(qaPath)) as GameObject;

        qa.transform.SetParent(popup.transform);
        qa.transform.localScale = new Vector2(1, 1);
        RectTransform qaTransform = qa.GetComponent <RectTransform> ();

        qaTransform.anchoredPosition = new Vector3(-540, 285, 0);
        qa.name = "qa";
        qa.GetComponent <QA> ().qaId = 2;


        //Pop text
        string     popTextPath = "Prefabs/Busyo/popText";
        GameObject popText     = Instantiate(Resources.Load(popTextPath)) as GameObject;

        popText.transform.SetParent(popup.transform);
        popText.transform.localScale = new Vector2(0.35f, 0.35f);
        RectTransform popTextTransform = popText.GetComponent <RectTransform> ();

        popTextTransform.anchoredPosition = new Vector3(0, 260, 0);
        popText.name = "popText";
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            popText.GetComponent <Text>().text = "Finance";
        }
        else
        {
            popText.GetComponent <Text> ().text = "内政状況";
        }

        //Cyosyu
        string     cyosyuPath = "Prefabs/Cyosyu/CyosyuObj";
        GameObject CyosyuObj  = Instantiate(Resources.Load(cyosyuPath)) as GameObject;

        CyosyuObj.transform.SetParent(popup.transform);
        CyosyuObj.transform.localScale = new Vector2(1, 1);



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

        char[] delimiterChars = { ',' };

        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
        int myDaimyoId = PlayerPrefs.GetInt("myDaimyo");

        //Get my Kuni
        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int seiryokuId = int.Parse(seiryokuList [i]);
            if (seiryokuId == myDaimyoId)
            {
                int kuniId = i + 1;
                mySeiryokuList.Add(kuniId.ToString());
            }
        }


        //Kuni Loop Start
        int naiseiBldg = 0;
        int syogyo     = 0;
        int nogyo      = 0;
        int gunjyu     = 0;
        int ashigaru   = 0;
        int boubi      = 0;
        int bukkyo     = 0;
        int kirisuto   = 0;
        int bunka      = 0;

        //seiryoku loop
        for (int i = 0; i < mySeiryokuList.Count; i++)
        {
            int kuniKozan  = 0;
            int kuniSyogyo = 0;

            int    kuniId      = int.Parse(mySeiryokuList[i]);
            string temp        = "kuni" + mySeiryokuList[i];
            string clearedKuni = PlayerPrefs.GetString(temp);
            //Shiro Qty
            if (clearedKuni != null && clearedKuni != "")
            {
                List <string> shiroList = new List <string>();
                shiroList = new List <string>(clearedKuni.Split(delimiterChars));
                shiro     = shiroList.Count;

                //Kuni Name
                Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;
                kuniName = kuniMst.param[kuniId - 1].kuniName;

                string naiseiTemp   = "naisei" + mySeiryokuList[i];
                string naiseiString = PlayerPrefs.GetString(naiseiTemp);
                if (PlayerPrefs.HasKey(naiseiTemp))
                {
                    List <string> naiseiList = new List <string>();
                    naiseiList = new List <string>(naiseiString.Split(delimiterChars));
                    char[]        delimiterChars2 = { ':' };
                    List <string> deletePanelList = new List <string>();


                    for (int j = 1; j < naiseiList.Count; j++)
                    {
                        List <string> naiseiContentList = new List <string>();
                        naiseiContentList = new List <string>(naiseiList[j].Split(delimiterChars2));


                        if (naiseiContentList[0] != "0")
                        {
                            //Exist
                            Entity_naisei_mst naiseiMst = Resources.Load("Data/naisei_mst") as Entity_naisei_mst;
                            string            type      = naiseiMst.param [int.Parse(naiseiContentList[0])].code;
                            naiseiBldg = naiseiBldg + 1;

                            //Effect by Level
                            List <int>       naiseiEffectList = new List <int>();
                            NaiseiController naisei           = new NaiseiController();
                            naiseiEffectList = naisei.getNaiseiList(type, int.Parse(naiseiContentList[1]));


                            //Status
                            if (type == "shop")
                            {
                                kuniSyogyo = kuniSyogyo + naiseiEffectList[0];
                            }
                            else if (type == "kzn")
                            {
                                kuniKozan = kuniKozan + naiseiEffectList[0];
                            }
                            else if (type == "ta")
                            {
                                nogyo        = nogyo + naiseiEffectList[0];
                                totalHyourou = totalHyourou + naiseiEffectList[0];
                            }
                            else if (type == "yr")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRL = totalYRL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRM = totalYRM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRH = totalYRH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "kb")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBL = totalKBL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBM = totalKBM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBH = totalKBH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "ym")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYML = totalYML + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYMM = totalYMM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYMH = totalYMH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "tp")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPL = totalTPL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPM = totalTPM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPH = totalTPH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "snb")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBL = totalSNBL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBM = totalSNBM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBH = totalSNBH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "trd")
                            {
                                boubi = boubi + naiseiEffectList[0];
                            }
                            else if (type == "nbn")
                            {
                                kirisuto = kirisuto + naiseiEffectList[0];
                            }
                            else if (type == "kgy")
                            {
                                bunka = bunka + naiseiEffectList [0];
                            }
                            else if (type == "bky")
                            {
                                bukkyo = bukkyo + naiseiEffectList [0];
                            }
                            else if (type == "hsy")
                            {
                                ashigaru = ashigaru + naiseiEffectList [0];
                            }
                        }
                    }

                    //Shiro
                    int shiroLv            = int.Parse(naiseiList[0]);
                    NaiseiController naise = new NaiseiController();
                    List <int>       naiseiShiroEffectList = new List <int>();
                    naiseiShiroEffectList = naise.getNaiseiList("shiro", shiroLv);
                    ashigaru = ashigaru + naiseiShiroEffectList[0];
                    boubi    = boubi + naiseiShiroEffectList[0];


                    //Jyosyu Addition
                    string jyosyuTemp = "jyosyu" + kuniId;

                    if (PlayerPrefs.HasKey(jyosyuTemp))
                    {
                        int       jyosyuId  = PlayerPrefs.GetInt(jyosyuTemp);
                        StatusGet sts       = new StatusGet();
                        int       lv        = PlayerPrefs.GetInt(jyosyuId.ToString());
                        float     naiseiSts = (float)sts.getDfc(jyosyuId, lv);

                        float hpSts  = (float)sts.getHp(jyosyuId, lv);
                        float atkSts = (float)sts.getAtk(jyosyuId, lv);

                        float tempKuniSyogyo = (float)kuniSyogyo;
                        tempKuniSyogyo = tempKuniSyogyo + (tempKuniSyogyo * naiseiSts / 200);
                        kuniSyogyo     = (int)tempKuniSyogyo;

                        float tempKuniKozan = (float)kuniKozan;
                        tempKuniKozan = tempKuniKozan + (tempKuniKozan * naiseiSts / 200);
                        kuniKozan     = (int)tempKuniKozan;
                    }
                }
            }
            kozanMoney = kozanMoney + kuniKozan;
            totalMoney = totalMoney + kuniSyogyo;
            syogyo     = syogyo + (kuniKozan * 4 + kuniSyogyo);
        }//Kuni Loop Finish


        /*visualize*/
        //Upper Board
        GameObject spring = CyosyuObj.transform.FindChild("spring").gameObject;

        spring.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text = (totalMoney + kozanMoney).ToString();

        GameObject summerWinter = CyosyuObj.transform.FindChild("summerWinter").gameObject;

        summerWinter.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text = kozanMoney.ToString();
        GameObject TargetGunjyu = summerWinter.transform.FindChild("TargetGunjyu").gameObject;

        if (totalYRH != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueH").GetComponent <Text>().text = totalYRH.ToString();
        }
        if (totalYRM != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueM").GetComponent <Text>().text = totalYRM.ToString();
        }
        if (totalYRL != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueL").GetComponent <Text>().text = totalYRL.ToString();
        }
        if (totalKBH != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueH").GetComponent <Text>().text = totalKBH.ToString();
        }
        if (totalKBM != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueM").GetComponent <Text>().text = totalKBM.ToString();
        }
        if (totalKBL != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueL").GetComponent <Text>().text = totalKBL.ToString();
        }
        if (totalYMH != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueH").GetComponent <Text>().text = totalYMH.ToString();
        }
        if (totalYMM != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueM").GetComponent <Text>().text = totalYMM.ToString();
        }
        if (totalYML != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueL").GetComponent <Text>().text = totalYML.ToString();
        }
        if (totalTPH != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueH").GetComponent <Text>().text = totalTPH.ToString();
        }
        if (totalTPM != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueM").GetComponent <Text>().text = totalTPM.ToString();
        }
        if (totalTPL != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueL").GetComponent <Text>().text = totalTPL.ToString();
        }
        if (totalSNBH != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueH").GetComponent <Text>().text = totalSNBH.ToString();
        }
        if (totalSNBM != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueM").GetComponent <Text>().text = totalSNBM.ToString();
        }
        if (totalSNBL != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueL").GetComponent <Text>().text = totalSNBL.ToString();
        }

        GameObject autumn = CyosyuObj.transform.FindChild("autumn").gameObject;

        autumn.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text   = kozanMoney.ToString();
        autumn.transform.FindChild("TargetHyourou").transform.FindChild("Value").GetComponent <Text>().text = totalHyourou.ToString();

        //Color
        int nowSeason = MainStageController.nowSeason;

        if (nowSeason == 1)
        {
            summerWinter.transform.FindChild("summer").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 2)
        {
            autumn.transform.FindChild("autumn").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 3)
        {
            summerWinter.transform.FindChild("winter").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 4)
        {
            spring.transform.FindChild("spring").gameObject.AddComponent <TextBlinker>();
        }


        //Lower Board
        GameObject status = CyosyuObj.transform.FindChild("statusBack").gameObject;

        //Kamon
        string     imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyoId.ToString();
        GameObject kamon     = status.transform.FindChild("Kamon").gameObject;

        kamon.GetComponent <Image> ().sprite =
            Resources.Load(imagePath, typeof(Sprite)) as Sprite;
        if (Application.systemLanguage == SystemLanguage.Japanese)
        {
            kamon.transform.FindChild("Value").GetComponent <Text> ().text = GameObject.Find("DaimyoValue").GetComponent <Text> ().text + "  国状況";
        }
        else
        {
            kamon.transform.FindChild("Value").GetComponent <Text>().text = GameObject.Find("DaimyoValue").GetComponent <Text>().text + " Status";
        }
        //Kuni
        status.transform.FindChild("Shiro").transform.FindChild("No").GetComponent <Text>().text = mySeiryokuList.Count.ToString();

        //Naisei Bldg.
        status.transform.FindChild("Naisei").transform.FindChild("No").GetComponent <Text>().text = (naiseiBldg + mySeiryokuList.Count).ToString();

        //Tabibito
        int tabibitoQty = PlayerPrefs.GetInt("HstTabibito");

        status.transform.FindChild("Tabibito").transform.FindChild("No").GetComponent <Text>().text = tabibitoQty.ToString();

        //Nanbansen
        int nanbansenQty = PlayerPrefs.GetInt("HstNanbansen");

        status.transform.FindChild("Ship").transform.FindChild("No").GetComponent <Text>().text = nanbansenQty.ToString();

        //Syogyo
        status.transform.FindChild("StatusSyogyo").transform.FindChild("SyogyoValue").GetComponent <Text>().text = syogyo.ToString();

        //Nogyo
        status.transform.FindChild("StatusNougyo").transform.FindChild("NougyoValue").GetComponent <Text>().text = nogyo.ToString();

        //Gunjyu
        status.transform.FindChild("StatusGunjyu").transform.FindChild("GunjyuValue").GetComponent <Text>().text = (gunjyu * 2).ToString();

        //Ashigaru
        status.transform.FindChild("StatusAshigaru").transform.FindChild("AshigaruValue").GetComponent <Text>().text = ashigaru.ToString();

        //Boubi
        status.transform.FindChild("StatusBoubi").transform.FindChild("BoubiValue").GetComponent <Text>().text = boubi.ToString();

        //Bukkyo
        status.transform.FindChild("StatusBukkyo").transform.FindChild("BukkyoValue").GetComponent <Text>().text = bukkyo.ToString();

        //Kirisuto
        status.transform.FindChild("StatusKirisuto").transform.FindChild("KirisutoValue").GetComponent <Text>().text = kirisuto.ToString();

        //Bunka
        status.transform.FindChild("StatusBunka").transform.FindChild("BunkaValue").GetComponent <Text>().text = bunka.ToString();

        //tutorial
        if (Application.loadedLevelName == "tutorialMain")
        {
            Destroy(transform.FindChild("point_up").gameObject);
            TutorialController TutorialController = new TutorialController();
            Vector2            vect     = new Vector2(0, 50);
            GameObject         closeObj = popup.transform.FindChild("close").gameObject;
            GameObject         animObj  = TutorialController.SetPointer(closeObj, vect);
            animObj.transform.localScale = new Vector2(120, 120);

            GameObject SubButtonViewLeft = GameObject.Find("SubButtonViewLeft").gameObject;
            GameObject.Find("SeiryokuInfo").transform.SetParent(SubButtonViewLeft.transform);
        }
    }
Exemple #3
0
    void getAllData()
    {
        kuniLv = PlayerPrefs.GetInt("kuniLv");
        if (kuniLv <= 0)
        {
            kuniLv = 1;
        }
        PlayerPrefs.SetInt("kuniLv", kuniLv);
        kuniExp    = PlayerPrefs.GetInt("kuniExp");
        myDaimyo   = PlayerPrefs.GetInt("myDaimyo");
        addJinkei1 = PlayerPrefs.GetBool("addJinkei1");
        addJinkei2 = PlayerPrefs.GetBool("addJinkei2");
        addJinkei3 = PlayerPrefs.GetBool("addJinkei3");
        addJinkei4 = PlayerPrefs.GetBool("addJinkei4");

        //common
        yearSeason     = PlayerPrefs.GetString("yearSeason");
        seiryoku       = PlayerPrefs.GetString("seiryoku");
        money          = PlayerPrefs.GetInt("money");
        busyoDama      = PlayerPrefs.GetInt("busyoDama");
        syogunDaimyoId = PlayerPrefs.GetInt("syogunDaimyoId");
        doumei         = PlayerPrefs.GetString("doumei");
        movieCount     = PlayerPrefs.GetInt("movieCount");

        Entity_quest_mst questMst = Resources.Load("Data/quest_mst") as Entity_quest_mst;

        for (int i = 0; i < questMst.param.Count; i++)
        {
            bool dailyFlg = questMst.param[i].daily;
            if (!dailyFlg)
            {
                string tmp       = "questSpecialFlg" + i.ToString();
                bool   activeFlg = PlayerPrefs.GetBool(tmp, false);
                if (activeFlg)
                {
                    questSpecialFlgId.Add(i);
                    string tmp2       = "questSpecialReceivedFlg" + i.ToString();
                    bool   activeFlg2 = PlayerPrefs.GetBool(tmp2, false);
                    if (!activeFlg2)
                    {
                        questSpecialReceivedFlgId.Add(false);
                    }
                    else
                    {
                        questSpecialReceivedFlgId.Add(true);
                    }
                }
            }
        }
        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)
            {
                string tmp       = "questSpecialCountReceivedFlg" + i.ToString();
                bool   activeFlg = PlayerPrefs.GetBool(tmp, false);
                if (activeFlg)
                {
                    questSpecialCountReceivedFlg.Add(true);
                }
                else
                {
                    questSpecialCountReceivedFlg.Add(false);
                }
            }
        }


        //busyo
        myBusyo        = PlayerPrefs.GetString("myBusyo");
        gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst");

        char[] delimiterChars = { ',' };
        if (myBusyo.Contains(","))
        {
            myBusyoList = new List <string>(myBusyo.Split(delimiterChars));
        }
        else
        {
            myBusyoList.Add(myBusyo);
        }
        for (int i = 0; i < myBusyoList.Count; i++)
        {
            string busyoId = myBusyoList[i];

            int busyoLv = PlayerPrefs.GetInt(busyoId);
            lvList.Add(busyoLv);

            string heiTmp    = "hei" + busyoId;
            string heiString = PlayerPrefs.GetString(heiTmp);
            heiList.Add(heiString);

            string senpouTmp = "senpou" + busyoId;
            int    senpouLv  = PlayerPrefs.GetInt(senpouTmp);
            senpouLvList.Add(senpouLv);

            string sakuTmp = "saku" + busyoId;
            int    sakuLv  = PlayerPrefs.GetInt(sakuTmp);
            sakuLvList.Add(sakuLv);

            string kahouTmp    = "kahou" + busyoId;
            string kahouString = PlayerPrefs.GetString(kahouTmp);
            kahouList.Add(kahouString);

            //addLevel
            string addLvTmp = "addlv" + busyoId.ToString();
            int    addlv    = PlayerPrefs.GetInt(addLvTmp);
            addLvList.Add(addlv);

            //gokui
            string gokuiTmp = "gokui" + busyoId;
            int    gokuiId  = PlayerPrefs.GetInt(gokuiTmp);
            gokuiList.Add(gokuiId);

            //kanni
            string kanniTmp = "kanni" + busyoId;
            int    kanniId  = PlayerPrefs.GetInt(kanniTmp);
            kanniList.Add(kanniId);
        }

        //item
        myKanni              = PlayerPrefs.GetString("myKanni");
        availableBugu        = PlayerPrefs.GetString("availableBugu");
        availableKabuto      = PlayerPrefs.GetString("availableKabuto");
        availableGusoku      = PlayerPrefs.GetString("availableGusoku");
        availableMeiba       = PlayerPrefs.GetString("availableMeiba");
        availableCyadougu    = PlayerPrefs.GetString("availableCyadougu");
        availableHeihousyo   = PlayerPrefs.GetString("availableHeihousyo");
        availableChishikisyo = PlayerPrefs.GetString("availableChishikisyo");
        kanjyo      = PlayerPrefs.GetString("kanjyo");
        cyouheiYR   = PlayerPrefs.GetString("cyouheiYR");
        cyouheiKB   = PlayerPrefs.GetString("cyouheiKB");
        cyouheiTP   = PlayerPrefs.GetString("cyouheiTP");
        cyouheiYM   = PlayerPrefs.GetString("cyouheiYM");
        hidensyoGe  = PlayerPrefs.GetInt("hidensyoGe");
        hidensyoCyu = PlayerPrefs.GetInt("hidensyoCyu");
        hidensyoJyo = PlayerPrefs.GetInt("hidensyoJyo");
        shinobiGe   = PlayerPrefs.GetInt("shinobiGe");
        shinobiCyu  = PlayerPrefs.GetInt("shinobiCyu");
        shinobiJyo  = PlayerPrefs.GetInt("shinobiJyo");
        kengouItem  = PlayerPrefs.GetString("kengouItem");
        gokuiItem   = PlayerPrefs.GetString("gokuiItem");
        nanbanItem  = PlayerPrefs.GetString("nanbanItem");
        transferTP  = PlayerPrefs.GetInt("transferTP");
        transferKB  = PlayerPrefs.GetInt("transferKB");
        meisei      = PlayerPrefs.GetInt("meisei");
        shiro       = PlayerPrefs.GetString("shiro");
        koueki      = PlayerPrefs.GetString("koueki");
        cyoutei     = PlayerPrefs.GetString("cyoutei");

        //zukan
        zukanBusyoHst       = PlayerPrefs.GetString("zukanBusyoHst");
        zukanBuguHst        = PlayerPrefs.GetString("zukanBuguHst");
        zukanGusokuHst      = PlayerPrefs.GetString("zukanGusokuHst");
        zukanKabutoHst      = PlayerPrefs.GetString("zukanKabutoHst");
        zukanMeibaHst       = PlayerPrefs.GetString("zukanMeibaHst");
        zukanCyadouguHst    = PlayerPrefs.GetString("zukanCyadouguHst");
        zukanChishikisyoHst = PlayerPrefs.GetString("zukanChishikisyoHst");
        zukanHeihousyoHst   = PlayerPrefs.GetString("zukanHeihousyoHst");
        gameClearDaimyo     = PlayerPrefs.GetString("gameClearDaimyo");
        gameClearDaimyoHard = PlayerPrefs.GetString("gameClearDaimyoHard");

        //naisei
        Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;

        for (int i = 0; i < kuniMst.param.Count; i++)
        {
            int    kuniId    = i + 1;
            string naiseiTmp = "naisei" + kuniId.ToString();
            if (PlayerPrefs.HasKey(naiseiTmp))
            {
                naiseiKuniList.Add(kuniId);
                naiseiList.Add(PlayerPrefs.GetString(naiseiTmp));

                string shiroTmp = "shiro" + kuniId;
                int    shiroId  = PlayerPrefs.GetInt(shiroTmp, 0);
                naiseiShiroList.Add(shiroId);
            }
        }
    }
Exemple #4
0
    public void showSeiryoku()
    {
        /*--------------------*/
        /*Show Daimyo Seiryoku*/
        /*--------------------*/
        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;

        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/";
        GameObject kuniIconView = GameObject.Find("KuniIconView");
        GameObject KuniMap      = GameObject.Find("KuniMap");

        myDaimyo = PlayerPrefs.GetInt("myDaimyo");
        Daimyo daimyo = new Daimyo();

        myDaimyoName = daimyo.getName(myDaimyo);

        string        gameClearDaimyo     = PlayerPrefs.GetString("gameClearDaimyo");
        List <string> gameClearDaimyoList = new List <string> ();

        if (gameClearDaimyo != null && gameClearDaimyo != "")
        {
            if (gameClearDaimyo.Contains(","))
            {
                gameClearDaimyoList = new List <string> (gameClearDaimyo.Split(delimiterChars));
            }
            else
            {
                gameClearDaimyoList.Add(gameClearDaimyo);
            }
        }
        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);
            kuni.GetComponent <Button>().enabled = false;

            //Seiryoku Handling
            int    daimyoId          = int.Parse(seiryokuList [kuniId - 1]);
            string daimyoName        = daimyoMst.param [daimyoId - 1].daimyoName;
            int    daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId;

            //Color Handling
            float colorR    = (float)daimyoMst.param [daimyoId - 1].colorR;
            float colorG    = (float)daimyoMst.param [daimyoId - 1].colorG;
            float colorB    = (float)daimyoMst.param [daimyoId - 1].colorB;
            Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);

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

            //Daimyo Kamon Image
            string imagePath = "Prefabs/Kamon/" + daimyoId.ToString();
            kuni.GetComponent <Image> ().sprite =
                Resources.Load(imagePath, typeof(Sprite)) as Sprite;
            RectTransform kuniTransform = kuni.GetComponent <RectTransform> ();
            kuniTransform.anchoredPosition = new Vector3(locationX, locationY, 0);


            //My daimyo Check
            if (daimyoId == myDaimyo)
            {
                string myDaimyoPath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString();
                kuni.GetComponent <Image> ().sprite =
                    Resources.Load(myDaimyoPath, typeof(Sprite)) as Sprite;
            }

            //Clear Flg
            if (gameClearDaimyoList.Contains(daimyoId.ToString()))
            {
                kuni.GetComponent <SendParam> ().clearFlg = true;
            }
        }
    }
    public void OnClick()
    {
        if (close.GetComponent <CloseBoard> ().kuniId != kuniId)
        {
            close.GetComponent <CloseBoard> ().kuniId = kuniId;

            AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
            audioSources [2].Play();

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

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

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

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

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

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

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

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


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

            //Gaikou
            {
                targetGaikouKuniId = getGaikouTargetKuni(kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
                if (targetGaikouKuniId != 0)
                {
                    string targetGaikouKuniName   = kuni.getKuniName(targetGaikouKuniId);
                    int    targetGaikouDaimyoId   = int.Parse(seiryokuList [targetGaikouKuniId - 1]);
                    string targetGaikouDaimyoName = daimyo.getName(targetGaikouDaimyoId);

                    if (targetDaimyoId != targetGaikouDaimyoId)
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")";
                    }
                    else
                    {
                        sameDaimyoFlg = true;
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None";
                        }
                        else
                        {
                            status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = "無し";
                        }
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None";
                    }
                    else
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "無し";
                    }
                }

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


                //Exist Check
                if (doumeiList.Count != 0)
                {
                    List <string> doumeiListTmp = new List <string> (doumeiList);
                    for (int j = 0; j < doumeiListTmp.Count; j++)
                    {
                        string doumeiDaimyoId = doumeiListTmp [j];
                        if (!seiryokuList.Contains(doumeiDaimyoId))
                        {
                            doumeiList.Remove(doumeiDaimyoId);
                        }
                    }
                }
                string doumeiNameList = "";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    doumeiNameList = "None";
                }
                else
                {
                    doumeiNameList = "無し";
                }

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

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


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

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

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


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


            //Create Map
            GameObject originalKuniMap = GameObject.Find("KuniMap");
            GameObject copiedKuniMap   = Object.Instantiate(originalKuniMap) as GameObject;
            copiedKuniMap.transform.SetParent(board.transform);
            copiedKuniMap.transform.localScale = new Vector2(1, 0.8f);
            Vector3       vect    = copiedKuniMap.transform.FindChild(kuniId.ToString()).transform.localPosition;
            float         adjstX  = vect.x * -1;
            float         adjustY = vect.y * -1;
            RectTransform mapRect = copiedKuniMap.GetComponent <RectTransform>();
            mapRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0);

            //Create Kamon
            GameObject originalKamon = GameObject.Find("KuniIconView");
            GameObject copiedKamon   = Object.Instantiate(originalKamon) as GameObject;
            copiedKamon.transform.SetParent(board.transform);
            copiedKamon.transform.localScale = new Vector2(1, 0.8f);
            RectTransform kamonRect = copiedKamon.GetComponent <RectTransform>();
            kamonRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0);

            Entity_kuni_mst kuniMst    = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;
            Color           whiteColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
            for (int i = 0; i < kuniMst.param.Count; i++)
            {
                int subKuniId = i + 1;

                GameObject tmpKuniObj  = copiedKuniMap.transform.FindChild(subKuniId.ToString()).gameObject;
                GameObject tmpKamonObj = copiedKamon.transform.FindChild(subKuniId.ToString()).gameObject;
                tmpKamonObj.GetComponent <Image>().color = whiteColor;

                if (subKuniId == kuniId)
                {
                    tmpKamonObj.GetComponent <Button>().enabled = false;
                    tmpKamonObj.GetComponent <Image>().sprite   =
                        Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                    //EFFECT
                    string     effectPath = "Prefabs/EffectAnime/point_up";
                    GameObject pointUp    = Instantiate(Resources.Load(effectPath)) as GameObject;
                    pointUp.transform.SetParent(tmpKamonObj.transform);
                    pointUp.transform.localScale             = new Vector2(70, 70);
                    pointUp.transform.localPosition          = new Vector2(0, 25);
                    pointUp.GetComponent <Fadeout>().enabled = false;
                }
                else
                {
                    if (targetKuniList.Contains(subKuniId))
                    {
                        tmpKamonObj.GetComponent <Button>().enabled = false;
                        int subDaimyoId = int.Parse(seiryokuList[subKuniId - 1]);

                        if (daimyoId != subDaimyoId)
                        {
                            //yukoudo
                            int        yukoudoValue = gaikou.getExistGaikouValue(daimyoId, subDaimyoId);
                            string     syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
                            GameObject yukoudoObj   = Instantiate(Resources.Load(syukoudoPath)) as GameObject;
                            yukoudoObj.transform.SetParent(tmpKamonObj.transform);
                            yukoudoObj.GetComponent <Text>().text = yukoudoValue.ToString();
                            yukoudoObj.transform.localScale       = new Vector2(0.08f, 0.1f);
                            yukoudoObj.transform.localPosition    = new Vector2(0, 26);
                        }
                        else
                        {
                            tmpKamonObj.GetComponent <Image>().sprite =
                                Resources.Load(imagePath, typeof(Sprite)) as Sprite;
                        }

                        if (targetKuniId != 0)
                        {
                            if (targetKuniId == subKuniId)
                            {
                                //kassen target
                                Color atkColor = new Color(180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
                                tmpKamonObj.GetComponent <Image>().color = atkColor;
                            }
                        }
                        if (snbRank > 1)
                        {
                            if (targetGaikouKuniId != 0)
                            {
                                if (targetGaikouKuniId == subKuniId)
                                {
                                    if (!sameDaimyoFlg)
                                    {
                                        //gaikou target
                                        Color gaikouColor = new Color(80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
                                        tmpKamonObj.GetComponent <Image>().color = gaikouColor;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Color noSubKuniColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
                        tmpKuniObj.GetComponent <Image>().color = noSubKuniColor;

                        tmpKamonObj.SetActive(false);
                    }
                }
            }

            /*
             * string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage";
             * GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
             * mainMap.transform.SetParent(board.transform);
             * mainMap.transform.localScale = new Vector2 (13, 9);
             * mainMap.name = "kuniMap" + kuniId;
             * string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString ();
             * mainMap.GetComponent<Image> ().sprite =
             *  Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite;
             *
             * int baseX = kuni.getKuniLocationX (kuniId);
             * int baseY = kuni.getKuniLocationY (kuniId);
             * int adjstX = baseX * -1;
             * int adjustY = baseY * -1;
             *
             * float colorR = daimyo.getColorR (daimyoId);
             * float colorG = daimyo.getColorG (daimyoId);
             * float colorB = daimyo.getColorB (daimyoId);
             * Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);
             * mainMap.GetComponent<Image> ().color = kuniColor;
             *
             * RectTransform mapRect = mainMap.GetComponent<RectTransform> ();
             * mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0);
             *
             * //My Kuni Kamon Icon
             * string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack";
             * GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject;
             * kamonBack.transform.SetParent (board.transform);
             * kamonBack.transform.localScale = new Vector2 (1, 1);
             * kamonBack.transform.localPosition = new Vector2(0,0);
             *
             * string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString();
             * GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject;
             * kamonObj.transform.SetParent (kamonBack.transform);
             * kamonObj.transform.localScale = new Vector2 (1, 0.8f);
             * kamonObj.transform.localPosition = new Vector2(0,0);
             * kamonObj.GetComponent<Image> ().sprite =
             *  Resources.Load (imagePath, typeof(Sprite)) as Sprite;
             * kamonObj.GetComponent<Button> ().enabled = false;
             *
             *
             * //Mapping Kuni
             * Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
             * for (int i=0; i < kuniMst.param.Count; i++) {
             * //for (int i=0; i < targetKuniList.Count; i++) {
             *  int subKuniId = i + 1;
             *
             *  GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
             *  subMap.transform.SetParent(mainMap.transform);
             *  subMap.transform.localScale = new Vector2 (1, 1);
             *  subMap.transform.localPosition = new Vector2 (0, 0);
             *
             *  subMap.name = "kuniMap" + subKuniId;
             *  string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId;
             *  subMap.GetComponent<Image> ().sprite =
             *      Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite;
             *
             *
             *  if (targetKuniList.Contains (subKuniId)) {
             *      //color
             *      int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]);
             *      float subColorR = daimyo.getColorR (subDaimyoId);
             *      float subColorG = daimyo.getColorG (subDaimyoId);
             *      float subColorB = daimyo.getColorB (subDaimyoId);
             *      Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f);
             *      subMap.GetComponent<Image> ().color = subKuniColor;
             *
             *      //Kamon
             *      string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString ();
             *      GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject;
             *      subKamonObj.transform.SetParent (board.transform);
             *      subKamonObj.transform.localScale = new Vector2 (1, 0.8f);
             *      if (daimyoId != subDaimyoId) {
             *          string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString ();
             *          subKamonObj.GetComponent<Image> ().sprite =
             *              Resources.Load (subImagePath, typeof(Sprite)) as Sprite;
             *
             *          //yukoudo
             *          int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId);
             *          string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
             *          GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject;
             *          yukoudoObj.transform.SetParent (subKamonObj.transform);
             *          yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString ();
             *          yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f);
             *          yukoudoObj.transform.localPosition = new Vector2 (0, 26);
             *
             *      } else {
             *          subKamonObj.GetComponent<Image> ().sprite =
             *              Resources.Load (imagePath, typeof(Sprite)) as Sprite;
             *      }
             *      subKamonObj.GetComponent<Button> ().enabled = false;
             *
             *      //Kamon adjustment
             *      int subBaseX = kuni.getKuniLocationX (subKuniId);
             *      int subBaseY = kuni.getKuniLocationY (subKuniId);
             *      int subAdjstX = subBaseX - baseX;
             *      int subAdjstY = subBaseY - baseY;
             *
             *      RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> ();
             *      subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0);
             *
             *      if (targetKuniId != 0) {
             *          if (targetKuniId == subKuniId) {
             *              //kassen target
             *              Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
             *              subKamonObj.GetComponent<Image> ().color = atkColor;
             *          }
             *      }
             *
             *      if (snbRank > 1) {
             *          if (targetGaikouKuniId != 0) {
             *              if (targetGaikouKuniId == subKuniId) {
             *                  if (!sameDaimyoFlg) {
             *                      //gaikou target
             *                      Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
             *                      subKamonObj.GetComponent<Image> ().color = gaikouColor;
             *                  }
             *              }
             *          }
             *      }
             *  } else {
             *      Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
             *      subMap.GetComponent<Image> ().color = noSubKuniColor;
             *  }
             *
             * }
             *
             */
        }
    }
Exemple #6
0
    public void makeDaimyoSeiryoku()
    {
        Destroy(fin.gameObject);

        string     kuniMapPath = "Prefabs/clearOrGameOver/KuniMap";
        GameObject KuniMap     = Instantiate(Resources.Load(kuniMapPath)) as GameObject;

        KuniMap.transform.SetParent(panel.transform);
        KuniMap.transform.localScale = new Vector2(1, 1);

        string     kuniIconViewPath = "Prefabs/clearOrGameOver/KuniIconView";
        GameObject kuniIconView     = Instantiate(Resources.Load(kuniIconViewPath)) as GameObject;

        kuniIconView.transform.SetParent(panel.transform);
        kuniIconView.transform.localScale = new Vector2(1, 1);

        string     messagePath = "Prefabs/clearOrGameOver/FixedMessage";
        GameObject msg         = Instantiate(Resources.Load(messagePath)) as GameObject;

        msg.transform.SetParent(panel.transform);
        msg.transform.localScale    = new Vector2(1, 1);
        msg.transform.localPosition = new Vector2(0, 380);

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

        string        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";
        List <string> seiryokuList = new List <string> ();

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

        string        kuniQtybyDaimyo = "1,1,3,2,1,1,1,2,1,1,1,1,1,1,1,1,2,1,3,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,2,1,1,4,1,1,4,1,1,1,2,1";
        List <string> KuniQtyList     = new List <string> ();

        KuniQtyList = new List <string> (kuniQtybyDaimyo.Split(delimiterChars));

        string        gameClearDaimyo     = PlayerPrefs.GetString("gameClearDaimyo");
        List <string> gameClearDaimyoList = new List <string> ();

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

        string        myBusyo     = PlayerPrefs.GetString("myBusyo");
        List <string> myBusyoList = new List <string> ();

        if (myBusyo != null && myBusyo != "")
        {
            if (myBusyo.Contains(","))
            {
                myBusyoList = new List <string> (myBusyo.Split(delimiterChars));
            }
            else
            {
                myBusyoList.Add(myBusyo);
            }
        }
        string kuniPath = "Prefabs/Map/kuni/";

        KuniInfo kuniScript   = new KuniInfo();
        Daimyo   daimyoScript = new Daimyo();

        for (int i = 0; i < kuniMst.param.Count; i++)
        {
            int kuniId = kuniMst.param [i].kunId;

            string newKuniPath = kuniPath + kuniId.ToString();
            int    locationX   = kuniMst.param [i].locationX;
            int    locationY   = kuniMst.param [i].locationY;

            GameObject kuni = Instantiate(Resources.Load(newKuniPath)) as GameObject;

            kuni.transform.SetParent(kuniIconView.transform);
            kuni.name = kuniId.ToString();
            kuni.GetComponent <SendParam> ().kuniId   = kuniId;
            kuni.GetComponent <SendParam> ().kuniName = kuniScript.getKuniName(kuniId);
            kuni.transform.localScale = new Vector2(1, 1);
            kuni.GetComponent <SendParam> ().naiseiItem = kuniMst.param [i].naisei;

            //Seiryoku Handling
            int    daimyoId          = int.Parse(seiryokuList [kuniId - 1]);
            string daimyoName        = daimyoScript.getName(daimyoId);
            int    daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId;
            kuni.GetComponent <SendParam> ().daimyoId      = daimyoId;
            kuni.GetComponent <SendParam> ().daimyoName    = daimyoName;
            kuni.GetComponent <SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp;
            kuni.GetComponent <SendParam> ().kuniQty       = int.Parse(KuniQtyList [daimyoId - 1]);

            if (gameClearDaimyoList.Contains(daimyoId.ToString()))
            {
                kuni.GetComponent <SendParam> ().gameClearFlg = true;
            }

            if (myBusyoList.Contains(daimyoBusyoIdTemp.ToString()))
            {
                kuni.GetComponent <SendParam> ().busyoHaveFlg = true;
            }

            //Color Handling
            float colorR    = (float)daimyoMst.param [daimyoId - 1].colorR;
            float colorG    = (float)daimyoMst.param [daimyoId - 1].colorG;
            float colorB    = (float)daimyoMst.param [daimyoId - 1].colorB;
            Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);

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

            //Daimyo Kamon Image
            string imagePath = "Prefabs/Kamon/" + daimyoId.ToString();
            kuni.GetComponent <Image> ().sprite =
                Resources.Load(imagePath, typeof(Sprite)) as Sprite;
            RectTransform kuniTransform = kuni.GetComponent <RectTransform> ();
            kuniTransform.anchoredPosition = new Vector3(locationX, locationY, 0);
        }
    }