Esempio n. 1
0
    private void SpawnSpecialBeat(int spawnOffSetX, int index, Beat beat)
    {
        GameObject barSpecial = new GameObject("beatBar", typeof(RectTransform));

        barSpecial.AddComponent <CanvasRenderer>();
        var imageComponent = barSpecial.AddComponent <Image>();

        imageComponent.sprite = sBeatList[index].pose.data.uiTexture;
        imageComponent.SetNativeSize();

        RectTransform rt = barSpecial.GetComponent <RectTransform>();

        barSpecial.transform.SetParent(canvas.transform);
        Vector3 p = rt.position;


        rt.anchorMax = Vector2.zero;
        rt.anchorMin = Vector2.zero;

        rt.pivot = new Vector2(imageComponent.sprite.pivot.x / 256f, 0.1f);

        rt.transform.position = new Vector3(p.x + spawnOffSetX + index * 300.0f - 100.0f, p.y + 30.0f, p.z);

        BeatBarBehaviour behaviour2 = barSpecial.AddComponent <BeatBarBehaviour>();

        behaviour2.beatController = this;
        behaviour2.beat           = beat;
        behaviour2.isPose         = true;

        behaviour2.Initialize();
    }
Esempio n. 2
0
    private void GenerateArray(float seconds)
    {
        Initialization(seconds);
        InitializeVisualBeatList();
        InitializeSpecialVisualBeats();

        SetBeatTimes();

        int spawnOffSetX = 1500;

        //TODO:
        //		for( int i = 0; i < sBeatLength; i++ )
        for (int i = 0; i < sBeatLength; i++)
        {
            GameObject bar = new GameObject("beatBar", typeof(RectTransform));
            bar.AddComponent <CanvasRenderer>();
            bar.AddComponent <Image>();

            RectTransform rt = bar.GetComponent <RectTransform>();
            bar.transform.SetParent(canvas.transform);
            Vector3 p = rt.position;

            Beat beat = sBeatList[i];


            rt.anchorMax = Vector2.zero;
            rt.anchorMin = Vector2.zero;

            if (beat.type == BarType.Normal)
            {
                rt.pivot = RegularBeatPivot;
            }
            else if (beat.type == BarType.Special)
            {
                rt.pivot = SpecialBeatPivot;
            }

            rt.transform.position = new Vector3(p.x + spawnOffSetX + i * 300.0f, 0f, p.z);



            BeatBarBehaviour behaviour = bar.AddComponent <BeatBarBehaviour>();
            behaviour.beatController = this;
            behaviour.beat           = beat;

            behaviour.Initialize();

            bar.GetComponent <Image>().sprite = beat.sprite;
            bar.GetComponent <Image>().SetNativeSize();
            if (beat.type == BarType.Special)
            {
                SpawnSpecialBeat(spawnOffSetX, i, beat);
            }
        }
    }