Exemple #1
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [2].Play();

        /*Busyo View*/
        //Delete Previous
        foreach (Transform n in GameObject.Find("BusyoView").transform)
        {
            GameObject.Destroy(n.gameObject);
        }
        //Jinkei Flg
        if (jinkeiFlg)
        {
            string     iconPath = "Prefabs/Busyo/Jinkei";
            GameObject jinkei   = Instantiate(Resources.Load(iconPath)) as GameObject;
            jinkei.transform.SetParent(GameObject.Find("BusyoView").transform);
            jinkei.transform.localScale    = new Vector2(0.3f, 0.3f);
            jinkei.transform.localPosition = new Vector2(220, 200);
            jinkei.name = "jinkei";
        }

        //Make New Busyo
        string busyoId;

        busyoId = this.name.Remove(0, 4);
        string     path  = "Prefabs/Player/Unit/BusyoUnit";
        GameObject Busyo = Instantiate(Resources.Load(path)) as GameObject;

        Busyo.name = busyoId.ToString();
        Busyo.transform.SetParent(GameObject.Find("BusyoView").transform);
        Busyo.transform.localScale = new Vector2(4, 4);
        Busyo.GetComponent <DragHandler> ().enabled = false;

        RectTransform rect_transform = Busyo.GetComponent <RectTransform>();

        rect_transform.anchoredPosition3D = new Vector3(300, 200, 0);
        rect_transform.sizeDelta          = new Vector2(100, 100);

        //Ship Rank
        string     shipPath = "Prefabs/Busyo/ShipSts";
        GameObject ShipObj  = Instantiate(Resources.Load(shipPath)) as GameObject;

        ShipObj.transform.SetParent(Busyo.transform);
        preKaisen kaisenScript = new preKaisen();
        int       shipId       = kaisenScript.getShipSprite(ShipObj, int.Parse(busyoId));

        ShipObj.transform.localPosition = new Vector3(-40, -40, 0);
        ShipObj.transform.localScale    = new Vector2(0.4f, 0.4f);
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            if (shipId == 1)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "High";
            }
            else if (shipId == 2)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Mid";
            }
            else if (shipId == 3)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Low";
            }
        }
        else
        {
            if (shipId == 1)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "上";
            }
            else if (shipId == 2)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "中";
            }
            else if (shipId == 3)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "下";
            }
        }
        //Text Modification
        GameObject text = Busyo.transform.FindChild("Text").gameObject;

        text.GetComponent <Text> ().color = new Color(255, 255, 255, 255);
        RectTransform text_transform = text.GetComponent <RectTransform>();

        text_transform.anchoredPosition3D = new Vector3(-70, 30, 0);
        text_transform.sizeDelta          = new Vector2(630, 120);
        text.transform.localScale         = new Vector2(0.2f, 0.2f);

        //Rank Text Modification
        GameObject    rank           = Busyo.transform.FindChild("Rank").gameObject;
        RectTransform rank_transform = rank.GetComponent <RectTransform>();

        rank_transform.anchoredPosition3D   = new Vector3(20, -50, 0);
        rank_transform.sizeDelta            = new Vector2(200, 200);
        rank.GetComponent <Text>().fontSize = 200;


        /*Busyo Status*/
        NowOnBusyo   NowOnBusyoScript   = GameObject.Find("GameScene").GetComponent <NowOnBusyo> ();
        BusyoInfoGet busyoInfoGetScript = new BusyoInfoGet();

        if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Ronkou")
        {
            int       lv  = PlayerPrefs.GetInt(busyoId);
            StatusGet sts = new StatusGet();
            int       hp  = sts.getHp(int.Parse(busyoId), lv);
            int       atk = sts.getAtk(int.Parse(busyoId), lv);
            int       dfc = sts.getDfc(int.Parse(busyoId), lv);
            int       spd = sts.getSpd(int.Parse(busyoId), lv);

            int adjHp  = hp * 100;
            int adjAtk = atk * 10;
            int adjDfc = dfc * 10;

            //add lv
            string addLvTmp = "addlv" + busyoId.ToString();
            if (PlayerPrefs.HasKey(addLvTmp))
            {
                string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp);
                GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString();
            }
            else
            {
                GameObject.Find("addLvValue").GetComponent <Text>().text = "";
            }
            int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp);

            GameObject.Find("LvValue").GetComponent <Text> ().text       = lv.ToString();
            GameObject.Find("TosotsuValue").GetComponent <Text> ().text  = adjHp.ToString();
            GameObject.Find("BuyuuValue").GetComponent <Text> ().text    = adjAtk.ToString();
            GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString();
            GameObject.Find("SpeedValue").GetComponent <Text> ().text    = spd.ToString();

            //Exp
            string expId       = "exp" + busyoId.ToString();
            string expString   = "";
            int    nowExp      = PlayerPrefs.GetInt(expId);
            Exp    exp         = new Exp();
            int    requiredExp = 0;
            if (lv != maxLv)
            {
                requiredExp = exp.getExpforNextLv(lv);
            }
            else
            {
                requiredExp = exp.getExpLvMax(maxLv);
            }


            expString = nowExp + "/" + requiredExp;
            GameObject.Find("ExpValue").GetComponent <Text> ().text = expString;

            //Kahou status
            KahouStatusGet kahouSts         = new KahouStatusGet();
            string[]       KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd);
            int            totalBusyoHp     = 0;


            //Kanni
            string kanniTmp      = "kanni" + busyoId;
            float  addAtkByKanni = 0;
            float  addHpByKanni  = 0;
            float  addDfcByKanni = 0;

            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int kanniId = PlayerPrefs.GetInt(kanniTmp);
                if (kanniId != 0)
                {
                    Kanni  kanni     = new Kanni();
                    string kanniIkai = kanni.getIkai(kanniId);
                    string kanniName = kanni.getKanni(kanniId);
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName;

                    //Status
                    string kanniTarget = kanni.getEffectTarget(kanniId);
                    int    effect      = kanni.getEffect(kanniId);
                    if (kanniTarget == "atk")
                    {
                        addAtkByKanni = ((float)adjAtk * (float)effect) / 100;
                    }
                    else if (kanniTarget == "hp")
                    {
                        addHpByKanni = ((float)adjHp * (float)effect) / 100;
                    }
                    else if (kanniTarget == "dfc")
                    {
                        addDfcByKanni = ((float)adjDfc * (float)effect) / 100;
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                    }
                    else
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                    }
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = "No Rank";
                }
                else
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                }
            }

            //Jyosyu
            string jyosyuTmp = "jyosyuBusyo" + busyoId;
            if (PlayerPrefs.HasKey(jyosyuTmp))
            {
                int      kuniId   = PlayerPrefs.GetInt(jyosyuTmp);
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text> ().text = kuniName + "\nLord";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
                }
            }

            //Show Additional Status
            int finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni);
            int finalHp  = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni);
            int finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni);
            int finalSpd = int.Parse(KahouStatusArray [3]);

            GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString();
            GameObject.Find("KahouHpValue").GetComponent <Text>().text   = "+" + finalHp.ToString();
            totalBusyoHp = adjHp + finalHp;
            GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString();
            GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString();

            //Butai Status
            string heiId   = "hei" + busyoId.ToString();
            string chParam = PlayerPrefs.GetString(heiId, "0");

            if (chParam == "0" || chParam == "")
            {
                StatusGet statusScript = new StatusGet();
                string    heisyu       = statusScript.getHeisyu(int.Parse(busyoId));
                chParam = heisyu + ":1:1:1";
                PlayerPrefs.SetString(heiId, chParam);
                PlayerPrefs.Flush();
            }


            if (chParam.Contains(":"))
            {
                char[]   delimiterChars = { ':' };
                string[] ch_list        = chParam.Split(delimiterChars);

                string ch_type   = ch_list [0];
                int    ch_num    = int.Parse(ch_list [1]);
                int    ch_lv     = int.Parse(ch_list [2]);
                float  ch_status = float.Parse(ch_list [3]);

                string  heisyu = "";
                Message msg    = new Message();
                if (ch_type == "KB")
                {
                    heisyu = msg.getMessage(55);
                }
                else if (ch_type == "YR")
                {
                    heisyu = msg.getMessage(56);
                }
                else if (ch_type == "TP")
                {
                    heisyu = msg.getMessage(57);
                }
                else if (ch_type == "YM")
                {
                    heisyu = msg.getMessage(58);
                }

                GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu;
                GameObject.Find("ChildQtyValue").GetComponent <Text> ().text  = ch_num.ToString();
                GameObject.Find("ChildLvValue").GetComponent <Text> ().text   = ch_lv.ToString();

                //Jyosyu Handling
                JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku();
                float          addHei    = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId);
                float          hei       = ch_status * 10;
                GameObject.Find("ChildHeiryokuValue").GetComponent <Text>().text = hei.ToString();
                float newHei = finalHp + addHei;
                GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString();

                int    chAtkDfc       = (int)sts.getChAtkDfc((int)hei, totalBusyoHp);
                string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString();
                GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString;


                //Child Image
                foreach (Transform n in GameObject.Find("Img").transform)
                {
                    GameObject.Destroy(n.gameObject);
                }
                string     chPath = "Prefabs/Player/Unit/" + ch_type;
                GameObject chObj  = Instantiate(Resources.Load(chPath)) as GameObject;
                chObj.transform.SetParent(GameObject.Find("Img").transform);
                RectTransform chTransform = chObj.GetComponent <RectTransform> ();
                chTransform.anchoredPosition3D = new Vector3(-200, -50, 0);
                chTransform.sizeDelta          = new Vector2(40, 40);
                chObj.transform.localScale     = new Vector2(4, 4);


                GameObject chigyo = GameObject.Find("ButtonCyouhei");
                if (ch_num < 20)
                {
                    chigyo.GetComponent <Image> ().color = OKClorBtn;
                    chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
                    chigyo.GetComponent <Button>().enabled = true;

                    chigyo.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
                    chigyo.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
                }
                else
                {
                    //MAX
                    chigyo.GetComponent <Image> ().color = NGClorBtn;
                    chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                    chigyo.GetComponent <Button>().enabled = false;
                }
                GameObject kunren = GameObject.Find("ButtonKunren");
                if (ch_lv < 100)
                {
                    kunren.GetComponent <Image> ().color = OKClorBtn;
                    kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
                    kunren.GetComponent <Button>().enabled = true;

                    kunren.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
                    kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
                    kunren.GetComponent <BusyoStatusButton> ().ch_lv     = ch_lv;
                    kunren.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
                    kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
                    kunren.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
                    kunren.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
                }
                else
                {
                    //MAX
                    kunren.GetComponent <Image> ().color = NGClorBtn;
                    kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                    kunren.GetComponent <Button>().enabled = false;
                }
            }

            //Parametor Setting
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Senpou")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            SenpouScene scene = new SenpouScene();
            scene.createSenpouStatusView(busyoId);
            scene.createSakuStatusView(busyoId);
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Kahou")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            KahouScene kahou = new KahouScene();
            kahou.createKahouStatusView(busyoId);
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Syogu")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            SyoguScene syogu = new SyoguScene();
            syogu.createSyoguView(busyoId);
        }
    }
