Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (m_bObj.m_activeFlag)
        {
            if (col.transform.tag == "AttackArea")
            {
                AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_objDestroy"), Camera.main.transform.position);

                m_bObj.StartCoroutine("Break");

                GameObject eff = Instantiate(Resources.Load <GameObject>("Prefabs/Effect/EF_Broken"), transform.position, Quaternion.identity);
                Destroy(eff, 1);


                //スコア加算
                manager.AddScore(m_bObj.m_myPoint);

                if (!player.IsSpecailNow())
                {
                    rush.AddGage(0.1f);
                }
            }
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        m_attackAreaTransform.position = m_trans.position + new Vector3(0, -0.8f, 0);

        switch (state)
        {
        case State.Idle:

            m_trans.Translate(new Vector2(Input.GetAxisRaw("Horizontal") * m_horizontalSpeed, 0));

            //zx連打で下降
            if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.X))
            {
                AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_mogaku"), Camera.main.transform.position);

                m_resuleSpeed += m_HunbariNum;
                m_manager.AddScore(1);
            }

            //エンターでパンチ
            if (Input.GetKeyDown(KeyCode.Return))
            {
                //音

                if (m_rushGage.IsSpecialAttack())
                {
                    AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_final_attack"), Camera.main.transform.position);

                    state = State.Special;
                    m_specialEffect.SetActive(true);
                    m_myCollider.enabled = false;
                }
                else
                {
                    AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_middle_punch1"), Camera.main.transform.position);

                    m_resuleSpeed += m_HunbariNum * 3;
                    state          = State.Attack;
                }

                m_anim.SetBool("Attack", true);
                m_anim.SetBool("Idle", false);
            }
            break;

        case State.Attack:

            m_trans.Translate(new Vector2(Input.GetAxisRaw("Horizontal") * m_horizontalSpeed, 0));

            m_Time += Time.deltaTime;

            if (m_Time > 0.1f)
            {
                m_attackArea.SetActive(true);
            }

            if (m_Time > m_attackTime)
            {
                state = State.Idle;

                m_attackArea.SetActive(false);
                m_anim.SetBool("Attack", false);
                m_anim.SetBool("Idle", true);

                m_Time = 0;
            }

            break;

        case State.Special:

            //左右移動二倍速
            m_trans.Translate(new Vector2(Input.GetAxisRaw("Horizontal") * (m_horizontalSpeed * 2), 0));

            m_Time += Time.deltaTime;

            m_rushGage.AddGage(-(1 / m_specailAttackTime) * Time.deltaTime);

            m_resuleSpeed -= 0.1f;

            if (m_Time > 0.1f)
            {
                m_attackArea.SetActive(true);
                m_attackAreaTransform.position   = m_trans.position;
                m_attackAreaTransform.localScale = new Vector3(10, 3, 1);
            }

            if (m_Time > m_specailAttackTime)
            {
                state = State.Idle;
                m_specialEffect.SetActive(false);

                //攻撃範囲を元に戻す
                m_attackAreaTransform.position   = m_attackAreaPos;
                m_attackAreaTransform.localScale = m_attackAreaScale;

                m_myCollider.enabled = true;

                m_rushGage.SetGage(0);

                m_attackArea.SetActive(false);
                m_anim.SetBool("Attack", false);
                m_anim.SetBool("Idle", true);

                m_Time = 0;
            }

            break;

        case State.Damage:

            //zx連打で復帰を早める
            if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.X))
            {
                AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_mogaku"), Camera.main.transform.position);
                m_Time -= 0.1f;
            }

            m_Time -= Time.deltaTime;

            if (m_Time <= 0)
            {
                m_anim.SetBool("Damage", false);
                m_anim.SetBool("Idle", true);

                m_Time = 0;

                state = State.Idle;
            }

            break;

        case State.Dead:

            m_Time += Time.deltaTime;

            if (m_Time > 1f)
            {
                Debug.Log("in");
                AppManager.Instance.m_fade.StartFade(new FadeOut(), Color.black, 1.0f);

                Invoke("GameEnd", 1);

                //糞みたいな再発防止策
                m_Time = -100;
            }



            break;
        }

        if (m_trans.position.y > DeadLine && state != State.Dead)
        {
            //ゲームオーバー
            m_anim.SetBool("Idle", false);
            m_anim.SetBool("Attack", false);
            m_anim.SetBool("Special", false);
            m_anim.SetBool("Damage", false);
            m_specialEffect.SetActive(false);
            m_attackArea.SetActive(false);

            m_myCollider.enabled = false;

            AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("Sounds/SE/SE_Dead"), Camera.main.transform.position);

            m_anim.SetTrigger("Dead");

            //リザルト遷移用
            m_Time = 0;


            state = State.Dead;
        }

        Vacuum();

        Clamp();
    }