public void LoadTrigger()
 {
     try
     {
         ClearTrigger();
         if (TriggerSize <= 0)
         {
             return;
         }
         if (TriggerSize > 100)
         {
             TriggerSize = 100;
         }
         if (TriggerSize > 0)
         {
             meshtriggers = new GameObject[TriggerSize];
             for (int i = 0; i < meshtriggers.Length; i++)
             {
                 meshtriggers[i] = GameObject.CreatePrimitive(PrimitiveType.Plane);
                 meshtriggers[i].GetComponent <MeshCollider>().sharedMesh.Clear();
                 meshtriggers[i].GetComponent <MeshFilter>().mesh.Clear();
                 meshtriggers[i].AddComponent <MTrigger>();
                 meshtriggers[i].GetComponent <MTrigger>().Index = i;
                 meshtriggers[i].transform.localScale            = new Vector3(1, 1, 1);
                 meshtriggers[i].transform.localPosition         = new Vector3(0, 0, 0);
                 meshtriggers[i].name = "_meshtrigger" + i.ToString();
             }
         }
     }
     catch (System.Exception ex)
     {
         GeoTools.Log("Error! LoadTrigger Failed!");
         GeoTools.Log(ex.ToString());
     }
 }
 public void LoadWater()
 {
     try
     {
         if (WaterSize <= 0)
         {
             return;
         }
         if (this.gameObject.GetComponent <Prop>().TileTemp == null)
         {
             return;
         }
         Mwater = new GameObject[WaterSize];
         for (int i = 0; i < Mwater.Length; i++)
         {
             Mwater[i]      = Instantiate(gameObject.GetComponent <Prop>().TileTemp);
             Mwater[i].name = "water" + i.ToString();
             Mwater[i].SetActive(true);
             Mwater[i].transform.localScale    = new Vector3(1, 1, 1);
             Mwater[i].transform.localPosition = new Vector3(0, 0, 0);
         }
     }
     catch (Exception ex)
     {
         GeoTools.Log("LoadWater Failed");
         GeoTools.Log(ex.ToString());
     }
 }
Beispiel #3
0
        /// <summary>
        /// 隐藏雾
        /// </summary>
        public void HideFog()
        {
            FogEnable = !FogEnable;

            //try
            //{
            //    GameObject mainCamera = GameObject.Find("Main Camera");
            //    mainCamera.GetComponent<ColorfulFog>().enabled = FogEnable;
            //}
            //catch
            //{ }

            try
            {
                GameObject fogSPHERE = GameObject.Find("FOG SPHERE");
                fogSPHERE.GetComponent <MeshRenderer>().enabled = FogEnable;
            }
            catch
            { }

            try
            {
                GameObject.Find("Fog Volume").GetComponent <MeshRenderer>().enabled = FogEnable;
            }
            catch (Exception e)
            {
                GeoTools.Log(e.Message);
            }
        }
 void Start()
 {
     new CommandRegistration("VP_CloudSize", (string[] args) =>
     {
         if (args.Length < 1)
         {
             GeoTools.Log("ERROR!");
         }
         try
         {
             int cloudSize = int.Parse(args[0]);
             if (cloudSize < 0 || cloudSize > 3000)
             {
                 GeoTools.Log("Your cloud amount is not available. ");
             }
             else
             {
                 CloudSize = cloudSize;
                 LoadCloud();
             }
         }
         catch
         {
             GeoTools.Log("Could not parse " + args[0] + "to cloud amount");
         }
         GeoTools.Log("There will be " + CloudSize.ToString() + " clouds" + "\n");
     }, "Set CloudSize.No bigger than 80 and no less than 10.");
 }
Beispiel #5
0
        /// <summary>
        /// 加载地图包
        /// </summary>
        /// <param name="ScenePack">地图包列表序号</param>
        public void LoadScenePack(int index)
        {
#if DEBUG
            GeoTools.Log("load scene pack");
#endif
            if (BesiegeNetworkManager.Instance == null)
            {
#if DEBUG
                GeoTools.Log("load scene pack not in multiplayers");
#endif
                StartCoroutine(ILoadScenePack(ScenePacks[index]));
                return;
            }


            if (BesiegeNetworkManager.Instance.isActiveAndEnabled && BesiegeNetworkManager.Instance.isConnected)
            {
#if DEBUG
                GeoTools.Log("load scene pack in multiplayers");
#endif
                StartCoroutine(ILoadScenePack_Multiplayer(ScenePacks[index]));
                return;
            }

            //StartCoroutine(ILoadScenePack(ScenePacks[index]));
        }
