Esempio n. 1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     nowDir = chara.transform.position - gameObject.transform.position;
     if (nowDir.x > 0)
     {
         gameObject.transform.localScale = new Vector3(-0.4f, 0.4f, 0.35f);
     }
     else
     {
         gameObject.transform.localScale = new Vector3(0.4f, 0.4f, 0.35f);
     }
     nowDir.Normalize();
     if (state == m_AI.findV)
     {
         gameObject.transform.Translate(nowDir * speed * Time.deltaTime);
     }
     if (state == m_AI.isHit)
     {
         hitTC -= Time.deltaTime;
         if (hitTC < 0)
         {
             state = m_AI.isDie;
         }
     }
     if (state == m_AI.isDie)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 2
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        Vector3 hitBack = new Vector3(0, 0, 0);

        if (coll.gameObject.tag == "bullet")
        {
            soundControl.MonsterHit();
            blood--;
            if (blood == 0 && state == m_AI.findV)
            {
                state = m_AI.isHit;
                soundControl.PlayChange();
                m_Animator.SetBool(isFissionID, true);
                m_collider1.enabled = false;
                m_collider2.enabled = false;
                return;
            }
            //Debug.Log ("bullet coll");
            if (coll.gameObject.name == "bulletDown(Clone)")
            {
                hitBack = new Vector3(0, -1, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletUp(Clone)")
            {
                hitBack = new Vector3(0, 1, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletRight(Clone)")
            {
                hitBack = new Vector3(1, 0, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletLeft(Clone)")
            {
                hitBack = new Vector3(-1, 0, 0);
                Debug.Log("this");
            }
            gameObject.transform.position = gameObject.transform.position + hitBack * 0.3f;
            coll.gameObject.GetComponent <BoxCollider2D> ().enabled = false;
        }
    }
Esempio n. 3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     nowDir = new Vector3(0, 0, 0) - gameObject.transform.position;
     nowDir.Normalize();
     if (state == m_AI.findV)
     {
         gameObject.transform.Translate(nowDir * speed * Time.deltaTime);
     }
     if (state == m_AI.isHit)
     {
         hitTC -= Time.deltaTime;
         if (hitTC < 0)
         {
             state = m_AI.isDie;
         }
     }
     if (state == m_AI.isDie)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 4
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        Vector3 hitBack = new Vector3(0, 0, 0);

        if (coll.gameObject.tag == "bullet")
        {
            soundControl.MonsterHit();
            blood--;
            Debug.Log(blood);
            if (blood == 0)
            {
                state = m_AI.isHit;
                m_Animator.SetBool(isDieID, true);
                //m_collider.enabled =false;
                return;
            }
            if (coll.gameObject.name == "bulletDown(Clone)")
            {
                hitBack = new Vector3(0, -1, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletUp(Clone)")
            {
                hitBack = new Vector3(0, 1, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletRight(Clone)")
            {
                hitBack = new Vector3(1, 0, 0);
                Debug.Log("this");
            }
            else if (coll.gameObject.name == "bulletLeft(Clone)")
            {
                hitBack = new Vector3(-1, 0, 0);
                Debug.Log("this");
            }
            coll.gameObject.GetComponent <BoxCollider2D> ().enabled = false;
            gameObject.transform.position = gameObject.transform.position + hitBack * 0.2f;
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void FixedUpdate()
    {
//		Vector3 distance = chara.transform.position - gameObject.transform.position;
//		if (distance.magnitude < 3) {
//			state = m_AI.isHit;
//			m_Animator.SetBool (isFissionID, true);
//			m_collider.enabled =false;
//		}

        nowDir = new Vector3(0, 0, 0) - gameObject.transform.position;
        nowDir.Normalize();
        if (state == m_AI.findV)
        {
            gameObject.transform.Translate(nowDir * speed * Time.deltaTime);
        }
        if (state == m_AI.isHit)
        {
            hitTC -= Time.deltaTime;
            if (hitTC < 0)
            {
                state = m_AI.isDie;
            }
        }
        if (state == m_AI.isDie)
        {
            tmpMonster = Instantiate(monster1, gameObject.transform.position, Quaternion.identity);
            if (tmpMonster.transform.position.x > 0)
            {
                tmpMonster.transform.localScale = new Vector3(-0.4f, 0.4f, 0.35f);
            }
            else
            {
                tmpMonster.transform.localScale = new Vector3(0.4f, 0.4f, 0.35f);
            }
            Destroy(gameObject);
        }
    }