Exemple #1
0
    public int heiryokuCalc(int kuni)
    {
        GameObject targetKuni    = GameObject.Find("KuniIconView");
        int        enemyTotalHei = 0;

        if (targetKuni.transform.FindChild(kuni.ToString()))
        {
            SendParam sendParam     = targetKuni.transform.FindChild(kuni.ToString()).GetComponent <SendParam> ();
            int       daimyoBusyoId = sendParam.daimyoBusyoId;
            int       busyoLv       = sendParam.busyoLv;
            int       busyoQty      = sendParam.busyoQty;
            int       butaiLv       = sendParam.butaiLv;
            int       butaiQty      = sendParam.butaiQty;


            if (daimyoBusyoId != 0)
            {
                StatusGet sts      = new StatusGet();
                int       hp       = sts.getHp(daimyoBusyoId, busyoLv);
                int       hpResult = hp * 100 * busyoQty;
                string    type     = sts.getHeisyu(daimyoBusyoId);
                int       chHp     = sts.getChHp(type, butaiLv, hp);
                chHp          = chHp * butaiQty * busyoQty * 10;
                enemyTotalHei = hpResult + chHp;
            }
        }
        return(enemyTotalHei);
    }
Exemple #2
0
    public void IconMapValueUpdate(int kuniId, int changeDaimyoId, GameObject kuniIconView, GameObject kuniMap, int myKuniQty)
    {
        Daimyo     daimyo         = new Daimyo();
        GameObject targetKuniIcon = kuniIconView.transform.FindChild(kuniId.ToString()).gameObject;

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

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

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

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

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

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

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

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

        script.heiryoku = myHeiryoku;
    }
    private void _Send(byte cmd, SendParam param)
    {
        byte[] DataToSend = new byte[mDataByteNum];
        DataToSend[0] = 0Xfa;
        DataToSend[1] = cmd;
        DataToSend[2] = param.HD;
        DataToSend[3] = param.LD;
        DataToSend[4] = (byte)(cmd + param.HD + param.LD);
        DataToSend[5] = (byte)(DataToSend[4] + 1);

        mSerial.Send(DataToSend);
    }
Exemple #4
0
        private static void SendMessage(object obj)
        {
            SendParam   param    = (SendParam)obj;
            ControlPack CtrlPack = param.CtrlPack;
            int         Compnum  = param.CompNum;

            //Socket myClientSocket = param.clientSocket;
            byte[] buffer = StructToBytes(CtrlPack);
            try
            {
                clientSocket[Compnum].Send(buffer);
            }
            catch (NullReferenceException)
            {
                return;
            }
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                MessageBox.Show(this, "이미지를 가져와야 합니다.");
                return;
            }

            string filePath = img.FilePath;

            if (!File.Exists(filePath))
            {
                MessageBox.Show(this, "이미지가 존재하지 않습니다.");
                return;
            }

            string imgbinary_base64 = Encode.ImgBinaryToBase64String(filePath);

            SendParam sendParam = new SendParam(img.ScanDate, filePath, imgbinary_base64);

            WinMessage_ClientToServer workCompleteResponse = new WinMessage_ClientToServer(EXEKIND.TestScan, "workComplete", sendParam);

            AgentInterface.SendToServer(workCompleteResponse, serverHandle);
        }
