コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        BPM = 92;
        int[] data = Edit_useFile.ReadFile();
        int   i    = 0;

        for (int r = 0; r < 4; r++)
        {
            i = 0;
            foreach (int y in data)
            {
                if ((y & (byte)Mathf.Pow(2, r)) != 0)
                {
                    var obj = Instantiate(note) as GameObject;
                    obj.transform.parent        = Lines[r].transform;
                    obj.transform.localPosition = new Vector3(0, -(60.0f / BPM) * 2 * i, 0);
                    obj.transform.rotation      = Quaternion.Euler(0, 0, 90 * -r + 180);
                }
                i++;
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var mousePos = Input.mousePosition;
            mousePos.z = 0;
            mousePos   = Camera.main.ScreenToWorldPoint(mousePos);
            mousePos.x = (float)Math.Round(mousePos.x, MidpointRounding.AwayFromZero);
            mousePos.y = (float)Math.Round(mousePos.y, MidpointRounding.AwayFromZero);
            mousePos.z = 0;
            if (-3 <= mousePos.y && mousePos.y <= 0 && mousePos.x >= 0)
            {
                if (!Check(Edit_HumenData.humen[(int)mousePos.x], (int)Math.Pow(2, (int)Math.Abs(mousePos.y))))
                {
                    noteMarker.transform.rotation = Quaternion.Euler(0, 0, 180 + 90 * mousePos.y);
                    noteMarker.transform.position = mousePos;
                    Instantiate(noteMarker);
                    Edit_HumenData.humen[(int)mousePos.x] += (int)Math.Pow(2, (int)Math.Abs(mousePos.y));
                    Debug.Log(Edit_HumenData.humen[(int)mousePos.x]);
                }
                else
                {
                    Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit2D hit = Physics2D.Raycast((Vector2)ray.origin, (Vector2)ray.direction);

                    if (hit)
                    {
                        Destroy(hit.transform.gameObject);
                        Edit_HumenData.humen[(int)mousePos.x] -= (int)Math.Pow(2, (int)Math.Abs(mousePos.y));
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            var data = Edit_useFile.ReadFile();
            Edit_HumenData.humen = data;
            foreach (var obj in GameObject.FindGameObjectsWithTag("Marker"))
            {
                Destroy(obj);
            }
            int x = 0;
            foreach (int data_i in data)
            {
                if (data_i != 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (Check(data_i, (int)Math.Pow(2, i)))
                        {
                            noteMarker.transform.position = new Vector3(x, -i, 0);
                            noteMarker.transform.rotation = Quaternion.Euler(0, 0, 180 + 90 * -i);
                            Instantiate(noteMarker);
                        }
                    }
                }
                x++;
            }
        }
    }