Exemple #2
0
    public void createSyoguView(string busyoId)
    {
        int lv = PlayerPrefs.GetInt(busyoId);

        Color ngImageColor = new Color(40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f);
        Color ngTextColor  = new Color(90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f);
        Color okImageColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f);
        Color okTextColor  = new Color(40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f);

        GameObject kanjyo  = GameObject.Find("kanjyo").gameObject;
        GameObject tsuihou = GameObject.Find("tsuihou").gameObject;

        int daimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo");

        if (busyoId == daimyoBusyoId.ToString())
        {
            kanjyo.GetComponent <Image> ().color = ngImageColor;
            kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
            kanjyo.GetComponent <Button> ().enabled = false;

            tsuihou.GetComponent <Image> ().color = ngImageColor;
            tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
            tsuihou.GetComponent <Button> ().enabled = false;
        }
        else
        {
            string addLvTmp = "addlv" + busyoId.ToString();
            int    maxLv    = 100 + PlayerPrefs.GetInt(addLvTmp);

            if (lv != maxLv)
            {
                kanjyo.GetComponent <BusyoStatusButton> ().pa_lv = lv;
                kanjyo.GetComponent <Image> ().color             = okImageColor;
                kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor;
                kanjyo.GetComponent <Button> ().enabled = true;
            }
            else
            {
                kanjyo.GetComponent <Image> ().color = ngImageColor;
                kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
                kanjyo.GetComponent <Button> ().enabled = false;
            }

            tsuihou.GetComponent <Image> ().color = okImageColor;
            tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor;
            tsuihou.GetComponent <Button> ().enabled = true;
        }

        GameObject kanni  = GameObject.Find("kanni").gameObject;
        GameObject jyosyu = GameObject.Find("jyosyu").gameObject;
        GameObject syugyo = GameObject.Find("syugyo").gameObject;
        GameObject gokui  = GameObject.Find("gokui").gameObject;

        kanni.GetComponent <RonkouKousyoMenu>().busyoId  = busyoId;
        jyosyu.GetComponent <RonkouKousyoMenu>().busyoId = busyoId;
        syugyo.GetComponent <RonkouKousyoMenu>().busyoId = busyoId;
        gokui.GetComponent <RonkouKousyoMenu>().busyoId  = busyoId;

        //Kanni
        string kanniTmp    = "kanni" + busyoId;
        Kanni  kanniScript = new Kanni();

        if (PlayerPrefs.HasKey(kanniTmp))
        {
            int kanniId = PlayerPrefs.GetInt(kanniTmp);
            if (kanniId != 0)
            {
                foreach (Transform n in kanni.transform)
                {
                    if (n.name == "KanniName")
                    {
                        Destroy(n.gameObject);
                    }
                }
                kanni.GetComponent <RonkouKousyoMenu> ().kanniId = kanniId;
                string     path      = "Prefabs/Busyo/KanniName";
                GameObject kanniName = Instantiate(Resources.Load(path)) as GameObject;
                kanniName.transform.SetParent(kanni.transform);
                kanniName.transform.localScale    = new Vector2(0.12f, 0.12f);
                kanniName.transform.localPosition = new Vector2(0, 0);
                kanniName.name = "KanniName";

                string kanniNameString = kanniScript.getKanni(kanniId);
                string kanniIkai       = kanniScript.getIkai(kanniId);
                kanniName.transform.FindChild("value").GetComponent <Text>().text = kanniIkai + "\n" + kanniNameString;

                string effectLabel = kanniScript.getEffectLabel(kanniId);
                int    effect      = kanniScript.getEffect(kanniId);
                kanniName.transform.FindChild("effectLabel").GetComponent <Text>().text = effectLabel;
                kanniName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + effect.ToString() + "%";

                kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = false;
            }
            else
            {
                foreach (Transform n in kanni.transform)
                {
                    if (n.name == "KanniName")
                    {
                        Destroy(n.gameObject);
                    }
                }

                kanni.GetComponent <RonkouKousyoMenu>().kanniId = 0;
                kanni.transform.FindChild("Text").GetComponent <Text>().enabled = true;
            }
        }
        else
        {
            foreach (Transform n in kanni.transform)
            {
                if (n.name == "KanniName")
                {
                    Destroy(n.gameObject);
                }
            }

            kanni.GetComponent <RonkouKousyoMenu> ().kanniId = 0;
            kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = true;
        }

        //Jyosyu
        string jyosyuTmp = "jyosyuBusyo" + busyoId;

        if (PlayerPrefs.HasKey(jyosyuTmp))
        {
            BusyoInfoGet busyoInfo = new BusyoInfoGet();
            string       busyoName = busyoInfo.getName(int.Parse(busyoId));
            jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuName = busyoName;

            int kuniId = PlayerPrefs.GetInt(jyosyuTmp);

            if (kuniId != 0)
            {
                foreach (Transform n in jyosyu.transform)
                {
                    if (n.name == "JyosyuName")
                    {
                        Destroy(n.gameObject);
                    }
                }

                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);

                string jyosyuHeiTmp = "jyosyuHei" + busyoId;
                int    jyosyuHei    = PlayerPrefs.GetInt(jyosyuHeiTmp);

                jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuKuniId = kuniId;
                string     jyosyuPath = "Prefabs/Busyo/JyosyuName";
                GameObject jyosyuName = Instantiate(Resources.Load(jyosyuPath)) as GameObject;
                jyosyuName.transform.SetParent(jyosyu.transform);
                jyosyuName.transform.localScale    = new Vector2(0.12f, 0.12f);
                jyosyuName.transform.localPosition = new Vector2(0, 0);
                jyosyuName.name = "JyosyuName";

                jyosyuName.transform.FindChild("value").GetComponent <Text>().text       = kuniName;
                jyosyuName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + jyosyuHei.ToString();

                jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = false;
            }
        }
        else
        {
            foreach (Transform n in jyosyu.transform)
            {
                if (n.name == "JyosyuName")
                {
                    Destroy(n.gameObject);
                }
            }
            jyosyu.GetComponent <RonkouKousyoMenu> ().jyosyuKuniId            = 0;
            jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = true;
        }
    }
