void OnGUI()
    {
        GUI.BeginGroup(new Rect(10, 10, Screen.width - 20, 40));
        if (GUI.Button(new Rect(0, 0, 180, 40), "Combat")) {
            game.ChangeScene("Combat");
        }
        if (GUI.Button(new Rect(190, 0, 180, 40), "Navigate")) {
            game.Navigate();
        }
        GUI.EndGroup();

        GUILayout.BeginArea(new Rect(10, 10, 250, Screen.height - 20));
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Clear")) {
            hullManifest = null;
            inventoryManifest = null;
            hull.Reset();
            inventory.Reset();
        }
        if (GUILayout.Button("Reset")) {
            hull.Reset();
            inventory.Reset();
        }
        if (GUILayout.Button("Save")) {
            // Save the game with a prefix of Game
            var t = DateTime.Now;
            hull.Save();
            inventory.Save();
            LevelSerializer.SaveGame("Game");
            Radical.CommitLog();
            Debug.Log(string.Format("{0:0.000}", (DateTime.Now - t).TotalSeconds));
        }

        // Check to see if there is resume info
        if (LevelSerializer.CanResume) {
            if (GUILayout.Button("Resume")) {
                LevelSerializer.Resume();
            }
        }

        if (LevelSerializer.SavedGames.Count > 0) {
            GUILayout.Label("Available saved games");
            // Look for saved games under the given player name
            foreach (var g in LevelSerializer.SavedGames[LevelSerializer.PlayerName]) {
                if (GUILayout.Button(g.Caption)) {
                    g.Load();
                }

            }
        }

        if (GUILayout.Button("Delete All")) {
            PlayerPrefs.DeleteAll();
        }
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
示例#2
0
    /**
     * Save state to manifest
     */
    public InventoryManifest CreateManifest()
    {
        InventoryManifest manifest = new InventoryManifest(this);

        foreach (var slot in slots)
        {
            if (slot.module == null)
            {
                continue;
            }
            var            slotManifest   = new InventorySlotManifest();
            ModuleManifest moduleManifest = slot.module.manifest;
            slotManifest.module = moduleManifest;
            slotManifest.count  = slot.number;
            moduleManifest.inventorySlotIndex = slots.FindIndex((x) => x == slot);
            moduleManifest.type = (ModuleType)slot.module.GetType().GetField("type").GetRawConstantValue();
            manifest.slots.Add(slotManifest);
        }
        return(manifest);
    }
示例#3
0
    /**
     * construct invetory based on manifest
     */
    public void Construct(InventoryManifest manifest)
    {
        modules = new List <ConstructionModule>();
        foreach (var slotManifest in manifest.slots)
        {
            var moduleManifest        = slotManifest.module;
            ConstructionModule module = Instantiate(
                game.GetConstructionModulePrefab(moduleManifest.type),
                moduleManifest.position,
                moduleManifest.rotation
                ) as ConstructionModule;
            module.manifest = moduleManifest;

            var slot = slots[moduleManifest.inventorySlotIndex];

            slot.number += slotManifest.count - 1;
            AddModule(module, slot);

            Debug.Log("Created " + slotManifest.count + " " + module.GetModuleType() + " modules with name: " + moduleManifest.name);
        }
    }
 protected override void Awake()
 {
     base.Awake();
     hullManifest = game.hullManifest;
     inventoryManifest = game.inventoryManifest;
 }
示例#5
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(10, 10, Screen.width - 20, 40));
        if (GUI.Button(new Rect(0, 0, 180, 40), "Combat"))
        {
            game.ChangeScene("Combat");
        }
        if (GUI.Button(new Rect(190, 0, 180, 40), "Navigate"))
        {
            game.Navigate();
        }
        GUI.EndGroup();

        GUILayout.BeginArea(new Rect(10, 10, 250, Screen.height - 20));
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Clear"))
        {
            hullManifest      = null;
            inventoryManifest = null;
            hull.Reset();
            inventory.Reset();
        }
        if (GUILayout.Button("Reset"))
        {
            hull.Reset();
            inventory.Reset();
        }
        if (GUILayout.Button("Save"))
        {
            // Save the game with a prefix of Game
            var t = DateTime.Now;
            hull.Save();
            inventory.Save();
            LevelSerializer.SaveGame("Game");
            Radical.CommitLog();
            Debug.Log(string.Format("{0:0.000}", (DateTime.Now - t).TotalSeconds));
        }

        // Check to see if there is resume info
        if (LevelSerializer.CanResume)
        {
            if (GUILayout.Button("Resume"))
            {
                LevelSerializer.Resume();
            }
        }

        if (LevelSerializer.SavedGames.Count > 0)
        {
            GUILayout.Label("Available saved games");
            // Look for saved games under the given player name
            foreach (var g in LevelSerializer.SavedGames[LevelSerializer.PlayerName])
            {
                if (GUILayout.Button(g.Caption))
                {
                    g.Load();
                }
            }
        }

        if (GUILayout.Button("Delete All"))
        {
            PlayerPrefs.DeleteAll();
        }
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
示例#6
0
 override protected void Awake()
 {
     base.Awake();
     hullManifest      = game.hullManifest;
     inventoryManifest = game.inventoryManifest;
 }