示例#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);
        }
    }