Exemple #3
0
    public void createBusyoStatusView(string busyoId)
    {
        bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg");
        int  lv = 1;

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            lv = PlayerPrefs.GetInt(busyoId);
        }

        StatusGet sts = new StatusGet();
        int       hp  = sts.getHp(int.Parse(busyoId), lv);
        int       atk = sts.getAtk(int.Parse(busyoId), lv);
        int       dfc = sts.getDfc(int.Parse(busyoId), lv);
        int       spd = sts.getSpd(int.Parse(busyoId), lv);

        int adjHp  = hp * 100;
        int adjAtk = atk * 10;
        int adjDfc = dfc * 10;

        //add lv
        string addLvTmp = "addlv" + busyoId.ToString();

        if (PlayerPrefs.HasKey(addLvTmp))
        {
            string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp);
            GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString();
        }
        else
        {
            GameObject.Find("addLvValue").GetComponent <Text>().text = "";
        }
        int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp);

        GameObject.Find("LvValue").GetComponent <Text> ().text       = lv.ToString();
        GameObject.Find("TosotsuValue").GetComponent <Text> ().text  = adjHp.ToString();
        GameObject.Find("BuyuuValue").GetComponent <Text> ().text    = adjAtk.ToString();
        GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString();
        GameObject.Find("SpeedValue").GetComponent <Text> ().text    = spd.ToString();


        //Exp
        string expId     = "exp" + busyoId.ToString();
        string expString = "";
        int    nowExp    = 0;

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            nowExp = PlayerPrefs.GetInt(expId);
        }
        Exp exp         = new Exp();
        int requiredExp = 0;

        if (lv != maxLv)
        {
            requiredExp = exp.getExpforNextLv(lv);
        }
        else
        {
            requiredExp = exp.getExpLvMax(maxLv);
        }

        expString = nowExp + "/" + requiredExp;
        GameObject.Find("ExpValue").GetComponent <Text> ().text = expString;


        //Kahou status
        int totalBusyoHp = 0;
        int finalAtk     = 0;
        int finalHp      = 0;
        int finalDfc     = 0;
        int finalSpd     = 0;

        if (tutorialDoneFlg && Application.loadedLevelName != "tutorialBusyo")
        {
            KahouStatusGet kahouSts         = new KahouStatusGet();
            string[]       KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd);

            //Kanni
            string kanniTmp      = "kanni" + busyoId;
            float  addAtkByKanni = 0;
            float  addHpByKanni  = 0;
            float  addDfcByKanni = 0;

            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int kanniId = PlayerPrefs.GetInt(kanniTmp);
                if (kanniId != 0)
                {
                    Kanni  kanni     = new Kanni();
                    string kanniIkai = kanni.getIkai(kanniId);
                    string kanniName = kanni.getKanni(kanniId);
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName;

                    //Status
                    string kanniTarget = kanni.getEffectTarget(kanniId);
                    int    effect      = kanni.getEffect(kanniId);
                    if (kanniTarget == "atk")
                    {
                        addAtkByKanni = ((float)adjAtk * (float)effect) / 100;
                    }
                    else if (kanniTarget == "hp")
                    {
                        addHpByKanni = ((float)adjHp * (float)effect) / 100;
                    }
                    else if (kanniTarget == "dfc")
                    {
                        addDfcByKanni = ((float)adjDfc * (float)effect) / 100;
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                    }
                    else
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                    }
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                }
                else
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                }
            }

            //Jyosyu
            string jyosyuTmp = "jyosyuBusyo" + busyoId;
            if (PlayerPrefs.HasKey(jyosyuTmp))
            {
                int      kuniId   = PlayerPrefs.GetInt(jyosyuTmp);
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);

                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\nLord";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
                }
            }

            //Show Additional Status
            finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni);
            finalHp  = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni);
            finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni);
            finalSpd = int.Parse(KahouStatusArray [3]);

            GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString();
            GameObject.Find("KahouHpValue").GetComponent <Text>().text   = "+" + finalHp.ToString();
            totalBusyoHp = adjHp + finalHp;
            GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString();
            GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString();
        }
        else
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
            }
            else
            {
                GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
            }

            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
            }
            else
            {
                GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
            }
        }

        //Butai Status
        string heiId   = "hei" + busyoId.ToString();
        string chParam = "";

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            chParam = PlayerPrefs.GetString(heiId, "0");
        }
        else
        {
            //retry tutorial
            chParam = "TP: 1:1:1";
        }

        if (chParam == "0" || chParam == "")
        {
            StatusGet statusScript  = new StatusGet();
            string    chParamHeisyu = statusScript.getHeisyu(int.Parse(busyoId));
            chParam = chParamHeisyu + ":1:1:1";
            PlayerPrefs.SetString(heiId, chParam);
            PlayerPrefs.Flush();
        }


        char[]   delimiterChars = { ':' };
        string[] ch_list        = chParam.Split(delimiterChars);

        string ch_type   = ch_list [0];
        int    ch_num    = int.Parse(ch_list [1]);
        int    ch_lv     = int.Parse(ch_list [2]);
        float  ch_status = float.Parse(ch_list [3]);

        string heisyu = "";

        Message msg = new Message();

        if (ch_type == "KB")
        {
            heisyu = msg.getMessage(55);
        }
        else if (ch_type == "YR")
        {
            heisyu = msg.getMessage(56);
        }
        else if (ch_type == "TP")
        {
            heisyu = msg.getMessage(57);
        }
        else if (ch_type == "YM")
        {
            heisyu = msg.getMessage(58);
        }

        GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu;
        GameObject.Find("ChildQtyValue").GetComponent <Text> ().text  = ch_num.ToString();
        GameObject.Find("ChildLvValue").GetComponent <Text> ().text   = ch_lv.ToString();

        //Jyosyu Handling
        JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku();
        float          addHei    = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId);
        float          hei       = ch_status * 10;

        GameObject.Find("ChildHeiryokuValue").GetComponent <Text> ().text = hei.ToString();
        float newHei = finalHp + addHei;

        GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString();


        int    chAtkDfc       = (int)sts.getChAtkDfc((int)hei, totalBusyoHp);
        string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString();

        GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString;

        //Child Image
        foreach (Transform n in GameObject.Find("Img").transform)
        {
            GameObject.Destroy(n.gameObject);
        }
        string     chPath = "Prefabs/Player/Unit/" + ch_type;
        GameObject chObj  = Instantiate(Resources.Load(chPath)) as GameObject;

        chObj.transform.SetParent(GameObject.Find("Img").transform);
        RectTransform chTransform = chObj.GetComponent <RectTransform> ();

        chTransform.anchoredPosition3D = new Vector3(-200, -50, 0);
        chTransform.sizeDelta          = new Vector2(40, 40);
        chObj.transform.localScale     = new Vector2(4, 4);



        GameObject chigyo = GameObject.Find("ButtonCyouhei");

        if (ch_num < 20)
        {
            chigyo.GetComponent <Image> ().color = OKClorBtn;
            chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
            chigyo.GetComponent <Button>().enabled = true;

            chigyo.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
            chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
            chigyo.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
            chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
            chigyo.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
            chigyo.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
        }
        else
        {
            //MAX
            chigyo.GetComponent <Image> ().color = NGClorBtn;
            chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
            chigyo.GetComponent <Button>().enabled = false;
        }
        GameObject kunren = GameObject.Find("ButtonKunren");

        if (ch_lv < 100)
        {
            kunren.GetComponent <Image> ().color = OKClorBtn;
            kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
            kunren.GetComponent <Button>().enabled = true;

            kunren.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
            kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
            kunren.GetComponent <BusyoStatusButton> ().ch_lv     = ch_lv;
            kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
            kunren.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
            kunren.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
            kunren.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
        }
        else
        {
            //MAX
            kunren.GetComponent <Image> ().color = NGClorBtn;
            kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
            kunren.GetComponent <Button>().enabled = false;
        }
        //Parametor Setting
        GameObject.Find("GameScene").GetComponent <NowOnBusyo>().OnBusyo = busyoId;

        //Jinkei Flg
        GameObject BusyoView = GameObject.Find("BusyoView");

        if (!BusyoView.transform.FindChild("jinkei"))
        {
            if (jinkeiBusyoCheck(int.Parse(busyoId)))
            {
                string     iconPath = "Prefabs/Busyo/Jinkei";
                GameObject jinkei   = Instantiate(Resources.Load(iconPath)) as GameObject;
                jinkei.transform.SetParent(GameObject.Find("BusyoView").transform);
                jinkei.transform.localScale    = new Vector2(0.3f, 0.3f);
                jinkei.transform.localPosition = new Vector2(220, 200);
                jinkei.name = "jinkei";
            }
        }
    }
