예제 #1
0
    //PLの攻撃によるダメージ
    public void addDamage(int dmgVal)
    {
        mLife -= dmgVal;

        GameObject obj = Instantiate(Resources.Load("damageEffect"), transform.position + new Vector3(0.0f, 1.0f, 0.0f), Quaternion.identity) as GameObject;

        obj.GetComponent <damageEffect> ().damage = dmgVal;

        GameObject sceneMng = GameObject.Find("SceneMng");

        sceneMng.GetComponent <sceneMng> ().addScore(dmgVal);

        if (mLife <= 0)
        {
            mItemNum = 1;
            status plStatus = GameObject.Find("PlayerStatus").GetComponent <status> ();
            plStatus.setLastKill(ExpType);
            if (plStatus.getLastKillExp() == ExpType)
            {
                mItemNum += plStatus.getKillStreak();
            }

            mItemNum = Mathf.Clamp(mItemNum, 1, 10);

            Debug.Log("ItemNum=" + mItemNum);
            for (int i = 0; i < mItemNum; i++)
            {
                GameObject item = Instantiate(Resources.Load("ItemExp"), transform.position + new Vector3(0.1f * Random.Range(-1.0f, 1.0f), 0.01f * i, 0.0f), Quaternion.identity) as GameObject;
                item.transform.parent = GameObject.Find("Items").gameObject.transform;
                item.GetComponent <item> ().ExpType = ExpType;
            }

            Destroy(this.gameObject);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!status)
        {
            return;
        }

        if (status.getLastKillExp() != lastType)
        {
            lastType = status.getLastKillExp();
            Destroy(effect);
            foreach (var trail in Trails)
            {
                trail.SetActive(false);
            }

            switch (lastType)
            {
            case item.eExpType.Jump:

                effect = Instantiate(Effects[1], transform.position, Quaternion.identity) as GameObject;
                Trails[1].SetActive(true);
                break;

            case item.eExpType.MeleePow:

                effect = Instantiate(Effects[0], transform.position, Quaternion.identity) as GameObject;
                Trails[0].SetActive(true);
                break;

            case item.eExpType.ShotPow:

                effect = Instantiate(Effects[2], transform.position, Quaternion.identity) as GameObject;
                Trails[2].SetActive(true);
                break;
            }

            effect.transform.parent = this.transform;
        }
    }