Example #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);
        }
    }
Example #2
0
    public void GetPlayerSenryoku(string busyoId)
    {
        int  i      = 0;
        bool result = int.TryParse(busyoId, out i);

        if (result)
        {
            //Parent
            int myDaimyoBusyo = PlayerPrefs.GetInt("myDaimyoBusyo");
            if (int.Parse(busyoId) == myDaimyoBusyo)
            {
                myDaimyoBusyoFlg = true;
            }

            BusyoInfoGet busyo = new BusyoInfoGet();
            belongDaimyoId = busyo.getDaimyoId(int.Parse(busyoId));
            if (belongDaimyoId == 0)
            {
                belongDaimyoId = busyo.getDaimyoHst(int.Parse(busyoId));
            }
            shipId = busyo.getShipId(int.Parse(busyoId));

            lv = PlayerPrefs.GetInt(busyoId, 1);
            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;

            JyosyuHeiryoku jyosyuHei    = new JyosyuHeiryoku();
            int            addJyosyuHei = jyosyuHei.GetJyosyuHeiryoku(busyoId.ToString());

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

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

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

            totalBusyoAtk = adjAtk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt(addAtkByKanni);
            totalBusyoHp  = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt(addHpByKanni) + addJyosyuHei;
            totalBusyoDfc = adjDfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt(addDfcByKanni);
            totalSpd      = spd + int.Parse(KahouStatusArray[3]);
            if (Application.loadedLevelName == "preKaisen")
            {
                if (shipId == 1)
                {
                    totalBusyoHp = totalBusyoHp * 2;
                }
                else if (shipId == 2)
                {
                    totalBusyoHp = Mathf.FloorToInt((float)totalBusyoHp * 1.5f);
                }
            }

            //Child
            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();
            }

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

                chQty = int.Parse(ch_list [1]);
                chlv  = int.Parse(ch_list [2]);
                int ch_status    = int.Parse(ch_list [3]);
                int totalChldHp  = 0;
                int totalChldAtk = 0;
                int totalChldDfc = 0;

                ch_status = ch_status * 10;
                int atkDfc = (int)sts.getChAtkDfc(ch_status, totalBusyoHp);

                totalChldHp  = ch_status * chQty;
                totalChldAtk = atkDfc * chQty;
                totalChldDfc = atkDfc * chQty;

                //Set value
                totalHp  = totalBusyoHp + totalChldHp;
                totalAtk = totalBusyoAtk + totalChldAtk;
                totalDfc = totalBusyoDfc + totalChldDfc;
            }
        }
    }
Example #3
0
    public void makeKaisenInstance(int mapId, int busyoId, int shipId, int lv, string ch_type, int ch_num, int hp, int atk, int dfc, int spd, string busyoName, int linkNo, bool taisyo, ArrayList senpouArray)
    {
        string     path   = "Prefabs/Kaisen/" + shipId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name  = busyoId.ToString();
        prefab.tag   = "Enemy";
        prefab.layer = LayerMask.NameToLayer("Enemy");
        Destroy(prefab.GetComponent <PlayerHP>());
        Destroy(prefab.GetComponent <PlayerAttack>());
        prefab.AddComponent <EnemyHP> ();
        prefab.AddComponent <EnemyAttack>();

        //Senpou Script Parametor
        StatusGet senpouScript = new StatusGet();
        bool      shipFlg      = senpouScript.getSenpouShipFlg((int)senpouArray[0]);

        if (shipFlg)
        {
            prefab.GetComponent <SenpouController>().senpouId     = (int)senpouArray[0];
            prefab.GetComponent <SenpouController>().senpouTyp    = senpouArray[1].ToString();
            prefab.GetComponent <SenpouController>().senpouName   = senpouArray[2].ToString();
            prefab.GetComponent <SenpouController>().senpouEach   = (float)senpouArray[4];
            prefab.GetComponent <SenpouController>().senpouRatio  = (float)senpouArray[5];
            prefab.GetComponent <SenpouController>().senpouTerm   = (float)senpouArray[6];
            prefab.GetComponent <SenpouController>().senpouStatus = (int)senpouArray[7];
            prefab.GetComponent <SenpouController>().senpouLv     = (int)senpouArray[8];
            //Serihu
            Entity_serihu_mst serihuMst = Resources.Load("Data/serihu_mst") as Entity_serihu_mst;
            string            serihu    = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsgEng;
            }
            else
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsg;
            }
            prefab.GetComponent <SenpouController>().senpouSerihu = serihu;
        }
        else
        {
            Destroy(prefab.GetComponent <SenpouController>());
        }

        //Script Adjust
        Destroy(prefab.GetComponent <UnitMover>());
        prefab.AddComponent <Homing>();



        //Busyo Detail Info [Name & HP Bar]
        string dtlPath = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlEnemyEng";
        }
        else
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlEnemy";
        }
        GameObject dtl = Instantiate(Resources.Load(dtlPath)) as GameObject;

        dtl.transform.SetParent(prefab.transform);
        dtl.transform.localPosition = new Vector3(0, 1, -1);
        dtl.transform.localScale    = new Vector3(1, 1, 0);
        dtl.name = "BusyoDtlEnemy";

        //Name
        GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;

        nameLabel.GetComponent <TextMesh>().text = busyoName;
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            nameLabel.GetComponent <TextMesh>().fontSize = 40;
        }
        //Location by map id
        if (mapId == 1)
        {
            prefab.transform.position = new Vector2(5, 16);
        }
        else if (mapId == 2)
        {
            prefab.transform.position = new Vector2(20, 16);
        }
        else if (mapId == 3)
        {
            prefab.transform.position = new Vector2(35, 16);
        }
        else if (mapId == 4)
        {
            prefab.transform.position = new Vector2(50, 16);
        }
        else if (mapId == 5)
        {
            prefab.transform.position = new Vector2(65, 16);
        }
        else if (mapId == 6)
        {
            prefab.transform.position = new Vector2(5, 8);
        }
        else if (mapId == 7)
        {
            prefab.transform.position = new Vector2(20, 8);
        }
        else if (mapId == 8)
        {
            prefab.transform.position = new Vector2(35, 8);
        }
        else if (mapId == 9)
        {
            prefab.transform.position = new Vector2(50, 8);
        }
        else if (mapId == 10)
        {
            prefab.transform.position = new Vector2(65, 8);
        }
        else if (mapId == 11)
        {
            prefab.transform.position = new Vector2(5, 0);
        }
        else if (mapId == 12)
        {
            prefab.transform.position = new Vector2(20, 0);
        }
        else if (mapId == 13)
        {
            prefab.transform.position = new Vector2(35, 0);
        }
        else if (mapId == 14)
        {
            prefab.transform.position = new Vector2(50, 0);
        }
        else if (mapId == 15)
        {
            prefab.transform.position = new Vector2(65, 0);
        }
        else if (mapId == 16)
        {
            prefab.transform.position = new Vector2(5, -8);
        }
        else if (mapId == 17)
        {
            prefab.transform.position = new Vector2(20, -8);
        }
        else if (mapId == 18)
        {
            prefab.transform.position = new Vector2(35, -8);
        }
        else if (mapId == 19)
        {
            prefab.transform.position = new Vector2(50, -8);
        }
        else if (mapId == 20)
        {
            prefab.transform.position = new Vector2(65, -8);
        }
        else if (mapId == 21)
        {
            prefab.transform.position = new Vector2(5, -16);
        }
        else if (mapId == 22)
        {
            prefab.transform.position = new Vector2(20, -16);
        }
        else if (mapId == 23)
        {
            prefab.transform.position = new Vector2(35, -16);
        }
        else if (mapId == 24)
        {
            prefab.transform.position = new Vector2(50, -16);
        }
        else if (mapId == 25)
        {
            prefab.transform.position = new Vector2(65, -16);
        }

        //Link Adjustment
        float linkAdjst = (float)linkNo / 10;

        hp  = hp * 100;
        dfc = dfc * 10;

        if (linkNo != 0)
        {
            float adjstHp = hp * linkAdjst;
            hp = hp + (int)adjstHp;
            float adjstDfc = dfc * linkAdjst;
            dfc = dfc + (int)adjstDfc;
        }

        //Adjust
        float adjSpd = (float)spd / 10;

        if (adjSpd <= 0)
        {
            adjSpd = 1;
        }

        if (shipId == 1)
        {
            hp     = hp * 2;
            dfc    = dfc * 2;
            adjSpd = Mathf.FloorToInt((float)adjSpd * 0.5f);
        }
        else if (shipId == 2)
        {
            hp     = Mathf.FloorToInt((float)hp * 1.5f);
            dfc    = Mathf.FloorToInt((float)dfc * 1.5f);
            adjSpd = Mathf.FloorToInt((float)adjSpd * 0.6f);
        }
        else if (shipId == 3)
        {
            adjSpd = Mathf.FloorToInt((float)adjSpd * 0.8f);
        }
        atk = atk * 10;
        if (linkNo != 0)
        {
            float adjstAtk = atk * linkAdjst;
            atk = atk + (int)adjstAtk;
        }
        if (adjSpd <= 0)
        {
            adjSpd = 1;
        }
        GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;

        minHpBar.GetComponent <BusyoHPBar>().initLife = hp;
        prefab.GetComponent <EnemyHP>().life          = hp;
        prefab.GetComponent <EnemyAttack>().attack    = atk;
        prefab.GetComponent <Homing>().speed          = adjSpd;
        prefab.GetComponent <EnemyHP>().dfc           = dfc;

        if (taisyo)
        {
            prefab.GetComponent <EnemyHP>().taisyo = true;
        }

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(prefab, "SHP");

        //Child Instantiate
        //set child object
        string    ch_path = "Prefabs/Kaisen/3";
        StatusGet sts     = new StatusGet();

        for (int i = 1; i <= ch_num; i++)
        {
            //Make Relationship
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.transform.SetParent(prefab.transform);
            ch_prefab.name = "Child" + i.ToString();
            ch_prefab.transform.localScale = new Vector2(0.7f, 0.7f);
            ch_prefab.GetComponent <SpriteRenderer>().sortingOrder = 3;
            ch_prefab.tag = "EnemyChild";

            Destroy(ch_prefab.GetComponent <Rigidbody2D>());
            Destroy(ch_prefab.GetComponent <UnitMover>());
            Destroy(ch_prefab.GetComponent <Kunkou>());
            Destroy(ch_prefab.GetComponent <PolygonCollider2D>());
            Destroy(ch_prefab.GetComponent <PlayerAttack>());
            Destroy(ch_prefab.GetComponent <PlayerHP>());
            Destroy(ch_prefab.GetComponent <SenpouController>());

            //Location
            if (i == 1)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 0);
            }
            else if (i == 2)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 0.5f);
            }
            else if (i == 3)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -0.5f);
            }
            else if (i == 4)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 1.0f);
            }
            else if (i == 5)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -1.0f);
            }
            else if (i == 6)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 0.5f);
            }
            else if (i == 7)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -0.5f);
            }
            else if (i == 8)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 1.0f);
            }
            else if (i == 9)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -1.0f);
            }
            else if (i == 10)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 0);
            }
            else if (i == 11)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 0.5f);
            }
            else if (i == 12)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -0.5f);
            }
            else if (i == 13)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 1.0f);
            }
            else if (i == 14)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -1.0f);
            }
            else if (i == 15)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 1.5f);
            }
            else if (i == 16)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -1.5f);
            }
            else if (i == 17)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 1.5f);
            }
            else if (i == 18)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -1.5f);
            }
            else if (i == 19)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 1.5f);
            }
            else if (i == 20)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -1.5f);
            }


            int ch_status = getChildStatus(lv, ch_type, linkNo);

            //Round up because of Link adjustment might be under 0
            int atkDfc = Mathf.CeilToInt(sts.getChAtkDfc(ch_status, hp));

            if (i == 1)
            {
                //Child Qty
                prefab.GetComponent <EnemyHP>().childQty = ch_num;

                //Child Unit HP
                prefab.GetComponent <EnemyHP>().childHP = ch_status;

                //Attack
                prefab.GetComponent <EnemyAttack>().attack = prefab.GetComponent <EnemyAttack>().attack + (ch_num * atkDfc);

                //Dfc
                prefab.GetComponent <EnemyHP>().dfc = prefab.GetComponent <EnemyHP>().dfc + (ch_num * atkDfc);
            }
        }
    }