Exemple #4
0
	public void createBusyoStatusView(string busyoId){
		int lv = PlayerPrefs.GetInt (busyoId);
		StatusGet sts = new StatusGet ();
		int hp = sts.getHp (int.Parse (busyoId), lv);
		int atk = sts.getAtk (int.Parse (busyoId), lv);
		int dfc = sts.getDfc (int.Parse (busyoId), lv);
		int spd = sts.getSpd (int.Parse (busyoId), lv);
		
		int adjHp = hp * 100;
		int adjAtk = atk * 10;
		int adjDfc = dfc * 10;
		
		GameObject.Find ("LvValue").GetComponent<Text> ().text = lv.ToString ();
		GameObject.Find ("TosotsuValue").GetComponent<Text> ().text = adjHp.ToString ();
		GameObject.Find ("BuyuuValue").GetComponent<Text> ().text = adjAtk.ToString ();
		GameObject.Find ("ChiryakuValue").GetComponent<Text> ().text = adjDfc.ToString ();
		GameObject.Find ("SpeedValue").GetComponent<Text> ().text = spd.ToString ();

		//Exp
		string expId = "exp" + busyoId.ToString ();
		string expString = "";
		int nowExp = PlayerPrefs.GetInt(expId);
		Exp exp = new Exp ();
		int requiredExp = 0;
		if (lv != 100) {
			requiredExp = exp.getExpforNextLv (lv);
		} else {
			requiredExp = exp.getExpLv100();
		}

		expString = nowExp + "/" + requiredExp;
		GameObject.Find ("ExpValue").GetComponent<Text> ().text = expString;


		//Kahou status
		KahouStatusGet kahouSts = new KahouStatusGet ();
		string[] KahouStatusArray =kahouSts.getKahouForStatus (busyoId,adjHp,adjAtk,adjDfc,spd);
		int totalBusyoHp =0;


		//Kanni
		string kanniTmp = "kanni" + busyoId;
		float addAtkByKanni = 0;
		float addHpByKanni = 0;
		float addDfcByKanni = 0;

		if (PlayerPrefs.HasKey (kanniTmp)) {
			int kanniId = PlayerPrefs.GetInt (kanniTmp);
			Kanni kanni = new Kanni ();
			string kanniIkai = kanni.getIkai (kanniId);
			string kanniName = kanni.getKanni (kanniId);
			GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = kanniIkai + "\n" + kanniName;

			//Status
			string kanniTarget = kanni.getEffectTarget(kanniId);
			int effect = kanni.getEffect(kanniId);
			if(kanniTarget=="atk"){
				addAtkByKanni = ((float)adjAtk * (float)effect)/100;
			}else if(kanniTarget=="hp"){
				addHpByKanni = ((float)adjHp * (float)effect)/100;
			}else if(kanniTarget=="dfc"){
				addDfcByKanni = ((float)adjDfc * (float)effect)/100;
			}

		
		} else {
			GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = "官位無し";
		}

		//Jyosyu
		string jyosyuTmp = "jyosyuBusyo" + busyoId;
		if (PlayerPrefs.HasKey (jyosyuTmp)) {
			int kuniId = PlayerPrefs.GetInt(jyosyuTmp);
			KuniInfo kuni = new KuniInfo();
			string kuniName = kuni.getKuniName(kuniId);

			GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = kuniName + "\n城主";

		} else {
			GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = "城無し";
		}




		//Show Additional Status
		int finalAtk = int.Parse (KahouStatusArray [0]) + Mathf.FloorToInt (addAtkByKanni);
		int finalHp = int.Parse (KahouStatusArray [1]) + Mathf.FloorToInt (addHpByKanni);
		int finalDfc= int.Parse (KahouStatusArray [2]) + Mathf.FloorToInt (addDfcByKanni);
		int finalSpd = int.Parse (KahouStatusArray [3]);

		GameObject.Find ("KahouAtkValue").GetComponent<Text> ().text = "+" + finalAtk.ToString ();
		GameObject.Find ("KahouHpValue").GetComponent<Text>().text = "+" + finalHp.ToString();
		totalBusyoHp = adjHp + finalHp;
		GameObject.Find ("KahouDfcValue").GetComponent<Text>().text = "+" + finalDfc.ToString();
		GameObject.Find ("KahouSpdValue").GetComponent<Text>().text = "+" + finalSpd.ToString();


		//Butai Status
		string heiId = "hei" + busyoId.ToString ();
		string chParam = PlayerPrefs.GetString (heiId, "0");
		
		char[] delimiterChars = {':'};
		string[] ch_list = chParam.Split (delimiterChars);
		
		string ch_type = ch_list [0];
		int ch_num = int.Parse (ch_list [1]);
		int ch_lv = int.Parse (ch_list [2]);
		float ch_status = float.Parse (ch_list [3]);
		
		string heisyu = "";
		if (ch_type == "KB") {
			heisyu = "騎馬隊";
		} else if (ch_type == "YR") {
			heisyu = "槍隊";
		} else if (ch_type == "TP") {
			heisyu = "鉄砲隊";
		} else if (ch_type == "YM") {
			heisyu = "弓隊";
		}
		GameObject.Find ("ChildNameValue").GetComponent<Text> ().text = heisyu;
		GameObject.Find ("ChildQtyValue").GetComponent<Text> ().text = ch_num.ToString ();
		GameObject.Find ("ChildLvValue").GetComponent<Text> ().text = ch_lv.ToString ();

		//Jyosyu Handling
		JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku ();
		float addHei = (float)jyosyuHei.GetJyosyuHeiryoku (busyoId);
		float hei = ch_status * 10;
		string heiText = hei.ToString() + "<size=150><Color=#35D74BFF>+" + addHei + "</Color></size>";
		GameObject.Find ("ChildHeiryokuValue").GetComponent<Text> ().text = heiText;


		int chAtkDfc = (int)sts.getChAtkDfc ((int)hei, totalBusyoHp);
		string chAtkDfcString = chAtkDfc.ToString () + "/" + chAtkDfc.ToString (); 
		GameObject.Find ("ChildStatusValue").GetComponent<Text> ().text = chAtkDfcString;
		
		//Child Image
		foreach (Transform n in GameObject.Find ("Img").transform) {
			GameObject.Destroy (n.gameObject);
		}
		string chPath = "Prefabs/Player/Unit/" + ch_type;
		GameObject chObj = Instantiate (Resources.Load (chPath)) as GameObject;
		chObj.transform.SetParent(GameObject.Find ("Img").transform);
		RectTransform chTransform = chObj.GetComponent<RectTransform> ();
		chTransform.anchoredPosition3D = new Vector3 (-200, -50, 0);
		chTransform.sizeDelta = new Vector2 (40, 40);
		chObj.transform.localScale = new Vector2 (4, 4);



		GameObject chigyo = GameObject.Find ("ButtonCyouhei");
		chigyo.GetComponent<BusyoStatusButton> ().ch_type = ch_type;
		chigyo.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu;
		chigyo.GetComponent<BusyoStatusButton> ().ch_num = ch_num;
		chigyo.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc;
		chigyo.GetComponent<BusyoStatusButton> ().ch_hp = hei;
		chigyo.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100;

		GameObject kunren = GameObject.Find ("ButtonKunren");
		kunren.GetComponent<BusyoStatusButton> ().ch_type = ch_type;
		kunren.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu;
		kunren.GetComponent<BusyoStatusButton> ().ch_lv = ch_lv;
		kunren.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc;
		kunren.GetComponent<BusyoStatusButton> ().ch_hp = hei ;
		kunren.GetComponent<BusyoStatusButton> ().ch_num = ch_num;
		kunren.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100;

		//Parametor Setting
		GameObject.Find ("GameScene").GetComponent<NowOnBusyo>().OnBusyo = busyoId;

	}
	public void OnClick(){

		BusyoStatusButton bsb = new BusyoStatusButton ();

		if (name == "kanni") {
			if(kanniId ==0){
				string myKanni = PlayerPrefs.GetString("myKanni");

				if(myKanni != null && myKanni !=""){

					bsb.commonPopup ();
					GameObject.Find ("popText").GetComponent<Text> ().text ="官位一覧";
					
					string scrollPath = "Prefabs/Busyo/KanniScrollView";
					GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject;
					scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform);
					scroll.transform.localScale = new Vector2 (1, 1);
					scroll.name = "KanniScrollView";
					RectTransform scrollTransform = scroll.GetComponent<RectTransform> ();
					scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0);

					List<string> myKanniList = new List<string> ();

					if(myKanni.Contains(",")){
						char[] delimiterChars = {','};
						myKanniList = new List<string> (myKanni.Split (delimiterChars));
					}else{
						myKanniList.Add(myKanni);
					}

					myKanniList.Sort();

					string pathSlot = "Prefabs/Busyo/KanniSlot";
					Kanni kanni = new Kanni();
					GameObject content = scroll.transform.FindChild("KanniContent").gameObject;
					for(int i=0; i<myKanniList.Count; i++){
						GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject;
						slot.transform.SetParent(content.transform);
						slot.transform.localScale = new Vector2 (1, 1);

						int kanniIdTmp = int.Parse(myKanniList[i]);
						string kanniName = kanni.getKanni(kanniIdTmp);
						string kanniIkai = kanni.getIkai(kanniIdTmp);
						string EffectLabel = kanni.getEffectLabel(kanniIdTmp);
						int effect = kanni.getEffect(kanniIdTmp);

						slot.transform.FindChild("Name").GetComponent<Text>().text = kanniIkai + "\t" + kanniName;
						slot.transform.FindChild("EffectLabel").GetComponent<Text>().text = EffectLabel;
						slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%";

						GameObject btn = slot.transform.FindChild("GiveButton").gameObject;
						btn.GetComponent<GiveKanni>().busyoId = busyoId;
						btn.GetComponent<GiveKanni>().kanniId = kanniIdTmp;

					}



				}else{
					Message msg = new Message();
					msg.makeMessage("官位を持っておりませんぞ。\n山城国にある朝廷を訪れてみましょう。");
				}
			}else{

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

				string removePath = "Prefabs/Busyo/KanniRemoveConfirm";
				GameObject remove = Instantiate (Resources.Load (removePath)) as GameObject;
				remove.transform.SetParent(GameObject.Find ("Panel").transform);
				remove.transform.localScale = new Vector2 (1, 1);
				remove.transform.localPosition = new Vector3(0,0,0);
				remove.name = "KanniRemoveConfirm";
				BusyoInfoGet busyo = new BusyoInfoGet();
				string busyoName = busyo.getName(int.Parse(busyoId));
				remove.transform.FindChild("YesButton").GetComponent<DoRemoveKanni>().busyoId = busyoId;
				remove.transform.FindChild("RemoveText").GetComponent<Text>().text = busyoName + "殿の官位を\n罷免なさるのですか?";

			}



		}else if(name == "jyosyu"){
			if(jyosyuKuniId ==0){
				//Available Kuni

				string openKuniString = PlayerPrefs.GetString ("openKuni");
				char[] delimiterChars = {','};
				List<string> openKuniList = new List<string> ();
				if (openKuniString.Contains (",")) {
					openKuniList = new List<string> (openKuniString.Split (delimiterChars));
				} else {
					openKuniList.Add(openKuniString);
				}

				List<string> okKuniList = new List<string> ();
				for (int i=0; i<openKuniList.Count; i++) {
					int kuniId = int.Parse(openKuniList[i]);
					string temp = "kuni" + kuniId.ToString();
					string clearedKuni = PlayerPrefs.GetString (temp);
					//Shiro Qty
					if(clearedKuni != null && clearedKuni != ""){
						//Jyosyu Exist Check
						string jyosyuTmp = "jyosyu" + kuniId.ToString();
						if(!PlayerPrefs.HasKey(jyosyuTmp)){
							okKuniList.Add(kuniId.ToString());
						}
					}
				}

				if(okKuniList.Count != 0){
					bsb.commonPopup ();
					GameObject.Find ("popText").GetComponent<Text> ().text ="国一覧";
					
					string scrollPath = "Prefabs/Busyo/KanniScrollView";
					GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject;
					scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform);
					scroll.transform.localScale = new Vector2 (1, 1);
					scroll.name = "KanniScrollView";
					RectTransform scrollTransform = scroll.GetComponent<RectTransform> ();
					scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0);

					string pathSlot = "Prefabs/Busyo/ShiroSlot";
					GameObject content = scroll.transform.FindChild("KanniContent").gameObject;
					KuniInfo kuni = new KuniInfo();
					for(int i=0; i<okKuniList.Count; i++){

						GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject;
						slot.transform.SetParent(content.transform);
						slot.transform.localScale = new Vector2 (1, 1);
						
						int kuniId = int.Parse(okKuniList[i]);
						string kuniName = kuni.getKuniName(kuniId);

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


						//Status
						int jyosyuHei = 0;
						string naiseiTemp = "naisei" + kuniId.ToString();
						string naiseiString = PlayerPrefs.GetString (naiseiTemp);

						List<string> naiseiList = new List<string>();
						naiseiList = new List<string>(naiseiString.Split (delimiterChars));
						char[] delimiterChars2 = {':'};
						Entity_naisei_mst naiseiMst = Resources.Load ("Data/naisei_mst") as Entity_naisei_mst;
						NaiseiController naisei = new NaiseiController();


						string shiroLv = naiseiList[0];
						List<int> shiroEffectList = new List<int>();
						shiroEffectList = naisei.getNaiseiList("shiro", int.Parse(shiroLv));
						jyosyuHei = shiroEffectList[0];

						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"){
								string type = naiseiMst.param [int.Parse(naiseiContentList[0])].code;
								if(type == "hsy"){
									List<int> naiseiEffectList = new List<int>();
									naiseiEffectList = naisei.getNaiseiList(type, int.Parse(naiseiContentList[1]));

									jyosyuHei = jyosyuHei + naiseiEffectList[0];
								}

							}
						}


						slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString();
						
						GameObject btn = slot.transform.FindChild("GiveButton").gameObject;
						btn.GetComponent<DoNinmei>().busyoId = busyoId;
						btn.GetComponent<DoNinmei>().kuniId = kuniId;
						btn.GetComponent<DoNinmei>().jyosyuHei = jyosyuHei;
					}



				}else{
					Message msg = new Message();
					msg.makeMessage("任命可能な国はありませんぞ。\nまずは城を落としなされ。");
				}




			}else{
				string backPath = "Prefabs/Common/TouchBack";
				GameObject back = Instantiate (Resources.Load (backPath)) as GameObject;
				back.transform.SetParent(GameObject.Find ("Panel").transform);
				back.transform.localScale = new Vector2 (1, 1);
				RectTransform backTransform = back.GetComponent<RectTransform> ();
				backTransform.anchoredPosition3D = new Vector3 (0, 0, 0);
				back.name = "TouchBack";

				//Message Box
				string msgPath = "Prefabs/Naisei/KaininConfirm";
				GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject;
				msg.transform.SetParent(back.transform);
				msg.transform.localScale = new Vector2 (1, 1);
				RectTransform msgTransform = msg.GetComponent<RectTransform> ();
				msgTransform.anchoredPosition3D = new Vector3 (0, 0, 0);
				msgTransform.name = "kaininConfirm";
				msg.transform.FindChild("YesButton").GetComponent<DoKainin>().kuniId = jyosyuKuniId;


				//Message Text Mod
				GameObject msgObj = msg.transform.FindChild ("KaininText").gameObject;
				int myDaimyoBusyo = PlayerPrefs.GetInt ("myDaimyoBusyo");
				string msgText = msgObj.GetComponent<Text> ().text;
				if (myDaimyoBusyo == int.Parse(busyoId)) {
					msgText = msgText.Replace("A殿を", "自らを");
				} else {
					msgText = msgText.Replace("A", jyosyuName);
				}
				msgObj.GetComponent<Text> ().text = msgText;
			}

		}


	}
