void do_barrel_block(Collider2D col)
    {
        Debug.Log("do_barrel_block " + move_direction);
        bool isStop = false;

        if (move_direction == 1)
        {
            if ((col.gameObject.transform.position.x == transform.position.x) && (col.gameObject.transform.position.y > transform.position.y))
            {
                isStop             = true;
                transform.position = col.gameObject.transform.position + Vector3.down;
            }
            else
            {
                isStop = false;
            }
        }
        else if (move_direction == 2)
        {
            if ((col.gameObject.transform.position.x == transform.position.x) && (col.gameObject.transform.position.y < transform.position.y))
            {
                isStop             = true;
                transform.position = col.gameObject.transform.position + Vector3.up;
                Debug.Log("down");
            }
            else
            {
                isStop = false;
            }
        }
        else if (move_direction == 3)
        {
            if ((col.gameObject.transform.position.y == transform.position.y) && (col.gameObject.transform.position.x < transform.position.x))
            {
                isStop             = true;
                transform.position = col.gameObject.transform.position + Vector3.right;
            }
            else
            {
                isStop = false;
            }
        }
        else if (move_direction == 4)
        {
            if ((col.gameObject.transform.position.y == transform.position.y) && (col.gameObject.transform.position.x > transform.position.x))
            {
                isStop             = true;
                transform.position = col.gameObject.transform.position + Vector3.left;
            }
            else
            {
                isStop = false;
            }
        }

        if (isStop == true)
        {
            barrel_controller b_c = col.gameObject.GetComponent <barrel_controller>();
            b_c.move(move_direction);

            /*if(move_direction == 2){
             *                  move_direction = 0;
             *          }else{
             *                  move_direction = 2;
             *          }*/
            move_direction = 0;
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //		checkCollider (col);

        if (my_tag == LEFT_SPRING_TAG)
        {
            if ((col.gameObject.transform.position.y <= transform.position.y + 0.1 || col.gameObject.transform.position.y >= transform.position.y - 0.1) && col.gameObject.transform.position.x > transform.position.x + 0.5)
            {
                if (col.gameObject.tag == Common_data.PANDA_TAG)
                {
                    panda_controller p_c = col.gameObject.GetComponent <panda_controller>();

                    player.SetTrigger(IS_TRIGER);

                    col.gameObject.transform.position = transform.position + new Vector3(1.5f, 0f, 0f);
                    p_c.move(4);
                    Debug.Log("panda");
                }
                else if (col.gameObject.tag == Common_data.BARREL_BLOCK_TAG)
                {
                    player.SetTrigger(IS_TRIGER);
                    barrel_controller b_c = col.gameObject.GetComponent <barrel_controller>();
                    col.gameObject.transform.position = transform.position + new Vector3(1.5f, 0f, 0f);
                    b_c.move(4);
                }
            }
        }
        else if (my_tag == RIGHT_SPRING_TAG)
        {
            if ((col.gameObject.transform.position.y <= transform.position.y + 0.1 || col.gameObject.transform.position.y >= transform.position.y - 0.1) && col.gameObject.transform.position.x < transform.position.x - 0.5)
            {
                if (col.gameObject.tag == Common_data.PANDA_TAG)
                {
                    panda_controller p_c = col.gameObject.GetComponent <panda_controller>();

                    player.SetTrigger(IS_TRIGER);

                    col.gameObject.transform.position = transform.position + new Vector3(-1.5f, 0f, 0f);
                    p_c.move(3);
                    Debug.Log("panda");
                }
                else if (col.gameObject.tag == Common_data.BARREL_BLOCK_TAG)
                {
                    player.SetTrigger(IS_TRIGER);
                    barrel_controller b_c = col.gameObject.GetComponent <barrel_controller>();
                    col.gameObject.transform.position = transform.position + new Vector3(-1.5f, 0f, 0f);
                    b_c.move(3);
                }
            }
        }
        else if (my_tag == DOWN_SPRING_TAG)
        {
            if ((col.gameObject.transform.position.x <= transform.position.x + 0.1 || col.gameObject.transform.position.x >= transform.position.x - 0.1) && col.gameObject.transform.position.y > transform.position.y + 0.5)
            {
                if (col.gameObject.tag == Common_data.PANDA_TAG)
                {
                    panda_controller p_c = col.gameObject.GetComponent <panda_controller>();

                    player.SetTrigger(IS_TRIGER);

                    col.gameObject.transform.position = transform.position + new Vector3(0f, 1.5f, 0f);
                    p_c.move(1);
                    Debug.Log("panda");
                }
                else if (col.gameObject.tag == Common_data.BARREL_BLOCK_TAG)
                {
                    player.SetTrigger(IS_TRIGER);
                    barrel_controller b_c = col.gameObject.GetComponent <barrel_controller>();
                    col.gameObject.transform.position = transform.position + new Vector3(0f, 1.5f, 0f);
                    b_c.move(1);
                }
            }
        }
        else if (my_tag == UP_SPRING_TAG)
        {
            if ((col.gameObject.transform.position.x <= transform.position.x + 0.1 || col.gameObject.transform.position.x >= transform.position.x - 0.1) && col.gameObject.transform.position.y < transform.position.y - 0.5)
            {
                if (col.gameObject.tag == Common_data.PANDA_TAG)
                {
                    panda_controller p_c = col.gameObject.GetComponent <panda_controller>();

                    player.SetTrigger(IS_TRIGER);

                    col.gameObject.transform.position = transform.position + new Vector3(0f, -1.5f, 0f);
                    p_c.move(2);
                    Debug.Log("panda");
                }
                else if (col.gameObject.tag == Common_data.BARREL_BLOCK_TAG)
                {
                    player.SetTrigger(IS_TRIGER);
                    barrel_controller b_c = col.gameObject.GetComponent <barrel_controller>();
                    col.gameObject.transform.position = transform.position + new Vector3(0f, -1.5f, 0f);
                    b_c.move(2);
                }
            }
        }
    }
Exemplo n.º 3
0
    public void move(int direction)
    {
        bool is_run = false;

        if (is_done == 1)
        {
            move_direction = 0;
            is_done        = 0;
            return;
        }

        if (move_direction != 0)
        {
            return;
        }

        Collider2D col = getCollider_street(direction);

        if (col == null)
        {
            return;
        }

        Debug.Log("direction is " + move_direction + ",tag is " + col.gameObject.tag);



        street_line s_l = col.gameObject.GetComponent <street_line>();

        is_run = s_l.is_run(direction);



        if (is_run)
        {
            col = getCollider(direction);
            if (col != null)
            {
                if (col.tag == "fire_block")
                {
                    return;
                }

                if (col.tag == Common_data.ICE_BLOCK_TAG)
                {
                    ice_controller i_c = col.gameObject.GetComponent <ice_controller>();
                    if (i_c.cur_state == 0)
                    {
                        i_c.attact();
                        return;
                    }

                    i_c.attact();
                }
                else if (col.tag == Common_data.BARREL_BLOCK_TAG)
                {
                    barrel_controller barrel = col.gameObject.GetComponent <barrel_controller> ();
                    barrel.move(move_direction);
                    return;
                }
                else
                {
                    return;
                }
            }

            bool       is_cross = true;
            Collider2D enemy    = getEnemyCollider(direction);
            if (enemy != null)
            {
                if (enemy.gameObject.tag == Common_data.NOR_ENEMY_TAG)
                {
                    Debug.Log("enemy tag is " + enemy.gameObject.tag);
                    nor_enemy_controller enc = enemy.gameObject.GetComponent <nor_enemy_controller> ();
                    is_cross = enc.is_cross(direction);
                }
            }
            if (is_cross)
            {
                move_direction = direction;
                x = transform.position.x;
                y = transform.position.y;
            }
        }
    }