// Update is called once per frame
    void FixedUpdate()
    {
        if (move_direction == 0)
        {
            if (drop_direction == 1)
            {
                my_transform.Translate(Vector3.up * Common_data.panda_speed * Time.fixedDeltaTime * speed_yz);
                Collider2D up_collider = getCollider(1);
                if (up_collider)
                {
                    if (up_collider.tag == Common_data.BARREL_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.ICE_BLOCK_TAG)
                    {
                        ice_controller i_c = up_collider.gameObject.GetComponent <ice_controller> ();
                        i_c.attact();
                    }
                    else if (up_collider.tag == Common_data.UP_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.DOWN_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.LEFT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.RIGHT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.MOVE_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.TRAP_TAG)
                    {
                        return;
                    }


                    transform.position = up_collider.gameObject.transform.position + Vector3.down;
                    stand_direction    = 2;
                    act_stop(2);
                    return;
                }
            }
            else if (drop_direction == 2)
            {
                my_transform.Translate(Vector3.down * Common_data.panda_speed * Time.fixedDeltaTime * speed_yz);
                Collider2D up_collider = getCollider(2);
                if (up_collider)
                {
                    if (up_collider.tag == Common_data.BARREL_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.ICE_BLOCK_TAG)
                    {
                        ice_controller i_c = up_collider.gameObject.GetComponent <ice_controller> ();
                        i_c.attact();
                    }
                    else if (up_collider.tag == Common_data.UP_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.DOWN_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.LEFT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.RIGHT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.MOVE_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.TRAP_TAG)
                    {
                        return;
                    }


                    transform.position = up_collider.gameObject.transform.position + Vector3.up;
                    stand_direction    = 1;
                    act_stop(1);
                    return;
                }
            }
            else if (drop_direction == 3)
            {
                my_transform.Translate(Vector3.left * Common_data.panda_speed * Time.fixedDeltaTime * speed_yz);
                Collider2D up_collider = getCollider(3);
                if (up_collider)
                {
                    if (up_collider.tag == Common_data.BARREL_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.ICE_BLOCK_TAG)
                    {
                        ice_controller i_c = up_collider.gameObject.GetComponent <ice_controller> ();
                        i_c.attact();
                    }
                    else if (up_collider.tag == Common_data.UP_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.DOWN_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.LEFT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.RIGHT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.MOVE_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.TRAP_TAG)
                    {
                        return;
                    }


                    transform.position = up_collider.gameObject.transform.position + Vector3.right;
                    stand_direction    = 3;
                    act_stop(3);
                    return;
                }
            }
            else if (drop_direction == 4)
            {
                my_transform.Translate(Vector3.right * Common_data.panda_speed * Time.fixedDeltaTime * speed_yz);
                Collider2D up_collider = getCollider(4);
                if (up_collider)
                {
                    if (up_collider.tag == Common_data.BARREL_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.ICE_BLOCK_TAG)
                    {
                        ice_controller i_c = up_collider.gameObject.GetComponent <ice_controller> ();
                        i_c.attact();
                    }
                    else if (up_collider.tag == Common_data.UP_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.DOWN_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.LEFT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.RIGHT_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.MOVE_BLOCK_TAG)
                    {
                        return;
                    }
                    else if (up_collider.tag == Common_data.TRAP_TAG)
                    {
                        return;
                    }


                    transform.position = up_collider.gameObject.transform.position + Vector3.left;
                    stand_direction    = 4;
                    act_stop(4);
                    return;
                }
            }
            else if (drop_direction == 0)
            {
                if (stand_direction == 1)
                {
                    Collider2D up_collider = getCollider(2);
                    if (up_collider == null)
                    {
                        move();
                        player.CrossFade("move_up", 0);
                        return;
                    }
                }
            }
        }
        else if (move_direction == 1)
        {
            move_enemy.eulerAngles = new Vector3(0, 0, 90);
            my_transform.Translate(Vector3.up * Common_data.panda_speed * Time.fixedDeltaTime);
        }
        else if (move_direction == 2)
        {
            move_enemy.eulerAngles = new Vector3(0, 0, -90);
            my_transform.Translate(Vector3.down * Common_data.panda_speed * Time.fixedDeltaTime);
        }
        else if (move_direction == 3)
        {
            move_enemy.eulerAngles = new Vector3(0, 180, 0);
            my_transform.Translate(Vector3.left * Common_data.panda_speed * Time.fixedDeltaTime);
        }
        else if (move_direction == 4)
        {
            my_transform.Translate(Vector3.right * Common_data.panda_speed * Time.fixedDeltaTime);
        }
        else if (move_direction == -1)
        {
            if (last_move == 1)
            {
                dead_time += Time.fixedDeltaTime;
                float x = x_dead_offset.Evaluate(dead_time) * x_dead_speed;
                float y = y_dead_offset.Evaluate(dead_time) * y_dead_speed;

                my_transform.position = dead_position + new Vector3(x, y, 0);
            }
            else if (last_move == 2)
            {
                dead_time += Time.fixedDeltaTime;
                float x = x_dead_offset.Evaluate(dead_time) * x_dead_speed;
                float y = y_dead_offset.Evaluate(dead_time) * y_dead_speed;

                my_transform.position = dead_position + new Vector3(x, y, 0);
            }
            else if (last_move == 3)
            {
                dead_time += Time.fixedDeltaTime;
                float x = x_dead_offset.Evaluate(dead_time) * x_dead_speed;
                float y = y_dead_offset.Evaluate(dead_time) * y_dead_speed;

                my_transform.position = dead_position + new Vector3(x, y, 0);
            }
            else if (last_move == 4)
            {
                dead_time += Time.fixedDeltaTime;
                float x = x_dead_offset.Evaluate(dead_time) * x_dead_speed;
                float y = y_dead_offset.Evaluate(dead_time) * y_dead_speed;

                my_transform.position = dead_position + new Vector3(x, y, 0);
            }
        }
    }