Exemple #6
0
    public void OnClick()
    {
        //SE
        sound = GameObject.Find("SEController").GetComponent <AudioSource> ();
        sound.PlayOneShot(sound.clip);

        if (!bakuhuFlg)
        {
            /*Common Process*/
            if (Application.loadedLevelName != "tutorialMain")
            {
                string     pathOfBack = "Prefabs/Common/TouchBack";
                GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
                back.transform.SetParent(GameObject.Find("Panel").transform);
                back.transform.localScale    = new Vector2(1, 1);
                back.transform.localPosition = new Vector2(0, 0);
            }

            if (Application.loadedLevelName != "clearOrGameOver")
            {
                string     pathOfBoard = "Prefabs/Map/smallBoard";
                GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;
                board.transform.SetParent(GameObject.Find("Panel").transform);
                board.transform.localScale = new Vector2(1, 1);

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

                /*Value Setting*/
                //Kuni Name
                GameObject.Find("kuniName").GetComponent <Text> ().text = kuniName;

                //Daimyo Name
                GameObject.Find("DaimyoNameValue").GetComponent <Text> ().text = daimyoName;

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

                //Daimyo Busyo View
                string     busyoViewPath = "Prefabs/Map/daimyoView";
                GameObject daimyoView    = Instantiate(Resources.Load(busyoViewPath)) as GameObject;
                daimyoView.transform.SetParent(kamon.transform);
                daimyoView.transform.localScale = new Vector2(1, 1);
                RectTransform busyoTransform = daimyoView.GetComponent <RectTransform> ();
                busyoTransform.anchoredPosition = new Vector3(90, 125, 0);
                busyoTransform.sizeDelta        = new Vector2(180, 230);

                string daimyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
                daimyoView.GetComponent <Image> ().sprite =
                    Resources.Load(daimyoPath, typeof(Sprite)) as Sprite;


                /*
                 * string busyoPath = "Prefabs/Player/Unit/" + daimyoBusyoId;
                 * GameObject busyo = Instantiate (Resources.Load (busyoPath)) as GameObject;
                 * busyo.transform.SetParent (kamon.transform);
                 * busyo.transform.localScale = new Vector2 (1, 1);
                 * busyo.GetComponent<DragHandler> ().enabled = false;
                 *
                 * RectTransform busyoTransform = busyo.GetComponent<RectTransform> ();
                 * busyoTransform.anchoredPosition = new Vector3 (90, 100, 0);
                 * busyoTransform.sizeDelta = new Vector2 (180, 200);
                 *
                 * foreach (Transform n in busyo.transform) {
                 *      GameObject.Destroy (n.gameObject);
                 * }
                 */

                //Doumei
                if (doumeiFlg)
                {
                    string     doumeiPath = "Prefabs/Common/Doumei";
                    GameObject doumei     = Instantiate(Resources.Load(doumeiPath)) as GameObject;
                    doumei.transform.SetParent(kamon.transform);
                    doumei.transform.localScale = new Vector2(1, 1);
                    RectTransform doumeiTransform = doumei.GetComponent <RectTransform> ();
                    doumeiTransform.anchoredPosition = new Vector3(-50, 80, 0);
                    doumei.name = "Doumei";
                }

                //Naisei Shigen Icon
                List <string> naiseiIconList = new List <string> ();
                char[]        delimiterChars = { ':' };
                if (naiseiItem != "null" && naiseiItem != "")
                {
                    if (naiseiItem.Contains(":"))
                    {
                        naiseiIconList = new List <string> (naiseiItem.Split(delimiterChars));
                    }
                    else
                    {
                        naiseiIconList.Add(naiseiItem);
                    }

                    //Base
                    string     nasieiBasePath = "Prefabs/Map/Common/NaiseiList";
                    GameObject naiseiBase     = Instantiate(Resources.Load(nasieiBasePath)) as GameObject;
                    naiseiBase.transform.SetParent(board.transform);
                    naiseiBase.transform.localScale = new Vector2(1, 1);
                    RectTransform naiseiBaseTransform = naiseiBase.GetComponent <RectTransform> ();
                    naiseiBaseTransform.anchoredPosition = new Vector3(405, -80, 0);


                    //Icon
                    string nasieiIconPath = "Prefabs/Map/Common/NaiseiItem";
                    for (int i = 0; i < naiseiIconList.Count; i++)
                    {
                        GameObject naiseiIcon = Instantiate(Resources.Load(nasieiIconPath)) as GameObject;
                        naiseiIcon.transform.SetParent(naiseiBase.transform);
                        naiseiIcon.transform.localScale = new Vector2(1, 1);

                        string naiseiName = naiseiIconList [i];
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            if (naiseiName == "kb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "H";
                                naiseiIcon.GetComponent <IconExp>().IconId = 5;
                            }
                            else if (naiseiName == "tp")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "G";
                                naiseiIcon.GetComponent <IconExp>().IconId = 6;
                            }
                            else if (naiseiName == "kzn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "M";
                                naiseiIcon.GetComponent <IconExp>().IconId = 7;
                            }
                            else if (naiseiName == "snb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "N";
                                naiseiIcon.GetComponent <IconExp>().IconId = 8;
                            }
                            else if (naiseiName == "nbn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "W";
                                naiseiIcon.GetComponent <IconExp>().IconId = 9;
                            }
                            else if (naiseiName == "mkd")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text> ().text = "E";
                                naiseiIcon.GetComponent <IconExp>().IconId = 10;
                            }
                            else if (naiseiName == "syn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "T";
                                naiseiIcon.GetComponent <IconExp>().IconId = 11;
                            }
                        }
                        else
                        {
                            if (naiseiName == "kb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "馬";
                                naiseiIcon.GetComponent <IconExp>().IconId = 5;
                            }
                            else if (naiseiName == "tp")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "砲";
                                naiseiIcon.GetComponent <IconExp>().IconId = 6;
                            }
                            else if (naiseiName == "kzn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "鉱";
                                naiseiIcon.GetComponent <IconExp>().IconId = 7;
                            }
                            else if (naiseiName == "snb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "忍";
                                naiseiIcon.GetComponent <IconExp>().IconId = 8;
                            }
                            else if (naiseiName == "nbn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "南";
                                naiseiIcon.GetComponent <IconExp>().IconId = 9;
                            }
                            else if (naiseiName == "mkd")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "帝";
                                naiseiIcon.GetComponent <IconExp>().IconId = 10;
                            }
                            else if (naiseiName == "syn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "商";
                                naiseiIcon.GetComponent <IconExp>().IconId = 11;
                            }
                        }
                    }
                }


                //Heiryoku Calc
                GameObject yukouValue     = GameObject.Find("YukouValue");
                GameObject atkBtn         = GameObject.Find("AttackButton");
                GameObject gaikouBtn      = GameObject.Find("GaikouButton");
                GameObject bouryakuhouBtn = GameObject.Find("BouryakuButton");

                Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f);
                Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f);


                if (clearFlg == false)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atkBtn.transform.FindChild("Text").GetComponent <Text>().text = "Attack";
                    }
                    else
                    {
                        atkBtn.transform.FindChild("Text").GetComponent <Text>().text = "侵略";
                    }

                    if (cyouhouSnbRankId != 0)
                    {
                        GameObject.Find("HeiryokuValue").GetComponent <Text> ().text = heiryoku.ToString();

                        //Shinobi Icon
                        string     shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi";
                        GameObject shinobi         = Instantiate(Resources.Load(shinobiItemPath)) as GameObject;
                        shinobi.transform.SetParent(board.transform);
                        shinobi.transform.localScale = new Vector2(0.25f, 0.31f);
                        shinobi.name = "shinobi";
                        RectTransform snbTransform = shinobi.GetComponent <RectTransform> ();
                        snbTransform.anchoredPosition            = new Vector3(-251, 250, 0);
                        shinobi.GetComponent <Button> ().enabled = false;

                        if (cyouhouSnbRankId == 1)
                        {
                            Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = lowColor;
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "Low";
                            }
                            else
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "下";
                            }
                        }
                        else if (cyouhouSnbRankId == 2)
                        {
                            Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = midColor;
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "Mid";
                            }
                            else
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "中";
                            }
                        }
                        else if (cyouhouSnbRankId == 3)
                        {
                            Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = highColor;
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "High";
                            }
                            else
                            {
                                shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "上";
                            }
                        }
                    }
                    else
                    {
                        GameObject.Find("HeiryokuValue").GetComponent <Text> ().text = "?";
                    }


                    //Yukoudo
                    yukouValue.GetComponent <Text> ().text = myYukouValue.ToString();

                    //Cyouhou
                    atkBtn.GetComponent <AttackNaiseiView> ().cyouhouSnbRankId = cyouhouSnbRankId;
                }
                else
                {
                    //Cleard
                    GameObject.Find("HeiryokuValue").GetComponent <Text> ().text = heiryoku.ToString();

                    //Yukoudo
                    yukouValue.GetComponent <Text> ().text = "-";

                    //Enable Gaiko & Cyouhou
                    gaikouBtn.GetComponent <Image> ().color    = NGClorBtn;
                    gaikouBtn.GetComponent <Button> ().enabled = false;
                    gaikouBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;


                    bouryakuhouBtn.GetComponent <Image> ().color    = NGClorBtn;
                    bouryakuhouBtn.GetComponent <Button> ().enabled = false;
                    bouryakuhouBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;

                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atkBtn.transform.FindChild("Text").GetComponent <Text> ().text = "Develop";
                    }
                    else
                    {
                        atkBtn.transform.FindChild("Text").GetComponent <Text>().text = "内政";
                    }
                    if (Application.loadedLevelName == "tutorialMain")
                    {
                        TutorialController tutorialScript = new TutorialController();
                        Vector2            vect           = new Vector2(0, 50);
                        GameObject         animObj        = tutorialScript.SetPointer(atkBtn, vect);
                        animObj.transform.localScale = new Vector2(150, 150);
                    }
                }

                //Enable Attack
                if (openFlg == false && clearFlg == false)
                {
                    atkBtn.GetComponent <Image> ().color = NGClorBtn;
                    //test
                    atkBtn.GetComponent <Button> ().enabled = false;
                    atkBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                }
                //Enable Gaikou
                if (soubujireiFlg)
                {
                    gaikouBtn.GetComponent <Image> ().color    = NGClorBtn;
                    gaikouBtn.GetComponent <Button> ().enabled = false;
                    gaikouBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                }

                //Doumei Flg
                if (doumeiFlg)
                {
                    atkBtn.GetComponent <AttackNaiseiView> ().doumeiFlg = doumeiFlg;
                    gaikouBtn.GetComponent <GaikouView> ().doumeiFlg    = doumeiFlg;

                    atkBtn.GetComponent <Image> ().color    = NGClorBtn;
                    atkBtn.GetComponent <Button> ().enabled = false;
                    atkBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                }

                //Set Hidden Value
                if (Application.loadedLevelName != "tutorialMain")
                {
                    GameObject close = GameObject.Find("close").gameObject;
                    close.GetComponent <CloseBoard> ().title           = kuniName;
                    close.GetComponent <CloseBoard> ().daimyoId        = daimyoId;
                    close.GetComponent <CloseBoard> ().daimyoBusyoId   = daimyoBusyoId;
                    close.GetComponent <CloseBoard> ().daimyoBusyoName = daimyoName;
                    close.GetComponent <CloseBoard> ().doumeiFlg       = doumeiFlg;
                    close.GetComponent <CloseBoard> ().kuniQty         = kuniQty;
                    close.GetComponent <CloseBoard> ().kuniId          = kuniId;
                    close.GetComponent <CloseBoard> ().daimyoBusyoAtk  = daimyoBusyoAtk;
                    close.GetComponent <CloseBoard> ().daimyoBusyoDfc  = daimyoBusyoDfc;
                    close.GetComponent <CloseBoard> ().yukoudo         = myYukouValue;
                    close.GetComponent <CloseBoard> ().naiseiItem      = naiseiItem;


                    bool cyouhouFlg = false;
                    if (cyouhouSnbRankId != 0)
                    {
                        cyouhouFlg = true;
                    }
                    close.GetComponent <CloseBoard> ().cyouhouFlg       = cyouhouFlg;
                    close.GetComponent <CloseBoard> ().cyouhouSnbRankId = cyouhouSnbRankId;
                }

                //Set Button Value
                AttackNaiseiView attkNaiseView = GameObject.Find("AttackButton").GetComponent <AttackNaiseiView> ();
                attkNaiseView.kuniId         = kuniId;
                attkNaiseView.kuniName       = kuniName;
                attkNaiseView.myDaimyoId     = GameObject.Find("GameController").GetComponent <MainStageController> ().myDaimyo;
                attkNaiseView.daimyoId       = daimyoId;
                attkNaiseView.daimyoName     = daimyoName;
                attkNaiseView.openFlg        = openFlg;
                attkNaiseView.clearFlg       = clearFlg;
                attkNaiseView.activeBusyoQty = busyoQty;
                attkNaiseView.activeBusyoLv  = busyoLv;
                attkNaiseView.activeButaiQty = butaiQty;
                attkNaiseView.activeButaiLv  = butaiLv;



                //Cyoutei Button
                if (kuniId == 16)
                {
                    //Yamashiro
                    string     pathOfButton = "Prefabs/Cyoutei/CyouteiIcon";
                    GameObject btn          = Instantiate(Resources.Load(pathOfButton)) as GameObject;
                    btn.transform.SetParent(board.transform);
                    btn.transform.localScale    = new Vector2(1, 1);
                    btn.transform.localPosition = new Vector2(225, -220);
                    btn.name = "CyouteiIcon";

                    btn.GetComponent <CyouteiPop> ().yukoudo            = myYukouValue;
                    btn.GetComponent <CyouteiPop> ().myDaimyoFlg        = clearFlg;
                    btn.GetComponent <CyouteiPop> ().occupiedDaimyoId   = daimyoId;
                    btn.GetComponent <CyouteiPop> ().occupiedDaimyoName = daimyoName;
                }

                //Syounin Button
                if (kuniId == 38 || kuniId == 39 || kuniId == 58)
                {
                    //Hakata or Sakai
                    string     pathOfButton = "Prefabs/Syounin/SyouninIcon";
                    GameObject btn          = Instantiate(Resources.Load(pathOfButton)) as GameObject;
                    btn.transform.SetParent(board.transform);
                    btn.transform.localScale    = new Vector2(1, 1);
                    btn.transform.localPosition = new Vector2(225, -220);
                    btn.name = "SyouninIcon";

                    btn.GetComponent <SyouninPop> ().yukoudo            = myYukouValue;
                    btn.GetComponent <SyouninPop> ().myDaimyoFlg        = clearFlg;
                    btn.GetComponent <SyouninPop> ().occupiedDaimyoName = daimyoName;

                    if (kuniId == 38 || kuniId == 39)
                    {
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            btn.transform.FindChild("Text").GetComponent <Text>().text     = "Sakai";
                            btn.transform.FindChild("Text").GetComponent <Text>().font     = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
                            btn.transform.FindChild("Text").GetComponent <Text>().fontSize = 200;
                        }
                        else
                        {
                            btn.transform.FindChild("Text").GetComponent <Text>().text = "堺";
                        }
                        btn.GetComponent <SyouninPop> ().sakaiFlg = true;
                    }
                    else if (kuniId == 58)
                    {
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            btn.transform.FindChild("Text").GetComponent <Text>().text     = "Hakata";
                            btn.transform.FindChild("Text").GetComponent <Text>().font     = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
                            btn.transform.FindChild("Text").GetComponent <Text>().fontSize = 200;
                        }
                        else
                        {
                            btn.transform.FindChild("Text").GetComponent <Text>().text = "博多";
                        }
                    }
                }
            }
            else
            {
                //Select Initial Daimyo Screen
                string     pathOfBoard = "Prefabs/clearOrGameOver/DaimyoSelectBoard";
                GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;
                board.transform.SetParent(GameObject.Find("Panel").transform);
                board.transform.localScale = new Vector2(1, 1);
                GameObject selectBtn = board.transform.FindChild("SelectButton").gameObject;

                //Kuni Name
                GameObject.Find("kuniName").GetComponent <Text> ().text = kuniName;

                //Daimyo Name
                GameObject.Find("DaimyoNameValue").GetComponent <Text> ().text = daimyoName;

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

                //Daimyo Busyo View
                string     busyoPath = "Prefabs/Player/Unit/BusyoUnit";
                GameObject busyo     = Instantiate(Resources.Load(busyoPath)) as GameObject;
                busyo.name = daimyoBusyoId.ToString();
                busyo.transform.SetParent(kamon.transform);
                busyo.transform.localScale = new Vector2(1, 1);
                busyo.GetComponent <DragHandler> ().enabled = false;

                RectTransform busyoTransform = busyo.GetComponent <RectTransform> ();
                busyoTransform.anchoredPosition = new Vector3(90, 100, 0);
                busyoTransform.sizeDelta        = new Vector2(180, 200);

                foreach (Transform n in busyo.transform)
                {
                    GameObject.Destroy(n.gameObject);
                }

                //Kuni Qty
                GameObject.Find("KuniQtyValue").GetComponent <Text> ().text = kuniQty.ToString();

                //Once Cleared Flg
                if (gameClearFlg)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("KouryakuFlg").transform.FindChild("Label").GetComponent <Text>().text = " Cleared";
                    }
                    else
                    {
                        GameObject.Find("KouryakuFlg").transform.FindChild("Label").GetComponent <Text>().text = "攻略済";
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("KouryakuFlg").transform.FindChild("Label").GetComponent <Text>().text = " Never Cleared";
                    }
                    else
                    {
                        GameObject.Find("KouryakuFlg").transform.FindChild("Label").GetComponent <Text>().text = "未攻略";
                    }
                }

                //Status
                //Daimyo Have Flg
                char[]    delimiterChars = { ':' };
                int       lv             = 0;
                StatusGet sts            = new StatusGet();

                //Default Status
                lv = 1;
                GameObject.Find("ButaiQtyValue").GetComponent <Text> ().text = "1";
                GameObject.Find("ButaiLvValue").GetComponent <Text> ().text  = "1";


                //Hp
                int hp = sts.getHp(daimyoBusyoId, lv);
                hp = hp * 100;
                GameObject.Find("HPValue").GetComponent <Text> ().text = hp.ToString();

                //Atk
                int atk = sts.getAtk(daimyoBusyoId, lv);
                atk = atk * 10;
                GameObject.Find("AtkValue").GetComponent <Text> ().text = atk.ToString();

                //Dfc
                int dfc = sts.getDfc(daimyoBusyoId, lv);
                dfc = dfc * 10;
                GameObject.Find("DfcValue").GetComponent <Text> ().text = dfc.ToString();

                //Spd
                int spd = sts.getSpd(daimyoBusyoId, lv);
                GameObject.Find("SpdValue").GetComponent <Text> ().text = spd.ToString();

                //Heisyu
                string heisyu      = sts.getHeisyu(daimyoBusyoId);
                string heisyuKanji = "";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    if (heisyu == "YR")
                    {
                        heisyuKanji = "Spear";
                    }
                    else if (heisyu == "KB")
                    {
                        heisyuKanji = "Cavalry";
                    }
                    else if (heisyu == "YM")
                    {
                        heisyuKanji = "Bow";
                    }
                    else if (heisyu == "TP")
                    {
                        heisyuKanji = "Gun";
                    }
                }
                else
                {
                    if (heisyu == "YR")
                    {
                        heisyuKanji = "槍";
                    }
                    else if (heisyu == "KB")
                    {
                        heisyuKanji = "騎馬";
                    }
                    else if (heisyu == "YM")
                    {
                        heisyuKanji = "弓";
                    }
                    else if (heisyu == "TP")
                    {
                        heisyuKanji = "鉄砲";
                    }
                }
                GameObject.Find("HeisyuValue").GetComponent <Text> ().text = heisyuKanji.ToString();

                //Naisei Shigen Icon
                List <string> naiseiIconList = new List <string> ();
                if (naiseiItem != "null" && naiseiItem != "")
                {
                    if (naiseiItem.Contains(":"))
                    {
                        naiseiIconList = new List <string> (naiseiItem.Split(delimiterChars));
                    }
                    else
                    {
                        naiseiIconList.Add(naiseiItem);
                    }

                    //Base
                    string     nasieiBasePath = "Prefabs/Map/Common/NaiseiList";
                    GameObject naiseiBase     = Instantiate(Resources.Load(nasieiBasePath)) as GameObject;
                    naiseiBase.transform.SetParent(board.transform);
                    naiseiBase.transform.localScale = new Vector2(1, 1);
                    RectTransform naiseiBaseTransform = naiseiBase.GetComponent <RectTransform> ();
                    naiseiBaseTransform.anchoredPosition = new Vector3(405, -80, 0);


                    //Icon
                    string nasieiIconPath = "Prefabs/Map/Common/NaiseiItem";
                    for (int i = 0; i < naiseiIconList.Count; i++)
                    {
                        GameObject naiseiIcon = Instantiate(Resources.Load(nasieiIconPath)) as GameObject;
                        naiseiIcon.transform.SetParent(naiseiBase.transform);
                        naiseiIcon.transform.localScale = new Vector2(1, 1);

                        string naiseiName = naiseiIconList [i];
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            if (naiseiName == "kb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "H";
                                naiseiIcon.GetComponent <IconExp>().IconId = 5;
                            }
                            else if (naiseiName == "tp")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "G";
                                naiseiIcon.GetComponent <IconExp>().IconId = 6;
                            }
                            else if (naiseiName == "kzn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "M";
                                naiseiIcon.GetComponent <IconExp>().IconId = 7;
                            }
                            else if (naiseiName == "snb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "N";
                                naiseiIcon.GetComponent <IconExp>().IconId = 8;
                            }
                            else if (naiseiName == "nbn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "W";
                                naiseiIcon.GetComponent <IconExp>().IconId = 9;
                            }
                            else if (naiseiName == "mkd")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "E";
                                naiseiIcon.GetComponent <IconExp>().IconId = 10;
                            }
                            else if (naiseiName == "syn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "T";
                                naiseiIcon.GetComponent <IconExp>().IconId = 11;
                            }
                        }
                        else
                        {
                            if (naiseiName == "kb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "馬";
                                naiseiIcon.GetComponent <IconExp>().IconId = 5;
                            }
                            else if (naiseiName == "tp")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "砲";
                                naiseiIcon.GetComponent <IconExp>().IconId = 6;
                            }
                            else if (naiseiName == "kzn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "鉱";
                                naiseiIcon.GetComponent <IconExp>().IconId = 7;
                            }
                            else if (naiseiName == "snb")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "忍";
                                naiseiIcon.GetComponent <IconExp>().IconId = 8;
                            }
                            else if (naiseiName == "nbn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "南";
                                naiseiIcon.GetComponent <IconExp>().IconId = 9;
                            }
                            else if (naiseiName == "mkd")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "帝";
                                naiseiIcon.GetComponent <IconExp>().IconId = 10;
                            }
                            else if (naiseiName == "syn")
                            {
                                naiseiIcon.transform.FindChild("Text").GetComponent <Text>().text = "商";
                                naiseiIcon.GetComponent <IconExp>().IconId = 11;
                            }
                        }
                    }
                }
                selectBtn.GetComponent <SelectDaimyo> ().daimyoId      = daimyoId;
                selectBtn.GetComponent <SelectDaimyo> ().daimyoName    = daimyoName;
                selectBtn.GetComponent <SelectDaimyo> ().daimyoBusyoId = daimyoBusyoId;
                selectBtn.GetComponent <SelectDaimyo> ().busyoHaveFlg  = busyoHaveFlg;
                selectBtn.GetComponent <SelectDaimyo> ().heisyu        = heisyu;
            }
        }
        else
        {
            //Bakuhu Menu
            GameObject BakuhuBase = GameObject.Find("BakuhuBase").gameObject;

            if (BakuhuBase.transform.FindChild("ToubatsuText") != null)
            {
                Destroy(BakuhuBase.transform.FindChild("ToubatsuText").gameObject);
            }

            if (BakuhuBase.transform.FindChild("ToubatsuSelect") == null)
            {
                string toubatsuPath = "Prefabs/Bakuhu/ToubatsuSelect";
                toubatsu = Instantiate(Resources.Load(toubatsuPath)) as GameObject;
                toubatsu.transform.SetParent(BakuhuBase.transform);
                toubatsu.transform.localScale = new Vector2(1, 1);
                toubatsu.name = "ToubatsuSelect";
            }
            else
            {
                toubatsu = BakuhuBase.transform.FindChild("ToubatsuSelect").gameObject;
            }

            string kamonImagePath = "Prefabs/Kamon/" + daimyoId.ToString();
            toubatsu.transform.FindChild("ToubatsuTarget").transform.FindChild("Kamon").GetComponent <Image> ().sprite =
                Resources.Load(kamonImagePath, typeof(Sprite)) as Sprite;

            string imagePath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
            toubatsu.transform.FindChild("ToubatsuTarget").transform.FindChild("Daimyo").GetComponent <Image> ().sprite =
                Resources.Load(imagePath, typeof(Sprite)) as Sprite;

            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                toubatsu.transform.FindChild("Exp").GetComponent <Text> ().text =
                    "Would you declare " + daimyoName + " attack order to surrounding parties?";
            }
            else
            {
                toubatsu.transform.FindChild("Exp").GetComponent <Text>().text =
                    daimyoName + "の討伐令を周辺大名に出しますか?";
            }

            //Blinker
            GameObject BakuhuKuniIconView = BakuhuBase.transform.FindChild("BakuhuKuniIconView").gameObject;
            foreach (Transform obj in BakuhuKuniIconView.transform)
            {
                SendParam script = obj.GetComponent <SendParam> ();
                if (script.daimyoId != daimyoId)
                {
                    if (obj.GetComponent <ImageBlinker> ())
                    {
                        Destroy(obj.GetComponent <ImageBlinker> ());
                        obj.GetComponent <Image>().color = new Color(255, 255, 255);
                    }
                }
                else
                {
                    if (!obj.GetComponent <ImageBlinker> ())
                    {
                        obj.gameObject.AddComponent <ImageBlinker>();
                    }
                }
            }

            //Set Param to Button
            toubatsu.transform.FindChild("ToubatsuBtn").GetComponent <DoTobatsu>().targetDaimyoId   = daimyoId;
            toubatsu.transform.FindChild("ToubatsuBtn").GetComponent <DoTobatsu>().targetDaimyoName = daimyoName;
            toubatsu.transform.FindChild("ToubatsuBtn").GetComponent <DoTobatsu> ().kuniQty         = kuniQty;
        }
    }
