void do_move_block(Collider2D col)
    {
//		if(move_direction == 1){
//			move_block_controller m_b_c = col.gameObject.GetComponent<move_block_controller> ();
//			m_b_c.move (1);
//			if (m_b_c.move_direction != 0) {
//				return;
//			}
//
//		}else if(move_direction == 2){
//			move_block_controller m_b_c = col.gameObject.GetComponent<move_block_controller> ();
//			m_b_c.move (2);
//			if (m_b_c.move_direction != 0) {
//				return;
//			}
//		}else if(move_direction == 3){
//
//			move_block_controller m_b_c = col.gameObject.GetComponent<move_block_controller> ();
//			m_b_c.move (3);
//			if (m_b_c.move_direction != 0) {
//				return;
//			}
//		}else if(move_direction == 4){
//			move_block_controller m_b_c = col.gameObject.GetComponent<move_block_controller> ();
//			m_b_c.move (4);
//			if (m_b_c.move_direction != 0) {
//				return;
//			}
//
//		}
        move_block_controller m_b_c = col.gameObject.GetComponent <move_block_controller> ();

        m_b_c.move(move_direction);
        if (m_b_c.move_direction != 0)
        {
            return;
        }
        do_normal_block(col);
    }
Esempio n. 2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (move_direction == 0)
        {
            if (col.gameObject.tag == Common_data.PANDA_TAG)
            {
                initActionState();
                player.SetTrigger("dead_begin");
                panda_controller p_c = col.gameObject.GetComponent <panda_controller> ();
                move_direction = p_c.move_direction;
                load_sound(SOUND_TYPE.hit);
                GameObject explode_instance = (GameObject)Instantiate(explode, transform.position, explode.transform.rotation);
                Debug.Log("panda move dead move is " + p_c.move_direction);
            }
            else if (col.gameObject.tag == Common_data.BARREL_BLOCK_TAG)
            {
                initActionState();
                player.SetTrigger("dead_begin");
                barrel_controller b_c = col.gameObject.GetComponent <barrel_controller> ();
                move_direction = b_c.move_direction;
                load_sound(SOUND_TYPE.hit);
                GameObject explode_instance = (GameObject)Instantiate(explode, transform.position, explode.transform.rotation);
            }
            else if (col.gameObject.tag == Common_data.MOVE_BLOCK_TAG)
            {
                initActionState();

                move_block_controller m_b_c = col.gameObject.GetComponent <move_block_controller> ();
                last_move = m_b_c.move_direction;
                player.SetInteger(DEAD_MOVE, 2);
                move_direction = -1;
                dead_position  = transform.position;
                GameObject explode_instance = (GameObject)Instantiate(explode, transform.position, explode.transform.rotation);
                dead();
                Destroy(this.gameObject.GetComponent <BoxCollider2D>());
            }
        }
        else
        {
            Debug.Log("dead tag is " + col.gameObject.tag);
            if (col.tag == Common_data.BARELL_COLLIDER_TAG || col.tag == Common_data.TRAP_COLLIDER_TAG)
            {
                return;
            }
            if (move_direction == 1)
            {
                if (col.tag == Common_data.UP_BLOCK_TAG || col.tag == Common_data.LEFT_BLOCK_TAG || col.tag == Common_data.RIGHT_BLOCK_TAG || col.tag == Common_data.STREET_TAG)
                {
                    return;
                }
            }
            else if (move_direction == 2)
            {
                if (col.tag == Common_data.DOWN_BLOCK_TAG || col.tag == Common_data.LEFT_BLOCK_TAG || col.tag == Common_data.RIGHT_BLOCK_TAG || col.tag == Common_data.STREET_TAG)
                {
                    return;
                }
            }
            else if (move_direction == 3)
            {
                if (col.tag == Common_data.UP_BLOCK_TAG || col.tag == Common_data.LEFT_BLOCK_TAG || col.tag == Common_data.DOWN_BLOCK_TAG || col.tag == Common_data.STREET_TAG)
                {
                    return;
                }
            }
            else if (move_direction == 4)
            {
                if (col.tag == Common_data.UP_BLOCK_TAG || col.tag == Common_data.DOWN_BLOCK_TAG || col.tag == Common_data.RIGHT_BLOCK_TAG || col.tag == Common_data.STREET_TAG)
                {
                    return;
                }
            }


            initActionState();
            player.SetInteger(DEAD_MOVE, 2);
            last_move      = move_direction;
            move_direction = -1;
            dead_position  = transform.position;
            GameObject explode_instance = (GameObject)Instantiate(explode, dead_position, explode.transform.rotation);
            dead();
            Destroy(this.gameObject.GetComponent <BoxCollider2D>());
        }
    }