Beispiel #6
0
 public void LoadSnow()
 {
     try
     {
         if (SnowSize <= 0)
         {
             return;
         }
         if (this.gameObject.GetComponent <Prop>().SnowTemp == null)
         {
             return;
         }
         MSnow = new GameObject[SnowSize];
         for (int i = 0; i < MSnow.Length; i++)
         {
             MSnow[i]      = (GameObject)Instantiate(gameObject.GetComponent <Prop>().SnowTemp);
             MSnow[i].name = "snow" + i.ToString();
             MSnow[i].SetActive(true);
             MSnow[i].transform.SetParent(transform);
             MSnow[i].transform.localScale    = new Vector3(1, 1, 1);
             MSnow[i].transform.localPosition = new Vector3(0, 0, 0);
         }
     }
     catch (Exception ex)
     {
         GeoTools.Log("Error! LoadSnow Failed");
         GeoTools.Log(ex.ToString());
         ClearSnow();
     }
 }
        public void ClearWater()
        {
            ClearFloater();
            if (Mwater == null)
            {
                return;
            }
            if (Mwater.Length <= 0)
            {
                return;
            }
            if (WaterSize > 0)
            {
                GeoTools.Log("ClearWater");
            }
            gameObject.GetComponent <Prop>().WaterTemp.SetActive(false);
            try
            {
                Destroy(GameObject.Find("WaterTempReflectionMain Camera"));
            }
            catch { }
            for (int i = 0; i < Mwater.Length; i++)
            {
                Destroy(Mwater[i]);
            }

            Mwater    = null;
            WaterSize = 0;
        }
            public LanguageFile(string path)
            {
                string filePath = path;

                dic_Translation = new Dictionary <int, string>();

                try
                {
                    if (!File.Exists(filePath))
                    {
                        GeoTools.Log("Error! Language File not exists!");
                        return;
                    }

                    FileStream fs = new FileStream(filePath, FileMode.Open);
                    //打开数据文件
                    StreamReader srd = new StreamReader(fs, Encoding.Default);

                    while (srd.Peek() != -1)
                    {
                        string str = srd.ReadLine();

                        if (str.Contains(" = ") && str.Length > 2)
                        {
                            //BesiegeConsoleController.ShowMessage(str);

                            string id = str.Substring(0, str.IndexOf(" = "));
                            //BesiegeConsoleController.ShowMessage(id);

                            if (Regex.IsMatch(id, @"^[0-9]*$") && !string.IsNullOrEmpty(id))
                            {
                                int    index = str.IndexOf(" = ") + 3;
                                string value = str.Substring(index, str.Length - index).Replace("\"", string.Empty);

                                dic_Translation[int.Parse(id)] = value;
                                //BesiegeConsoleController.ShowMessage(value);
                            }
                        }
                    }

                    srd.Close();

                    //foreach (var v in dic_Translation)
                    //{
                    //    BesiegeConsoleController.ShowMessage(v.Key + "|" + v.Value);
                    //}

                    GeoTools.Log("Read Language File Completed!");
                }
                catch (Exception ex)
                {
                    GeoTools.Log("Read Language File Failed!");
                    GeoTools.Log(ex.ToString());
                    return;
                }
            }
Beispiel #9
0
 public void LoadCloud()
 {
     try
     {
         ClearCloud();
         if (this.gameObject.GetComponent <Prop>().CloudTemp == null)
         {
             return;
         }
         if (CloudSize < 0)
         {
             CloudSize = 0;
         }
         if (CloudSize > 1000)
         {
             CloudSize = 1000;
         }
         if (CloudSize == 0)
         {
             return;
         }
         else
         {
             clouds = new GameObject[CloudSize];
             axis   = new Vector3[CloudSize];
             for (int i = 0; i < clouds.Length; i++)
             {
                 clouds[i] = (GameObject)Instantiate(this.gameObject.GetComponent <Prop>().CloudTemp, new Vector3(
                                                         UnityEngine.Random.Range(-cloudScale.x + transform.localPosition.x, cloudScale.x + transform.localPosition.x),
                                                         UnityEngine.Random.Range(transform.localPosition.y, cloudScale.y + transform.localPosition.y),
                                                         UnityEngine.Random.Range(-cloudScale.z + transform.localPosition.z, cloudScale.z + transform.localPosition.z)),
                                                     new Quaternion(0, 0, 0, 0));
                 clouds[i].transform.SetParent(this.transform);
                 clouds[i].transform.localScale = new Vector3(100, 100, 100);
                 clouds[i].SetActive(true);
                 ParticleSystem ps = clouds[i].GetComponent <ParticleSystem>();
                 ps.startColor = CloudsColor;
                 axis[i]       = new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f), 1f, UnityEngine.Random.Range(-0.1f, 0.1f));
             }
             // GeoTools.Log("LoadCloud Successfully");
         }
     }
     catch (Exception ex)
     {
         GeoTools.Log("Error! LoadCloud Failed");
         GeoTools.Log(ex.ToString());
         ClearCloud();
     }
 }