Exemple #7
0
    public void changeKuniIconAndParam(int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId)
    {
        //Change Icon
        string     imagePath    = "Prefabs/Kamon/" + srcDaimyoId.ToString();
        GameObject kuniIconView = GameObject.Find("KuniIconView");
        GameObject targetKuni   = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject;

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

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

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

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

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

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

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


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

        MainStageController main = new MainStageController();

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

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

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

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

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

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

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



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

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

        if (!myDoumeiList.Contains(srcDaimyoId.ToString()) && myDoumeiList.Contains(dstDaimyoId.ToString()))
        {
            Color unDoumeiColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
            targetKuni.GetComponent <SendParam> ().doumeiFlg = false;
            targetKuni.GetComponent <Image>().color          = unDoumeiColor;
        }
    }
Exemple #8
0
    public void deleteDoumeiKuniIcon(int doumeiDaimyoId)
    {
        GameObject kuniIconView = GameObject.Find("KuniIconView");

        //Set Seiryoku
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

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



        //Change Kuni Icon Color & Param
        Color normalColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);          //White

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int seiryokuDaimyoId = int.Parse(seiryokuList[i]);
            if (seiryokuDaimyoId == doumeiDaimyoId)
            {
                int       KuniId = i + 1;         //Kuni Id
                SendParam sp     = kuniIconView.transform.FindChild(KuniId.ToString()).GetComponent <SendParam> ();
                Image     image  = kuniIconView.transform.FindChild(KuniId.ToString()).GetComponent <Image> ();

                sp.doumeiFlg = false;
                image.color  = normalColor;
            }
        }


        //Open Kuni
        Color         openKuniColor = new Color(255f / 255f, 255f / 255f, 0f / 255f, 255f / 255f);  //Yellow
        string        openKuni      = PlayerPrefs.GetString("openKuni");
        List <string> openKuniList  = new List <string> ();

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

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

        for (int i = 0; i < openKuniList.Count; i++)
        {
            string openKuniId = openKuniList [i];

            //Flg Change
            GameObject targetOpenKuni = GameObject.Find("KuniIconView").transform.FindChild(openKuniId).gameObject;
            targetOpenKuni.GetComponent <SendParam> ().openFlg = true;
            bool doumeiFlg = targetOpenKuni.GetComponent <SendParam>().doumeiFlg;

            //Color Change
            if (!clearedKuniList.Contains(openKuniId))
            {
                if (!doumeiFlg)
                {
                    targetOpenKuni.GetComponent <Image> ().color = openKuniColor;
                }
            }
        }
    }
    public int getGaikouTargetKuni(int srcKuniId, int srcDaimyoId, List <int> targetKuniList, GameObject kuniIconView, bool aggressiveFlg, List <string> seiryokuList, int myDaimyoId)
    {
        //Yukoudo Check
        int    bestGaikouDaimyo  = 0;
        int    bestGaikouValue   = 0;
        int    bestGaikouKuni    = 0;
        int    bestHeiryokuValue = 0;
        Gaikou gaikou            = new Gaikou();

        for (int k = 0; k < targetKuniList.Count; k++)
        {
            SendParam sendParam = kuniIconView.transform.FindChild(targetKuniList [k].ToString()).GetComponent <SendParam> ();

            if (aggressiveFlg)
            {
                //Find best gaikou daimyo

                int dstDaimyoId = int.Parse(seiryokuList [targetKuniList [k] - 1]);
                int gaikouValue = 0;

                if (srcDaimyoId != dstDaimyoId)
                {
                    if (dstDaimyoId == myDaimyoId)
                    {
                        //Get Gaikou Value

                        string eGaikouM = "gaikou" + srcDaimyoId;
                        gaikouValue = PlayerPrefs.GetInt(eGaikouM);
                    }
                    else
                    {
                        //Gaikou Data Check
                        string gaikouTemp = "";
                        if (srcDaimyoId < dstDaimyoId)
                        {
                            gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
                        }
                        else
                        {
                            gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
                        }

                        if (PlayerPrefs.HasKey(gaikouTemp))
                        {
                            //exsit
                            gaikouValue = PlayerPrefs.GetInt(gaikouTemp);
                        }
                        else
                        {
                            //non exist
                            //gaikou check
                            gaikouValue = gaikou.getGaikouValue(srcDaimyoId, dstDaimyoId);
                        }
                    }

                    //Compare with Previous one
                    //Best one
                    if (gaikouValue >= bestGaikouValue)
                    {
                        bestGaikouValue  = gaikouValue;
                        bestGaikouDaimyo = dstDaimyoId;
                        bestGaikouKuni   = targetKuniList [k];
                    }
                }
            }
            else
            {
                //Find best heiryoku daimyo
                int dstDaimyoId = int.Parse(seiryokuList [targetKuniList [k] - 1]);

                if (srcDaimyoId != dstDaimyoId)
                {
                    //Heiryoku Check
                    int heiryoku = sendParam.heiryoku;

                    //Compare with Previous one
                    if (heiryoku >= bestHeiryokuValue)
                    {
                        bestHeiryokuValue = heiryoku;

                        int gaikouValue = 0;
                        if (dstDaimyoId == myDaimyoId)
                        {
                            //Get Gaikou Value
                            string eGaikouM = "gaikou" + srcDaimyoId;
                            gaikouValue = PlayerPrefs.GetInt(eGaikouM);
                        }
                        else
                        {
                            //Gaikou Data Check
                            string gaikouTemp = "";
                            if (srcDaimyoId < dstDaimyoId)
                            {
                                gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
                            }
                            else
                            {
                                gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
                            }
                            if (PlayerPrefs.HasKey(gaikouTemp))
                            {
                                //exsit
                                gaikouValue = PlayerPrefs.GetInt(gaikouTemp);
                            }
                            else
                            {
                                //non exist
                                gaikouValue = gaikou.getGaikouValue(srcDaimyoId, dstDaimyoId);
                            }
                        }
                        bestGaikouValue  = gaikouValue;
                        bestGaikouDaimyo = dstDaimyoId;
                        bestGaikouKuni   = targetKuniList [k];
                    }
                }
            }
        }        //Loop End

        return(bestGaikouKuni);
    }
