Beispiel #1
0
 public static void SetRotation(BuildObject buildObject, Quaternion rotation)
 {
     buildObject.rw = GmUtil.FloatToInt(rotation.w);
     buildObject.rx = GmUtil.FloatToInt(rotation.x);
     buildObject.ry = GmUtil.FloatToInt(rotation.y);
     buildObject.rz = GmUtil.FloatToInt(rotation.z);
 }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        build = Resources.Load("Builds/Build") as BuildObject;
        build = build.Get(); //creates clone so that the build object does not get overwritten ie stays the same

        setText();
        createButtons();
        setAudio();
    }
Beispiel #3
0
    public void Build()
    {
        BuildObject BO = currentPreview.GetComponent <BuildObject>();

        if (BO.isBuildable)
        {
            Instantiate(currentObjects.prefab, currentpos, Quaternion.Euler(currentRot));
        }
    }
Beispiel #4
0
        public static Quaternion GetRotation(BuildObject buildObject)
        {
            Quaternion r = new Quaternion();

            r.w = GmUtil.IntToFloat(buildObject.rw);
            r.x = GmUtil.IntToFloat(buildObject.rx);
            r.y = GmUtil.IntToFloat(buildObject.ry);
            r.z = GmUtil.IntToFloat(buildObject.rz);
            return(r);
        }
Beispiel #5
0
    public override void OnInspectorGUI()
    {
        BuildObject myTarget = (BuildObject)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Build Object"))
        {
            myTarget.InstantiateObject();
        }
    }
Beispiel #6
0
    public void ChangeCurrentBuilding(int curr)
    {
        currObject = objects [curr];

        if (preview != null)
        {
            Destroy(preview.gameObject);
        }

        GameObject currPreview = Instantiate(currObject.preview, currPosition, Quaternion.Euler(currRotation)) as GameObject;

        preview = currPreview.transform;
    }
        /// <summary>
        /// Run the requested executable and produce a report of the results.
        /// </summary>
        /// <param name="executionRequest">The execution request.</param>
        /// <returns>A report of the results.</returns>
        private CloudExecutionReport RunAnExecutable(CloudExecutionRequest executionRequest)
        {
            // REVIEW: How/whether to use this.
            BuildObject diagnosticsBase = new BuildObject(Path.Combine("nuobj", "diagnostics", "process"));

            // Prep working directory with input files and output dirs.
            // TODO: The below will throw cache exceptions if something
            // isn't there (they should all be though).  Need to catch
            // these and fail the execution request when this happens.
            WorkingDirectory workingDirectory = new WorkingDirectory(this.virtualIronRoot);

            foreach (BuildObjectValuePointer inputFile in executionRequest.InputFileMappings)
            {
                // REVIEW: How to determine cache container here.
                ItemCacheContainer container = ItemCacheContainer.Sources;
                if (this.multiplexedItemCache.GetItemSize(container, inputFile.ObjectHash) == -1)
                {
                    container = ItemCacheContainer.Objects;
                }

                // TODO: Move path/directory manipulation code into
                // WorkingDirectory and/or ItemCache.
                string inputFilePath = workingDirectory.PathTo(inputFile.RelativePath);
                Directory.CreateDirectory(Path.GetDirectoryName(inputFilePath));  // REVIEW: Still neeeded?
                this.multiplexedItemCache.FetchItemToFile(
                    container,
                    inputFile.ObjectHash,
                    inputFilePath);
            }

            foreach (BuildObject outputFile in executionRequest.OutputFiles)
            {
                workingDirectory.CreateDirectoryFor(outputFile);
            }

            // Run executable.
            ProcessInvoker pinv = new ProcessInvoker(
                workingDirectory,
                executionRequest.Executable,
                new string[] { executionRequest.Arguments },
                diagnosticsBase,
                null,  // This is captureStdout.  TODO: Should cleanup how this is used in ProcessInvoker.
                null); // This is dbgText.  REVIEW: How/whether to use this.

            // When ProcessInvoker's constructor returns, the process has
            // finished running.
            Console.WriteLine("Request {0} completed in {1} seconds.", executionRequest.Identifier, pinv.CpuTime);

            // Store output files in the (cloud) item cache, and create a
            // list of the mappings.
            List <BuildObjectValuePointer> outputFileMappings = new List <BuildObjectValuePointer>();

            foreach (BuildObject outFile in executionRequest.OutputFiles)
            {
                if (File.Exists(workingDirectory.PathTo(outFile)))
                {
                    string fileHash = Util.hashFilesystemPath(workingDirectory.PathTo(outFile));
                    Util.Assert(!string.IsNullOrEmpty(fileHash));

                    // Note we explicitly write to the cloud cache here.
                    this.cloudCache.StoreItemFromFile(ItemCacheContainer.Objects, fileHash, workingDirectory.PathTo(outFile));
                    outputFileMappings.Add(new BuildObjectValuePointer(fileHash, outFile.getRelativePath()));
                }
            }

            // Collect the results into a report.
            CloudExecutionReport report = new CloudExecutionReport(
                executionRequest.Identifier,
                CloudExecutionReport.StatusCode.Completed,
                pinv.ExitCode,
                pinv.GetStdout(),
                pinv.GetStderr(),
                pinv.CpuTime,
                outputFileMappings);

            return(report);
        }
Beispiel #8
0
    public void BuildCanvas(string path)
    {
        //creates friendly version for loading at runtime
        if (nodes == null)
        {
            nodes = new List <Node>();
        }
        if (connections == null)
        {
            connections = new List <Connection>();
        }
        List <BuildNode> buildNodes = new List <BuildNode>();

        //build node array
        List <Node> node_index_reference = new List <Node>();

        for (int i = 0; i < nodes.Count; i++)
        {
            if (nodes[i].GetType() == typeof(DialogNode))
            {
                node_index_reference.Add(nodes[i]);
                NodeInfo temp = nodes[i].GetInfo();
                buildNodes.Add(new BuildNode(temp.title, temp.text, temp.clip, temp.triggers));
            }
        }

        //build next indexes //indices?
        for (int i = 0; i < node_index_reference.Count; i++)
        {
            for (int j = 0; j < connections.Count; j++)
            {
                if (connections[j].outPoint.node == node_index_reference[i])
                {
                    int index_of_next    = node_index_reference.IndexOf(connections[j].inPoint.node);
                    int index_of_trigger = ((DialogNode)node_index_reference[i]).outPoints.IndexOf(connections[j].outPoint);
                    buildNodes[i].next_index[index_of_trigger] = index_of_next;
                }
            }
        }

        //get starting DialogNode
        Node start_n = null;

        for (int i = 0; i < nodes.Count; i++)
        {
            if (nodes[i].GetType() == typeof(StartNode))
            {
                start_n = nodes[i];
            }
        }
        if (start_n == null)
        {
            Debug.LogError("No Start Node");
            return;
        }
        int starting_index = -1;

        for (int i = 0; i < connections.Count; i++)
        {
            if (connections[i].outPoint.node == start_n)
            {
                starting_index = node_index_reference.IndexOf(connections[i].inPoint.node);
            }
        }
        if (starting_index < 0)
        {
            Debug.LogError("Start Node not connected to anything");
            return;
        }

        BuildObject build = CreateInstance <BuildObject>();

        build.Init(buildNodes, starting_index, starting_index);

        //
        AssetDatabase.CreateAsset(build, path);
    }