Beispiel #1
0
    void create_note(ref Note note, Vector3 start_position, System.DateTime current_time)
    {
        GameObject go = new GameObject();
        // go.name = "character";
        // go.tag = "Player";
        // go.layer = MyConsts.LAYER_PLAYER;
        SpriteRenderer renderer = go.AddComponent <SpriteRenderer>();

        renderer.sprite = Resources.Load <Sprite>("normal_note");
        // renderer.sortingLayerName = MyConsts.SORTING_LAYER_FOREGROUND_NAME;
        go.transform.localPosition = start_position;
        go.transform.localScale    = m_sprite_scale;

        // rigid body
        Rigidbody2D rigidbody = go.AddComponent <Rigidbody2D>();

        rigidbody.mass           = 0;
        rigidbody.gravityScale   = 0;
        rigidbody.freezeRotation = true;
        BoxCollider2D collider = go.AddComponent <BoxCollider2D>();

        //collider.isTrigger = true;

        note.m_visible     = true;
        note.m_appear_time = current_time;
        note.m_gameobject  = go;

        MyNoteMotor motor = go.AddComponent <MyNoteMotor>();

        motor.set_param(note, start_position, m_velocity);
        motor.index = note.m_appear_beat_index;
    }
Beispiel #2
0
    void create_note(ref Note note, Vector3 start_position, System.DateTime current_time)
    {
        float   T = note.m_appear_beat_index / m_beats_per_second;
        Vector3 x = m_velocity * T;

        System.TimeSpan span = m_current_time - m_start_time;
        GameObject      go   = new GameObject();

        go.layer = MyConst.LAYER_NOTE;

        // go.name = "character";
        go.tag = "Note";
        SpriteRenderer renderer = go.AddComponent <SpriteRenderer>();

        if (NoteType.NoteTypeKePressed == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("keypressed_note");
        }
        else if (NoteType.NoteTypePush == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("push_note");
        }
        else if (NoteType.NoteTypeRelease == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("release_note");
        }
        else
        {
            renderer.sprite = Resources.Load <Sprite>("normal_note");
        }
        // renderer.sortingLayerName = MyConsts.SORTING_LAYER_FOREGROUND_NAME;
        go.transform.localPosition = start_position;
        // go.transform.localPosition = x - m_velocity * span.TotalMilliseconds * 1000;

        // rigid body
        Rigidbody2D rigidbody = go.AddComponent <Rigidbody2D>();

        rigidbody.mass           = 0;
        rigidbody.gravityScale   = 0;
        rigidbody.freezeRotation = true;
        BoxCollider2D collider = go.AddComponent <BoxCollider2D>();

        //collider.isTrigger = true;

        note.m_visible     = true;
        note.m_appear_time = current_time;
        note.m_gameobject  = go;

        MyNoteMotor motor = go.AddComponent <MyNoteMotor>();

        motor.set_param(note, start_position, m_velocity);
        motor.index = note.m_appear_beat_index;

        MyNote mynote = go.AddComponent <MyNote>();

        mynote.m_note = note;
    }