Example #1
0
        private void AddEvents()
        {
            _leftEventManager = _leftSaber.GetComponent <EventManager>();
            if (_leftEventManager == null)
            {
                _leftEventManager = _leftSaber.AddComponent <EventManager>();
            }

            _rightEventManager = _rightSaber.GetComponent <EventManager>();
            if (_rightEventManager == null)
            {
                _rightEventManager = _rightSaber.AddComponent <EventManager>();
            }

            _leftEventManager.OnLevelStart.Invoke();
            _rightEventManager.OnLevelStart.Invoke();
            try
            {
                _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                if (_beatmapObjectSpawnController == null)
                {
                    Console.WriteLine("SPAWN CONTROLLER NULL");
                    //_beatmapObjectSpawnController = _saberRoot.AddComponent<BeatmapObjectSpawnController>();
                }
                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (_scoreController == null)
                {
                    Console.WriteLine("SCORE CONTROLLER NULL");
                    //_scoreController = _saberRoot.AddComponent<ScoreController>();
                }
                _saberCollisionManager =
                    Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (_saberCollisionManager == null)
                {
                    Console.WriteLine("COLLISION MANAGER NULL");
                    //_saberCollisionManager = _saberRoot.AddComponent<ObstacleSaberSparkleEffectManager>();
                }
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (_gameEnergyCounter == null)
                {
                    Console.WriteLine("energery counter null");
                    //_gameEnergyCounter = _saberRoot.AddComponent<GameEnergyCounter>();
                }
                _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (_beatmapCallback == null)
                {
                    Console.WriteLine("BEATMAP CALLBACK NULL");
                    //_beatmapCallback = _saberRoot.AddComponent<BeatmapObjectCallbackController>();
                }

                _gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault();
                if (_gamePauseManager == null)
                {
                    Console.WriteLine("GamePauseManager Null");
                    //_gamePauseManager = _saberRoot.AddComponent<GamePauseManager>();
                }

                _playerHeadAndObstacleInteraction = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault();
                if (_playerHeadAndObstacleInteraction == null)
                {
                    Console.WriteLine("PlayerHeadAndObstacleInteraction Null");
                    //_playerHeadAndObstacleInteraction = _saberRoot.AddComponent<PlayerHeadAndObstacleInteraction>();
                }

                _beatmapObjectSpawnController.noteWasCutEvent    += SliceCallBack;
                _beatmapObjectSpawnController.noteWasMissedEvent += NoteMissCallBack;
                _scoreController.multiplierDidChangeEvent        += MultiplierCallBack;
                _scoreController.comboDidChangeEvent             += ComboChangeEvent;

                _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;

                _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;

                _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
                //  ReflectionUtil.SetPrivateField(_gamePauseManager, "_gameDidResumeSignal", (Action)OnPauseMenuClosed); //For some reason _gameDidResumeSignal isn't public.
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }

            try
            {
                MainGameSceneSetup mgs = GetGameSceneSetup();
                BeatmapDataModel   _beatmapDataModel = ReflectionUtil.GetPrivateField <BeatmapDataModel>(mgs, "_beatmapDataModel");
                BeatmapData        beatmapData       = _beatmapDataModel.beatmapData;

                BeatmapLineData[] beatmapLinesData = beatmapData.beatmapLinesData;
                float             LastTime         = 0.0f;

                for (int i = 0; i < beatmapLinesData.Length; i++)
                {
                    BeatmapObjectData[] beatmapObjectsData = beatmapLinesData[i].beatmapObjectsData;
                    for (int j = beatmapObjectsData.Length - 1; j > 0; j--)
                    {
                        if (beatmapObjectsData[j].beatmapObjectType == BeatmapObjectType.Note)
                        {
                            if (((NoteData)beatmapObjectsData[j]).noteType != NoteType.Bomb)
                            {
                                if (beatmapObjectsData[j].time > LastTime)
                                {
                                    LastNoteId = beatmapObjectsData[j].id;
                                    LastTime   = beatmapObjectsData[j].time;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }
        }
        public override void Start()
        {
            base.Start();

            ReflectionUtil.GetPrivateField <MeshRenderer>(_trailRenderer, "_meshRenderer").material = _customMaterial;
        }
 public void SetMaterial(Material newMaterial)
 {
     _customMaterial = newMaterial;
     ReflectionUtil.GetPrivateField <MeshRenderer>(_trailRenderer, "_meshRenderer").material = _customMaterial;
 }
Example #4
0
 public void SetColor(Color newColor)
 {
     TrailColor = newColor;
     ReflectionUtil.SetPrivateField(trail, "MyColor", TrailColor);
 }
Example #5
0
 public void SetMaterial(Material newMat)
 {
     TrailMaterial = newMat;
     ReflectionUtil.SetPrivateField(trail, "MyMaterial", TrailMaterial);
 }
Example #6
0
        //protected override void DidActivate(bool firstActivation, ActivationType activationType)
        //{
        //    if (firstActivation)
        //    {

        //        title = "Saber Select";

        //        ui = CustomSaberUI._instance;
        //        _saberListViewController = BeatSaberUI.CreateViewController<SaberListViewController>();
        //        _saberListViewController.backButtonPressed += Dismiss;
        //    }

        //    if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy)
        //    {
        //        ProvideInitialViewControllers(_saberListViewController, null, null);
        //    }
        //}

        void Dismiss()
        {
            ReflectionUtil.InvokePrivateMethod((mainFlowCoordinator as FlowCoordinator), "DismissFlowCoordinator", new object[] { this, null, false });
        }
Example #7
0
        private void Start()
        {
            _leftEventManager = _leftSaber.GetComponent <EventManager>();
            if (_leftEventManager == null)
            {
                _leftEventManager = _leftSaber.AddComponent <EventManager>();
            }

            _rightEventManager = _rightSaber.GetComponent <EventManager>();
            if (_rightEventManager == null)
            {
                _rightEventManager = _rightSaber.AddComponent <EventManager>();
            }

            _leftEventManager.OnLevelStart.Invoke();
            _rightEventManager.OnLevelStart.Invoke();
            try
            {
                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (_scoreController == null)
                {
                    Console.WriteLine("SCORE CONTROLLER NULL");
                }
                _saberCollisionManager =
                    Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (_saberCollisionManager == null)
                {
                    Console.WriteLine("COLLISION MANAGER NULL");
                }
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (_gameEnergyCounter == null)
                {
                    Console.WriteLine("energery counter null");
                }
                _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (_beatmapCallback == null)
                {
                    Console.WriteLine("BEATMAP CALLBACK NULL");
                }

                _gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault();
                if (_gamePauseManager == null)
                {
                    Console.WriteLine("GamePauseManager Null");
                }

                _scoreController.noteWasCutEvent          += SliceCallBack;
                _scoreController.noteWasMissedEvent       += NoteMissCallBack;
                _scoreController.multiplierDidChangeEvent += MultiplierCallBack;
                _scoreController.comboDidChangeEvent      += ComboChangeEvent;

                _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;

                _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;

                _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
                ReflectionUtil.SetPrivateField(_gamePauseManager, "_gameDidResumeSignal", (Action)OnPauseMenuClosed); //For some reason _gameDidResumeSignal isn't public.
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            previewparent = Instantiate(new GameObject("preview parent"));
            previewparent.transform.position = new Vector3(2.5f, 1, 0.3f);
            previewparent.transform.Rotate(new Vector3(0, -30, 0));
            _customSaberUI        = CustomSaberUI.Instance;
            _parentViewController = GetComponentInParent <CustomSaberMasterViewController>();
            try
            {
                if (_pageDownButton == null)
                {
                    try
                    {
                        _pageDownButton = _customSaberUI.CreateButton(rectTransform, "PageDownButton");
                        ((RectTransform)_pageDownButton.transform).anchorMin        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchorMax        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchoredPosition = new Vector2(0f, 10f);
                        _pageDownButton.interactable = true;
                        _pageDownButton.onClick.AddListener(delegate()
                        {
                            _sabersTableView.PageScrollDown();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
                if (_pageUpButton == null)
                {
                    try
                    {
                        _pageUpButton = _customSaberUI.CreateButton(rectTransform, "PageUpButton");
                        ((RectTransform)_pageUpButton.transform).anchorMin        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchorMax        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchoredPosition = new Vector2(0f, -14f);
                        _pageUpButton.interactable = true;
                        _pageUpButton.onClick.AddListener(delegate()
                        {
                            _sabersTableView.PageScrollUp();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }


                if (_sabersTableView == null)
                {
                    _sabersTableView = new GameObject().AddComponent <TableView>();

                    _sabersTableView.transform.SetParent(rectTransform, false);

                    var viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <Mask>().First(), _sabersTableView.transform, false);
                    viewportMask.transform.DetachChildren();
                    _sabersTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                    ((RectTransform)_sabersTableView.transform).anchorMin        = new Vector2(0f, 0.5f);
                    ((RectTransform)_sabersTableView.transform).anchorMax        = new Vector2(1f, 0.5f);
                    ((RectTransform)_sabersTableView.transform).sizeDelta        = new Vector2(0f, 60f);
                    ((RectTransform)_sabersTableView.transform).anchoredPosition = new Vector2(0f, 0f);

                    _sabersTableView.didSelectRowEvent += _sabersTableView_DidSelectRowEvent;

                    ReflectionUtil.SetPrivateField(_sabersTableView, "_pageUpButton", _pageUpButton);
                    ReflectionUtil.SetPrivateField(_sabersTableView, "_pageDownButton", _pageDownButton);

                    _sabersTableView.dataSource = this;

                    _sabersTableView.ScrollToRow(0, false);
                }
                else
                {
                    _sabersTableView.ReloadData();
                    _sabersTableView.ScrollToRow(0, false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }


            _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell"));

            LoadSabers();

            base.DidActivate(true, ActivationType.AddedToHierarchy);
        }