Exemple #1
0
        public static TestText Instantiate(FontMeshData data, string text, float fontWidth, float fontHeight, TextAnchor anchor)
        {
            // Create GameObject
            GameObject obj = new GameObject();

            obj.name = text;
            obj.tag  = Tags.UNTAGGED;

            // Add TestText Component
            TestText beatsObj = obj.AddComponent <TestText>();

            // Add Sprite Component
            FontMesh sprite = obj.AddComponent <FontMesh>();

            sprite.Setup(data, fontWidth, fontHeight, anchor);
            sprite.text      = text;
            beatsObj._sprite = sprite;

            // Return instantiated BeatsObject
            return(beatsObj);
        }
Exemple #2
0
        public static FpsCounter Instantiate(FontMeshData data, float fontHeight)
        {
            // Create GameObject
            GameObject obj = new GameObject();

            obj.name = NAME;
            obj.tag  = Tags.UNTAGGED;

            // Add FpsCounter Component
            FpsCounter beatsObj = obj.AddComponent <FpsCounter>();

            beatsObj.FPS_UPDATE_INTERVAL = SettingsManager.GetValueFloat(Settings.MISC_FPS_UPDATE_INTERVAL);
            beatsObj.ResetCounter();

            // Add Sprite Component
            FontMesh sprite = obj.AddComponent <FontMesh>();

            sprite.Setup(data, data.width * fontHeight / data.height, fontHeight, TextAnchor.UpperRight);
            sprite.text      = "XXX.XX FPS";
            beatsObj._sprite = sprite;

            // Return instantiated BeatsObject
            return(beatsObj);
        }
Exemple #3
0
        // Use this for initialization
        public override void Start()
        {
            // Initialize
            InitAll();
            Logger.debug = true;

            // Set up input listeners
            Inputs.SetKeyListeners(_keyListeners);

            // Beats logo
            TestLogo.Init();
            TestLogo logo = TestLogo.Instantiate();

            logo.position = new Vector3(Screens.xmid, Screens.ymid, Screens.zmin);

            // Arrow in each corner
            TestArrow.Init();
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    float     posX  = (x == 0) ? Screens.xmin : (x == 1) ? Screens.xmid : Screens.xmax;
                    float     posY  = (y == 0) ? Screens.ymin : (y == 1) ? Screens.ymid : Screens.ymax;
                    float     posZ  = Screens.zmin;
                    TestArrow arrow = TestArrow.Instantiate();
                    arrow.name     = String.Format("_arrow({0}, {1})", x, y);
                    arrow.position = new Vector3(posX, posY, posZ);
                }
            }
            _randomArrow          = TestArrow.Instantiate();
            _randomArrow.name     = "_randomArrow";
            _randomArrow.position = new Vector3(Screens.xmax - 75f, Screens.ymax - 50f, Screens.zmin);

            // Two random holds
            TestHold.Init();
            _hold1          = TestHold.Instantiate(Screens.height - _randomArrow.height);
            _hold1.name     = "_hold1";
            _hold1.position = new Vector3(Screens.xmax - (_hold1.width / 2), Screens.ymid, Screens.zmid);

            _hold2          = TestHold.Instantiate(_randomArrow.height * 4);
            _hold2.name     = "_hold2";
            _hold2.position = new Vector3(_hold1.x - _hold1.width * 2, Screens.ymid, Screens.zmid);

            // Background image
            TestBackground background = TestBackground.Instantiate();

            background.name     = "_background2";
            background.position = new Vector3(Screens.xmid, Screens.ymid, Screens.zmax);
            background.color    = new Color(background.color.r, background.color.g, background.color.b, 0.75f);

            // Generated arrows
            _arrows     = new List <TestArrow>();
            _addTimer   = ADD_INTERVAL;
            _arrowCount = 0;

            // Text label
            FontMeshData squareTextData = new FontMeshData(
                "_SquareFont",
                SysInfo.GetPath("Sandbox/Square.png"),
                SysInfo.GetPath("Sandbox/Square.fnt")
                );
            float textWidth  = squareTextData.width * (_randomArrow.height / 2) / squareTextData.height;
            float textHeight = (_randomArrow.height / 2);

            _sysInfo = TestText.Instantiate(
                squareTextData,
                "_SysInfo",
                textWidth * 0.7f, textHeight * 0.7f,
                TextAnchor.UpperLeft
                );
            _sysInfo.position = new Vector3(Screens.xmin, Screens.ymax, Screens.zdebug);
            _sysInfo.color    = new Color(1f, 1f, 1f, 0.5f);          // Semi-transparent Gray
            _sysInfo.text     = SysInfo.InfoString();

            _audioTime = TestText.Instantiate(
                squareTextData,
                "_AudioTime",
                textWidth, textHeight,
                TextAnchor.LowerLeft
                );
            _audioTime.position = new Vector3(Screens.xmin, Screens.ymin + (_randomArrow.height / 2), Screens.zdebug);

            _touchLog = TestText.Instantiate(
                squareTextData,
                "_Touch Log",
                textWidth, textHeight,
                TextAnchor.LowerLeft
                );
            _touchLog.position = new Vector3(Screens.xmin, Screens.ymin, Screens.zdebug);
            _touchLog.color    = new Color(255f / 255f, 204f / 255f, 0f);        // Tangerine

            _collisionLog = TestText.Instantiate(
                squareTextData,
                "_Collision Log",
                textWidth, textHeight,
                TextAnchor.LowerRight
                );
            _collisionLog.position = new Vector3(Screens.xmax, Screens.ymin, Screens.zdebug);
            _collisionLog.color    = Color.red;

            // FPS Counter
            _fpsCounter          = FpsCounter.Instantiate(squareTextData, textHeight);
            _fpsCounter.position = new Vector3(Screens.xmax, Screens.ymax, Screens.zdebug);

            // Load music
            _audioPlayer = AudioPlayer.Instantiate();
            _audioPlayer.Set(AudioClips.SANDBOX_SONG);
            _audioPlayer.loop = true;
            _audioPlayer.Play();

            TestMine.Init();
            _mine = TestMine.Instantiate();
            _mine.gameObject.transform.position = new Vector3(Screens.xmid, (Screens.ymin + Screens.ymid) / 2, Screens.zmin - 10);

            SettingsFile testIniFile = new SettingsFile(SysInfo.GetPath("Sandbox/Test.ini"));

            testIniFile.Set("Beats", "Version", "MODIFIED");
            testIniFile.Write(SysInfo.GetPath("Sandbox/Test2.ini"));
        }