Beispiel #10
0
        public void ReadScene(CustomSceneMod.ScenePack scenePack)
        {
            //skyBoxTexturePath = scenePack.TexturesPath + "/SkyBoxTexture.jpg";
            //skyBoxMeshPath = scenePack.MeshsPath + "/Skydome.obj";


            try
            {
                if (!File.Exists(scenePack.SettingFilePath))
                {
                    GeoTools.Log("Error! Scene File not exists!");
                    return;
                }

                FileStream fs = new FileStream(scenePack.SettingFilePath, FileMode.Open);

                //打开数据文件
                StreamReader srd = new StreamReader(fs, Encoding.Default);

                while (srd.Peek() != -1)
                {
                    string   str   = srd.ReadLine();
                    string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    if (chara.Length > 2)
                    {
                        #region Mesheses
                        if (chara[0] == "Sky")
                        {
                            skyBoxTexturePath = scenePack.TexturesPath + "/" + chara[1];
                            create();
                        }
                        #endregion
                    }
                }
                srd.Close();
                //   for (int i = 0; i < this.meshes.Length; i++){GeoTools.MeshFilt(ref this.meshes[i]);}
                GeoTools.Log("Read Sky Completed!");
            }
            catch (Exception ex)
            {
                GeoTools.Log("Error! Read Sky Failed!");
                GeoTools.Log(ex.ToString());
                return;
            }
        }
 public GameObject GetObjectInScene(string ObjectName)
 {
     try
     {
         GameObject ObjectTemp = (GameObject)Instantiate(GameObject.Find(ObjectName));
         ObjectTemp.name = ObjectName + "Temp";
         UnityEngine.Object.DontDestroyOnLoad(ObjectTemp);
         GeoTools.Log("Get " + ObjectName + "Temp Successfully");
         ObjectTemp.SetActive(false);
         return(ObjectTemp);
     }
     catch (Exception ex)
     {
         GeoTools.Log("Error! Get " + ObjectName + "Temp Failed");
         GeoTools.Log(ex.ToString());
         return(null);
     }
 }
Beispiel #12
0
        void create()
        {
            try
            {
                getMesh();

                getTexture();

                CreateSkyMaterialBall();

                skySphere.AddComponent <CameraFollower>();
            }
            catch (Exception e)
            {
                GeoTools.Log("create filed");
                GeoTools.Log(e.Message);
            }
        }
 public void LoadFloater()
 {
     try
     {
         MyBlockInfo[] infoArray = UnityEngine.Object.FindObjectsOfType <MyBlockInfo>();
         foreach (MyBlockInfo info in infoArray)
         {
             if (info.gameObject.GetComponent <Floater>() == null)
             {
                 info.gameObject.AddComponent <Floater>();
             }
         }
     }
     catch
     {
         GeoTools.Log("Error! LoadFloater Failed");
     }
 }
Beispiel #14
0
 public void ClearSnow()
 {
     if (MSnow == null)
     {
         return;
     }
     if (MSnow.Length <= 0)
     {
         return;
     }
     if (SnowSize > 0)
     {
         GeoTools.Log("ClearSnow");
     }
     for (int i = 0; i < MSnow.Length; i++)
     {
         Destroy(MSnow[i]);
     }
 }
        public void LoadCube()
        {
            try
            {
                if (CubeAmount <= 0)
                {
                    return;
                }
                if (CubeAmount > 100)
                {
                    CubeAmount = 100;
                }
                if (CubeAmount > 0)
                {
                    meshCubes = new GameObject[CubeAmount];
                    for (int i = 0; i < CubeAmount; i++)
                    {
                        //meshCubes[i] = GameObject.CreatePrimitive( PrimitiveType.Cube);
                        meshCubes[i] = GameObject.CreatePrimitive(PrimitiveType.Plane);
                        Shader diffuse = Shader.Find("Legacy Shaders/Diffuse");
                        if (diffuse != null)
                        {
                            meshCubes[i].GetComponent <Renderer>().material.shader = diffuse;
                        }
                        meshCubes[i].GetComponent <MeshCollider>().sharedMesh.Clear();
                        meshCubes[i].GetComponent <MeshFilter>().mesh.Clear();
                        meshCubes[i].AddComponent <CubeScript>();
                        meshCubes[i].transform.localScale    = Vector3.one;
                        meshCubes[i].transform.localPosition = Vector3.zero;
                        meshCubes[i].name = "_meshCube" + i.ToString();
                    }
                }
            }
            catch (System.Exception ex)
            {
                GeoTools.Log("Error! Load Cube Failed!");
                GeoTools.Log(ex.ToString());
            }

#if DEBUG
            GeoTools.Log("加载方块");
#endif
        }
 public void ClearMeshes()
 {
     if (meshes == null)
     {
         return;
     }
     if (meshes.Length <= 0)
     {
         return;
     }
     if (MeshSize > 0)
     {
         GeoTools.Log("ClearMeshes");
     }
     for (int i = 0; i < meshes.Length; i++)
     {
         UnityEngine.Object.Destroy(meshes[i]);
     }
 }
 public void ClearTrigger()
 {
     if (meshtriggers == null)
     {
         return;
     }
     if (meshtriggers.Length <= 0)
     {
         return;
     }
     if (TriggerSize > 0)
     {
         GeoTools.Log("ClearTriggers");
     }
     for (int i = 0; i < meshtriggers.Length; i++)
     {
         Destroy(meshtriggers[i]);
     }
 }