Exemple #10
0
    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;
             *  }
             *
             * }
             *
             */
        }
    }
    public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts)
    {
        //In the case of My Damyo was Attacked

        //For Dramatic Enemy Creation
        GameObject kuniView = GameObject.Find("KuniIconView");

        if (kuniView.transform.FindChild(srcKuni.ToString()))
        {
            SendParam param    = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent <SendParam> ();
            int       busyoQty = param.busyoQty;
            int       busyoLv  = param.busyoLv;
            int       butaiQty = param.butaiQty;
            int       butaiLv  = param.butaiLv;

            //Dummy
            PlayerPrefs.SetInt("activeStageId", 0);
            PlayerPrefs.SetInt("activeStageMoney", busyoQty * 500);
            PlayerPrefs.SetInt("activeStageExp", busyoQty * 100);
            PlayerPrefs.SetString("activeItemType", "");
            PlayerPrefs.SetInt("activeItemId", 0);
            PlayerPrefs.SetFloat("activeItemRatio", 0);
            PlayerPrefs.SetInt("activeItemQty", 0);

            //Actual
            PlayerPrefs.SetInt("activeKuniId", dstKuni);
            KuniInfo kuni       = new KuniInfo();
            string   kuniName   = kuni.getKuniName(dstKuni);
            string   kassenName = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kassenName = kuniName + " Defence";
            }
            else
            {
                kassenName = kuniName + "防衛";
            }
            PlayerPrefs.SetString("activeStageName", kassenName);

            PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeBusyoQty", busyoQty);
            PlayerPrefs.SetInt("activeBusyoLv", busyoLv);
            PlayerPrefs.SetInt("activeButaiQty", butaiQty);
            PlayerPrefs.SetInt("activeButaiLv", butaiLv);

            //Passive only
            PlayerPrefs.SetBool("isAttackedFlg", true);
            PlayerPrefs.DeleteKey("isKessenFlg");
            PlayerPrefs.SetString("activeKey", key);
            PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

            //Engun
            if (dstEngunFlg)
            {
                PlayerPrefs.SetString("playerEngunList", dstEngunSts);
                PlayerPrefs.DeleteKey("enemyEngunList");
            }
            else
            {
                PlayerPrefs.DeleteKey("playerEngunList");
                PlayerPrefs.DeleteKey("enemyEngunList");
            }

            //Gaikou Down
            Gaikou gaikou = new Gaikou();
            gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId);

            //Delete "Start Kassen Flg"
            PlayerPrefs.DeleteKey("activeLink");
            PlayerPrefs.DeleteKey("activePowerType");

            List <int> powerTypeList = new List <int> ()
            {
                1, 2, 3
            };
            int random = UnityEngine.Random.Range(1, powerTypeList.Count + 1);
            PlayerPrefs.SetInt("activePowerType", random);


            //Boubi effect
            string boubiTmp = "boubi" + dstKuni.ToString();
            int    boubi    = PlayerPrefs.GetInt(boubiTmp, 0);
            boubi = boubi / 10;
            PlayerPrefs.SetInt("activeBoubi", boubi);



            PlayerPrefs.Flush();
            Application.LoadLevel("preKassen");
        }
    }
