Exemplo n.º 1
0
 public Level(int levelIndex, SerializableTypes.SerializeColor firstColor, SerializableTypes.SerializeColor secondColor,
              SerializableTypes.SerializeColor thirdColor, int subLevelPassCount)
 {
     this.levelNumber       = levelIndex;
     this.firstColor        = firstColor;
     this.secondColor       = secondColor;
     this.thirdColor        = thirdColor;
     this.subLevelPassCount = subLevelPassCount;
     levelObjectsData       = new List <LevelObjectData>();
 }
Exemplo n.º 2
0
    private void OnGUI()
    {
        GUILayout.Label("Sub Level Complete Number", EditorStyles.boldLabel);
        sublevelCompleteNumber = EditorGUILayout.IntField("Number", sublevelCompleteNumber, EditorStyles.textField);
        EditorGUILayout.Space();
        GUILayout.Label("Level Index", EditorStyles.boldLabel);
        levelIndex = EditorGUILayout.IntField("Level", levelIndex, EditorStyles.textField);
        EditorGUILayout.Space();
        GUILayout.Label("Level Colors", EditorStyles.boldLabel);
        firstColor  = EditorGUILayout.ColorField("FirstColor(Ground)", firstColor);
        secondColor = EditorGUILayout.ColorField("SecondColor(Obstacles)", secondColor);
        thirdColor  = EditorGUILayout.ColorField("ThirdColor(Gates & Traps)", thirdColor);
        EditorGUILayout.Space();

        if (GUILayout.Button("Save Level To File"))
        {
            Level newLevel = new Level(levelIndex, SerializeColor.fromColor(firstColor), SerializeColor.fromColor(secondColor),
                                       SerializeColor.fromColor(thirdColor), sublevelCompleteNumber);
            newLevel.levelObjectsData.InsertRange(0, findLevelObjects());
            newLevel.levelPassCount = levelCompleteNumber;

            if (newLevel.levelObjectsData.Count <= 0)
            {
                errorMessages += "Number of Created Objects Must Be Greater Than Zero";
            }

            try
            {
                LevelSerializer.SerializeLevel(newLevel);
                AssetDatabase.Refresh();
            }
            catch (Exception err)
            {
                Debug.LogError("ERROR SAVING FILE");
                errorMessages += err.Message;
            }
        }

        if (errorMessages != "")
        {
            EditorGUILayout.HelpBox(errorMessages, MessageType.Error);

            if (GUILayout.Button("Clear"))
            {
                errorMessages = "";
            }
        }
    }
Exemplo n.º 3
0
 public void SetMaterialColor(SerializeColor color, MaterialType type)
 {
     gameMaterials[(int)type].color = color.getColor();
 }