Exemplo n.º 1
0
    void GameplayUI()
    {
        int gemCount = MapComponents.GetNumOf("Gem");

        FoldoutLabel("Pickups", 1);
        GUILayout.Space(2);
        if (FoldoutButton("Gem", 1))
        {
            CreateGem();
        }
        if (FoldoutButton("Super Jump", 1))
        {
            CreateSJ();
        }
        if (FoldoutButton("Super Speed", 1))
        {
            CreateSS();
        }
        if (FoldoutButton("Feather Fall", 1))
        {
            CreateFF();
        }
        if (FoldoutButton("Time Travel", 1))
        {
            CreateTT();
        }
        if (FoldoutButton("Trophy", 1))
        {
            CreateTrophy();
        }
        GUILayout.Space(2);
        FoldoutLabel("Gems: <color=#0085ff>" + gemCount + "</color>", 1);
        GUILayout.Space(10);
        FoldoutLabel("Interactive", 1);
        GUILayout.Space(2);
        if (FoldoutButton("Bumper", 1))
        {
            CreateBumper();
        }
        if (FoldoutButton("Checkpoint", 1))
        {
            CreateCheckpoint();
        }
        if (FoldoutButton("Tutorial", 1))
        {
            CreateTutorial();
        }
        GUILayout.Space(5);
    }
Exemplo n.º 2
0
    public static void BakeScene()
    {
        hasResult = false;
        var assembly = Assembly.GetAssembly(typeof(SceneView));
        var type     = assembly.GetType("UnityEditor.LogEntries");
        var method   = type.GetMethod("Clear");

        method.Invoke(new object(), null);
        LevelSerializer.failCause = "";
        Debug.Log("Starting Level Export");

        if (MapComponents.GetNumOf("SpawnPoint") == 0)
        {
            if (MapComponents.GetNumOf("StartPad") != 1)
            {
                LevelSerializer.failCause = "Singleplayer Level needs one StartPad!";
            }
            if (MapComponents.GetNumOf("EndPad") != 1)
            {
                LevelSerializer.failCause = "Singleplayer Level needs one EndPad!";
            }
            if (FindObjectsOfType <LevelTiming>().Length != 1)
            {
                LevelSerializer.failCause = "Singleplayer Level needs one Level Times object!";
            }
        }
        else
        {
            if (MapComponents.GetNumOf("StartPad") > 0)
            {
                LevelSerializer.failCause = "Multiplayer Maps can't have StartPads.";
            }
            if (MapComponents.GetNumOf("EndPad") > 0)
            {
                LevelSerializer.failCause = "Multiplayer Maps can't have EndPads.";
            }
            if (FindObjectsOfType <LevelTiming>().Length > 0)
            {
                LevelSerializer.failCause = "Multiplayer Maps can't have timers.";
            }
        }

        if (MapComponents.GetNumOf("LevelBounds") != 1)
        {
            LevelSerializer.failCause = "Level needs one Level Bounds!";
        }
        else
        {
            GameObject  bounds = MapComponents.FindFixed("LevelBounds");
            BoxCollider box    = bounds.GetComponent <BoxCollider>();
            if (box.size.x > 4096 || box.size.y > 4096 || box.size.z > 4096)
            {
                LevelSerializer.failCause = "Map is too large! Ensure leve bounds dimensions are under 4096.";
            }
        }

        var        serializer = new LevelSerializer();
        ByteStream levelBits  = new ByteStream();

        if (LevelSerializer.failCause.Length == 0)
        {
            serializer.Serialize(ref levelBits);
        }

        if (LevelSerializer.failCause.Length == 0)
        {
            string filePath = "Assets/" + LevelSerializer.GetCurrentSceneLevelId() + ".level";

            FileStream file;
            if (!File.Exists(filePath))
            {
                file = File.Create(filePath);
            }
            else
            {
                file = File.Open(filePath, FileMode.Truncate, FileAccess.Write);
            }
            file.Write(levelBits.Buffer, 0, levelBits.Position);
            file.Close();

            Debug.Log("<color=green>Level Exported:</color> " + filePath);
        }
        else
        {
            Debug.Log("<color=#ff3232>Export Failed:</color> " + LevelSerializer.failCause);
        }
        hasResult = true;
    }