Beispiel #18
0
        /// <summary>
        /// 隐藏空气墙
        /// </summary>
        public void HideWorldBoundaries()
        {
            try
            {
                //单人模式下
                GameObject WorldBoundaries_Large = GameObject.Find("WORLD BOUNDARIES_LARGE");

                Set_WorldBoundaries(WorldBoundaries_Large);
            }
            catch (Exception e)
            {
                GeoTools.Log(e.Message);
                WorldBoundariesEnable = !WorldBoundariesEnable;
            }

            try
            {
                //多人模式下
                GameObject WorldBoundaries = GameObject.Find("WORLD BOUNDARIES");

                Set_WorldBoundaries(WorldBoundaries);
            }
            catch (Exception e)
            {
                GeoTools.Log(e.Message);
                WorldBoundariesEnable = !WorldBoundariesEnable;
            }

            void Set_WorldBoundaries(GameObject WorldBoundaries)
            {
                WorldBoundariesEnable = !WorldBoundariesEnable;

                foreach (BoxCollider BC in WorldBoundaries.GetComponentsInChildren <BoxCollider>())
                {
                    BC.isTrigger = !WorldBoundariesEnable;
                }

                foreach (Renderer MR in WorldBoundaries.GetComponentsInChildren <Renderer>())
                {
                    MR.enabled = WorldBoundariesEnable;
                }
            }
        }
Beispiel #19
0
 public void ClearCloud()
 {
     // step = 0;
     if (clouds == null)
     {
         return;
     }
     if (clouds.Length <= 0)
     {
         return;
     }
     if (CloudSize > 0)
     {
         GeoTools.Log("ClearCloud");
     }
     for (int i = 0; i < clouds.Length; i++)
     {
         Destroy(clouds[i]);
     }
 }
        public void ClearCube()
        {
            if (meshCubes == null)
            {
                return;
            }

            if (meshCubes.Length <= 0)
            {
                return;
            }
#if DEBUG
            GeoTools.Log("ClearCubes Amount: " + meshCubes.Length);
#endif
            for (int i = 0; i < meshCubes.Length; i++)
            {
                Destroy(meshCubes[i]);
            }

            meshCubes  = null;
            CubeAmount = 0;
        }
Beispiel #21
0
        /// <summary>
        /// 读取指定路径下所有地图包
        /// </summary>
        /// <param name="scenesPackPath">地图包路径</param>
        /// <returns></returns>
        public List <ScenePack> ReadScenePacks(string scenesPackPath)
        {
            List <ScenePack> SPs = new List <ScenePack>()
            {
            };

            if (!Directory.Exists(scenesPackPath))
            {
                GeoTools.Log("Error! Scenes Path Directory not exists!");
                return(SPs);
            }

            DirectoryInfo TheFolder = new DirectoryInfo(scenesPackPath);

            //遍历文件夹
            foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
            {
                SPs.Add(new ScenePack(NextFolder));
            }

            return(SPs);
        }
 public void LoadMesh()
 {
     try
     {
         ClearMeshes();
         if (MeshSize > 100)
         {
             MeshSize = 100;
         }
         if (MeshSize < 0)
         {
             MeshSize = 0; return;
         }
         if (MeshSize > 0)
         {
             meshes = new GameObject[MeshSize];
             for (int i = 0; i < meshes.Length; i++)
             {
                 meshes[i] = GameObject.CreatePrimitive(PrimitiveType.Plane);
                 Shader diffuse = Shader.Find("Legacy Shaders/Diffuse");
                 if (diffuse != null)
                 {
                     meshes[i].GetComponent <Renderer>().material.shader = diffuse;
                 }
                 meshes[i].GetComponent <MeshCollider>().sharedMesh.Clear();
                 meshes[i].GetComponent <MeshFilter>().mesh.Clear();
                 meshes[i].transform.localScale    = new Vector3(1, 1, 1);
                 meshes[i].transform.localPosition = new Vector3(0, 0, 0);
                 meshes[i].name = "_mesh" + i.ToString();
             }
         }
     }
     catch (System.Exception ex)
     {
         GeoTools.Log("Error! LoadMesh Failed!");
         GeoTools.Log(ex.ToString());
     }
 }
