Пример #1
0
    public void cyouryaku(int heiQty, string cyouryakuTmp)
    {
        //Cyouryaku Target
        int counter = 0;

        foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("EnemyChild"))
        {
            //Param
            EnemyHP enemyHpScript     = obs.transform.parent.GetComponent <EnemyHP>();
            Heisyu  enemyAtkDfcScript = obs.transform.parent.GetComponent <Heisyu>();
            float   child_hp          = enemyHpScript.childHP;
            float   child_atk         = enemyAtkDfcScript.atk;
            float   child_dfc         = enemyAtkDfcScript.dfc;
            string  heisyu            = enemyAtkDfcScript.heisyu;
            Vector2 child_location    = obs.transform.position;

            string busyoId   = obs.transform.parent.name;
            float  child_spd = 0;
            if (obs.transform.parent.GetComponent <Homing> ())
            {
                child_spd = obs.transform.parent.GetComponent <Homing> ().speed;
            }
            else
            {
                child_spd = obs.transform.parent.GetComponent <HomingLong> ().speed;
            }

            //Reduce Qty & Status
            enemyHpScript.childQty = enemyHpScript.childQty - 1;
            if (enemyAtkDfcScript.heisyu == "YR" || enemyAtkDfcScript.heisyu == "KB" || enemyAtkDfcScript.heisyu == "SHP")
            {
                obs.transform.parent.GetComponent <EnemyAttack> ().attack = obs.transform.parent.GetComponent <EnemyAttack> ().attack - child_atk;
                obs.transform.parent.GetComponent <EnemyHP> ().dfc        = obs.transform.parent.GetComponent <EnemyHP> ().dfc - child_dfc;
            }
            else
            {
                obs.transform.parent.GetComponent <AttackLong> ().childAttack = obs.transform.parent.GetComponent <AttackLong> ().childAttack - child_atk;
                obs.transform.parent.GetComponent <EnemyHP> ().dfc            = obs.transform.parent.GetComponent <EnemyHP> ().dfc - child_dfc;
            }

            //Delete
            Destroy(obs.gameObject);

            //Create
            string ch_path = "";
            if (Application.loadedLevelName == "kaisen")
            {
                ch_path = "Prefabs/Kaisen/3";
            }
            else
            {
                ch_path = "Prefabs/Player/hukuhei" + heisyu;
            }
            GameObject ch_prefab = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.name = "hukuhei";

            if (Application.loadedLevelName != "kaisen")
            {
                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 (heisyu == "YR")
                {
                    sashimono.transform.localPosition = new Vector2(-1, 0.6f);
                    ch_prefab.transform.position      = child_location;
                }
                else if (heisyu == "KB")
                {
                    sashimono.transform.localPosition = new Vector2(-0.5f, 1);
                    ch_prefab.transform.position      = child_location;
                }
                else if (heisyu == "TP")
                {
                    sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                    ch_prefab.transform.position      = child_location;
                }
                else if (heisyu == "YM")
                {
                    sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
                    ch_prefab.transform.position      = child_location;
                }

                ch_prefab.GetComponent <PlayerHP> ().life = child_hp;
                if (ch_prefab.GetComponent <PlayerAttack> ())
                {
                    ch_prefab.GetComponent <PlayerAttack> ().attack = child_atk;
                }
                else
                {
                    ch_prefab.GetComponent <AttackLong> ().attack = child_atk;
                }
                ch_prefab.GetComponent <PlayerHP> ().dfc = child_dfc;

                if (ch_prefab.GetComponent <Homing> () != null)
                {
                    ch_prefab.GetComponent <Homing> ().speed = child_spd;
                }
                else if (ch_prefab.GetComponent <HomingLong> () != null)
                {
                    ch_prefab.GetComponent <HomingLong> ().speed = child_spd;
                }
            }
            else
            {
                //kaisen
                if (ch_prefab.GetComponent <UnitMover>())
                {
                    Destroy(ch_prefab.GetComponent <UnitMover>());
                }
                Destroy(ch_prefab.GetComponent <Kunkou>());
                Destroy(ch_prefab.GetComponent <SenpouController>());
                ch_prefab.AddComponent <Homing>();
                ch_prefab.GetComponent <PlayerHP>().life       = child_hp;
                ch_prefab.GetComponent <PlayerAttack>().attack = child_atk;
                ch_prefab.GetComponent <PlayerHP>().dfc        = child_dfc;
                ch_prefab.GetComponent <Homing>().speed        = child_spd;
                ch_prefab.transform.position = child_location;
            }

            //SE
            AudioController audio = new AudioController();
            audio.addComponentMoveAttack(ch_prefab, heisyu);

            //Effect
            string     effect_path = "Prefabs/Effect/betray";
            GameObject effect      = Instantiate(Resources.Load(effect_path)) as GameObject;
            effect.transform.SetParent(ch_prefab.transform);
            effect.transform.localScale    = new Vector2(1, 1);
            effect.transform.localPosition = new Vector2(0, 0);


            //Counter
            counter = counter + 1;

            //Break
            if (counter == heiQty)
            {
                break;
            }
        }



        //Delete Data
        string cyoryakuHst = PlayerPrefs.GetString("cyouryaku");

        char[]        delimiterChars  = { ',' };
        List <string> cyoryakuHstList = new List <string> ();

        if (cyoryakuHst != null && cyoryakuHst != "")
        {
            if (cyoryakuHst.Contains(","))
            {
                cyoryakuHstList = new List <string> (cyoryakuHst.Split(delimiterChars));
            }
            else
            {
                cyoryakuHstList.Add(cyoryakuHst);
            }
        }
        cyoryakuHstList.Remove(cyouryakuTmp);

        string newCyoryakuHst = "";

        for (int i = 0; i < cyoryakuHstList.Count; i++)
        {
            if (i == 0)
            {
                newCyoryakuHst = cyoryakuHstList[i];
            }
            else
            {
                newCyoryakuHst = newCyoryakuHst + "," + cyoryakuHstList[i];
            }
        }
        PlayerPrefs.SetString("cyouryaku", newCyoryakuHst);
        PlayerPrefs.DeleteKey(cyouryakuTmp);
        PlayerPrefs.Flush();


        Message msg = new Message();

        msg.makeKassenMessage(msg.getMessage(132));
    }