Exemple #12
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "YesButton")
        {
            audioSources [0].Play();

            GameObject kuniView = GameObject.Find("KuniIconView");
            SendParam  param    = kuniView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam>();

            //adjust
            int busyoQty       = param.busyoQty;
            int jinkeiBusyoQty = PlayerPrefs.GetInt("jinkeiBusyoQty");
            if (busyoQty < jinkeiBusyoQty)
            {
                busyoQty = jinkeiBusyoQty;
            }

            int busyoLv = param.busyoLv;

            //adjsut
            int butaiQty       = param.butaiQty;
            int jinkeiAveChQty = PlayerPrefs.GetInt("jinkeiAveChQty");
            if (butaiQty < jinkeiAveChQty)
            {
                butaiQty = jinkeiAveChQty;
            }
            int butaiLv = param.butaiLv;

            //Dummy
            PlayerPrefs.SetInt("activeStageId", 0);
            PlayerPrefs.SetInt("activeStageMoney", busyoQty * busyoLv * 100);
            PlayerPrefs.SetInt("activeStageExp", busyoQty * busyoLv * 10);
            PlayerPrefs.SetString("activeItemType", "");
            PlayerPrefs.SetInt("activeItemId", 0);
            PlayerPrefs.SetFloat("activeItemRatio", 0);
            PlayerPrefs.SetInt("activeItemQty", 0);
            PlayerPrefs.SetString("activeItemGrp", "no");

            //Actual
            KuniInfo kuni       = new KuniInfo();
            string   kassenName = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kassenName = " Final Battle with " + daimyoName;
            }
            else
            {
                kassenName = daimyoName + "決戦";
            }
            PlayerPrefs.SetString("activeStageName", kassenName);

            PlayerPrefs.SetInt("activeDaimyoId", daimyoId);
            PlayerPrefs.SetInt("activeBusyoQty", busyoQty);
            PlayerPrefs.SetInt("activeBusyoLv", busyoLv);
            PlayerPrefs.SetInt("activeButaiQty", butaiQty);
            PlayerPrefs.SetInt("activeButaiLv", butaiLv);


            //Flag
            PlayerPrefs.DeleteKey("isAttackedFlg");
            PlayerPrefs.SetBool("isKessenFlg", true);
            PlayerPrefs.SetInt("kessenHyourou", needHyourouNo);

            //Player Doumei Flg
            PlayerPrefs.DeleteKey("playerEngunList");

            //Enemy Doumei Handling
            PlayerPrefs.DeleteKey("enemyEngunList");
            string        doumeiTemp        = "doumei" + daimyoId;
            string        enemyDoumeiString = PlayerPrefs.GetString(doumeiTemp);
            char[]        delimiterChars    = { ',' };
            List <string> doumeiList        = new List <string>();
            if (enemyDoumeiString != null && enemyDoumeiString != "")
            {
                if (enemyDoumeiString.Contains(","))
                {
                    doumeiList = new List <string> (enemyDoumeiString.Split(delimiterChars));
                }
                else
                {
                    doumeiList.Add(enemyDoumeiString);
                }
            }
            string        seiryoku     = PlayerPrefs.GetString("seiryoku");
            List <string> seiryokuList = new List <string> ();
            seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

            Doumei        doumei           = new Doumei();
            Gaikou        gaikou           = new Gaikou();
            List <string> okDaimyoList     = new List <string> ();
            List <string> checkedList      = new List <string> ();
            string        dstEngunDaimyoId = "";
            string        dstEngunSts      = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv:

            okDaimyoList = doumei.traceNeighborDaimyo(kuniId, daimyoId, doumeiList, seiryokuList, checkedList, okDaimyoList);
            if (okDaimyoList.Count != 0)
            {
                for (int k = 0; k < okDaimyoList.Count; k++)
                {
                    string engunDaimyo = okDaimyoList [k];
                    int    yukoudo     = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), daimyoId);

                    //engun check
                    MainEventHandler main        = new MainEventHandler();
                    bool             dstEngunFlg = main.CheckByProbability(yukoudo);
                    if (dstEngunFlg)
                    {
                        //Engun OK
                        dstEngunFlg = true;
                        if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                        {
                            dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                            string tempEngunSts = main.getEngunSts(engunDaimyo);
                            dstEngunSts = dstEngunSts + ":" + engunDaimyo + "-" + tempEngunSts;
                        }
                        else
                        {
                            dstEngunDaimyoId = engunDaimyo;
                            string tempEngunSts = main.getEngunSts(engunDaimyo);
                            dstEngunSts = engunDaimyo + "-" + tempEngunSts;
                        }
                    }
                }
                PlayerPrefs.SetString("enemyEngunList", dstEngunSts);
            }

            //Delete "Start Kassen Flg"
            PlayerPrefs.DeleteKey("activeLink");
            PlayerPrefs.SetInt("activePowerType", 3);

            PlayerPrefs.Flush();
            Application.LoadLevel("preKassen");
        }
        else
        {
            audioSources [1].Play();
            Destroy(confirm.gameObject);
            Destroy(back.gameObject);
        }
    }