Beispiel #23
0
 void Update()
 {
     if (Input.GetKeyDown(_DisplayUI) && Input.GetKey(KeyCode.LeftControl))
     {
         ShowGUI = !ShowGUI;
     }
     if (Input.GetKeyDown(_ReloadUI) && Input.GetKey(KeyCode.LeftControl))
     {
         ReadUI();
     }
     if (Input.GetKeyDown(_GetLevelInfo) && Input.GetKey(KeyCode.LeftControl))
     {
         GeoTools.GetLevelInfo();
     }
     if (Input.GetKeyDown(_GetCenter) && Input.GetKey(KeyCode.LeftControl))
     {
         GeoTools.GetCenter();
     }
     if (Input.GetKeyDown(_GetShader) && Input.GetKey(KeyCode.LeftControl))
     {
         GeoTools.PrintShader();
     }
 }
 public void ClearFloater()
 {
     try
     {
         bool          sign      = false;
         MyBlockInfo[] infoArray = UnityEngine.Object.FindObjectsOfType <MyBlockInfo>();
         foreach (MyBlockInfo info in infoArray)
         {
             if (info.gameObject.GetComponent <Floater>() != null)
             {
                 Destroy(info.gameObject.GetComponent <Floater>());
                 sign = true;
             }
         }
         if (sign)
         {
             GeoTools.Log("ClearFloater");
         }
     }
     catch
     {
         GeoTools.Log("Error! ClearFloater Failed");
     }
 }
