public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        GameDataEditor myScript = (GameDataEditor)target;

        EditorGUILayout.Space();

        if (GUILayout.Button("Show Data from File"))
        {
            myScript.LoadData();
            Repaint();
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("Save Data to File"))
        {
            myScript.SaveData();
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("Clear Data from File"))
        {
            myScript.ClearData();
            Repaint();
        }

        EditorGUILayout.Space();
    }
예제 #2
0
    static void Init()
    {
        GameDataEditor window = (GameDataEditor)EditorWindow.GetWindow(typeof(GameDataEditor));

        window.maxSize = new Vector2(1920, 1080);
        window.minSize = new Vector2(300, 1000);
        window.Show();
    }
예제 #3
0
        public void _4_Best_Score_Load()
        {
            var gameSession = new GameSession();

            gameSession.Idle();

            Assert.AreEqual(gameSession.BestScore, BestScoreIncreaseIterationsForSaveLoadTest,
                            "GameSession's BestScore property was saved incorrectly. This test should be executed after \"BestScoreSave\" test");

            GameDataEditor.ClearData();
        }
    static void Init()
    {
        // creating a editor windows of the Game Data Editor Type (GameDataEditor:EditorWindow:ScriptableObject)
        GameDataEditor window = (GameDataEditor)EditorWindow.GetWindow(typeof(GameDataEditor));
        // customise window title
        GUIContent title = new GUIContent();

        title.text          = "Data Editor";
        window.titleContent = title;
        // show window
        window.Show();
    }
예제 #5
0
        public void _5_Play_State()
        {
            GameDataEditor.ClearData();

            var gameSession = new GameSession();

            gameSession.Play();

            Assert.AreEqual(gameSession.ReadyToPlay, false);
            Assert.AreEqual(gameSession.IsPlaying, true);

            GameDataEditor.ClearData();
        }
예제 #6
0
        public void _3_Best_Score_Save()
        {
            GameDataEditor.ClearData();

            var gameSession = new GameSession();

            gameSession.Idle();

            for (int i = 0; i < BestScoreIncreaseIterationsForSaveLoadTest; i++)
            {
                gameSession.IncreaseScore();
            }

            gameSession.Stop();
        }
예제 #7
0
        public void _1_Current_Score_Increase()
        {
            GameDataEditor.ClearData();

            var gameSession = new GameSession();

            gameSession.Idle();

            for (int i = 0; i < CurrentScoreIncreaseIterations; i++)
            {
                gameSession.IncreaseScore();
            }

            Assert.AreEqual(gameSession.CurrentScore, CurrentScoreIncreaseIterations,
                            "GameSession's CurrentScore property was calculated incorrectly");

            GameDataEditor.ClearData();
        }
예제 #8
0
        public void _2_Best_Score_Increase()
        {
            GameDataEditor.ClearData();

            var gameSession = new GameSession();

            gameSession.Idle();

            for (int i = 0; i < BestScoreIncreaseIterations; i++)
            {
                gameSession.IncreaseScore();
            }

            gameSession.Stop();
            Assert.AreEqual(gameSession.BestScore, BestScoreIncreaseIterations,
                            "GameSession's BestScore property was calculated incorrectly");

            GameDataEditor.ClearData();
        }
예제 #9
0
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        DontDestroyOnLoad(this);

        if (dataFileName == null)
        {
            dataFileName = "/gameData.json";
        }

        if (loadFromFile)
        {
            data = new GameData();
            LoadData();
        }
    }
예제 #10
0
    static void Init()
    {
        GameDataEditor window = (GameDataEditor)EditorWindow.GetWindow(typeof(GameDataEditor));

        window.Show();
    }
예제 #11
0
    static void Init()
    {
        GameDataEditor window = (GameDataEditor)GetWindow(typeof(GameDataEditor), true, "Game Editor");

        window.Show();
    }