Пример #2
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;
            }
        }
    }
    void do_ice_block(Collider2D col)
    {
        Debug.Log("do_ice_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)
        {
            ice_controller b_c = col.gameObject.GetComponent <ice_controller>();
            b_c.attact();
            move_direction = 0;
        }
    }
Пример #4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log("attact tag is " + col.tag);

        if (col.gameObject.tag == Common_data.PANDA_TAG)
        {
            explode_effect(col);
            panda_controller p_c = col.gameObject.GetComponent <panda_controller>();
            p_c.dead();
            load_sound();
            dead();
        }
        else if (col.gameObject.tag == Common_data.ICE_BLOCK_TAG)
        {
            explode_effect(col);
            dead();
            ice_controller i_c = col.gameObject.GetComponent <ice_controller>();
            i_c.attact();
        }
        else if (col.gameObject.tag == Common_data.UP_BLOCK_TAG)
        {
            if (move_direction == 1)
            {
                unidirection_controller u_c = col.gameObject.GetComponent <unidirection_controller>();
                u_c.open_door();
            }
            else if (move_direction == 2)
            {
                explode_effect(col);
                load_sound();
                dead();
            }
            else
            {
                return;
            }
        }
        else if (col.gameObject.tag == Common_data.DOWN_BLOCK_TAG)
        {
            if (move_direction == 1)
            {
                explode_effect(col);
                load_sound();
                dead();
            }
            else if (move_direction == 2)
            {
                unidirection_controller u_c = col.gameObject.GetComponent <unidirection_controller>();
                u_c.open_door();
            }
            else
            {
                return;
            }
        }
        else if (col.gameObject.tag == Common_data.LEFT_BLOCK_TAG)
        {
            if (move_direction == 3)
            {
                unidirection_controller u_c = col.gameObject.GetComponent <unidirection_controller>();
                u_c.open_door();
            }
            else if (move_direction == 4)
            {
                explode_effect(col);
                load_sound();
                dead();
            }
            else
            {
                return;
            }
        }
        else if (col.gameObject.tag == Common_data.RIGHT_BLOCK_TAG)
        {
            if (move_direction == 4)
            {
                unidirection_controller u_c = col.gameObject.GetComponent <unidirection_controller>();
                u_c.open_door();
            }
            else if (move_direction == 3)
            {
                explode_effect(col);
                load_sound();
                dead();
            }
            else
            {
                return;
            }
        }
        else
        {
            if (col.gameObject.tag != Common_data.BARELL_COLLIDER_TAG && col.gameObject.tag != Common_data.ATTACT_ENEMY_TAG && col.gameObject.tag != Common_data.STREET_TAG && col.gameObject.tag != "trap_collider" && col.gameObject.tag != "trap" && col.gameObject.tag != Common_data.BULLET_TAG)
            {
                explode_effect(col);
                load_sound();
                dead();
            }
        }
    }