Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        CurrentLevelIndex = 0;
        Debug.Log("level : " + CurrentLevelIndex);
        GameFSM.GetState(GameStateLevel).OnStateInEvent.AddListener(() =>
        {
            LevelFsm = new FSMLite();
            LevelFsm.RegisterState(new FSMLite.State()
            {
                Name = LevelStateOpen
            });
            LevelFsm.RegisterState(new FSMLite.State()
            {
                Name = LevelStateClose
            });
            LevelFsm.GetState(LevelStateOpen).OnStateInEvent.AddListener(() =>
            {
                DistortionMask.SetActive(false);
            });
            LevelFsm.GetState(LevelStateClose).OnStateInEvent.AddListener(() =>
            {
                DistortionMask.SetActive(true);
            });

            UI.SetLevelFSM(LevelFsm);
            LevelFsm.Start(LevelStateOpen);

            if (LevelPrefabList.Count > CurrentLevelIndex)
            {
                var levelPrefab = LevelPrefabList[CurrentLevelIndex];
                var levelGo     = Instantiate(levelPrefab, transform);
                if (!(levelGo is null))
                {
                    Level = levelGo.GetComponent <Level.Level>();
                }
                switchCameraLimit();
            }
        });
        GameFSM.GetState(GameStateLevel).OnStateOutEvent.AddListener(() =>
        {
            UI.UnSetLevelFSM(LevelFsm);
            LevelFsm.Clear();
            LevelFsm = null;
            Destroy(Level.gameObject);
        });

        UI.SetGameFSM(GameFSM);

        GameFSM.Start(GameStateMenu);
    }
Example #2
0
    private void OnEnable()
    {
        _Instance = this;
        Application.targetFrameRate = 60;

        DistortionMask = GameObject.Find("Distortion").gameObject;
        UI             = GameObject.Find("UIManager").GetComponent <UIManager>();

        GameFSM = new FSMLite();
        GameFSM.RegisterState(new FSMLite.State {
            Name = GameStateMenu
        });
        GameFSM.RegisterState(new FSMLite.State {
            Name = GameStateLevel
        });
        GameFSM.RegisterState(new FSMLite.State {
            Name = GameStateScore
        });
        GameFSM.RegisterState(new FSMLite.State {
            Name = GameStateFinish
        });
    }