示例#1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (move_direction == 0)
        {
            Debug.Log("dead tag _1is " + col.tag);
            Debug.Log("dead psotion is " + col.transform.position.x + "," + col.transform.position.y);
            if (col.gameObject.tag == Common_data.PANDA_TAG)
            {
                load_sound(SOUND_TYPE.hit);
                bar.enabled = false;
                player.CrossFade("dead_begin", 0);
                panda_controller p_c = col.gameObject.GetComponent <panda_controller> ();
                move_direction = p_c.move_direction;
                GameObject explode_instance = (GameObject)Instantiate(explode, my_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)
            {
                player.CrossFade("dead_begin", 0);
                load_sound(SOUND_TYPE.hit);
                bar.enabled = false;
                barrel_controller b_c = col.gameObject.GetComponent <barrel_controller> ();
                move_direction = b_c.move_direction;
                GameObject explode_instance = (GameObject)Instantiate(explode, my_transform.position, explode.transform.rotation);
            }
            else if (col.gameObject.tag == Common_data.MOVE_BLOCK_TAG)
            {
                player.CrossFade("dead_begin", 0);

                if (stand_direction == 1)
                {
                    last_move = 2;
                }
                else if (stand_direction == 2)
                {
                    last_move = 1;
                }
                else if (stand_direction == 3)
                {
                    last_move = 4;
                }
                else if (stand_direction == 4)
                {
                    last_move = 3;
                }
                player.CrossFade("dead_end", 0);
                move_direction = -1;
                dead_position  = my_transform.position;
                GameObject explode_instance = (GameObject)Instantiate(explode, my_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)
            {
                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;
                }
            }


            player.CrossFade("dead_end", 0);
            last_move      = move_direction;
            move_direction = -1;
            dead_position  = my_transform.position;
            GameObject explode_instance = (GameObject)Instantiate(explode, dead_position, explode.transform.rotation);
            dead();

            Destroy(this.gameObject.GetComponent <BoxCollider2D>());
        }
    }
示例#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);
                }
            }
        }
    }
    void OnTriggerEnter2D(Collider2D col)
    {
        if (move_direction == 0)
        {
            if (col.gameObject.tag == Common_data.PANDA_TAG)
            {
                panda_controller p_c = col.gameObject.GetComponent <panda_controller> ();

                Debug.Log("panda collider");
                if (p_c.move_direction == 0)
                {
                    p_c.dead();
                    Instantiate(explode, p_c.gameObject.transform.position, explode.transform.rotation);
                    return;
                }
                load_sound(SOUND_TYPE.hit);
                move_direction = p_c.move_direction;
                initActionState();
                player.CrossFade("dead_begin", 0);

                Vector3 d = new Vector3();
                if (move_direction == 1)
                {
                    d = Vector3.up;
                }
                else if (move_direction == 2)
                {
                    d = Vector3.down;
                }
                else if (move_direction == 3)
                {
                    d = Vector3.left;
                }
                else if (move_direction == 4)
                {
                    d = Vector3.right;
                }


                my_transform.position = col.gameObject.transform.position + d;
                GameObject explode_instance = (GameObject)Instantiate(explode, my_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.CrossFade("dead_begin", 0);
                barrel_controller b_c = col.gameObject.GetComponent <barrel_controller> ();
                move_direction = b_c.move_direction;
                load_sound(SOUND_TYPE.hit);
                Vector3 d = new Vector3();
                if (move_direction == 1)
                {
                    d = Vector3.up;
                }
                else if (move_direction == 2)
                {
                    d = Vector3.down;
                }
                else if (move_direction == 3)
                {
                    d = Vector3.left;
                }
                else if (move_direction == 4)
                {
                    d = Vector3.right;
                }


                my_transform.position = col.gameObject.transform.position + d;
                GameObject explode_instance = (GameObject)Instantiate(explode, my_transform.position, explode.transform.rotation);
            }
        }
        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.CrossFade("dead_end", 0);

            last_move      = move_direction;
            move_direction = -1;
            dead_position  = my_transform.position;
            GameObject explode_instance = (GameObject)Instantiate(explode, dead_position, explode.transform.rotation);
            dead();
            Destroy(this.gameObject.GetComponent <BoxCollider2D>());
        }
    }
示例#4
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>());
        }
    }
    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;
        }
    }
示例#6
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;
            }
        }
    }