Example #4
0
    public void makeInstance(int mapId, int busyoId, int lv, string ch_type, int ch_num, int hp, int atk, int dfc, int spd, string busyoName, int linkNo, bool taisyo, ArrayList senpouArray, string kahouList)
    {
        /*Roujyo Start*/
        bool       shiroFlg    = false;
        bool       torideFlg   = false;
        GameObject buildingObj = null;
        bool       pvpFlg      = GameObject.Find("GameScene").GetComponent <GameScene>().pvpFlg;

        if (!pvpFlg)
        {
            string eSRMap = "eSRMap" + mapId.ToString();
            shiroFlg = PlayerPrefs.GetBool(eSRMap);
            PlayerPrefs.DeleteKey(eSRMap);

            if (!shiroFlg)
            {
                string eTRMap = "eTRMap" + mapId.ToString();
                torideFlg = PlayerPrefs.GetBool(eTRMap);
                PlayerPrefs.DeleteKey(eTRMap);
            }

            if (shiroFlg)
            {
                string objPath = "Prefabs/Kassen/eShiro";
                buildingObj = Instantiate(Resources.Load(objPath)) as GameObject;
                buildingObj.transform.localScale = new Vector2(2, 1.5f);
                setEnemyObjectOnMap(mapId, buildingObj);
                buildingObj.name = "shiro";

                string stageName = PlayerPrefs.GetString("activeStageName");
                buildingObj.transform.FindChild("BusyoDtlEnemy").transform.FindChild("NameLabel").GetComponent <TextMesh> ().text = stageName;

                //HP
                int    powerType = PlayerPrefs.GetInt("activePowerType");
                string Type      = "";
                if (powerType == 1)
                {
                    Type = "s";
                }
                else if (powerType == 2)
                {
                    Type = "m";
                }
                else if (powerType == 3)
                {
                    Type = "l";
                }
                string imagePath = "Prefabs/Naisei/Shiro/Sprite/shiro_" + Type;
                buildingObj.GetComponent <SpriteRenderer> ().sprite =
                    Resources.Load(imagePath, typeof(Sprite)) as Sprite;
            }
            else
            {
                if (torideFlg)
                {
                    string objPath = "Prefabs/Kassen/eToride";
                    buildingObj = Instantiate(Resources.Load(objPath)) as GameObject;
                    buildingObj.transform.localScale = new Vector2(3, 3);
                    setEnemyObjectOnMap(mapId, buildingObj);
                    buildingObj.name = "toride";

                    //HP
                    int    powerType = PlayerPrefs.GetInt("activePowerType");
                    string Type      = "";
                    if (powerType == 1)
                    {
                        Type = "s";
                    }
                    else if (powerType == 2)
                    {
                        Type = "m";
                    }
                    else if (powerType == 3)
                    {
                        Type = "l";
                    }

                    string imagePath = "Prefabs/Kassen/kassenTrd_" + Type;
                    buildingObj.GetComponent <SpriteRenderer> ().sprite =
                        Resources.Load(imagePath, typeof(Sprite)) as Sprite;
                }
            }
        }
        /*Roujyo End*/


        string     path   = "Prefabs/Player/" + busyoId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();

        /**Player to Enemy**/
        Vector3 scale = prefab.transform.localScale;
        float   x     = prefab.transform.localScale.x;

        scale.x = scale.x * -1;
        prefab.transform.localScale = scale;
        Destroy(prefab.GetComponent <PlayerHP>());
        prefab.AddComponent <EnemyHP>();
        Destroy(prefab.GetComponent <Kunkou>());
        Destroy(prefab.GetComponent <UnitMover>());
        if (prefab.GetComponent <PlayerAttack>())
        {
            Destroy(prefab.GetComponent <PlayerAttack>());
            prefab.AddComponent <EnemyAttack>();
            prefab.AddComponent <Homing>();
        }
        else
        {
            prefab.AddComponent <HomingLong>();
            if (ch_type == "YM")
            {
                prefab.GetComponent <AttackLong>().bullet = Resources.Load("Prefabs/Enemy/EnemyArrow") as GameObject;
            }
            else
            {
                prefab.GetComponent <AttackLong>().bullet = Resources.Load("Prefabs/Enemy/EnemyBullet") as GameObject;
            }
        }
        prefab.tag   = "Enemy";
        prefab.layer = LayerMask.NameToLayer("Enemy");
        /**Player to Enemy End**/



        //Senpou Script Parametor
        StatusGet senpouScript = new StatusGet();
        bool      onlySeaFlg   = senpouScript.getSenpouOnlySeaFlg((int)senpouArray[0]);

        if (!onlySeaFlg)
        {
            prefab.GetComponent <SenpouController>().senpouId     = (int)senpouArray[0];
            prefab.GetComponent <SenpouController>().senpouTyp    = senpouArray[1].ToString();
            prefab.GetComponent <SenpouController>().senpouName   = senpouArray[2].ToString();
            prefab.GetComponent <SenpouController>().senpouEach   = (float)senpouArray[4];
            prefab.GetComponent <SenpouController>().senpouRatio  = (float)senpouArray[5];
            prefab.GetComponent <SenpouController>().senpouTerm   = (float)senpouArray[6];
            prefab.GetComponent <SenpouController>().senpouStatus = (int)senpouArray[7];
            prefab.GetComponent <SenpouController>().senpouLv     = (int)senpouArray[8];
            //Serihu
            Entity_serihu_mst serihuMst = Resources.Load("Data/serihu_mst") as Entity_serihu_mst;
            string            serihu    = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsgEng;
            }
            else
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsg;
            }
            prefab.GetComponent <SenpouController>().senpouSerihu = serihu;
        }
        else
        {
            Destroy(prefab.GetComponent <SenpouController>());
        }

        //Busyo Detail Info [Name & HP Bar]
        string dtlPath = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlEnemyEng";
        }
        else
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlEnemy";
        }
        GameObject dtl = Instantiate(Resources.Load(dtlPath)) as GameObject;

        dtl.transform.SetParent(prefab.transform);
        dtl.transform.localPosition = new Vector3(0, 1.3f, -1);
        dtl.transform.localScale    = new Vector3(-1.3f, 1.3f, 0);
        dtl.name = "BusyoDtlEnemy";

        //Name
        GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;

        nameLabel.GetComponent <TextMesh> ().text = busyoName;


        //Location by map id
        if (mapId == 1)
        {
            prefab.transform.position = new Vector2(5, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 2)
        {
            prefab.transform.position = new Vector2(20, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 3)
        {
            prefab.transform.position = new Vector2(35, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 4)
        {
            prefab.transform.position = new Vector2(50, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 5)
        {
            prefab.transform.position = new Vector2(65, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 6)
        {
            prefab.transform.position = new Vector2(5, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 7)
        {
            prefab.transform.position = new Vector2(20, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 8)
        {
            prefab.transform.position = new Vector2(35, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 9)
        {
            prefab.transform.position = new Vector2(50, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 10)
        {
            prefab.transform.position = new Vector2(65, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 11)
        {
            prefab.transform.position = new Vector2(5, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 12)
        {
            prefab.transform.position = new Vector2(20, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 13)
        {
            prefab.transform.position = new Vector2(35, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 14)
        {
            prefab.transform.position = new Vector2(50, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 15)
        {
            prefab.transform.position = new Vector2(65, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 16)
        {
            prefab.transform.position = new Vector2(5, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 17)
        {
            prefab.transform.position = new Vector2(20, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 18)
        {
            prefab.transform.position = new Vector2(35, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 19)
        {
            prefab.transform.position = new Vector2(50, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 20)
        {
            prefab.transform.position = new Vector2(65, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 21)
        {
            prefab.transform.position = new Vector2(5, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 22)
        {
            prefab.transform.position = new Vector2(20, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 23)
        {
            prefab.transform.position = new Vector2(35, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 24)
        {
            prefab.transform.position = new Vector2(50, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 25)
        {
            prefab.transform.position = new Vector2(65, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }



        //Link Adjustment
        float linkAdjst = (float)linkNo / 10;

        hp  = hp * 100;
        atk = atk * 10;
        dfc = dfc * 10;
        if (linkNo != 0)
        {
            float adjstHp = hp * linkAdjst;
            hp = hp + (int)adjstHp;
            float adjstDfc = dfc * linkAdjst;
            dfc = dfc + (int)adjstDfc;
        }

        /*Kahou Adjustment*/
        string[] KahouStatusArray;
        float    spdWithKahou = (float)spd;

        if (pvpFlg)
        {
            KahouStatusGet KahouStatusGet = new KahouStatusGet();
            KahouStatusArray = KahouStatusGet.getPvPKahouForStatus(kahouList, hp, atk, dfc, spd);
            hp           = hp + int.Parse(KahouStatusArray[1]);
            atk          = atk + int.Parse(KahouStatusArray[0]);
            dfc          = dfc + int.Parse(KahouStatusArray[2]);
            spdWithKahou = ((float)spd + float.Parse(KahouStatusArray[3]));
        }

        //HP Bar
        GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;

        minHpBar.GetComponent <BusyoHPBar>().initLife = hp;
        prefab.GetComponent <EnemyHP>().life          = hp;

        //adjust spd
        float adjSpd = spdWithKahou / 10;

        if (prefab.GetComponent <EnemyAttack> ())
        {
            if (linkNo != 0)
            {
                float adjstAtk = atk * linkAdjst;
                atk = atk + (int)adjstAtk;
            }
            prefab.GetComponent <EnemyAttack> ().attack = atk;
            if (adjSpd <= 0)
            {
                adjSpd = 1;
            }
            prefab.GetComponent <Homing> ().speed  = adjSpd;
            prefab.GetComponent <Homing>().leftFlg = true;
        }
        else
        {
            if (ch_type == "YM")
            {
                atk = atk * 3;
            }
            else if (ch_type == "TP")
            {
                atk = atk * 5;
            }
            if (linkNo != 0)
            {
                float adjstAtk = atk * linkAdjst;
                atk = atk + (int)adjstAtk;
            }

            prefab.GetComponent <AttackLong> ().attack = atk;
            if (adjSpd <= 0)
            {
                adjSpd = 1;
            }
            prefab.GetComponent <HomingLong> ().speed  = adjSpd;
            prefab.GetComponent <HomingLong>().leftFlg = true;
        }
        prefab.GetComponent <EnemyHP> ().dfc = dfc;

        if (taisyo)
        {
            prefab.GetComponent <EnemyHP> ().taisyo = true;
        }

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(prefab, ch_type);


        //Child Instantiate
        //set child object
        string    ch_path = "Prefabs/Enemy/" + ch_type;
        float     y1      = 3.0f;
        float     y2      = 3.0f;
        float     y3      = 3.0f;
        float     y4      = 3.0f;
        StatusGet sts     = new StatusGet();

        for (int i = 1; i <= ch_num; i++)
        {
            //Make Relationship
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.transform.SetParent(prefab.transform);
            ch_prefab.name = "Child" + i.ToString();

            //Sashimono Making
            string sashimono_path = "Prefabs/Sashimono/" + busyoId;
            //string sashimono_path = "Prefabs/Sashimono/1";
            GameObject sashimono = Instantiate(Resources.Load(sashimono_path)) as GameObject;
            sashimono.transform.SetParent(ch_prefab.transform);


            //reverse Horizonal
            sashimono.transform.localScale       = new Vector2(0.3f, 0.3f);
            sashimono.transform.localEulerAngles = new Vector3(sashimono.transform.localEulerAngles.x, sashimono.transform.localEulerAngles.y, 10);

            if (ch_type == "YR")
            {
                sashimono.transform.localPosition = new Vector2(-1, 0.6f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 3, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 6, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 9, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 12, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "KB")
            {
                sashimono.transform.localPosition = new Vector2(-0.5f, 1);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "TP")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "YM")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x + 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }

            int ch_status = getChildStatus(lv, ch_type, linkNo);

            //Round up because of Link adjustment might be under 0
            int atkDfc = Mathf.CeilToInt(sts.getChAtkDfc(ch_status, hp));

            if (i == 1)
            {
                //Child Qty
                prefab.GetComponent <EnemyHP>().childQty = ch_num;

                //Child Unit HP
                prefab.GetComponent <EnemyHP>().childHP = ch_status;

                //Attack
                if (ch_type == "YM")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 3;
                    prefab.GetComponent <Heisyu> ().atk             = atkDfc * 3;
                }
                else if (ch_type == "TP")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 5;
                    prefab.GetComponent <Heisyu> ().atk             = atkDfc * 5;
                }
                else
                {
                    prefab.GetComponent <EnemyAttack> ().attack = prefab.GetComponent <EnemyAttack> ().attack + (ch_num * atkDfc);
                    prefab.GetComponent <Heisyu> ().atk         = atkDfc;
                }

                //Dfc
                prefab.GetComponent <EnemyHP> ().dfc = prefab.GetComponent <EnemyHP> ().dfc + (ch_num * atkDfc);
                prefab.GetComponent <Heisyu> ().dfc  = atkDfc;
            }
        }

        //Busyo Config in Shiro or Toride
        if (shiroFlg || torideFlg)
        {
            //Choose AI Type
            int baseAtk = sts.getBaseAtk(busyoId);
            int baseDfc = sts.getBaseDfc(busyoId);
            int AIType  = getAIType(baseAtk, baseDfc, taisyo);

            buildingObj.GetComponent <ShiroSearch> ().busyoObjList.Add(prefab);
            if (ch_type == "YM" || ch_type == "TP")
            {
                prefab.GetComponent <HomingLong> ().backShiroObj = buildingObj;
                prefab.GetComponent <HomingLong> ().enabled      = false;
            }
            else
            {
                prefab.GetComponent <Homing> ().backShiroObj = buildingObj;
                prefab.GetComponent <Homing> ().enabled      = false;

                //YR & KB
                if (shiroFlg && AIType == 3)
                {
                    AIType = 1;
                }
            }

            //Size
            buildingObj.GetComponent <ShiroSearch> ().busyoObjSize.Add(prefab.transform.localScale);
            prefab.transform.localScale = new Vector2(0, 0);

            //AI
            buildingObj.GetComponent <ShiroSearch> ().AITypeList.Add(AIType);

            //HP
            List <float> randomList = new List <float>()
            {
                1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f
            };
            int   rdm         = UnityEngine.Random.Range(0, randomList.Count);
            float randomValue = randomList [rdm];
            buildingObj.transform.FindChild("BusyoDtlEnemy").transform.FindChild("MinHpBar").GetComponent <BusyoHPBar>().initLife = (float)hp * randomValue;
            buildingObj.GetComponent <EnemyHP>().life = (float)hp * randomValue;
        }
    }
Example #5
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";
            }
        }
    }
Example #6
0
	public void makeInstance(int mapId, int busyoId, int lv, string ch_type, int ch_num, int hp, int atk, int dfc,int spd, string busyoName, int linkNo, bool taisyo){
		string path = "Prefabs/Enemy/" + busyoId;
		GameObject prefab = Instantiate(Resources.Load (path)) as GameObject;


		//Busyo Detail Info [Name & HP Bar]
		string dtlPath = "Prefabs/BusyoDtl/BusyoDtlEnemy";
		GameObject dtl = Instantiate(Resources.Load (dtlPath)) as GameObject;
		dtl.transform.parent = prefab.transform;
		
		//Name
		GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;
		nameLabel.GetComponent<TextMesh> ().text = busyoName;
		

		//Location by map id
		if (mapId == 1) {
			prefab.transform.position = new Vector2 (5, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 2) {
			prefab.transform.position = new Vector2 (20, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 3) {
			prefab.transform.position = new Vector2 (35, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 4) {
			prefab.transform.position = new Vector2 (50, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 5) {
			prefab.transform.position = new Vector2 (65, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 6) {
			prefab.transform.position = new Vector2 (5, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;
		} else if (mapId == 7) {
			prefab.transform.position = new Vector2 (20, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;
		} else if (mapId == 8) {
			prefab.transform.position = new Vector2 (35, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;
		} else if (mapId == 9) {
			prefab.transform.position = new Vector2 (50, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;
		} else if (mapId == 10) {
			prefab.transform.position = new Vector2 (65, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;
		} else if (mapId == 11) {
			prefab.transform.position = new Vector2 (5, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;
		} else if (mapId == 12) {
			prefab.transform.position = new Vector2 (20, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;
		} else if (mapId == 13) {
			prefab.transform.position = new Vector2 (35, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;
		} else if (mapId == 14) {
			prefab.transform.position = new Vector2 (50, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;
		} else if (mapId == 15) {
			prefab.transform.position = new Vector2 (65, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;
		} else if (mapId == 16) {
			prefab.transform.position = new Vector2 (5, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;
		} else if (mapId == 17) {
			prefab.transform.position = new Vector2 (20, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;
		} else if (mapId == 18) {
			prefab.transform.position = new Vector2 (35, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;
		} else if (mapId == 19) {
			prefab.transform.position = new Vector2 (50, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;
		} else if (mapId == 20) {
			prefab.transform.position = new Vector2 (65, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;
		} else if (mapId == 21) {
			prefab.transform.position = new Vector2 (5, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;
		} else if (mapId == 22) {
			prefab.transform.position = new Vector2 (20, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;
		} else if (mapId == 23) {
			prefab.transform.position = new Vector2 (35, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;
		} else if (mapId == 24) {
			prefab.transform.position = new Vector2 (50, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;
		} else if (mapId == 25) {
			prefab.transform.position = new Vector2 (65, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;
		}


		//Link Adjustment
		float linkAdjst = (float)linkNo/10;
		hp = hp * 100;
		dfc = dfc * 10;

		if (linkNo != 0) {
			float adjstHp = hp * linkAdjst;
			hp = hp + (int)adjstHp;

			float adjstDfc = dfc * linkAdjst;
			dfc = dfc + (int)adjstDfc;
		}


		//HP Bar
		GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;
		minHpBar.GetComponent<BusyoHPBar>().initLife = hp;

		//parametor setting
		prefab.GetComponent<EnemyHP>().life = hp;
		if (prefab.GetComponent<EnemyAttack> ()) {
			atk = atk * 10;
			if (linkNo != 0) {
				float adjstAtk = atk * linkAdjst;
				atk = atk + (int)adjstAtk;

			}
			prefab.GetComponent<EnemyAttack> ().attack = atk;
			prefab.GetComponent<Homing> ().speed = spd;
			prefab.GetComponent<Homing>().leftFlg = true;

		} else {
			if(ch_type == "YM"){
				atk = atk * 30;
			}else if(ch_type == "TP"){
				atk = atk * 50;
			}
			if (linkNo != 0) {
				float adjstAtk = atk * linkAdjst;
				atk = atk + (int)adjstAtk;
			}

			prefab.GetComponent<AttackLong> ().attack = atk;
			prefab.GetComponent<HomingLong> ().speed = spd;
			prefab.GetComponent<HomingLong>().leftFlg = true;
		}
		prefab.GetComponent<EnemyHP> ().dfc = dfc;

		if (taisyo) {
			prefab.GetComponent<EnemyHP> ().taisyo = true;

		}



		/*Child Instantiate*/
		//set child object
		string ch_path = "Prefabs/Enemy/" + ch_type;
		float y1 = 3.0f;
		float y2 = 3.0f;
		float y3 = 3.0f;
		float y4 = 3.0f;


		for(int i = 1; i <= ch_num; i++){
			//Make Relationship
			GameObject ch_prefab = Instantiate(Resources.Load (ch_path)) as GameObject;
			ch_prefab.transform.parent = prefab.transform;
			ch_prefab.name = ch_prefab.name + "_" + prefab.name;

			//Sashimono Making
			string sashimono_path = "Prefabs/Sashimono/" + busyoId;
			GameObject sashimono = Instantiate(Resources.Load (sashimono_path)) as GameObject;
			sashimono.transform.parent = ch_prefab.transform;


			//reverse Horizonal
			sashimono.transform.localScale = new Vector2(0.3f,0.3f);
			sashimono.transform.localEulerAngles = new Vector3(sashimono.transform.localEulerAngles.x, sashimono.transform.localEulerAngles.y, 10);

			if(ch_type == "YR"){
				sashimono.transform.localPosition = new Vector2(-1,0.6f);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 3,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 6,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 9,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 12,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "KB"){
				sashimono.transform.localPosition = new Vector2(-0.5f,1);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "TP"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "YM"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x + 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}


			StatusGet sts = new StatusGet();
			int ch_status = getChildStatus(lv, ch_type, linkNo);

			//Round up because of Link adjustment might be under 0
			int atkDfc = Mathf.CeilToInt(sts.getChAtkDfc(ch_status, hp));

			ch_prefab.GetComponent<EnemyHP>().life = ch_status;
			if(ch_prefab.GetComponent<EnemyAttack> ()){
				ch_prefab.GetComponent<EnemyAttack> ().attack =atkDfc;
				ch_prefab.GetComponent<HomingPrnt>().leftFlg = true;
			}else{
				if (ch_type == "TP") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 5;
				} else if (ch_type == "YM") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 3;
				}
				ch_prefab.GetComponent<HomingLongPrnt>().leftFlg = true;
			}
			ch_prefab.GetComponent<EnemyHP>().dfc = atkDfc;
		}

	}
Example #7
0
    public void makeSimpleEnemy(int busyoId, GameObject battleArea, int xAdjust, GameObject YesBtn)
    {
        string     path   = "Prefabs/Player/" + busyoId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();
        prefab.transform.SetParent(battleArea.transform);
        prefab.transform.localScale = new Vector2(-0.4f, 0.6f);
        prefab.GetComponent <SpriteRenderer>().sortingLayerName = "UI";
        prefab.GetComponent <SpriteRenderer>().sortingOrder     = 350;

        /**Player to Enemy**/
        prefab.tag   = "Enemy";
        prefab.layer = LayerMask.NameToLayer("Enemy");
        /**Player to Enemy End**/

        float xAdjust2 = (float)xAdjust / 5;

        prefab.transform.localPosition = new Vector2(9 - xAdjust2, 1.8f);
        prefab.GetComponent <Rigidbody2D>().gravityScale = 1;

        //Set Scirpt
        Destroy(prefab.GetComponent <PlayerHP>());
        Destroy(prefab.GetComponent <SenpouController>());
        Destroy(prefab.GetComponent <LineLocation>());
        if (prefab.GetComponent <HomingLong>())
        {
            Destroy(prefab.GetComponent <HomingLong>());
            prefab.AddComponent <Homing>();
        }
        if (prefab.GetComponent <AttackLong>())
        {
            Destroy(prefab.GetComponent <AttackLong>());
        }
        else
        {
            Destroy(prefab.GetComponent <PlayerAttack>());
        }
        Destroy(prefab.GetComponent <PlayerHP>());
        prefab.AddComponent <SimpleAttack>();
        prefab.AddComponent <SimpleHP>();
        prefab.AddComponent <Homing>();
        prefab.GetComponent <Homing>().speed   = 50;
        prefab.GetComponent <Homing>().enabled = false;

        YesBtn.GetComponent <StartSimpleKassen>().busyoObjList.Add(prefab);

        //Parametor
        StartKassen stksn       = GameObject.Find("BattleButton").GetComponent <StartKassen>();
        int         lv          = stksn.activeBusyoLv;
        string      busyoString = busyoId.ToString();
        StatusGet   sts         = new StatusGet();
        int         hp          = 100 * sts.getHp(busyoId, lv);
        int         atk         = 10 * sts.getAtk(busyoId, lv);
        int         dfc         = 10 * sts.getDfc(busyoId, lv);
        float       spd         = sts.getSpd(busyoId, lv);


        //Child Parametor
        int           chlv          = stksn.activeButaiLv;
        int           chQty         = stksn.activeButaiQty;
        EnemyInstance enemyInstance = new EnemyInstance();
        string        ch_type       = sts.getHeisyu(busyoId);
        int           ch_status     = enemyInstance.getChildStatus(lv, ch_type, 0);
        int           totalChldHp   = 0;
        int           totalChldAtk  = 0;
        int           totalChldDfc  = 0;
        int           atkDfc        = (int)sts.getChAtkDfc(ch_status, hp);

        totalChldHp  = ch_status * chQty;
        totalChldAtk = atkDfc * chQty;
        totalChldDfc = atkDfc * chQty;

        //Set value
        hp  = hp + totalChldHp;
        atk = atk + totalChldAtk;
        dfc = dfc + totalChldDfc;

        prefab.GetComponent <Homing>().speed         = spd / 20;
        prefab.GetComponent <SimpleAttack>().atk     = atk;
        prefab.GetComponent <SimpleHP>().dfc         = dfc;
        prefab.GetComponent <SimpleAttack>().baseAtk = atk;
        prefab.GetComponent <SimpleHP>().baseDfc     = dfc;
        prefab.GetComponent <SimpleHP>().life        = hp;
    }
Example #8
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;

	}
Example #9
0
	public void GetPlayerSenryoku(string busyoId){

		//Parent
		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;
		
		KahouStatusGet kahouSts = new KahouStatusGet ();
		string[] KahouStatusArray =kahouSts.getKahouForStatus (busyoId,adjHp,adjAtk,adjDfc,spd);
		int totalBusyoHp =0;
		int totalBusyoAtk =0;
		int totalBusyoDfc =0;


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

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

		totalBusyoAtk = adjAtk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt (addAtkByKanni);
		totalBusyoHp = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt (addHpByKanni);
		totalBusyoDfc = adjDfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt (addDfcByKanni);



		//Child
		string heiId = "hei" + busyoId.ToString ();
		string chParam = PlayerPrefs.GetString (heiId, "0");
		
		char[] delimiterChars = {':'};
		string[] ch_list = chParam.Split (delimiterChars);
		
		int ch_num = int.Parse (ch_list [1]);
		chlv = int.Parse (ch_list [2]);
		int ch_status = int.Parse (ch_list [3]);
		int totalChldHp = 0;
		int totalChldAtk = 0;
		int totalChldDfc = 0;

		ch_status = ch_status * 10;
		int atkDfc = (int)sts.getChAtkDfc(ch_status, totalBusyoHp);
		JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku ();
		int addHei = jyosyuHei.GetJyosyuHeiryoku (busyoId.ToString());

		totalChldHp = ch_status * ch_num;
		totalChldAtk = atkDfc * ch_num;
		totalChldDfc = atkDfc * ch_num;
		
		//Set value
		totalHp = totalBusyoHp + totalChldHp;
		totalAtk = totalBusyoAtk + totalChldAtk;
		totalDfc = totalBusyoDfc + totalChldDfc;

	}
Example #10
0
    public void makeSimplePlayer(int busyoId, bool soudaisyoFlg, GameObject battleArea, int xAdjust, GameObject YesBtn)
    {
        string     path   = "Prefabs/Player/" + busyoId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();
        prefab.transform.SetParent(battleArea.transform);
        prefab.transform.localScale = new Vector2(0.4f, 0.6f);
        prefab.GetComponent <SpriteRenderer>().sortingLayerName = "UI";
        prefab.GetComponent <SpriteRenderer>().sortingOrder     = 350;
        if (soudaisyoFlg)
        {
            prefab.transform.localPosition = new Vector2(1.0f, 1.8f);
        }
        else
        {
            float xAdjust2 = (float)xAdjust / 20;
            prefab.transform.localPosition = new Vector2(3 - xAdjust2, 1.8f);
        }
        prefab.GetComponent <Rigidbody2D>().gravityScale = 1;

        //Set Scirpt
        Destroy(prefab.GetComponent <PlayerHP>());
        Destroy(prefab.GetComponent <SenpouController>());
        Destroy(prefab.GetComponent <UnitMover>());
        Destroy(prefab.GetComponent <Kunkou>());
        Destroy(prefab.GetComponent <LineLocation>());
        if (prefab.GetComponent <AttackLong>())
        {
            Destroy(prefab.GetComponent <AttackLong>());
        }
        else
        {
            Destroy(prefab.GetComponent <PlayerAttack>());
        }
        Destroy(prefab.GetComponent <PlayerHP>());
        prefab.AddComponent <SimpleAttack>();
        prefab.AddComponent <SimpleHP>();
        prefab.AddComponent <Homing>();

        prefab.GetComponent <Homing>().enabled = false;

        YesBtn.GetComponent <StartSimpleKassen>().busyoObjList.Add(prefab);

        //Parametor
        string    busyoString = busyoId.ToString();
        int       lv          = PlayerPrefs.GetInt(busyoString);
        StatusGet sts         = new StatusGet();
        int       hp          = 100 * sts.getHp(busyoId, lv);
        int       atk         = 10 * sts.getAtk(busyoId, lv);
        int       dfc         = 10 * sts.getDfc(busyoId, lv);
        float     spd         = sts.getSpd(busyoId, lv);

        JyosyuHeiryoku jyosyuHei    = new JyosyuHeiryoku();
        int            addJyosyuHei = jyosyuHei.GetJyosyuHeiryoku(busyoId.ToString());

        KahouStatusGet kahouSts = new KahouStatusGet();

        string[] KahouStatusArray = kahouSts.getKahouForStatus(busyoId.ToString(), hp, atk, dfc, (int)spd);
        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();

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

        atk = atk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt(addAtkByKanni);
        hp  = hp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt(addHpByKanni) + addJyosyuHei;
        dfc = dfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt(addDfcByKanni);


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

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

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

            int chQty        = int.Parse(ch_list[1]);
            int chlv         = int.Parse(ch_list[2]);
            int ch_status    = int.Parse(ch_list[3]);
            int totalChldHp  = 0;
            int totalChldAtk = 0;
            int totalChldDfc = 0;

            ch_status = ch_status * 10;
            int atkDfc = (int)sts.getChAtkDfc(ch_status, hp);

            totalChldHp  = ch_status * chQty;
            totalChldAtk = atkDfc * chQty;
            totalChldDfc = atkDfc * chQty;

            //Set value
            hp  = hp + totalChldHp;
            atk = atk + totalChldAtk;
            dfc = dfc + totalChldDfc;
        }


        prefab.GetComponent <Homing>().speed         = spd / 20;
        prefab.GetComponent <SimpleAttack>().atk     = atk;
        prefab.GetComponent <SimpleHP>().dfc         = dfc;
        prefab.GetComponent <SimpleAttack>().baseAtk = atk;
        prefab.GetComponent <SimpleHP>().baseDfc     = dfc;
        prefab.GetComponent <SimpleHP>().life        = hp;

        //check
        int myDaimyoBusyo = PlayerPrefs.GetInt("myDaimyoBusyo");

        if (busyoId == myDaimyoBusyo)
        {
            myDaimyoBusyoFlg = true;
        }
    }
Example #11
0
	public void makeInstance(int busyoId, int mapId, int hp, int atk, int dfc,int spd, ArrayList senpouArray, string busyoName, int soudaisyo, int boubi){

		/*Parent Instantiate*/
		string path = "Prefabs/Player/" + busyoId;
		GameObject prefab = Instantiate(Resources.Load (path)) as GameObject;

		//Senpou Script Parametor
		prefab.GetComponent<SenpouController>().senpouId = (int)senpouArray[0];
		prefab.GetComponent<SenpouController>().senpouTyp = senpouArray[1].ToString();
		prefab.GetComponent<SenpouController>().senpouName = senpouArray[2].ToString();
		prefab.GetComponent<SenpouController>().senpouEach = (float)senpouArray[4];
		prefab.GetComponent<SenpouController>().senpouRatio = (float)senpouArray[5];
		prefab.GetComponent<SenpouController>().senpouTerm = (float)senpouArray[6];
		prefab.GetComponent<SenpouController>().senpouStatus = (int)senpouArray[7];
		prefab.GetComponent<SenpouController>().senpouLv = (int)senpouArray[8];

		/*Player Status Setting*/
		//parametor setting
		int adjHp = hp*100;
		int adjAtk = atk * 10;
		int adjDfc = dfc * 10;

		//heisyu
		BusyoInfoGet info = new BusyoInfoGet ();
		string heisyu = info.getHeisyu (busyoId);

		//Kahou Adjustment
		KahouStatusGet kahouSts = new KahouStatusGet();
		string[] KahouStatusArray =kahouSts.getKahouForStatus (busyoId.ToString(),adjHp,adjAtk,adjDfc,spd);

		//Kanni Adjustment
		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 ();
			
			//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;
			}
		}


		//Busyo Detail Info [Name & HP Bar]
		string dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayer";
		GameObject dtl = Instantiate(Resources.Load (dtlPath)) as GameObject;
		dtl.transform.parent = prefab.transform;
		
		//Name
		GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;
		nameLabel.GetComponent<TextMesh> ().text = busyoName;
		
		//HP Bar
		GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;
		minHpBar.GetComponent<BusyoHPBar>().initLife = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt (addHpByKanni);


		//Location by map id
		if (mapId == 1) {
			prefab.transform.position = new Vector2 (-65, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 2) {
			prefab.transform.position = new Vector2 (-50, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;
		} else if (mapId == 3) {
			prefab.transform.position = new Vector2 (-35, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;

		} else if (mapId == 4) {
			prefab.transform.position = new Vector2 (-20, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;

		} else if (mapId == 5) {
			prefab.transform.position = new Vector2 (-5, 16);
			prefab.GetComponent<LineLocation>().nowLine = 1;

		} else if (mapId == 6) {
			prefab.transform.position = new Vector2 (-65, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;

		} else if (mapId == 7) {
			prefab.transform.position = new Vector2 (-50, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;

		} else if (mapId == 8) {
			prefab.transform.position = new Vector2 (-35, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;

		} else if (mapId == 9) {
			prefab.transform.position = new Vector2 (-20, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;

		} else if (mapId == 10) {
			prefab.transform.position = new Vector2 (-5, 8);
			prefab.GetComponent<LineLocation>().nowLine = 2;

		} else if (mapId == 11) {
			prefab.transform.position = new Vector2 (-65, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;

		} else if (mapId == 12) {
			prefab.transform.position = new Vector2 (-50, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;

		} else if (mapId == 13) {
			prefab.transform.position = new Vector2 (-35, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;

		} else if (mapId == 14) {
			prefab.transform.position = new Vector2 (-20, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;

		} else if (mapId == 15) {
			prefab.transform.position = new Vector2 (-5, 0);
			prefab.GetComponent<LineLocation>().nowLine = 3;

		} else if (mapId == 16) {
			prefab.transform.position = new Vector2 (-65, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;

		} else if (mapId == 17) {
			prefab.transform.position = new Vector2 (-40, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;

		} else if (mapId == 18) {
			prefab.transform.position = new Vector2 (-35, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;

		} else if (mapId == 19) {
			prefab.transform.position = new Vector2 (-20, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;

		} else if (mapId == 20) {
			prefab.transform.position = new Vector2 (-5, -8);
			prefab.GetComponent<LineLocation>().nowLine = 4;

		} else if (mapId == 21) {
			prefab.transform.position = new Vector2 (-65, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;

		} else if (mapId == 22) {
			prefab.transform.position = new Vector2 (-50, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;

		} else if (mapId == 23) {
			prefab.transform.position = new Vector2 (-45, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;

		} else if (mapId == 24) {
			prefab.transform.position = new Vector2 (-20, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;

		} else if (mapId == 25) {
			prefab.transform.position = new Vector2 (-5, -16);
			prefab.GetComponent<LineLocation>().nowLine = 5;

		}

		int adjHpWithKahou = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt (addHpByKanni);
		prefab.GetComponent<PlayerHP> ().life = adjHpWithKahou;

		if (prefab.GetComponent<PlayerAttack> ()) {
			prefab.GetComponent<PlayerAttack> ().attack = adjAtk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt (addAtkByKanni);
			prefab.GetComponent<Homing> ().speed = spd + int.Parse(KahouStatusArray[3]);
		} else {
			if (heisyu == "TP") {
				prefab.GetComponent<AttackLong> ().attack = 5 * (adjAtk + int.Parse (KahouStatusArray [0]) + Mathf.FloorToInt (addAtkByKanni));
			} else if (heisyu == "YM") {
				prefab.GetComponent<AttackLong> ().attack = 3 * (adjAtk + int.Parse (KahouStatusArray [0]) + Mathf.FloorToInt (addAtkByKanni));
			}
			prefab.GetComponent<HomingLong> ().speed = spd + int.Parse(KahouStatusArray[3]);
		}

		prefab.GetComponent<PlayerHP>().dfc = adjDfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt (addDfcByKanni) + boubi;



		//Soudaisyo
		if (busyoId == soudaisyo) {
			prefab.GetComponent<PlayerHP> ().taisyo = true;
		}


		/*Child Instantiate*/
		//set child object
		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]);
		ch_status = ch_status * 10;

		string ch_path = "Prefabs/Player/" + ch_type;

		float y1 = 3.0f;
		float y2 = 3.0f;
		float y3 = 3.0f;
		float y4 = 3.0f;

		for(int i = 1; i <= ch_num; i++){
			//Make Relationship
			GameObject ch_prefab = Instantiate(Resources.Load (ch_path)) as GameObject;
			ch_prefab.transform.parent = prefab.transform;
			ch_prefab.name = ch_prefab.name + "_" + prefab.name;

			//Sashimono Making
			string sashimono_path = "Prefabs/Sashimono/" + busyoId;
			GameObject sashimono = Instantiate(Resources.Load (sashimono_path)) as GameObject;
			sashimono.transform.parent = ch_prefab.transform;
			sashimono.transform.localScale = new Vector2(0.3f,0.3f);


			if(ch_type == "YR"){
				sashimono.transform.localPosition = new Vector2(-1,0.6f);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 3,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;

				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 6,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;

				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 9,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;

				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 12,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "KB"){
				sashimono.transform.localPosition = new Vector2(-0.5f,1);
				//Location
				if(i<6){

					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "TP"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "YM"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}


			//Jyosyu Handling
			JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku ();
			float addHei = (float)jyosyuHei.GetJyosyuHeiryoku (busyoId.ToString());
			float addTotalHei = ch_status + addHei;

			StatusGet sts = new StatusGet();
			int atkDfc = (int)sts.getChAtkDfc((int)ch_status, adjHpWithKahou);

			ch_prefab.GetComponent<PlayerHP>().life = addTotalHei;
			if(ch_prefab.GetComponent<PlayerAttack> ()){
				ch_prefab.GetComponent<PlayerAttack> ().attack = atkDfc;
			}else{
				if (ch_type == "TP") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 5;
				} else if (ch_type == "YM") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 3;
				}
			}
			ch_prefab.GetComponent<PlayerHP>().dfc = atkDfc;
		}

	}
Example #12
0
	/*make engun instance*/
	public void makeEngunInstance(int busyoId, int hp, int atk, int dfc, int spd, ArrayList senpouArray, string busyoName, int ch_num, int ch_lv){
		
		/*Parent Instantiate*/
		string path = "Prefabs/Player/" + busyoId;
		GameObject prefab = Instantiate(Resources.Load (path)) as GameObject;
		
		//Senpou Script Parametor
		prefab.GetComponent<SenpouController>().senpouId = (int)senpouArray[0];
		prefab.GetComponent<SenpouController>().senpouTyp = senpouArray[1].ToString();
		prefab.GetComponent<SenpouController>().senpouName = senpouArray[2].ToString();
		prefab.GetComponent<SenpouController>().senpouEach = (float)senpouArray[4];
		prefab.GetComponent<SenpouController>().senpouRatio = (float)senpouArray[5];
		prefab.GetComponent<SenpouController>().senpouTerm = (float)senpouArray[6];
		prefab.GetComponent<SenpouController>().senpouStatus = (int)senpouArray[7];
		prefab.GetComponent<SenpouController>().senpouLv = (int)senpouArray[8];

		//Engun Flg
		prefab.GetComponent<Kunkou> ().engunFlg = true;

		/*Player Status Setting*/
		//parametor setting
		int adjHp = hp*100;
		int adjAtk = atk * 10;
		int adjDfc = dfc * 10;

		//Busyo Detail Info [Name & HP Bar]
		string dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayer";
		GameObject dtl = Instantiate(Resources.Load (dtlPath)) as GameObject;
		dtl.transform.parent = prefab.transform;
		
		//Name
		GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;
		nameLabel.GetComponent<TextMesh> ().text = busyoName;
		
		//HP Bar
		GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;
		minHpBar.GetComponent<BusyoHPBar>().initLife = adjHp;
		
		//Location by map id
		prefab.transform.position = new Vector2 (-20, -16);
		prefab.GetComponent<LineLocation>().nowLine = 5;

		//heisyu
		BusyoInfoGet info = new BusyoInfoGet ();
		string ch_type = info.getHeisyu (busyoId);
		
		prefab.GetComponent<PlayerHP> ().life = adjHp;		
		if (prefab.GetComponent<PlayerAttack> ()) {
			prefab.GetComponent<PlayerAttack> ().attack = adjAtk;
			prefab.GetComponent<Homing> ().speed = spd;
		} else {
			if (ch_type == "TP") {
				prefab.GetComponent<AttackLong> ().attack = 5* adjAtk;
			} else if (ch_type == "YM") {
				prefab.GetComponent<AttackLong> ().attack = 3 * adjAtk;
			}
			prefab.GetComponent<HomingLong> ().speed = spd;
		}
		prefab.GetComponent<PlayerHP>().dfc = adjDfc;
		
		/*Child Instantiate*/
		//set child object
		Entity_lvch_mst lvMst  = Resources.Load ("Data/lvch_mst") as Entity_lvch_mst;
		int startline = 0;
		if(ch_type=="KB"){
			startline = 0;
		}else if(ch_type=="YR"){
			startline = 1;
		}else if(ch_type=="TP"){
			startline = 2;
		}else if(ch_type=="YM"){
			startline = 3;
		}
		object stslst = lvMst.param[startline];
		Type t = stslst.GetType();
		String param = "lv" + ch_lv.ToString();
		FieldInfo f = t.GetField(param);
		int sts = (int)f.GetValue(stslst);

		float ch_status = (float)sts;
		ch_status = ch_status * 10;

		string ch_path = "Prefabs/Player/" + ch_type;
		
		float y1 = 3.0f;
		float y2 = 3.0f;
		float y3 = 3.0f;
		float y4 = 3.0f;
		
		for(int i = 1; i <= ch_num; i++){
			//Make Relationship
			GameObject ch_prefab = Instantiate(Resources.Load (ch_path)) as GameObject;
			ch_prefab.transform.parent = prefab.transform;
			ch_prefab.name = ch_prefab.name + "_" + prefab.name;
			
			//Sashimono Making
			string sashimono_path = "Prefabs/Sashimono/" + busyoId;
			GameObject sashimono = Instantiate(Resources.Load (sashimono_path)) as GameObject;
			sashimono.transform.parent = ch_prefab.transform;
			sashimono.transform.localScale = new Vector2(0.3f,0.3f);
			
			
			if(ch_type == "YR"){
				sashimono.transform.localPosition = new Vector2(-1,0.6f);
				//Location
				if(i<6){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 3,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 6,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 9,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 12,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "KB"){
				sashimono.transform.localPosition = new Vector2(-0.5f,1);
				//Location
				if(i<6){
					
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "TP"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}else if(ch_type == "YM"){
				sashimono.transform.localPosition = new Vector2(-0.8f,0.5f);
				//Location
				if(i<6){
					
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 4,prefab.transform.position.y + y1);
					y1 = y1 - 1.5f;
					
				}else if(5<i && i<11){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 7,prefab.transform.position.y + y2);
					y2 = y2 - 1.5f;
					
				}else if(10<i && i<16){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 10,prefab.transform.position.y + y3);
					y3 = y3 - 1.5f;
					
				}else if(15<i && i<21){
					ch_prefab.transform.position =  new Vector2(prefab.transform.position.x - 13,prefab.transform.position.y + y4);
					y4 = y4 - 1.5f;
				}
			}

			//Status
			StatusGet stsScript = new StatusGet();
			int atkDfc = (int)stsScript.getChAtkDfc((int)ch_status, adjHp);

			ch_prefab.GetComponent<PlayerHP>().life = ch_status;
			if(ch_prefab.GetComponent<PlayerAttack> ()){
				ch_prefab.GetComponent<PlayerAttack> ().attack = atkDfc;
			}else{
				if (ch_type == "TP") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 5;
				} else if (ch_type == "YM") {
					ch_prefab.GetComponent<AttackLong> ().attack = atkDfc * 3;
				}
			}
			ch_prefab.GetComponent<PlayerHP>().dfc = atkDfc;
		}
		
	}
Example #13
0
    public void makeKaisenInstance(int busyoId, int shipId, int mapId, int hp, int atk, int dfc, int spd, ArrayList senpouArray, string busyoName, int soudaisyo, int boubi, bool engunFlg, int engunButaiQty, int engunButaiSts)
    {
        /*Parent Instantiate*/
        string     path   = "Prefabs/Kaisen/" + shipId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();

        //Senpou Script Parametor
        StatusGet senpouScript = new StatusGet();
        bool      shipFlg      = senpouScript.getSenpouShipFlg((int)senpouArray[0]);

        if (shipFlg)
        {
            prefab.GetComponent <SenpouController>().senpouId     = (int)senpouArray[0];
            prefab.GetComponent <SenpouController>().senpouTyp    = senpouArray[1].ToString();
            prefab.GetComponent <SenpouController>().senpouName   = senpouArray[2].ToString();
            prefab.GetComponent <SenpouController>().senpouEach   = (float)senpouArray[4];
            prefab.GetComponent <SenpouController>().senpouRatio  = (float)senpouArray[5];
            prefab.GetComponent <SenpouController>().senpouTerm   = (float)senpouArray[6];
            prefab.GetComponent <SenpouController>().senpouStatus = (int)senpouArray[7];
            prefab.GetComponent <SenpouController>().senpouLv     = (int)senpouArray[8];
            //Serihu
            Entity_serihu_mst serihuMst = Resources.Load("Data/serihu_mst") as Entity_serihu_mst;
            string            serihu    = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsgEng;
            }
            else
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsg;
            }
            prefab.GetComponent <SenpouController>().senpouSerihu = serihu;
        }
        else
        {
            Destroy(prefab.GetComponent <SenpouController>());
        }



        /*Player Status Setting*/
        //parametor setting
        int adjHp  = hp * 100;
        int adjAtk = atk * 10;
        int adjDfc = dfc * 10;

        //Kahou Adjustment
        float addAtkByKanni = 0;
        float addHpByKanni  = 0;
        float addDfcByKanni = 0;

        //Jyosyu Adjustment
        float addJyosyuHei = 0;

        string[] KahouStatusArray = null;
        if (!engunFlg)
        {
            KahouStatusGet kahouSts = new KahouStatusGet();
            KahouStatusArray = kahouSts.getKahouForStatus(busyoId.ToString(), adjHp, adjAtk, adjDfc, spd);
            //Kanni Adjustment
            string kanniTmp = "kanni" + busyoId;

            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int kanniId = PlayerPrefs.GetInt(kanniTmp);
                if (kanniId != 0)
                {
                    Kanni kanni = new Kanni();

                    //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;
                    }
                }
            }
            JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku();
            addJyosyuHei = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId.ToString());
        }

        //Busyo Detail Info [Name & HP Bar]
        string dtlPath = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayerEng";
        }
        else
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayer";
        }
        GameObject dtl = Instantiate(Resources.Load(dtlPath)) as GameObject;

        dtl.transform.SetParent(prefab.transform);
        dtl.transform.localPosition = new Vector3(0, 1, -1);
        dtl.transform.localScale    = new Vector3(1, 1, 0);
        dtl.name = "BusyoDtlPlayer";
        //Name
        GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;

        nameLabel.GetComponent <TextMesh>().text = busyoName;
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            nameLabel.GetComponent <TextMesh>().fontSize = 40;
        }
        //Location by map id
        if (mapId == 1)
        {
            prefab.transform.position = new Vector2(-65, 16);
        }
        else if (mapId == 2)
        {
            prefab.transform.position = new Vector2(-50, 16);
        }
        else if (mapId == 3)
        {
            prefab.transform.position = new Vector2(-35, 16);
        }
        else if (mapId == 4)
        {
            prefab.transform.position = new Vector2(-20, 16);
        }
        else if (mapId == 5)
        {
            prefab.transform.position = new Vector2(-5, 16);
        }
        else if (mapId == 6)
        {
            prefab.transform.position = new Vector2(-65, 8);
        }
        else if (mapId == 7)
        {
            prefab.transform.position = new Vector2(-50, 8);
        }
        else if (mapId == 8)
        {
            prefab.transform.position = new Vector2(-35, 8);
        }
        else if (mapId == 9)
        {
            prefab.transform.position = new Vector2(-20, 8);
        }
        else if (mapId == 10)
        {
            prefab.transform.position = new Vector2(-5, 8);
        }
        else if (mapId == 11)
        {
            prefab.transform.position = new Vector2(-65, 0);
        }
        else if (mapId == 12)
        {
            prefab.transform.position = new Vector2(-50, 0);
        }
        else if (mapId == 13)
        {
            prefab.transform.position = new Vector2(-35, 0);
        }
        else if (mapId == 14)
        {
            prefab.transform.position = new Vector2(-20, 0);
        }
        else if (mapId == 15)
        {
            prefab.transform.position = new Vector2(-5, 0);
        }
        else if (mapId == 16)
        {
            prefab.transform.position = new Vector2(-65, -8);
        }
        else if (mapId == 17)
        {
            prefab.transform.position = new Vector2(-50, -8);
        }
        else if (mapId == 18)
        {
            prefab.transform.position = new Vector2(-35, -8);
        }
        else if (mapId == 19)
        {
            prefab.transform.position = new Vector2(-20, -8);
        }
        else if (mapId == 20)
        {
            prefab.transform.position = new Vector2(-5, -8);
        }
        else if (mapId == 21)
        {
            prefab.transform.position = new Vector2(-65, -16);
        }
        else if (mapId == 22)
        {
            prefab.transform.position = new Vector2(-50, -16);
        }
        else if (mapId == 23)
        {
            prefab.transform.position = new Vector2(-45, -16);
        }
        else if (mapId == 24)
        {
            prefab.transform.position = new Vector2(-20, -16);
        }
        else if (mapId == 25)
        {
            prefab.transform.position = new Vector2(-5, -16);
        }

        //Add Senryoku
        if (!engunFlg)
        {
            string key = "addSenryokuSlot" + mapId;
            if (PlayerPrefs.HasKey(key))
            {
                string        atkDfc          = PlayerPrefs.GetString(key);
                List <string> atkDfcList      = new List <string>();
                char[]        delimiterChars2 = { ',' };
                atkDfcList = new List <string>(atkDfc.Split(delimiterChars2));
                adjAtk     = adjAtk + int.Parse(atkDfcList[0]);
                adjDfc     = adjDfc + int.Parse(atkDfcList[1]);
            }
        }

        //Adjust Status & Set
        int   adjHpWithKahou  = 0;
        float adjAtkWithKahou = 0;
        float adjDfcWithKahou = 0;
        float adjSpd          = 0;

        if (!engunFlg)
        {
            adjHpWithKahou  = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt(addHpByKanni);
            adjAtkWithKahou = (float)adjAtk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt(addAtkByKanni);
            adjDfcWithKahou = (float)adjDfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt(addDfcByKanni) + boubi;
            adjSpd          = ((float)spd + float.Parse(KahouStatusArray[3])) / 10;
        }
        else
        {
            adjHpWithKahou  = adjHp;
            adjAtkWithKahou = (float)adjAtk;
            adjDfcWithKahou = (float)adjDfc;
            adjSpd          = (float)spd / 10;
        }

        if (shipId == 1)
        {
            adjHpWithKahou  = adjHpWithKahou * 2;
            adjDfcWithKahou = adjDfcWithKahou * 2;
            adjSpd          = Mathf.FloorToInt((float)adjSpd * 0.5f);
        }
        else if (shipId == 2)
        {
            adjHpWithKahou  = Mathf.FloorToInt((float)adjHpWithKahou * 1.5f);
            adjDfcWithKahou = Mathf.FloorToInt((float)adjDfcWithKahou * 1.5f);
            adjSpd          = Mathf.FloorToInt((float)adjSpd * 0.6f);
        }
        else if (shipId == 3)
        {
            adjSpd = Mathf.FloorToInt((float)adjSpd * 0.8f);
        }
        if (adjSpd <= 0)
        {
            adjSpd = 1;
        }
        GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;

        minHpBar.GetComponent <BusyoHPBar>().initLife = adjHpWithKahou;
        prefab.GetComponent <PlayerHP>().life         = adjHpWithKahou + addJyosyuHei;
        prefab.GetComponent <PlayerAttack>().attack   = adjAtkWithKahou;
        prefab.GetComponent <UnitMover>().speed       = adjSpd;
        prefab.GetComponent <UnitMover>().heisyu      = "SHP";
        prefab.GetComponent <PlayerHP>().dfc          = adjDfcWithKahou;


        //Soudaisyo
        if (!engunFlg)
        {
            if (busyoId == soudaisyo)
            {
                prefab.GetComponent <PlayerHP>().taisyo = true;
            }
        }

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(prefab, "SHP");


        /*Child Instantiate*/
        //set child object
        int   ch_num    = 0;
        int   ch_lv     = 0;
        float ch_status = 0;

        if (!engunFlg)
        {
            string heiId   = "hei" + busyoId.ToString();
            string chParam = PlayerPrefs.GetString(heiId, "0");
            if (chParam == "0")
            {
                StatusGet statusScript  = new StatusGet();
                string    chParamHeisyu = statusScript.getHeisyu(busyoId);
                chParam = chParamHeisyu + ":1:1:1";
                PlayerPrefs.SetString(heiId, chParam);
                PlayerPrefs.Flush();
            }

            char[]   delimiterChars = { ':' };
            string[] ch_list        = chParam.Split(delimiterChars);
            ch_num    = int.Parse(ch_list[1]);
            ch_lv     = int.Parse(ch_list[2]);
            ch_status = float.Parse(ch_list[3]);
        }
        else
        {
            ch_num    = engunButaiQty;
            ch_status = engunButaiSts;
        }
        ch_status = ch_status * 10;

        string ch_path = "Prefabs/Kaisen/3";

        for (int i = 1; i <= ch_num; i++)
        {
            //Make Relationship
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.transform.SetParent(prefab.transform);
            ch_prefab.name = "Child" + i.ToString();
            ch_prefab.transform.localScale = new Vector2(0.7f, 0.7f);
            ch_prefab.GetComponent <SpriteRenderer>().sortingOrder = 3;
            ch_prefab.tag = "PlayerChild";

            Destroy(ch_prefab.GetComponent <Rigidbody2D>());
            Destroy(ch_prefab.GetComponent <UnitMover>());
            Destroy(ch_prefab.GetComponent <Kunkou>());
            Destroy(ch_prefab.GetComponent <PolygonCollider2D>());
            Destroy(ch_prefab.GetComponent <PlayerHP>());
            Destroy(ch_prefab.GetComponent <PlayerAttack>());
            Destroy(ch_prefab.GetComponent <SenpouController>());

            //Location
            if (i == 1)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 0);
            }
            else if (i == 2)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 0.5f);
            }
            else if (i == 3)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -0.5f);
            }
            else if (i == 4)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 1.0f);
            }
            else if (i == 5)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -1.0f);
            }
            else if (i == 6)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 0.5f);
            }
            else if (i == 7)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -0.5f);
            }
            else if (i == 8)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 1.0f);
            }
            else if (i == 9)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -1.0f);
            }
            else if (i == 10)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 0);
            }
            else if (i == 11)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 0.5f);
            }
            else if (i == 12)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -0.5f);
            }
            else if (i == 13)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 1.0f);
            }
            else if (i == 14)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -1.0f);
            }
            else if (i == 15)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, 1.5f);
            }
            else if (i == 16)
            {
                ch_prefab.transform.localPosition = new Vector2(1.8f, -1.5f);
            }
            else if (i == 17)
            {
                ch_prefab.transform.localPosition = new Vector2(0, 1.5f);
            }
            else if (i == 18)
            {
                ch_prefab.transform.localPosition = new Vector2(0, -1.5f);
            }
            else if (i == 19)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, 1.5f);
            }
            else if (i == 20)
            {
                ch_prefab.transform.localPosition = new Vector2(-1.8f, -1.5f);
            }


            StatusGet sts    = new StatusGet();
            int       atkDfc = (int)sts.getChAtkDfc((int)ch_status, adjHpWithKahou);

            if (i == 1)
            {
                //Child Qty
                prefab.GetComponent <PlayerHP>().childQty = ch_num;

                //Child Unit HP
                prefab.GetComponent <PlayerHP>().childHP = (int)ch_status;

                //Attack
                prefab.GetComponent <PlayerAttack>().attack = prefab.GetComponent <PlayerAttack>().attack + (ch_num * atkDfc);

                //Dfc
                prefab.GetComponent <PlayerHP>().dfc = prefab.GetComponent <PlayerHP>().dfc + (ch_num * atkDfc);
            }
        }
    }
Example #14
0
    public void makeInstance(int busyoId, int mapId, int hp, int atk, int dfc, int spd, ArrayList senpouArray, string busyoName, int soudaisyo, int boubi)
    {
        /*Parent Instantiate*/
        string     path   = "Prefabs/Player/" + busyoId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();

        //Senpou Script Parametor
        StatusGet senpouScript = new StatusGet();
        bool      onlySeaFlg   = senpouScript.getSenpouOnlySeaFlg((int)senpouArray[0]);

        if (!onlySeaFlg)
        {
            prefab.GetComponent <SenpouController>().senpouId     = (int)senpouArray[0];
            prefab.GetComponent <SenpouController>().senpouTyp    = senpouArray[1].ToString();
            prefab.GetComponent <SenpouController>().senpouName   = senpouArray[2].ToString();
            prefab.GetComponent <SenpouController>().senpouEach   = (float)senpouArray[4];
            prefab.GetComponent <SenpouController>().senpouRatio  = (float)senpouArray[5];
            prefab.GetComponent <SenpouController>().senpouTerm   = (float)senpouArray[6];
            prefab.GetComponent <SenpouController>().senpouStatus = (int)senpouArray[7];
            prefab.GetComponent <SenpouController>().senpouLv     = (int)senpouArray[8];

            //Serihu
            Entity_serihu_mst serihuMst = Resources.Load("Data/serihu_mst") as Entity_serihu_mst;
            string            serihu    = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsgEng;
            }
            else
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsg;
            }
            prefab.GetComponent <SenpouController>().senpouSerihu = serihu;
        }
        else
        {
            Destroy(prefab.GetComponent <SenpouController>());
        }



        /*Player Status Setting*/
        //parametor setting
        int adjHp  = hp * 100;
        int adjAtk = atk * 10;
        int adjDfc = dfc * 10;

        //heisyu
        BusyoInfoGet info   = new BusyoInfoGet();
        string       heisyu = info.getHeisyu(busyoId);

        JyosyuHeiryoku jyosyuHei    = new JyosyuHeiryoku();
        float          addJyosyuHei = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId.ToString());

        //Kahou Adjustment
        KahouStatusGet kahouSts = new KahouStatusGet();

        string[] KahouStatusArray = kahouSts.getKahouForStatus(busyoId.ToString(), adjHp, adjAtk, adjDfc, spd);

        //Kanni Adjustment
        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();

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


        //Busyo Detail Info [Name & HP Bar]
        string dtlPath = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayerEng";
        }
        else
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayer";
        }
        GameObject dtl = Instantiate(Resources.Load(dtlPath)) as GameObject;

        dtl.transform.SetParent(prefab.transform);
        dtl.transform.localPosition = new Vector3(0, 1.3f, -1);
        dtl.transform.localScale    = new Vector3(1.3f, 1.3f, 0);
        dtl.name = "BusyoDtlPlayer";

        //Name
        GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;

        nameLabel.GetComponent <TextMesh> ().text = busyoName;


        //Location by map id
        if (mapId == 1)
        {
            prefab.transform.position = new Vector2(-65, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 2)
        {
            prefab.transform.position = new Vector2(-50, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 3)
        {
            prefab.transform.position = new Vector2(-35, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 4)
        {
            prefab.transform.position = new Vector2(-20, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 5)
        {
            prefab.transform.position = new Vector2(-5, 16);
            prefab.GetComponent <LineLocation>().nowLine = 1;
        }
        else if (mapId == 6)
        {
            prefab.transform.position = new Vector2(-65, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 7)
        {
            prefab.transform.position = new Vector2(-50, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 8)
        {
            prefab.transform.position = new Vector2(-35, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 9)
        {
            prefab.transform.position = new Vector2(-20, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 10)
        {
            prefab.transform.position = new Vector2(-5, 8);
            prefab.GetComponent <LineLocation>().nowLine = 2;
        }
        else if (mapId == 11)
        {
            prefab.transform.position = new Vector2(-65, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 12)
        {
            prefab.transform.position = new Vector2(-50, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 13)
        {
            prefab.transform.position = new Vector2(-35, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 14)
        {
            prefab.transform.position = new Vector2(-20, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 15)
        {
            prefab.transform.position = new Vector2(-5, 0);
            prefab.GetComponent <LineLocation>().nowLine = 3;
        }
        else if (mapId == 16)
        {
            prefab.transform.position = new Vector2(-65, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 17)
        {
            prefab.transform.position = new Vector2(-50, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 18)
        {
            prefab.transform.position = new Vector2(-35, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 19)
        {
            prefab.transform.position = new Vector2(-20, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 20)
        {
            prefab.transform.position = new Vector2(-5, -8);
            prefab.GetComponent <LineLocation>().nowLine = 4;
        }
        else if (mapId == 21)
        {
            prefab.transform.position = new Vector2(-65, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 22)
        {
            prefab.transform.position = new Vector2(-50, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 23)
        {
            prefab.transform.position = new Vector2(-45, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 24)
        {
            prefab.transform.position = new Vector2(-20, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }
        else if (mapId == 25)
        {
            prefab.transform.position = new Vector2(-5, -16);
            prefab.GetComponent <LineLocation>().nowLine = 5;
        }

        //Add Senryoku
        string key = "addSenryokuSlot" + mapId;

        if (PlayerPrefs.HasKey(key))
        {
            string        atkDfc          = PlayerPrefs.GetString(key);
            List <string> atkDfcList      = new List <string> ();
            char[]        delimiterChars2 = { ',' };
            atkDfcList = new List <string> (atkDfc.Split(delimiterChars2));
            adjAtk     = adjAtk + int.Parse(atkDfcList [0]);
            adjDfc     = adjDfc + int.Parse(atkDfcList [1]);
        }


        //HP Status
        int        adjHpWithKahou = adjHp + int.Parse(KahouStatusArray[1]) + Mathf.FloorToInt(addHpByKanni);
        GameObject minHpBar       = dtl.transform.FindChild("MinHpBar").gameObject;

        minHpBar.GetComponent <BusyoHPBar>().initLife = adjHpWithKahou;
        prefab.GetComponent <PlayerHP> ().life        = adjHpWithKahou + addJyosyuHei;


        //spd adjust
        float adjSpd = ((float)spd + float.Parse(KahouStatusArray[3])) / 10;

        prefab.GetComponent <UnitMover> ().heisyu = heisyu;
        if (prefab.GetComponent <PlayerAttack> ())
        {
            prefab.GetComponent <PlayerAttack> ().attack = adjAtk + int.Parse(KahouStatusArray[0]) + Mathf.FloorToInt(addAtkByKanni);
            prefab.GetComponent <UnitMover>().speed      = adjSpd;
        }
        else
        {
            if (heisyu == "TP")
            {
                prefab.GetComponent <AttackLong> ().attack = 5 * (adjAtk + int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni));
            }
            else if (heisyu == "YM")
            {
                prefab.GetComponent <AttackLong> ().attack = 3 * (adjAtk + int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni));
            }
            prefab.GetComponent <UnitMover> ().speed = adjSpd;
        }

        prefab.GetComponent <PlayerHP>().dfc = adjDfc + int.Parse(KahouStatusArray[2]) + Mathf.FloorToInt(addDfcByKanni) + boubi;



        //Soudaisyo
        if (busyoId == soudaisyo)
        {
            prefab.GetComponent <PlayerHP> ().taisyo = true;
        }

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(prefab, heisyu);


        /*Child Instantiate*/
        //set child object
        string heiId           = "hei" + busyoId.ToString();
        string chParam         = "";
        bool   tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg");

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialKassen")
        {
            chParam = PlayerPrefs.GetString(heiId, "0");
        }
        else
        {
            //retry tutorial
            if (busyoId == 19)
            {
                chParam = "TP:2:1:1";
            }
            else
            {
                StatusGet statusScript  = new StatusGet();
                string    chParamHeisyu = statusScript.getHeisyu(busyoId);
                chParam = chParamHeisyu + ":1:1:1";
            }
        }

        if (chParam == "0")
        {
            StatusGet statusScript  = new StatusGet();
            string    chParamHeisyu = statusScript.getHeisyu(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]);

        ch_status = ch_status * 10;

        string ch_path = "Prefabs/Player/" + ch_type;

        float y1 = 3.0f;
        float y2 = 3.0f;
        float y3 = 3.0f;
        float y4 = 3.0f;

        for (int i = 1; i <= ch_num; i++)
        {
            //Make Relationship
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.transform.parent = prefab.transform;
            ch_prefab.name             = "Child" + i.ToString();

            //Sashimono Making
            string     sashimono_path = "Prefabs/Sashimono/" + busyoId;
            GameObject sashimono      = Instantiate(Resources.Load(sashimono_path)) as GameObject;
            sashimono.transform.parent     = ch_prefab.transform;
            sashimono.transform.localScale = new Vector2(0.3f, 0.3f);


            if (ch_type == "YR")
            {
                sashimono.transform.localPosition = new Vector2(-1, 0.6f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 3, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 6, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 9, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 12, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "KB")
            {
                sashimono.transform.localPosition = new Vector2(-0.5f, 1);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "TP")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "YM")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }



            StatusGet sts    = new StatusGet();
            int       atkDfc = (int)sts.getChAtkDfc((int)ch_status, adjHpWithKahou);

            if (i == 1)
            {
                //Child Qty
                prefab.GetComponent <PlayerHP>().childQty = ch_num;

                //Child Unit HP
                float addTotalHei = ch_status;
                prefab.GetComponent <PlayerHP>().childHP = (int)addTotalHei;

                //Attack
                if (ch_type == "YM")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 3;
                    prefab.GetComponent <Heisyu> ().atk             = atkDfc * 3;
                }
                else if (ch_type == "TP")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 5;
                    prefab.GetComponent <Heisyu> ().atk             = atkDfc * 5;
                }
                else
                {
                    prefab.GetComponent <PlayerAttack> ().attack = prefab.GetComponent <PlayerAttack> ().attack + (ch_num * atkDfc);
                    prefab.GetComponent <Heisyu> ().atk          = atkDfc;
                }

                //Dfc
                prefab.GetComponent <PlayerHP> ().dfc = prefab.GetComponent <PlayerHP> ().dfc + (ch_num * atkDfc);
                prefab.GetComponent <Heisyu> ().dfc   = atkDfc;
            }
        }
    }
Example #15
0
    /*make engun instance*/
    public void makeEngunInstance(int busyoId, int hp, int atk, int dfc, int spd, ArrayList senpouArray, string busyoName, int ch_num, int ch_lv)
    {
        /*Parent Instantiate*/
        string     path   = "Prefabs/Player/" + busyoId;
        GameObject prefab = Instantiate(Resources.Load(path)) as GameObject;

        prefab.name = busyoId.ToString();

        //Senpou Script Parametor
        StatusGet senpouScript = new StatusGet();
        bool      onlySeaFlg   = senpouScript.getSenpouOnlySeaFlg((int)senpouArray[0]);

        if (!onlySeaFlg)
        {
            prefab.GetComponent <SenpouController>().senpouId     = (int)senpouArray[0];
            prefab.GetComponent <SenpouController>().senpouTyp    = senpouArray[1].ToString();
            prefab.GetComponent <SenpouController>().senpouName   = senpouArray[2].ToString();
            prefab.GetComponent <SenpouController>().senpouEach   = (float)senpouArray[4];
            prefab.GetComponent <SenpouController>().senpouRatio  = (float)senpouArray[5];
            prefab.GetComponent <SenpouController>().senpouTerm   = (float)senpouArray[6];
            prefab.GetComponent <SenpouController>().senpouStatus = (int)senpouArray[7];
            prefab.GetComponent <SenpouController>().senpouLv     = (int)senpouArray[8];

            //Serihu
            Entity_serihu_mst serihuMst = Resources.Load("Data/serihu_mst") as Entity_serihu_mst;
            string            serihu    = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsgEng;
            }
            else
            {
                serihu = serihuMst.param[busyoId - 1].senpouMsg;
            }
            prefab.GetComponent <SenpouController>().senpouSerihu = serihu;
        }
        else
        {
            Destroy(prefab.GetComponent <SenpouController>());
        }

        //Engun Flg
        prefab.GetComponent <Kunkou> ().engunFlg = true;



        /*Player Status Setting*/
        //parametor setting
        int adjHp  = hp * 100;
        int adjAtk = atk * 10;
        int adjDfc = dfc * 10;

        //Busyo Detail Info [Name & HP Bar]
        string dtlPath = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayerEng";
        }
        else
        {
            dtlPath = "Prefabs/BusyoDtl/BusyoDtlPlayer";
        }
        GameObject dtl = Instantiate(Resources.Load(dtlPath)) as GameObject;

        dtl.transform.SetParent(prefab.transform);
        dtl.transform.localPosition = new Vector3(0, 1.3f, -1);
        dtl.transform.localScale    = new Vector3(1.3f, 1.3f, 0);
        dtl.name = "BusyoDtlPlayer";
        //Name
        GameObject nameLabel = dtl.transform.FindChild("NameLabel").gameObject;

        nameLabel.GetComponent <TextMesh> ().text = busyoName;

        //HP Bar
        GameObject minHpBar = dtl.transform.FindChild("MinHpBar").gameObject;

        minHpBar.GetComponent <BusyoHPBar>().initLife = adjHp;

        //Location by map id
        prefab.transform.position = new Vector2(-20, -16);
        prefab.GetComponent <LineLocation>().nowLine = 5;

        //heisyu
        BusyoInfoGet info    = new BusyoInfoGet();
        string       ch_type = info.getHeisyu(busyoId);

        prefab.GetComponent <PlayerHP> ().life = adjHp;

        //adjust spd
        float adjSpd = (float)spd / 10;


        if (prefab.GetComponent <PlayerAttack> ())
        {
            prefab.GetComponent <PlayerAttack> ().attack = adjAtk;
            prefab.GetComponent <UnitMover> ().speed     = adjSpd;
        }
        else
        {
            if (ch_type == "TP")
            {
                prefab.GetComponent <AttackLong> ().attack = 5 * adjAtk;
            }
            else if (ch_type == "YM")
            {
                prefab.GetComponent <AttackLong> ().attack = 3 * adjAtk;
            }
            prefab.GetComponent <UnitMover> ().speed = adjSpd;
        }
        prefab.GetComponent <PlayerHP>().dfc     = adjDfc;
        prefab.GetComponent <UnitMover>().heisyu = ch_type;

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(prefab, ch_type);



        /*Child Instantiate*/
        //set child object
        Entity_lvch_mst lvMst     = Resources.Load("Data/lvch_mst") as Entity_lvch_mst;
        int             startline = 0;

        if (ch_type == "KB")
        {
            startline = 0;
        }
        else if (ch_type == "YR")
        {
            startline = 1;
        }
        else if (ch_type == "TP")
        {
            startline = 2;
        }
        else if (ch_type == "YM")
        {
            startline = 3;
        }
        object    stslst = lvMst.param[startline];
        Type      t      = stslst.GetType();
        String    param  = "lv" + ch_lv.ToString();
        FieldInfo f      = t.GetField(param);
        int       sts    = (int)f.GetValue(stslst);

        float ch_status = (float)sts;

        ch_status = ch_status * 10;

        string ch_path = "Prefabs/Player/" + ch_type;

        float y1 = 3.0f;
        float y2 = 3.0f;
        float y3 = 3.0f;
        float y4 = 3.0f;

        for (int i = 1; i <= ch_num; i++)
        {
            //Make Relationship
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.transform.parent = prefab.transform;
            ch_prefab.name             = "Child" + i.ToString();

            //Sashimono Making
            string     sashimono_path = "Prefabs/Sashimono/" + busyoId;
            GameObject sashimono      = Instantiate(Resources.Load(sashimono_path)) as GameObject;
            sashimono.transform.parent     = ch_prefab.transform;
            sashimono.transform.localScale = new Vector2(0.3f, 0.3f);


            if (ch_type == "YR")
            {
                sashimono.transform.localPosition = new Vector2(-1, 0.6f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 3, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 6, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 9, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 12, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "KB")
            {
                sashimono.transform.localPosition = new Vector2(-0.5f, 1);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "TP")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }
            else if (ch_type == "YM")
            {
                sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                //Location
                if (i < 6)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 4, prefab.transform.position.y + y1);
                    y1 = y1 - 1.5f;
                }
                else if (5 < i && i < 11)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 7, prefab.transform.position.y + y2);
                    y2 = y2 - 1.5f;
                }
                else if (10 < i && i < 16)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 10, prefab.transform.position.y + y3);
                    y3 = y3 - 1.5f;
                }
                else if (15 < i && i < 21)
                {
                    ch_prefab.transform.position = new Vector2(prefab.transform.position.x - 13, prefab.transform.position.y + y4);
                    y4 = y4 - 1.5f;
                }
            }

            //Status
            if (i == 1)
            {
                //Child Qty
                prefab.GetComponent <PlayerHP>().childQty = ch_num;

                //Child Unit HP
                prefab.GetComponent <PlayerHP>().childHP = (int)ch_status;

                StatusGet stsScript = new StatusGet();
                int       atkDfc    = (int)stsScript.getChAtkDfc((int)ch_status, adjHp);

                //Attack
                if (ch_type == "YM")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 3;
                }
                else if (ch_type == "TP")
                {
                    prefab.GetComponent <AttackLong> ().childAttack = atkDfc * 5;
                }
                else
                {
                    prefab.GetComponent <PlayerAttack> ().attack = prefab.GetComponent <PlayerAttack> ().attack + (ch_num * atkDfc);
                }

                //Dfc
                prefab.GetComponent <PlayerHP> ().dfc = prefab.GetComponent <PlayerHP> ().dfc + (ch_num * atkDfc);
            }
        }
    }