Exemple #6
0
	public void createSyoguView(string busyoId){

		int lv = PlayerPrefs.GetInt (busyoId);

		Color ngImageColor = new Color (40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f);
		Color ngTextColor = new Color (90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f);
		Color okImageColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f);
		Color okTextColor = new Color (40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f);
		
		GameObject kanjyo = GameObject.Find("kanjyo").gameObject;
		GameObject tsuihou = GameObject.Find("tsuihou").gameObject;

		int daimyoBusyoId = PlayerPrefs.GetInt ("myDaimyoBusyo");
		if (busyoId == daimyoBusyoId.ToString ()) {
			kanjyo.GetComponent<Image> ().color = ngImageColor; 
			kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
			kanjyo.GetComponent<Button> ().enabled = false;

			tsuihou.GetComponent<Image> ().color = ngImageColor; 
			tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
			tsuihou.GetComponent<Button> ().enabled = false;

		} else {

			if (lv != 100) {
				kanjyo.GetComponent<BusyoStatusButton> ().pa_lv = lv;
				kanjyo.GetComponent<Image> ().color = okImageColor; 
				kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor;
				kanjyo.GetComponent<Button> ().enabled = true;
			} else {
				kanjyo.GetComponent<Image> ().color = ngImageColor; 
				kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
				kanjyo.GetComponent<Button> ().enabled = false;
			}

			tsuihou.GetComponent<Image> ().color = okImageColor;
			tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor; 
			tsuihou.GetComponent<Button> ().enabled = true;

		}
		
		GameObject kanni = GameObject.Find("kanni").gameObject;
		GameObject jyosyu = GameObject.Find("jyosyu").gameObject;
		GameObject syugyo = GameObject.Find("syugyo").gameObject;
		GameObject gokui = GameObject.Find("gokui").gameObject;
		kanni.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		jyosyu.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		syugyo.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		gokui.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;

		//Kanni
		string kanniTmp = "kanni" + busyoId;
		Kanni kanniScript = new Kanni();
		if (PlayerPrefs.HasKey (kanniTmp)) {
			int kanniId = PlayerPrefs.GetInt (kanniTmp);
			if (kanniId != 0) {
				foreach(Transform n in kanni.transform){
					if(n.name == "KanniName"){
						Destroy(n.gameObject);
					}
				}
				kanni.GetComponent<RonkouKousyoMenu> ().kanniId = kanniId;
				string path = "Prefabs/Busyo/KanniName";
				GameObject kanniName = Instantiate (Resources.Load (path)) as GameObject;
				kanniName.transform.SetParent (kanni.transform);
				kanniName.transform.localScale = new Vector2 (0.12f, 0.12f);
				kanniName.transform.localPosition = new Vector2 (0, 0);
				kanniName.name = "KanniName";

				string kanniNameString = kanniScript.getKanni(kanniId);
				string kanniIkai = kanniScript.getIkai(kanniId);
				kanniName.transform.FindChild("value").GetComponent<Text>().text = kanniIkai + "\t" + kanniNameString; 

				string effectLabel = kanniScript.getEffectLabel(kanniId);
				int effect = kanniScript.getEffect(kanniId);
				kanniName.transform.FindChild("effectLabel").GetComponent<Text>().text = effectLabel;
				kanniName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%"; 

				kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = false;
			}
		} else {
			foreach(Transform n in kanni.transform){
				if(n.name == "KanniName"){
					Destroy(n.gameObject);
				}
			}


			kanni.GetComponent<RonkouKousyoMenu> ().kanniId = 0;
			kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = true;
		}

		//Jyosyu
		string jyosyuTmp = "jyosyuBusyo" + busyoId;

		if (PlayerPrefs.HasKey (jyosyuTmp)) {
			BusyoInfoGet busyoInfo = new BusyoInfoGet ();
			string busyoName = busyoInfo.getName (int.Parse(busyoId));
			jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuName = busyoName;

			int kuniId = PlayerPrefs.GetInt(jyosyuTmp);

			if(kuniId !=0){
				foreach(Transform n in jyosyu.transform){
					if(n.name == "JyosyuName"){
						Destroy(n.gameObject);
					}
				}

				KuniInfo kuni = new KuniInfo();
				string kuniName = kuni.getKuniName(kuniId);

				string jyosyuHeiTmp = "jyosyuHei" + busyoId;
				int jyosyuHei = PlayerPrefs.GetInt(jyosyuHeiTmp);

				jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuKuniId = kuniId;
				string jyosyuPath = "Prefabs/Busyo/JyosyuName";
				GameObject jyosyuName = Instantiate (Resources.Load (jyosyuPath)) as GameObject;
				jyosyuName.transform.SetParent (jyosyu.transform);
				jyosyuName.transform.localScale = new Vector2 (0.12f, 0.12f);
				jyosyuName.transform.localPosition = new Vector2 (0, 0);
				jyosyuName.name = "JyosyuName";

				jyosyuName.transform.FindChild("value").GetComponent<Text>().text = kuniName; 
				jyosyuName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString();
				
				jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = false;
			}			
		} else {
			foreach(Transform n in jyosyu.transform){
				if(n.name == "JyosyuName"){
					Destroy(n.gameObject);
				}
			}
			jyosyu.GetComponent<RonkouKousyoMenu> ().jyosyuKuniId = 0;
			jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = true;
		}




	}