Beispiel #25
0
 void ReadUI()
 {
     DefaultUI();
     //Debug.Log(Screen.currentResolution.ToString());
     try
     {
         StreamReader srd;
         if (File.Exists(GeoTools.UIPath + "CHN.txt"))
         {
             srd = File.OpenText(GeoTools.UIPath + "CHN.txt");
         }
         else
         {
             srd = File.OpenText(GeoTools.UIPath + "EN.txt");
         }
         //Debug.Log(Ci + "  " + Screen.width.ToString() + "*" + Screen.height.ToString());
         while (srd.Peek() != -1)
         {
             string   str   = srd.ReadLine();
             string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             if (chara.Length > 2)
             {
                 if (chara[0] == "_Timer")
                 {
                     if (chara[1] == "unit")
                     {
                         if (chara[2] == "kmh")
                         {
                             this.Unit = ModUnit.kmh;
                         }
                         if (chara[2] == "ms")
                         {
                             this.Unit = ModUnit.ms;
                         }
                         if (chara[2] == "mach")
                         {
                             this.Unit = ModUnit.mach;
                         }
                     }
                     else if (chara[1] == "overload")
                     {
                         if (chara[2] == "OFF")
                         {
                             _overloadUI = string.Empty;
                         }
                         else
                         {
                             _overloadUI = chara[2];
                         }
                     }
                     else if (chara[1] == "time")
                     {
                         if (chara[2] == "OFF")
                         {
                             _timeUI = string.Empty;
                         }
                         else
                         {
                             _timeUI = chara[2];
                         }
                     }
                     else if (chara[1] == "coordinates")
                     {
                         if (chara[2] == "OFF")
                         {
                             _coordinatesUI = string.Empty;
                         }
                         else
                         {
                             _coordinatesUI = chara[2];
                         }
                     }
                     else if (chara[1] == "velocity")
                     {
                         if (chara[2] == "OFF")
                         {
                             _velocityUI = string.Empty;
                         }
                         else
                         {
                             _velocityUI = chara[2];
                         }
                     }
                     else if (chara[1] == "timer")
                     {
                         if (chara[2] == "OFF")
                         {
                             _timerUI = string.Empty;
                         }
                         else
                         {
                             _timerUI = chara[2];
                         }
                     }
                     else if (chara[1] == "distance")
                     {
                         if (chara[2] == "OFF")
                         {
                             _distanceUI = string.Empty;
                         }
                         else
                         {
                             _distanceUI = chara[2];
                         }
                     }
                     else if (chara[1] == "trigger")
                     {
                         if (chara[2] == "OFF")
                         {
                             _triggerUI = string.Empty;
                         }
                         else
                         {
                             _triggerUI = chara[2];
                         }
                     }
                     else if (chara[1] == "display_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _DisplayUI = outputkey;
                         }
                     }
                     else if (chara[1] == "reload_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _ReloadUI = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_Center")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetCenter = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_LevelInfo")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetLevelInfo = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_Shader")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetShader = outputkey;
                         }
                     }
                     else if (chara[1] == "show_on_start")
                     {
                         if (chara[2] == "0" || chara[2] == "OFF")
                         {
                             ShowGUI = false;
                         }
                         else
                         {
                             ShowGUI = true;
                         }
                     }
                 }
                 else if (chara[0] == Screen.width.ToString() + "*" + Screen.height.ToString() + "_Timer")
                 {
                     if (chara[1] == "window_poistion")
                     {
                         windowRect.x = Convert.ToSingle(chara[2]);
                         windowRect.y = Convert.ToSingle(chara[3]);
                     }
                 }
             }
         }
         srd.Close();
         if (Unit == ModUnit.kmh)
         {
             _velocityUI += "(km/h)";
         }
         else if (Unit == ModUnit.ms)
         {
             _velocityUI += "(m/s)";
         }
         else if (Unit == ModUnit.mach)
         {
             _velocityUI += "(mach)";
         }
         filtUI();
         Debug.Log("TimerUISetting Completed!");
     }
     catch (Exception ex)
     {
         Debug.Log("Error! TimerUISetting Failed!");
         Debug.Log(ex.ToString());
         DefaultUI();
         return;
     }
 }
 private void Start()
 {
     try
     {
         this.WaterHeight = GameObject.Find("water0").transform.localPosition.y;
         if (base.GetComponent <Rigidbody>() == null)
         {
             UnityEngine.Object.Destroy(this);
             return;
         }
         else
         {
             float x = base.gameObject.transform.localScale.x;
             float y = base.gameObject.transform.localScale.y;
             float z = base.gameObject.transform.localScale.z;
             if ((x >= y) && (x >= z))
             {
                 this.minVolue = x;
             }
             else if ((y >= x) && (y >= z))
             {
                 this.minVolue = y;
             }
             else
             {
                 this.minVolue = z;
             }
             this.volume      = (x * y) * z;
             this.Drag        = base.GetComponent <Rigidbody>().drag;
             this.AngularDrag = base.GetComponent <Rigidbody>().angularDrag;
             if (base.GetComponent <FireTag>() != null)
             {
                 fireTag = true;
             }
             if (base.GetComponent <MyBlockInfo>().blockName == "SMALL WOOD BLOCK")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WOODEN BLOCK")
             {
                 this.Force = (4f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WOODEN POLE")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WOODEN PANEL")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "PROPELLER")
             {
                 this.Force = (4f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "SMALL PROPELLER")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WING")
             {
                 this.Force = (8f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WING PANEL")
             {
                 this.Force = (4f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "PROPELLOR SMALL")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "Rocket")
             {
                 this.Force = (0.8f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WHEEL")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "LARGE WHEEL")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "WHEEL FREE")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "UNPOWERED LARGE WHEEL")
             {
                 this.Force = (2f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "FLYING SPIRAL")
             {
                 this.Force = (0.8f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "BALLOON")
             {
                 this.Force = (8f * this.volume) / this.ForceScale;
             }
             else if (base.GetComponent <MyBlockInfo>().blockName == "FLAMETHROWER")
             {
                 this.Force = (0.8f * this.volume) / this.ForceScale;
             }
             else
             {
                 this.Force = 0f;
             }
         }
     }
     catch (Exception exception)
     {
         GeoTools.Log(exception.ToString());
         UnityEngine.Object.Destroy(this);
     }
 }
Beispiel #27
0
 public void ReadScene(string SceneName)
 {
     CloudsColor = new Color(0.9f, 0.9f, 0.9f, 0.6f);
     try
     {
         //GeoTools.Log(Application.dataPath);
         if (!File.Exists(ScenePath + SceneName + ".txt"))
         {
             GeoTools.Log("Error! Scene File not exists!");
             return;
         }
         StreamReader srd = File.OpenText(ScenePath + SceneName + ".txt");
         while (srd.Peek() != -1)
         {
             string   str   = srd.ReadLine();
             string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             if (chara.Length > 2)
             {
                 #region Cloud
                 if (chara[0] == "Cloud")
                 {
                     if (chara[1] == "size")
                     {
                         this.CloudSize = Convert.ToInt32(chara[2]);
                         LoadCloud();
                     }
                     if (chara[1] == "step")
                     {
                         this.cloudstep = Convert.ToInt32(chara[2]);
                     }
                     else if (chara[1] == "floorScale" || chara[1] == "cloudScale")
                     {
                         cloudScale = new Vector3(
                             Convert.ToSingle(chara[2]),
                             Convert.ToSingle(chara[3]),
                             Convert.ToSingle(chara[4]));
                     }
                     else if (chara[1] == "location")
                     {
                         this.transform.localPosition = new Vector3(
                             Convert.ToSingle(chara[2]),
                             Convert.ToSingle(chara[3]),
                             Convert.ToSingle(chara[4]));
                     }
                     else if (chara[1] == "color")
                     {
                         this.CloudsColor = new Color(
                             Convert.ToSingle(chara[2]),
                             Convert.ToSingle(chara[3]),
                             Convert.ToSingle(chara[4]),
                             Convert.ToSingle(chara[5]));
                     }
                 }
                 #endregion
             }
         }
         srd.Close();
         GeoTools.Log("ReadCloud Completed!");
     }
     catch (Exception ex)
     {
         GeoTools.Log("Error! ReadCloud Failed!");
         GeoTools.Log(ex.ToString());
         return;
     }
 }
 public void ReadScene(string SceneName)
 {
     WaterSize = 0;
     try
     {
         //  GeoTools.Log(Application.dataPath);
         if (!File.Exists(GeoTools.ScenePath + SceneName + ".txt"))
         {
             GeoTools.Log("Error! Scene File not exists!");
             return;
         }
         StreamReader srd = File.OpenText(GeoTools.ScenePath + SceneName + ".txt");
         while (srd.Peek() != -1)
         {
             string   str   = srd.ReadLine();
             string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             if (chara.Length > 2)
             {
                 #region Water
                 if (chara[0] == "MWater" || chara[0] == "Mwater")
                 {
                     if (chara[1] == "size")
                     {
                         this.WaterSize = Convert.ToInt32(chara[2]);
                         LoadWater();
                     }
                     if (chara[1] == "watertemp")
                     {
                         if (Convert.ToInt32(chara[2]) == 0)
                         {
                             gameObject.GetComponent <Prop>().WaterTemp.SetActive(false);
                         }
                         else
                         {
                             gameObject.GetComponent <Prop>().WaterTemp.SetActive(true);
                         }
                     }
                 }
                 else if (chara[0] == "Water")
                 {
                     int i = Convert.ToInt32(chara[1]);
                     if (chara[2] == "mesh")
                     {
                         Mwater[i].GetComponent <MeshFilter>().mesh = GeoTools.MeshFromObj(chara[3]);
                     }
                     else if (chara[2] == "wmesh")
                     {
                         Mwater[i].GetComponent <MeshFilter>().mesh = GeoTools.WMeshFromObj(chara[3]);
                     }
                     else if (chara[2] == "scale")
                     {
                         Mwater[i].transform.localScale = new Vector3(
                             Convert.ToSingle(chara[3]),
                             Convert.ToSingle(chara[4]),
                             Convert.ToSingle(chara[5]));
                     }
                     else if (chara[2] == "location")
                     {
                         Mwater[i].transform.localPosition = new Vector3(
                             Convert.ToSingle(chara[3]),
                             Convert.ToSingle(chara[4]),
                             Convert.ToSingle(chara[5]));
                     }
                     else if (chara[2] == "meshcollider")
                     {
                         Mwater[i].GetComponent <MeshCollider>().sharedMesh = GeoTools.MeshFromObj(chara[3]);
                         Mwater[i].GetComponent <MeshCollider>().convex     = true;
                         Mwater[i].GetComponent <MeshCollider>().isTrigger  = true;
                     }
                     else if (chara[2] == "wmeshcollider")
                     {
                         Mwater[i].GetComponent <MeshCollider>().sharedMesh = GeoTools.WMeshFromObj(chara[3]);
                         Mwater[i].GetComponent <MeshCollider>().convex     = true;
                         Mwater[i].GetComponent <MeshCollider>().isTrigger  = true;
                     }
                 }
                 #endregion
             }
         }
         srd.Close();
         GeoTools.Log("ReadWater Completed!");
     }
     catch (Exception ex)
     {
         GeoTools.Log("Error! ReadWater Failed!");
         GeoTools.Log(ex.ToString());
         return;
     }
 }
        void FixedUpdate()
        {
            if (Isstart > 6 * t)
            {
                return;
            }
            try
            {
                if (Isstart == 1 * t)
                {
                    try
                    {
                        WWW iteratorVariable0 = new WWW("file:///" + GeoTools.ShaderPath + "water5");
                        iteratorVariable1 = iteratorVariable0.assetBundle;
                        if (iteratorVariable1 != null)
                        {
                            string[] names = iteratorVariable1.GetAllAssetNames();
                            for (int i = 0; i < names.Length; i++)
                            {
#if DEBUG
                                GeoTools.Log(names[i]);
#endif
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        GeoTools.Log("Error! assetBundle failed");
                        GeoTools.Log(ex.ToString());
                    }
                }
                if (Isstart == 2 * t)
                {
                    StartedScene = SceneManager.GetActiveScene().name;
                    if (StartedScene != "TITLE SCREEN")
                    {
                        return;
                    }
                    //GeoTools.OpenScene("TITLE SCREEN");
                    CloudTemp = GetObjectInScene("CLoud");
                    ParticleSystemRenderer psr = CloudTemp.GetComponent <ParticleSystemRenderer>();
                    psr.receiveShadows             = false;
                    psr.sharedMaterial.mainTexture = iteratorVariable1.LoadAsset <Texture>(
                        "Assets/Standard Assets/ParticleSystems/Textures/ParticleCloudWhite.png");
                    psr.shadowCastingMode = ShadowCastingMode.Off;
                    ParticleSystem ps = CloudTemp.GetComponent <ParticleSystem>();
                    ps.startSize     = 30;
                    ps.startLifetime = 60;
                    ps.startSpeed    = 0.8f;
                    ps.maxParticles  = 15;
                    CloudTemp.name   = "CloudTemp";
                    DontDestroyOnLoad(CloudTemp);
                    CloudTemp.SetActive(false);
#if DEBUG
                    GeoTools.Log("Get " + CloudTemp.name + " Successfully");
#endif
                }
                if (Isstart == 3 * t)
                {
//                    for (int i = 0; i <= 10; i++)
//                    {
//                        string jpgName = "WM" + i.ToString();
//                        if (!File.Exists(GeoTools.TexturePath + jpgName + ".jpg")) break;
//                        GameObject WMTemp = GameObject.CreatePrimitive(PrimitiveType.Plane);
//                        WMTemp.GetComponent<Renderer>().material.shader = Shader.Find("Standard");
//                        WMTemp.GetComponent<Renderer>().material.SetFloat("_Glossiness", 1);
//                        WMTemp.GetComponent<Renderer>().material.mainTexture = GeoTools.LoadTexture(jpgName);
//                        WMTemp.name = jpgName + "Temp";
//                        DontDestroyOnLoad(WMTemp);
//                        WMTemp.SetActive(false);
//                        this.MaterialTemp.Add(WMTemp);
//#if DEBUG
//                        GeoTools.Log("Get " + WMTemp.name + " Successfully");
//#endif
//                    }
                }

                if (Isstart == 4 * t)
                {
                    WaterTemp = new GameObject();
                    WaterTemp.AddComponent <WaterBase>();
                    WaterTemp.AddComponent <SpecularLighting>();
                    WaterTemp.AddComponent <PlanarReflection>();
                    WaterTemp.AddComponent <GerstnerDisplace>();
                    TileTemp = iteratorVariable1.LoadAsset <GameObject>(
                        "assets/standard assets/environment/water/water4/prefabs/TileOnly.prefab");
                    TileTemp.AddComponent <WaterTile>();
                    TileTemp.GetComponent <WaterTile>().reflection = WaterTemp.GetComponent <PlanarReflection>();
                    TileTemp.GetComponent <WaterTile>().waterBase  = WaterTemp.GetComponent <WaterBase>();
                    Material mat = TileTemp.GetComponent <Renderer>().material;
                    GeoTools.ResetWaterMaterial(ref mat);
                    UnityEngine.Object.DontDestroyOnLoad(TileTemp);
                    TileTemp.name = "TileTemp";
                    TileTemp.SetActive(false);
                    WaterTemp.GetComponent <WaterBase>().sharedMaterial = TileTemp.GetComponent <Renderer>().material;
                    UnityEngine.Object.DontDestroyOnLoad(WaterTemp);
                    WaterTemp.name = "WaterTemp";
                    WaterTemp.SetActive(false);
#if DEBUG
                    GeoTools.Log("Get " + TileTemp.name + " Successfully");
#endif
                }
                if (Isstart == 5 * t)
                {
                    SnowTemp = iteratorVariable1.LoadAsset <GameObject>(
                        "assets/standard assets/particlesystems/prefabs/duststom2.prefab");
                    SnowTemp.name = "SnowTemp";
                    SnowTemp.SetActive(false);
                    UnityEngine.Object.DontDestroyOnLoad(SnowTemp);
#if DEBUG
                    GeoTools.Log("Get " + SnowTemp.name + " Successfully");
#endif
                }
            }
            catch (Exception ex)
            {
                GeoTools.Log(ex.ToString());
            }
            if (Isstart < 6 * t)
            {
                Isstart++;
            }
        }
            public SettingsFile()
            {
                string filePath = SettingsPath;

                settings = Settings.Default;

                try
                {
                    if (!File.Exists(filePath))
                    {
                        GeoTools.Log("Error! Settings.txt File not exists!");
                        return;
                    }

                    FileStream fs = new FileStream(filePath, FileMode.Open);
                    //打开数据文件
                    StreamReader srd = new StreamReader(fs, Encoding.Default);

                    while (srd.Peek() != -1)
                    {
                        string   str   = srd.ReadLine();
                        string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        if (chara.Length >= 2)
                        {
                            #region Camera
                            if (chara[0] == "_Scene")
                            {
                                if (chara[1] == "display_UI")
                                {
                                    settings.sceneUI = (KeyCode)Enum.Parse(typeof(KeyCode), chara[2].ToUpper(), true);
                                }
                                else if (chara[1] == "reload_UI")
                                {
                                    settings.sceneUI_refresh = (KeyCode)Enum.Parse(typeof(KeyCode), chara[2].ToUpper(), true);
                                }
                                else if (chara[1] == "show_on_start")
                                {
                                    if (chara[2] == "0" || chara[2] == "OFF")
                                    {
                                        settings.sceneUI_showOnAwake = false;
                                    }
                                }
                            }
                            else if (chara[0] == "_Timer")
                            {
                                if (chara[1] == "display_UI")
                                {
                                    settings.timerUI = (KeyCode)Enum.Parse(typeof(KeyCode), chara[2].ToUpper(), true);
                                }
                                else if (chara[1] == "reload_UI")
                                {
                                    settings.timerUI_refresh = (KeyCode)Enum.Parse(typeof(KeyCode), chara[2].ToUpper(), true);
                                }
                                else if (chara[1] == "show_on_start")
                                {
                                    if (chara[2] == "0" || chara[2] == "OFF")
                                    {
                                        settings.timerUI_showOnAwake = false;
                                    }
                                }
                            }
                            else if (chara[0] == "_Language")
                            {
                                if (chara[2] != settings.language)
                                {
                                    settings.language = chara[2];
                                }
                            }
                            #endregion
                        }
                    }
                    srd.Close();

                    GeoTools.Log("Read Settings Completed!");
                }
                catch (Exception ex)
                {
                    GeoTools.Log("Read Settings Failed!");
                    GeoTools.Log(ex.ToString());
                    return;
                }
            }