Ejemplo n.º 1
0
        private void OnDestroy()
        {
            Debug.Log("Something destroyed the session!");

            //singleton = null;
            if (mapVariantFileUpdated != null)
            {
                mapVariantFileUpdated(null);
            }

            //Make sure the sandbox is properly disposed of.
            mapVariantFile = null;
        }
Ejemplo n.º 2
0
        void LoadSandbox()
        {
            //byte[] mapData = null;

            //using (var wc = new System.Net.WebClient())
            //    mapData = wc.DownloadData(@"C:\Users\AlexN\Desktop\jenga.map");

            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\No Elephants (Alex231).bin"); //Sandtrap
            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\fatkid.map"); //Guardian
            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\jenga.map"); //Standoff
            mapVariantFile = new MapVariantFile(@"C:\Users\AlexN\Desktop\sandbox.map"); //Guardian
            //sandbox = new Sandbox(new MemoryStream(mapData)); //Sandtrap
            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\sandbox1.map"); //sandbox1
            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\sandbox2.map"); //sandbox2
            //sandbox = new Sandbox(@"C:\Users\AlexN\Desktop\sandtrap.map"); //sandtrap

            if (mapVariantFileUpdated != null)
            {
                mapVariantFileUpdated(mapVariantFile);
            }

            //Debug.Log("Processing " + sandbox.map.Placements.Count + " placements.");

            int count = 1;

            foreach (MapVariant.SandboxPlacement placement in mapVariantFile.MapVariant.sandboxPlacements)
            {
                GameObject go = null;

                if (placement.budgetIndex == -1)
                {
                    continue;
                    //go = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    //go.GetComponent<Renderer>().material = null;
                }
                else
                {
                    count++;

                    try
                    {
                        go = (GameObject)Instantiate(Resources.Load("Foundry/Tags/Prefabs/" + "0x" + mapVariantFile.MapVariant.budgetEntries[placement.budgetIndex].tagIndex.ToString("X4") /*sandbox.map.Budget[placement.BudgetIndex].TagIndex.ToString("X4")*/, typeof(GameObject)));
                    }
                    catch (ArgumentException ae)
                    {
                        go = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        Debug.LogAssertion("Couldn't find a prefab for " + "0x" + mapVariantFile.MapVariant.budgetEntries[placement.budgetIndex].tagIndex.ToString("X4") /*sandbox.map.Budget[placement.BudgetIndex].TagIndex.ToString("X4"))*/);
                        go.GetComponent <Renderer>().material = null;
                    }
                    finally
                    {
                        go.name = "0x" + mapVariantFile.MapVariant.budgetEntries[placement.budgetIndex].tagIndex.ToString("X4") /*sandbox.map.Budget[placement.BudgetIndex].TagIndex.ToString("X4"))*/;
                        //go.tag = "forgePlacement";
                        go.layer = LayerMask.NameToLayer("forgePlacement");

                        go.AddComponent <ForgePlacement>().PlacementData = placement;
                    }
                }
            }
            Debug.Log("Added " + count + " placements to the scene.");

            Maps.AdditiveLoadMap(mapVariantFile.MapVariant.VariantMapID);
        }