예제 #12
0
파일: GameScript.cs 프로젝트: Rom1P/2DEV
    //Clear data and load next level (if exists)
    void NextLevel()
    {
        GameObject[] gameObjects;

        gameObjects = GameObject.FindGameObjectsWithTag("ToDestroy");

        for (var i = 0; i < gameObjects.Length; i++)
        {
            Destroy(gameObjects[i]);
        }

        inGame = true;


        CubeGame.SendMessage("Restart");

        WinButtons.SetActive(false);

        Collider CubeCollider = CubeGame.GetComponent <Collider>();

        CubeCollider.isTrigger = true;
        CubeCollider.attachedRigidbody.useGravity = false;

        Rigidbody rigidbodyCube = CubeGame.GetComponent <Rigidbody>();

        rigidbodyCube.velocity        = Vector3.zero;
        rigidbodyCube.angularVelocity = Vector3.zero;



        List <String> CurrentProgress = sequenceData.LevelProgress;

        try
        {
            CurrentProgress.Add(sequenceData.ListLevels[CurrentProgress.Count]);
        }


        //If progress == listLevels
        catch
        {
        }

        SequenceDataEditor SaveProgress = new SequenceDataEditor();

        SaveProgress.ListLevels    = sequenceData.ListLevels;
        SaveProgress.LevelProgress = CurrentProgress;
        SaveProgress.Moves         = sequenceData.Moves;
        SaveProgress.Time          = sequenceData.Time;


        string SaveProgressString = JsonUtility.ToJson(SaveProgress);

        File.WriteAllText("Assets\\Levels\\" + sequence + "\\sequenceData.json", SaveProgressString);



        try
        {
            for (int i = 0; i <= CurrentProgress.Count; i++)
            {
                if (CurrentProgress[i] == NameFile)
                {
                    NameFile = CurrentProgress[i + 1];
                    if (i <= CurrentProgress.Count - 1)
                    {
                        CurrentProgress.RemoveAt(CurrentProgress.Count - 1);
                    }
                    break;
                }
            }
        }

        catch
        {
            NameFile = CurrentProgress[CurrentProgress.Count - 1];
        }

        TextNameLevel.GetComponentInChildren <Text>().text = NameFile;



        CompletePath = "Assets\\Levels\\" + sequence + "\\" + NameFile + ".txt";

        string DataPath = "Assets\\Levels\\" + sequence + "\\" + NameFile + ".json";


        string readText = File.ReadAllText(CompletePath);

        BoardListImport = Regex.Split(readText, "\n");

        BoardList.Clear();

        foreach (string TempString in BoardListImport)
        {
            if (TempString.Length > 1)
            {
                BoardList.Add(TempString);
            }
        }

        BoardLoaderObject = GameObject.Find("BoardLoader");
        BoardLoaderObject.SendMessage("LoadBoard", CompletePath);

        NormalSwitches = new Dictionary <string, List <GameObject> >();
        StrongSwitches = new Dictionary <string, List <GameObject> >();


        string DataJson2 = File.ReadAllText(DataPath);

        loadedData = JsonUtility.FromJson <GameDataEditor>(DataJson2);
        LoadData();


        string DataReloadJson = File.ReadAllText("Assets\\Levels\\" + sequence + "\\sequenceData.json");

        sequenceData = JsonUtility.FromJson <SequenceDataEditor>(DataReloadJson);

        timeElapsed = 0;

        if (withTimer)
        {
            UseTimer();
        }

        Moves = 0;
    }
예제 #13
0
파일: GameScript.cs 프로젝트: Rom1P/2DEV
    // Use this for initialization
    void Start()
    {
        //Get name of level to load by accessing other scenes
        try
        {
            GameObject GameManagerObject = GameObject.Find("MenuManager");

            MenuManagerAccess = (GameManagerObject.GetComponentInChildren <MenuManager>());

            NameFile = MenuManagerAccess.NameFile;

            withTimer = MenuManagerAccess.ToggleTimerIsOn;


            sequence = MenuManagerAccess.sequence;

            Destroy(GameManagerObject);
        }

        catch
        {
            NameFile  = "Level1";
            sequence  = "Normal";
            withTimer = false;
        }

        //Load sequence data in json


        string DataJson = File.ReadAllText("Assets\\Levels\\" + sequence + "\\sequenceData.json");

        sequenceData = JsonUtility.FromJson <SequenceDataEditor>(DataJson);



        //Get paths

        TextNameLevel.GetComponentInChildren <Text>().text = NameFile;


        CompletePath = "Assets\\Levels\\" + sequence + "\\" + NameFile + ".txt";

        string DataPath = "Assets\\Levels\\" + sequence + "\\" + NameFile + ".json";


        //Load Board as a list

        string readText = File.ReadAllText(CompletePath);

        BoardListImport = Regex.Split(readText, "\n");

        //Need to clear list in case of restarting

        BoardList.Clear();

        foreach (string TempString in BoardListImport)
        {
            if (TempString.Length > 1)
            {
                BoardList.Add(TempString);
            }
        }

        //Tell to BoardLoader to load the board

        BoardLoaderObject = GameObject.Find("BoardLoader");
        BoardLoaderObject.SendMessage("LoadBoard", CompletePath);

        //Create dictionnary that contains case of switches as key and list of GameObject to toggle as values

        NormalSwitches = new Dictionary <string, List <GameObject> >();
        StrongSwitches = new Dictionary <string, List <GameObject> >();

        //Usefull when the cube is on a bridge case to know if that case is on or off

        CurrentlyActivatedCasesBridge = new List <string>();

        //Load JsonData of the level

        string jsonString = File.ReadAllText(DataPath);

        loadedData = JsonUtility.FromJson <GameDataEditor>(jsonString);
        LoadData();

        //Add UI

        AddButtonsListener();

        //We start the game so turn bool true and set parameters of the level

        inGame = true;

        timeElapsed = 0;

        if (withTimer)
        {
            UseTimer();
        }

        Moves = 0;
    }