Exemple #13
0
    private void _Send(byte cmd,SendParam param)
    {
        byte[] DataToSend = new byte[mDataByteNum];
        DataToSend[0] = 0Xfa;
        DataToSend[1] = cmd;
        DataToSend[2] = param.HD;
        DataToSend[3] = param.LD;
        DataToSend[4] = (byte)(cmd + param.HD + param.LD);
        DataToSend[5] = (byte)(DataToSend[4] + 1);

        mSerial.Send(DataToSend);
    }
Exemple #14
0
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="httpUri">请求地址</param>
        /// <param name="method">请求的方法</param>
        /// <param name="httpData">请求参数 例:{"value": "HttpSend"} C#格式(@"{""value"":""HttpSend""}")</param>
        /// <param name="sendParam">发送参数</param>
        /// <returns></returns>
        public static string Send(string httpUri, string method = "GET", string httpData = null, SendParam sendParam = null)
        {
            HttpWebRequest  httpWebRequest  = null;
            HttpWebResponse httpWebResponse = null;
            Stream          reqStream       = null;
            Stream          resStream       = null;

            try
            {
                if (sendParam == null)
                {
                    sendParam = new SendParam();
                }
                httpWebRequest = (HttpWebRequest)WebRequest.Create(httpUri);
                if (sendParam.Headers != null)
                {
                    httpWebRequest.Headers = sendParam.Headers;
                }
                httpWebRequest.Method      = method;
                httpWebRequest.Timeout     = sendParam.TimeOut;
                httpWebRequest.ContentType = sendParam.ContentType;
                if (method != "GET")
                {
                    //这个在非GET的时候,一定要加上,如果服务器返回错误,他还会继续再去请求,不会使用之前的错误数据做返回数据
                    httpWebRequest.ServicePoint.Expect100Continue = false;
                    if (!string.IsNullOrEmpty(httpData))
                    {
                        var data = Encoding.UTF8.GetBytes(httpData);
                        httpWebRequest.ContentLength = data.Length;
                        reqStream = httpWebRequest.GetRequestStream();
                        reqStream.Write(data, 0, data.Length);
                        reqStream.Close();
                    }
                    else
                    {
                        httpWebRequest.ContentLength = 0;
                    }
                }
                var webResponse = httpWebRequest.GetResponse();
                httpWebResponse = (HttpWebResponse)webResponse;
                resStream       = httpWebResponse.GetResponseStream();
                string result;
                if (resStream != null)
                {
                    var streamReader = new StreamReader(resStream, Encoding.GetEncoding(sendParam.Encoding));
                    result = streamReader.ReadToEnd();
                    streamReader.Close();
                    resStream.Close();
                }
                else
                {
                    result = string.Empty;
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("CoreHttp.HttpSend Err: method=>" + method + " uri=>" + httpUri + " httpData=>" + httpData + "err=>" + ex);
            }
            finally
            {
                resStream?.Close();
                reqStream?.Close();
                httpWebResponse?.Close();
                httpWebRequest?.Abort();
            }
        }