Esempio n. 1
0
    //Unity and Sample Specific
    void Start()
    {
        lt    = 0f;
        blobs = new float[3][];
//        blobs[0] = new float[] { Random.Range(-0.8f, 0.16f), Random.Range(0.0f, 0.1999f), Random.Range(0.0f, 0.1999f), Random.Range(0.12f, 0.16f) };
//        blobs[1] = new float[] { Random.Range(-0.18f, 0.16f), Random.Range(0.0f, 0.1999f), Random.Range(0.0f, 0.1999f), Random.Range(0.12f, 0.16f) };
//        blobs[2] = new float[] { Random.Range(-0.18f, 0.16f), Random.Range(0.0f, 0.1999f), Random.Range(0.0f, 0.1999f), Random.Range(0.12f, 0.16f) };
//        blobs[3] = new float[] { Random.Range(-0.18f, 0.16f), Random.Range(0.0f, 0.1999f), Random.Range(0.0f, 0.1999f), Random.Range(0.12f, 0.16f) };
//        blobs[4] = new float[] { Random.Range(-0.18f, 0.16f), Random.Range(0.0f, 0.1999f), Random.Range(0.0f, 0.1999f), Random.Range(0.12f, 0.16f) };

        //default iso level
        //isoLevel = 1.95f;

        blobs[0] = new float[] { startBlobsPos[0].x, startBlobsPos[0].y, startBlobsPos[0].z, 0.14f };
        blobs[1] = new float[] { startBlobsPos[1].x, startBlobsPos[1].y, startBlobsPos[1].z, 0.14f };
        blobs[2] = new float[] { startBlobsPos[2].x, startBlobsPos[2].y, startBlobsPos[2].z, 0.14f };
        transform.Rotate(startBlobsRot[0], startBlobsRot[1], startBlobsRot[2]);
        isBroken = false;

        //custom iso level
        isoLevel = 1.5f;



        blobsPos = new Vector3[blobs.Length];
        GameObject mainCamera = GameObject.Find("Main Camera");

        timeMan = mainCamera.GetComponent <TimeManipulation>();

        Regen();
    }
Esempio n. 2
0
        public static void RPC_VPlusConfigSync(long sender, ZPackage configPkg)
        {
            if (ZNet.m_isServer) //Server
            {
                if (!Configuration.Current.Server.serverSyncsConfig)
                {
                    return;
                }

                ZPackage pkg = new ZPackage();

                string[]      rawConfigData   = File.ReadAllLines(ConfigurationExtra.ConfigIniPath);
                List <string> cleanConfigData = new List <string>();

                for (int i = 0; i < rawConfigData.Length; i++)
                {
                    if (rawConfigData[i].Trim().StartsWith(";") ||
                        rawConfigData[i].Trim().StartsWith("#"))
                    {
                        continue;                                          //Skip comments
                    }
                    if (rawConfigData[i].Trim().IsNullOrWhiteSpace())
                    {
                        continue;                                               //Skip blank lines
                    }
                    //Add to clean data
                    cleanConfigData.Add(rawConfigData[i]);
                }

                //Add number of clean lines to package
                pkg.Write(cleanConfigData.Count);

                //Add each line to the package
                foreach (string line in cleanConfigData)
                {
                    pkg.Write(line);

                    ZLog.Log("SENTCONFIG: " + line);
                }

                ZRoutedRpc.instance.InvokeRoutedRPC(sender, "VPlusConfigSync", new object[]
                {
                    pkg
                });

                ZLog.Log("VPlus configuration synced to peer #" + sender);
            }
            else //Client
            {
                if (configPkg != null &&
                    configPkg.Size() > 0 &&
                    sender == ZRoutedRpc.instance.GetServerPeerID()) //Validate the message is from the server and not another client.
                {
                    int numLines = configPkg.ReadInt();

                    if (numLines == 0)
                    {
                        ZLog.LogWarning("Got zero line config file from server. Cannot load.");
                        return;
                    }

                    using (MemoryStream memStream = new MemoryStream())
                    {
                        using (StreamWriter tmpWriter = new StreamWriter(memStream))
                        {
                            for (int i = 0; i < numLines; i++)
                            {
                                string line = configPkg.ReadString();

                                tmpWriter.WriteLine(line);

                                ZLog.Log("CONFIGDATA: " + line);
                            }

                            tmpWriter.Flush();      //Flush to memStream
                            memStream.Position = 0; //Rewind stream

                            Configuration.Current = ConfigurationExtra.LoadFromIni(memStream);

                            // Needed to make sure client is using server configuration as dayLength is setup before
                            TimeManipulation.SetupDayLength();

                            ZLog.Log("Successfully synced VPlus configuration from server.");
                        }
                    }
                }
            }
        }
 // Start is called before the first frame update
 void Start()
 {
     _timeManipulationScript = Globals.GetComponent <TimeManipulation>();
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        GameObject mainCamera = GameObject.Find("Main Camera");

        timeMan = mainCamera.GetComponent <TimeManipulation>();
    }