Пример #2
0
    public void betrayEnemy(GameObject obs)
    {
        EnemyHP enemyHpScript     = obs.transform.parent.GetComponent <EnemyHP> ();
        Heisyu  enemyAtkDfcScript = obs.transform.parent.GetComponent <Heisyu> ();
        float   child_hp          = enemyHpScript.childHP;
        float   child_atk         = enemyAtkDfcScript.atk;
        float   child_dfc         = enemyAtkDfcScript.dfc;
        string  heisyu            = enemyAtkDfcScript.heisyu;
        Vector2 child_location    = obs.transform.position;

        string busyoId   = obs.transform.parent.name;
        float  child_spd = 0;

        if (obs.transform.parent.GetComponent <Homing> ())
        {
            child_spd = obs.transform.parent.GetComponent <Homing> ().speed;
        }
        else
        {
            child_spd = obs.transform.parent.GetComponent <HomingLong> ().speed;
        }

        //Reduce Qty & Status
        enemyHpScript.childQty = enemyHpScript.childQty - 1;
        if (enemyAtkDfcScript.heisyu == "YR" || enemyAtkDfcScript.heisyu == "KB" || enemyAtkDfcScript.heisyu == "SHP")
        {
            obs.transform.parent.GetComponent <EnemyAttack> ().attack = obs.transform.parent.GetComponent <EnemyAttack> ().attack - child_atk;
            obs.transform.parent.GetComponent <EnemyHP> ().dfc        = obs.transform.parent.GetComponent <EnemyHP> ().dfc - child_dfc;
        }
        else
        {
            obs.transform.parent.GetComponent <AttackLong> ().childAttack = obs.transform.parent.GetComponent <AttackLong> ().childAttack - child_atk;
            obs.transform.parent.GetComponent <EnemyHP> ().dfc            = obs.transform.parent.GetComponent <EnemyHP> ().dfc - child_dfc;
        }

        //Delete
        Destroy(obs.gameObject);

        //Create
        GameObject ch_prefab = null;
        GameObject sashimono = null;

        if (heisyu == "SHP")
        {
            string ch_path = "Prefabs/Kaisen/3";
            ch_prefab      = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.name = "hukuhei";
            ch_prefab.AddComponent <Homing>();
            Destroy(ch_prefab.GetComponent <UnitMover>());
            Destroy(ch_prefab.GetComponent <SenpouController>());
            Destroy(ch_prefab.GetComponent <Kunkou>());
        }
        else
        {
            string ch_path = "Prefabs/Player/hukuhei" + heisyu;
            ch_prefab      = Instantiate(Resources.Load(ch_path)) as GameObject;
            ch_prefab.name = "hukuhei";
            string sashimono_path = "Prefabs/Sashimono/" + busyoId;
            sashimono = Instantiate(Resources.Load(sashimono_path)) as GameObject;
            sashimono.transform.parent     = ch_prefab.transform;
            sashimono.transform.localScale = new Vector2(0.3f, 0.3f);
        }

        if (heisyu == "YR")
        {
            sashimono.transform.localPosition = new Vector2(-1, 0.6f);
            ch_prefab.transform.position      = child_location;
        }
        else if (heisyu == "KB")
        {
            sashimono.transform.localPosition = new Vector2(-0.5f, 1);
            ch_prefab.transform.position      = child_location;
        }
        else if (heisyu == "TP")
        {
            sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
            ch_prefab.transform.position      = child_location;
        }
        else if (heisyu == "YM")
        {
            sashimono.transform.localPosition = new Vector2(-0.8f, 0.5f);
            ch_prefab.transform.position      = child_location;
        }
        else if (heisyu == "SHP")
        {
            ch_prefab.transform.position = child_location;
        }

        ch_prefab.GetComponent <PlayerHP> ().life = child_hp;
        if (ch_prefab.GetComponent <PlayerAttack> ())
        {
            ch_prefab.GetComponent <PlayerAttack> ().attack = child_atk;
        }
        else
        {
            ch_prefab.GetComponent <AttackLong> ().attack = child_atk;
        }
        ch_prefab.GetComponent <PlayerHP> ().dfc = child_dfc;

        if (ch_prefab.GetComponent <Homing> () != null)
        {
            ch_prefab.GetComponent <Homing> ().speed = child_spd;
        }
        else if (ch_prefab.GetComponent <HomingLong> () != null)
        {
            ch_prefab.GetComponent <HomingLong> ().speed = child_spd;
        }

        //SE
        AudioController audio = new AudioController();

        audio.addComponentMoveAttack(ch_prefab, heisyu);


        //Effect
        string     effect_path = "Prefabs/Effect/betray";
        GameObject effect      = Instantiate(Resources.Load(effect_path)) as GameObject;

        effect.transform.SetParent(ch_prefab.transform);
        effect.transform.localScale    = new Vector2(1, 1);
        effect.transform.localPosition = new Vector2(0, 0);
    }