示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }
        else if (Input.GetKey(KeyCode.P) || Input.GetKey(KeyCode.Home))
        {
            Application.CaptureScreenshot("Screenshot.png");
        }
        while (ArrowIndex < TestNotes.Data.Length - 1 && TestNotes.Data[ArrowIndex] < MusicScript.MusicTime + 3f)
        {
            float time = TestNotes.Data[ArrowIndex];
            ArrowIndex++;
            int column = (int)TestNotes.Data[ArrowIndex];
            Logger.Log(TAG, "Adding arrow: {0}, {1}", time, column);

            GameObject arrowPrefab = Arrow1Prefab;
            switch (column)
            {
            case 0: arrowPrefab = Arrow1Prefab; break;

            case 1: arrowPrefab = Arrow2Prefab; break;

            case 2: arrowPrefab = Arrow3Prefab; break;

            case 3: arrowPrefab = Arrow4Prefab; break;
            }
            Vector3 position = new Vector3(
                -210f + column * 140f,
                700f,
                0f
                );
            GameObject arrow = NGUITools.AddChild(_camera, arrowPrefab);
            arrow.name = "_arrow" + _arrowCount;
            arrow.transform.localPosition = position;
            UISprite sprite = arrow.GetComponent <UISprite>();
            sprite.depth = _arrowCount;
            TestArrowScript script = arrow.GetComponent <TestArrowScript>();
            script.column = column;
            script.time   = time;
            _arrowCount++;
            ArrowsList.Add(arrow);
        }
    }
示例#2
0
    public void OnHitboxClick(int column)
    {
        for (int i = 0; i < ArrowsList.size; i++)
        {
            GameObject      arrow  = ArrowsList.buffer[i];
            TestArrowScript script = arrow.GetComponent <TestArrowScript>();
            if (script.column == column)
            {
                float timeDiff = script.time - MusicScript.MusicTime;
                if (Mathf.Abs(timeDiff) < 0.3f)
                {
                    TimeDiffScript.TimeDiff = timeDiff;
                    Logger.Log(TAG, "Column {0} diff: {1}", column, timeDiff);
                    script.hit = true;
                    DestroyArrow(arrow);
                    return;
                }

                /*
                 * if (y > -350 && y < -100) {
                 *      Logger.Log(TAG, "Destroying arrow on column: {0}", column);
                 *      DestroyArrow(arrow);
                 *      return;
                 * }
                 */
                /*
                 * float diff = (arrow.transform.localPosition.y - TestHitbuttonScript.HITBUTTON_Y);
                 * if (diff > 0f && diff < 100f)
                 * {
                 *      Logger.Log(TAG, "Column {0} diff: {1}", column, diff);
                 *      DestroyArrow(arrow);
                 *      return;
                 * }
                 */
            }
        }
    }