public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the MoveNext method in Dictionary ValueCollection Enumerator");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.ValueCollection.Enumerator ValEnumer1 = new Dictionary<string, string>.ValueCollection(dic).GetEnumerator();
         if (ValEnumer1.Current != null || ValEnumer1.MoveNext() != true)
         {
             TestLibrary.TestFramework.LogError("001.1", "The ExpectResult is not the ActualResult");
             retVal = false;
         }
         if (ValEnumer1.MoveNext())
         {
             TestLibrary.TestFramework.LogError("001.2", "The method MoveNext should return false but it did not");
         }
         ValEnumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Return the property Current in Dictionary KeyCollection Enumerator 2");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer = new Dictionary<string, string>.KeyCollection(dic).GetEnumerator();
         while (keyEnumer.MoveNext())
         {
             if (keyEnumer.Current != "1")
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
         keyEnumer.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
        public void Dictionary_thread_test()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            Dictionary<int, int> testDictionary = new Dictionary<int, int>(path);
            try
            {
                _error = false;

                System.Collections.Generic.List<Thread> tList = new System.Collections.Generic.List<Thread>(100);
                for (int i = 0; i < 20; i++)
                {
                    Thread t = new Thread(DoWriteTest3);
                    tList.Add(t);
                    t.Start(testDictionary);
                }

                for (int i = 0; i < 20; i++)
                {
                    Thread t = new Thread(DoReadTest3);
                    tList.Add(t);
                    t.Start(testDictionary);
                }

                foreach (Thread t in tList)
                {
                    t.Join();
                }
                Assert.IsFalse(_error);
            }
            finally
            {
                testDictionary.Dispose();
            }
        }
Beispiel #4
0
 public void Dispose()
 {
     PostingLists?.Dispose();
     Dictionary?.Dispose();
     Fields?.Dispose();
     HeaderReader?.Dispose();
 }
 public void LoadExistingDict()
 {
     try
     {
         var dict = new Dictionary<int, int>(_path, 20, true, "test1");
         Assert.AreEqual(2, dict.Count);
         Assert.AreEqual(0, dict[0]);
         Assert.AreEqual(1, dict[1]);
         dict.Dispose();
     }
     catch (AssertionException e)
     {
         //assertfailed
         _errorMessage = e.Message;
         _error = true;
     }
 }
 public void CreateDict()
 {
     try
     {
         var dict = new Dictionary<int, int>(_path, 20, true, "test1");
         dict[0] = 0;
         dict[1] = 1;
         Assert.AreEqual(2, dict.Count);
         Assert.AreEqual(0, dict[0]);
         Assert.AreEqual(1, dict[1]);
         dict.Dispose();
     }
     catch (AssertionException e)
     {
         //Assertion failed..
         _errorMessage = e.Message;
         _error = true;
     }
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the property Current in Dictionary KeyCollection Enumerator 1");
     try
     {
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer = new Dictionary<string, string>.KeyCollection.Enumerator();
         if (keyEnumer.Current != null)
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult");
             retVal = false;
         }
         keyEnumer.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the Dispose method in Dictionary KeyCollection Enumerator 1");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         dic.Add("2", "test2");
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer1 = new Dictionary<string, string>.KeyCollection.Enumerator();
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer2 = new Dictionary<string,string>.KeyCollection(dic).GetEnumerator();
         keyEnumer2.Dispose();
         keyEnumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("001", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the Dispose method in Dictionary Enumerator 2");
     try
     {
         myClass TKey = new myClass();
         myClass TValue = new myClass();
         Dictionary<myClass, myClass> dic = new Dictionary<myClass, myClass>();
         dic.Add(TKey,TValue );
         Dictionary<myClass, myClass>.Enumerator enumer1 = new Dictionary<myClass, myClass>.Enumerator();
         Dictionary<myClass, myClass>.Enumerator enumer2 = dic.GetEnumerator();
         enumer2.Dispose();
         enumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Beispiel #10
0
        internal override void Update()
        {
            int num = Time.frameCount - 3;

            Dictionary <Camera, DynamicWaterCameraData> .Enumerator enumerator = this._Buffers.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <Camera, DynamicWaterCameraData> keyValuePair = enumerator.Current;
                if (keyValuePair.Value._LastFrameUsed < num)
                {
                    KeyValuePair <Camera, DynamicWaterCameraData> keyValuePair2 = enumerator.Current;
                    keyValuePair2.Value.Dispose();
                    List <Camera> lostCameras = this._LostCameras;
                    KeyValuePair <Camera, DynamicWaterCameraData> keyValuePair3 = enumerator.Current;
                    lostCameras.Add(keyValuePair3.Key);
                }
            }
            enumerator.Dispose();
            for (int i = 0; i < this._LostCameras.Count; i++)
            {
                this._Buffers.Remove(this._LostCameras[i]);
            }
            this._LostCameras.Clear();
        }
    public bool SaveToUpdateTxt(string fileName)
    {
        if (string.IsNullOrEmpty(fileName))
        {
            return(false);
        }
        FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write);

        try
        {
            Dictionary <string, ResInfo> .Enumerator iter = m_FileMd5Map.GetEnumerator();

            int writeBytes = 0;
            while (iter.MoveNext())
            {
                string s   = string.Format("{0}=0;false\r\n", iter.Current.Value.fileContentMd5);
                byte[] dst = System.Text.Encoding.ASCII.GetBytes(s);
                stream.Write(dst, 0, dst.Length);
                writeBytes += dst.Length;
                if (writeBytes > 2048)
                {
                    writeBytes = 0;
                    stream.Flush();
                }
            }

            iter.Dispose();
        } finally
        {
            stream.Close();
            stream.Dispose();
            stream = null;
        }

        return(true);
    }
Beispiel #12
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the Dispose method in Dictionary Enumerator 2");
        try
        {
            myClass TKey   = new myClass();
            myClass TValue = new myClass();
            Dictionary <myClass, myClass> dic = new Dictionary <myClass, myClass>();
            dic.Add(TKey, TValue);
            Dictionary <myClass, myClass> .Enumerator enumer1 = new Dictionary <myClass, myClass> .Enumerator();

            Dictionary <myClass, myClass> .Enumerator enumer2 = dic.GetEnumerator();
            enumer2.Dispose();
            enumer1.Dispose();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
        public void When_adding_more_items_to_an_existing_file_validate_the_content2()
        {
            var dict = new Dictionary<string, int>(_path, 20, true, "test1");
            dict["new0"] = 0;
            dict["new1"] = 1;

            foreach (var kvp in dict)
            {
                if( kvp.Key != "new0" && kvp.Key != "new1")
                    Assert.Fail("Error in reading keys");
            }

            dict.Dispose();
            dict = new Dictionary<string, int>(_path, 20, true, "test1");
            Assert.AreEqual(2, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            dict["test0"] = 2;

            foreach (var kvp in dict)
            {
                if (kvp.Key != "new0" && kvp.Key != "new1" && kvp.Key != "test0")
                    Assert.Fail("Error in reading keys");
            }

            Assert.AreEqual(3, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            Assert.AreEqual(2, dict["test0"]);

            dict.Dispose();
            dict = new Dictionary<string, int>(_path, 20, true, "test1");
            Assert.AreEqual(3, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            Assert.AreEqual(2, dict["test0"]);
        }
 /// <inheritdoc />
 public void Dispose() => _groupEnumerator.Dispose();
Beispiel #15
0
        public bool ContainType(ObjectType ba)
        {
            switch (ba)
            {
            case ObjectType.Seed:
                if (storage.Seeds.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ObjectType.Result:
                if (storage.Results.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ObjectType.PrimaryOil:
                if (storage.Oils.Count > 0)
                {
                    Dictionary <int, Oil> .Enumerator t = storage.Oils.GetEnumerator();
                    for (int i = 0; i < storage.Oils.Count; i++)
                    {
                        if (t.Current.Value.OilType == (int)ObjectType.PrimaryOil)
                        {
                            return(true);
                        }
                        t.MoveNext();
                    }
                    t.Dispose();

                    return(false);
                }
                else
                {
                    return(false);
                }

            case ObjectType.SemiOil:
                if (storage.Oils.Count > 0)
                {
                    Dictionary <int, Oil> .Enumerator t = storage.Oils.GetEnumerator();
                    for (int i = 0; i < storage.Oils.Count; i++)
                    {
                        if (t.Current.Value.OilType == (int)ObjectType.SemiOil)
                        {
                            return(true);
                        }
                        t.MoveNext();
                    }
                    t.Dispose();

                    return(false);
                }
                else
                {
                    return(false);
                }

            case ObjectType.SeniorOil:
                if (storage.Oils.Count > 0)
                {
                    Dictionary <int, Oil> .Enumerator t = storage.Oils.GetEnumerator();

                    Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", "大于0", "test1"));

                    for (int i = 0; i < storage.Oils.Count; i++)
                    {
                        t.MoveNext();
//                            Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", t.Current.Value.OilType, t.Current.Key));

                        if (t.Current.Value.OilType == (int)ObjectType.SeniorOil)
                        {
                            return(true);
                        }
                    }
                    Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", "test", "test1"));

                    t.Dispose();

                    return(false);
                }
                else
                {
                    return(false);
                }

            case ObjectType.DogFood:
                if (storage.DogFoods.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case ObjectType.Fertilizer:
                if (storage.Fertilizers.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(false);
            }
        }
Beispiel #16
0
    void OnGUI()
    {
        if (null == PreTargetsUri)
        {
            return;
        }


        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);

        Dictionary <int, string> .Enumerator enumerator = PreTargetsUri.GetEnumerator();
        while (enumerator.MoveNext())
        {
            KeyValuePair <int, string> keyValue = enumerator.Current;
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("删除", new GUILayoutOption[] { GUILayout.Height(lineHeight), GUILayout.Width(50) }))
            {
                if (PreTargetsUri.ContainsKey(keyValue.Key))
                {
                    PreTargetsUri.Remove(keyValue.Key);
                    break;
                }
            }

            GUILayout.TextField(keyValue.Value, new GUILayoutOption[] { GUILayout.Height(lineHeight) });
            if (GUILayout.Button("导入模型", new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(100) }))
            {
                string file = Utils.OpenFileLocalPath(new string[] { "fbx", "max", "mb", "obj" });
                if (!string.IsNullOrEmpty(file))
                {
                    string modelPath = "/model/" + file.Substring(file.LastIndexOf("/") + 1);
                    FileUtils.copyFile(file, Utils.GetAssetsPath() + modelPath);
                    AssetDatabase.Refresh();
                    string ModelAssetsPath = "Assets" + modelPath;
                    if (PreTargetsUri.ContainsKey(keyValue.Key))
                    {
                        AsyncUpdateTargetsUri.Add(keyValue.Key, ModelAssetsPath);
                    }
                    else
                    {
                        PreTargetsUri.Add(keyValue.Key, ModelAssetsPath);
                    }
                }
                else
                {
                    msg     = "所选模型格式错误";
                    showMsg = true;
                }
            }


            GUILayout.EndHorizontal();
        }



        enumerator.Dispose();

        if (null != AsyncUpdateTargetsUri && AsyncUpdateTargetsUri.Count > 0)
        {
            var buffer = new List <int>(AsyncUpdateTargetsUri.Keys);
            foreach (var key in buffer)
            {
                PreTargetsUri [key] = AsyncUpdateTargetsUri [key];
            }
            AsyncUpdateTargetsUri.Clear();
        }



        GUILayout.BeginVertical();

        if (GUILayout.Button("新增Item", new GUILayoutOption[] { GUILayout.Height(lineHeight) }))
        {
            PreTargetsUri.Add(PreTargetsUri.Count, PLEASEADDMODEL);
        }
        if (GUILayout.Button("制作场景", new GUILayoutOption[] { GUILayout.Height(lineHeight) }))
        {
            //Init ARCamera
            if (null == GameObject.Find(ARCAMERA))
            {
                Object arcamera = Resources.Load(ARCAMERA);
                Instantiate(arcamera).name = ARCAMERA;
            }

            //Add target
            Dictionary <int, string> .Enumerator enumerator1 = PreTargetsUri.GetEnumerator();
            while (enumerator1.MoveNext())
            {
                KeyValuePair <int, string> keyValue = enumerator1.Current;
                if (!keyValue.Value.Equals(PLEASEADDMODEL))
                {
                    Object obj = AssetDatabase.LoadAssetAtPath(keyValue.Value, typeof(GameObject));

                    AssetDatabase.CreateFolder("Assets", "Prefabs");



                    PrefabUtility.CreatePrefab("Prefabs/1.prefab", (GameObject)obj);

                    //GameObject.Instantiate (obj);
                }
                else
                {
                    showMsg = true;

                    msg = "请补全模型信息";

                    break;
                }
            }
            enumerator1.Dispose();
        }



        GUILayout.EndVertical();

        GUILayout.EndScrollView();


        timeShowMsg += Time.deltaTime;

        if (timeShowMsg > 15f)
        {
            showMsg     = false;
            msg         = "";
            timeShowMsg = 0;
        }


        if (showMsg)
        {
            GUILayout.BeginArea(new Rect(width / 4 + width / 8, height / 4 + height / 8, width, height));
            GUILayout.Button("(" + (int)(15 - timeShowMsg) + ")" + msg, new GUILayoutOption[] { GUILayout.Width(width / 4), GUILayout.Height(height / 4) });
            GUILayout.EndArea();
        }
    }
 public void Dispose()
 {
     _e.Dispose();
     _current = default(KeyValuePair <string, object>);
 }
Beispiel #18
0
 public void Dispose()
 {
     dict.Dispose(); parent = null;
 }
    /// <summary>
    /// 过滤字符串,默认遇到敏感词汇就以'*'代替
    /// </summary>
    /// <param name="text"></param>
    /// <param name="mask"></param>
    /// <returns></returns>
    unsafe public static string Filter(string text, string mask = "*")
    {
        Dictionary <int, int> dic = DetectIllegalWords(text);

        ///如果没有敏感词汇,则直接返回出去
        if (dic.Count == 0)
        {
            return(text);

            fixed(char *newText = text, cMask = mask)
            {
                var itor = newText;

                Dictionary <int, int> .Enumerator enumerator = dic.GetEnumerator();
                ///开始替换敏感词汇
                while (enumerator.MoveNext())
                {
                    ///偏移到敏感词出现的位置
                    itor = newText + enumerator.Current.Key;
                    for (int index = 0; index < enumerator.Current.Value; index++)
                    {
                        ///屏蔽掉敏感词汇
                        *itor++ = *cMask;
                    }
                }
                enumerator.Dispose();
            }

            return(text);
    }

    ///// <summary>
    ///// 判断text是否有敏感词汇,如果有返回敏感的词汇的位置,利用指针操作来加快运算速度,暂时独立出一个函数出来,不考虑代码复用的情况
    ///// </summary>
    ///// <param name="text"></param>
    ///// <returns></returns>
    //unsafe public static bool IllegalWordsExistJudgement(string text)
    //{
    //    if (string.IsNullOrEmpty(text))
    //        return false;

    //    fixed (char* ptext = text, detectedStrStart = dectectedBuffer)
    //    {
    //        ///缓存字符串的初始位置
    //        char* itor = (fastCheck[*ptext] & 0x01) == 0 ? ptext + 1 : ptext;
    //        ///缓存字符串的末尾位置
    //        char* end = ptext + text.Length;

    //        while (itor < end)
    //        {
    //            ///如果text的第一个词不是敏感词汇或者当前遍历到了text第一个词的后面的词,则循环检测到text词汇的倒数第二个词,看看这一段子字符串中有没有敏感词汇
    //            if ((fastCheck[*itor] & 0x01) == 0)
    //            {
    //                while (itor < end - 1 && (fastCheck[*(++itor)] & 0x01) == 0) ;
    //            }

    //            ///如果有只有一个词的敏感词,且当前的字符串的“非第一个词”满足这个敏感词,则先加入已检测到的敏感词列表
    //            if (startCache[*itor] != 0 && (fastLength[*itor] & 0x01) > 0)
    //            {
    //                return true;
    //            }

    //            char* strItor = detectedStrStart;
    //            *strItor++ = *itor;
    //            int remainLength = (int)(end - itor - 1);
    //            int skipCount = 0;
    //            ///此时已经检测到一个敏感词的“首词”了,记录下第一个检测到的敏感词的位置
    //            ///从当前的位置检测到字符串末尾
    //            for (int i = 1; i <= remainLength; ++i)
    //            {
    //                char* subItor = itor + i;
    //                /// 跳过一些过滤的字符,比如空格特殊符号之类的
    //                if (SkipBitArray[*subItor])
    //                {
    //                    ++skipCount;
    //                    continue;
    //                }
    //                ///如果检测到当前的词在所有敏感词中的位置信息中没有处在第i位的,则马上跳出遍历
    //                if ((fastCheck[*subItor] >> Math.Min(i - skipCount, 7)) == 0)
    //                {
    //                    break;
    //                }

    //                *strItor++ = *subItor;
    //                ///如果有检测到敏感词的最后一个词,并且此时的“检测到的敏感词汇”的长度也符合要求,则才进一步查看检测到的敏感词汇是否是真的敏感
    //                if ((fastLength[*itor] >> Math.Min(i - 1 - skipCount, 7)) > 0 && endCache[*subItor])
    //                {
    //                    ///如果此子字符串在敏感词字典中存在,则记录。做此判断是避免敏感词中夹杂了其他敏感词的单词,而上面的算法无法剔除,故先用hash数组来剔除
    //                    ///上述算法是用于减少大部分的比较消耗
    //                    if (wordsSet.Contains(new string(dectectedBuffer, 0, (int)(strItor - detectedStrStart))))
    //                    {
    //                        return true;
    //                    }
    //                }
    //                else if (i - skipCount > startCache[*itor] && startCache[*itor] < 0x80)///如果超过了以该词为首的一系列的敏感词汇的最大的长度,则不继续判断(前提是该词对应的所有敏感词汇没有超过8个词的)
    //                {
    //                    break;
    //                }
    //            }
    //            ++itor;
    //        }
    //    }

    //    return false;
    //}

    /// <summary>
    /// 判断text是否有敏感词汇,如果有返回敏感的词汇的位置,利用指针操作来加快运算速度
    /// </summary>
    /// <param name="text"></param>
    /// <returns></returns>
    unsafe public static Dictionary <int, int> DetectIllegalWords(string text)
 public void Dispose()
 {
     _e.Dispose();
 }
Beispiel #21
0
 public void Dispose()
 {
     DictionaryEnumerator.Dispose();
 }
Beispiel #22
0
 /// <summary>
 /// Releases all resources used by the <see cref="KeyEnumerator" />.
 /// </summary>
 public void Dispose() => _enumerator.Dispose();
    protected virtual IEnumerator BootingSystem()
    {
        //重新设置资源加载模式
        UniGameResources.gameResourcesWorkMode = UniGameResources.GameResourcesWorkMode.Mode_Mobile;
        //语言支持模式
        UniGameResources.gameResourcesWorkModeTwo = UniGameResources.GameResourcesWorkModeTwo.Mode_OutGameOptions;
        //更换成当前的资源加载支持对象
        UniGameResources.uniGameResourcesSupport = new IUniGameResourcesSupport();
        //启动协同程序装载包清单文件
        UniGameResources.AllocResourcesDownLoadWorker();
        yield return(StartCoroutine(UniGameResources.resourcesDownLoadWorker.LoadingGameAssetBundleInventoryPackageFile()));

        //显示启动页面
        yield return(StartCoroutine(OpenGameBootFace()));

        //检测当前程序版本是否符合资源版本的要求
        if (UniGameResources.produceInformation.SupportProgramVersion != UniGameResources.uniGameResourcesSupport.ProgramVersion)
        {
            bootingSystemStep = BootingSystemStep.Step_NeedInstallNewVersionProgram;
            yield break;
        }
        //装载要求强制装载的包,这些包不再卸载
        List <string> packageList = new List <string>(8);

        Dictionary <uint, UniGameResourcesPackage> .Enumerator list = UniGameResources.systemResourcesPackageTable.GetEnumerator();
        while (list.MoveNext())
        {
            if (list.Current.Value.assetBundleExistType == UniGameResourcesPackage.AssetBundleExistType.ExistType_ConstraintInstall)
            {
                packageList.Add(list.Current.Value.packageName);
            }
        }
        list.Dispose();
        if (packageList.Count != 0)
        {
            bootingSystemStep           = BootingSystemStep.Step_ConstraintInstallPackage;
            constraintInstallDownloader = UniGameResources.resourcesDownLoadWorker.AllocResourcesDownLoader_DontDestroyOnLoad();
            yield return(StartCoroutine(constraintInstallDownloader.DownloadPackageWithList(packageList)));
        }
        //进行强制下载的资源包
        List <UniGameResourcesPackage> ConstraintDownloadPackageList = UniGameResources.ComparisonSystemResourcesPackageVersion();

        if (ConstraintDownloadPackageList.Count != 0)
        {
            bootingSystemStep            = BootingSystemStep.Step_ConstraintDownloadPackage;
            constraintDownloadDownloader = UniGameResources.resourcesDownLoadWorker.AllocResourcesDownLoader();
            yield return(StartCoroutine(constraintDownloadDownloader.DownloadPackageWithList(ConstraintDownloadPackageList)));

            //下载完是需要卸载的
            UniGameResources.resourcesDownLoadWorker.ReleaseResourcesDownLoader(constraintDownloadDownloader);
            constraintDownloadDownloader = null;
        }
        //保存一次当前资源包版本
        UniGameResources.SaveSystemResourcesPackageVersion();
        //全部处理完毕
        bootingSystemStep = BootingSystemStep.Step_BootingOver;

        //示范代码下载并加载一个资源包内的场景
        //yield return StartCoroutine(UniGameResources.resourcesDownLoadWorker.LoadingGameSceneLevelAdditiveAsync("scene_game", "game"));

        //资源加载工作全部完成,开始初始化程序
        //这里GameRoot的初始化在GameRoot的静态构造函数里
        //这里需要检测GameRoot是否加载完成了
        GameRoot.GameRootInitializationSucceedEvent += OnGameRootInitializationSucceed;
        GameRoot.StartInitialization();
    }
Beispiel #24
0
 /// <summary>
 /// 清理枚举数。
 /// </summary>
 public void Dispose()
 {
     m_Enumerator.Dispose();
 }
Beispiel #25
0
        public void Cancel()
        {
            ActivityImplementationContext activityImplementationContext = null;
            IAsyncResult asyncResult = null;

            if (this.WorkflowHost != null)
            {
                if (this.commandQueue != null)
                {
                    while (!this.commandQueue.IsEmpty)
                    {
                        bool flag = this.commandQueue.TryDequeue(out activityImplementationContext);
                        if (!flag)
                        {
                            continue;
                        }
                        PowerShell powerShellInstance = activityImplementationContext.PowerShellInstance;
                        object[]   objArray           = new object[1];
                        objArray[0] = powerShellInstance;
                        this._tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "PowerShell activity: Cancelling pending command {0}.", objArray));
                        powerShellInstance.Dispose();
                    }
                }
                PSResumableActivityHostController pSActivityHostController = this.WorkflowHost.PSActivityHostController as PSResumableActivityHostController;
                if (pSActivityHostController == null)
                {
                    PSOutOfProcessActivityController pSOutOfProcessActivityController = this.WorkflowHost.PSActivityHostController as PSOutOfProcessActivityController;
                    if (pSOutOfProcessActivityController != null)
                    {
                        while (this.AsyncResults.Count > 0)
                        {
                            this.AsyncResults.TryDequeue(out asyncResult);
                            pSOutOfProcessActivityController.CancelInvokePowerShell(asyncResult);
                        }
                    }
                }
                else
                {
                    pSActivityHostController.StopAllResumablePSCommands(this.JobInstanceId);
                }
                while (this.runningCommands.Count > 0)
                {
                    PowerShell powerShell = null;
                    lock (this.runningCommands)
                    {
                        Dictionary <PowerShell, RetryCount> .KeyCollection.Enumerator enumerator = this.runningCommands.Keys.GetEnumerator();
                        try
                        {
                            if (enumerator.MoveNext())
                            {
                                PowerShell current = enumerator.Current;
                                powerShell = current;
                            }
                        }
                        finally
                        {
                            enumerator.Dispose();
                        }
                        if (powerShell == null)
                        {
                            break;
                        }
                    }
                    if (powerShell.InvocationStateInfo.State == PSInvocationState.Running)
                    {
                        object[] objArray1 = new object[1];
                        objArray1[0] = powerShell;
                        this._tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "PowerShell activity: Stopping command {0}.", objArray1));
                        try
                        {
                            powerShell.Stop();
                        }
                        catch (NullReferenceException nullReferenceException)
                        {
                        }
                        catch (InvalidOperationException invalidOperationException)
                        {
                        }
                    }
                    if (powerShell.InvocationStateInfo.State != PSInvocationState.Completed || powerShell.HadErrors)
                    {
                        this.Failed = true;
                    }
                    int num = RunCommandsArguments.DetermineCommandExecutionType(powerShell.Runspace.ConnectionInfo as WSManConnectionInfo, this.RunInProc, this.ActivityType, this);
                    if (num != 1)
                    {
                        PSActivity.CloseRunspaceAndDisposeCommand(powerShell, this.WorkflowHost, this, num);
                    }
                    this.runningCommands.Remove(powerShell);
                }
                return;
            }
            else
            {
                throw new InvalidOperationException("WorkflowHost");
            }
        }
    //是否支持及时下载模式
    public void Initialization()
    {
        //移动资源包模式需要加载文件解密器
        //移动模式必须提供资源包列表
        if (UniGameResources.gameResourcesWorkMode == GameResourcesWorkMode.Mode_Mobile)
        {
            xmlFileEncipher       = UniGameResources.AllocXmlFileEncipher();
            luaScriptFileEncipher = UniGameResources.AllocLuaScriptFileEncipher();
        }
        else if (UniGameResources.gameResourcesWorkMode == GameResourcesWorkMode.Mode_AloneSecurity)
        {
            xmlReaderSecurity = new FTLibrary.XML.XmlReaderSecurity();
            xmlReaderSecurity.Initialization(UniGameResources.ConnectPath(UniGameResources.DataPath, UniGameResourcesDefine.DefineAssetBundleName_Config, "\\"));
            xmlPublicReaderSecurity = new FTLibrary.XML.XmlPublicReaderSecurity();
            luaScriptReaderSecurity = new FTLibrary.XML.LuaScriptReaderSecurity();
            luaScriptReaderSecurity.Initialization(UniGameResources.ConnectPath(UniGameResources.DataPath, UniGameResourcesDefine.DefineAssetBundleName_LuaScript, "\\"));

            //需要载入包清单来构建包表
            //这里虚构一份资源进行加载
            GameResourcesNode data = new GameResourcesNode();
            data.packageName = UniGameResourcesDefine.DefineAssetBundleName_Config;
            data.path        = UniGameResourcesDefine.GameAssetBundleInventoryXmlFilePath;
            //载入系统包清单
            UniGameResources.BuildSystemResourcesPackageTable(LoadResource_XmlDocument(ref data, Encoding.Default));
        }

        //定于到资源对象的表内以方便所有资源进行索引
        Dictionary <uint, UniGameResourcesPackage> .Enumerator list = UniGameResources.systemResourcesPackageTable.GetEnumerator();
        while (list.MoveNext())
        {
            resourcesPackageTable.Add(list.Current.Value.packageId, list.Current.Value);
        }
        list.Dispose();


        //开始重建资源表
        //注册所有资源类型
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_XmlFile, UniGameResourcesDefine.ResourcesTypeIndex_XmlFile);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_ResourceFile, UniGameResourcesDefine.ResourcesTypeIndex_ResourceFile);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_LanguageResourceFile, UniGameResourcesDefine.ResourcesTypeIndex_LanguageResourceFile);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_LuaScript, UniGameResourcesDefine.ResourcesTypeIndex_LuaScript);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_String, UniGameResourcesDefine.ResourcesTypeIndex_String);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_Prefabs, UniGameResourcesDefine.ResourcesTypeIndex_Prefabs);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_PublicXmlFile, UniGameResourcesDefine.ResourcesTypeIndex_PublicXmlFile);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_Texture, UniGameResourcesDefine.ResourcesTypeIndex_Texture);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_AudioClip, UniGameResourcesDefine.ResourcesTypeIndex_AudioClip);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_TimerDefine, UniGameResourcesDefine.ResourcesTypeIndex_TimerDefine);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_Material, UniGameResourcesDefine.ResourcesTypeIndex_Material);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_PathDefine, UniGameResourcesDefine.ResourcesTypeIndex_PathDefine);
        RegisterResourcesType(UniGameResourcesDefine.ResourcesTypeName_CarList, UniGameResourcesDefine.ResourcesTypeIndex_CarList);

        //一些索引资源需要手动注册以方便读取
        uint configPackageId = 0;

        if (UniGameResources.gameResourcesWorkMode == GameResourcesWorkMode.Mode_Mobile)
        {
            GameResourcesPackage configPackage = LockPackage(UniGameResourcesDefine.DefineAssetBundleName_Config);
            configPackageId  = configPackage.packageId;
            luaScriptPackage = LockPackage(UniGameResourcesDefine.DefineAssetBundleName_LuaScript) as UniGameResourcesPackage;
            LockPackage(UniGameResourcesDefine.DefineAssetBundleName_PublicConfig);
            //这里锁定就不释放了,永远驻留内存
        }
        //注册LUA脚本读取器为从资源中加载脚本
        uniResourcesLuaScriptLoader = new UniResourcesLuaScriptLoader();
        //植入主清单文件
        AddResourcesToTable(UniGameResourcesDefine.ResourcesTypeIndex_XmlFile,
                            UniGameResourcesDefine.DefineResourcesName_MainResourcesFile,
                            configPackageId,
                            UniGameResourcesDefine.DefineAssetBundleName_Config,
                            UniGameResourcesDefine.DefineResourcesPath_MainResourcesFile, -1);
        //加载这个主清单文件
        XmlDocument mainXmlDoc = LoadResource_XmlFile(UniGameResourcesDefine.DefineResourcesName_MainResourcesFile);

        if (mainXmlDoc == null)
        {
            throw new Exception("load main xml Inventory file err!");
        }
        //加载这个资源清单
        BuildResourcesTable(mainXmlDoc);
        //加载其他资源清单
        Dictionary <uint, GameResourcesNode> .Enumerator resourceFileList = GetResourceEnumerator(UniGameResourcesDefine.ResourcesTypeIndex_ResourceFile);
        while (resourceFileList.MoveNext())
        {
            XmlDocument doc = LoadResource_ResourceXmlFile(resourceFileList.Current.Value.name);
            if (doc == null)
            {
                throw new Exception("load xml Inventory file err!");
            }
            //加载这份清单
            BuildResourcesTable(doc);
        }
        resourceFileList.Dispose();
        //资源清单已经加载完成了
        //加载语言定义
        LoadLanguageDefine();
        //外部定义模式不在这里加载语言定义
        if (UniGameResources.gameResourcesWorkModeTwo != GameResourcesWorkModeTwo.Mode_OutGameOptions)
        {
            //加载资源模块使用的LUA脚本
            uniLuaResourcesScript = new UniLuaResourcesScript();
            //选择当前使用的语言
            SelectCurrentLanguage();
            //加载语言资源清单
            LoadLanguageResourcesInventory();
        }
        //加载当前版本信息
        produceVersion.Initialization(LoadResource_PublicXmlFile(UniGameResourcesDefine.ProduceVersionFileName));
        //加载资源卸载器
        UniGameResources.AllocUnloadUnusedAssetsGameObject();
        //加载资源下载器
        UniGameResources.AllocResourcesDownLoadWorker();
    }
Beispiel #27
0
        private void SortHitSkill(List <HeroEntity> heros, List <EnemyEntity> enemies)
        {
            List <CharacterEntity> list = new List <CharacterEntity>();
            Dictionary <long, List <CharacterEntity> > result = new Dictionary <long, List <CharacterEntity> >();
            List <int> speeds = new List <int>();

            for (int i = 0, count = heros.Count; i < count; i++)
            {
                HeroEntity hero = heros[i];
                if (hero.characterInfo.hitId == 0)
                {
                    continue;
                }
                list.Add(hero);
                speeds.Add(hero.speed);
            }
            for (int i = 0, count = enemies.Count; i < count; i++)
            {
                EnemyEntity enmey = enemies[i];
                if (enmey.characterInfo.hitId == 0)
                {
                    continue;
                }
                list.Add(enmey);
                speeds.Add(enmey.speed);
            }
            long leastCommonMutiple = Common.Util.MathUtil.LeastCommonMultiple(speeds);
            int  min = speeds.MinValue();

            if (min > 0)
            {
                List <long> nums = CalcNumbers(leastCommonMutiple, speeds);
                for (int i = 0, iCount = nums.Count; i < iCount; i++)
                {
                    long num = nums[i];
                    for (int j = 0, count = list.Count; j < count; j++)
                    {
                        CharacterEntity c        = list[j];
                        long            interval = leastCommonMutiple / c.speed;
                        if (num % interval == 0)
                        {
                            if (!result.ContainsKey(num))
                            {
                                result.Add(num, new List <CharacterEntity>());
                            }
                            result[num].Add(c);
                        }
                    }
                }
                lock (hitSkillQueue)
                {
                    hitSkillQueue.Clear();
                    Dictionary <long, List <CharacterEntity> > .Enumerator e = result.GetEnumerator();
                    while (e.MoveNext())
                    {
                        KeyValuePair <long, List <CharacterEntity> > kvp = e.Current;
                        List <CharacterEntity> cs = SortedCross(kvp.Value);
                        for (int i = 0, count = cs.Count; i < count; i++)
                        {
                            CharacterEntity           c   = cs[i];
                            KeyValuePair <uint, uint> hit = new KeyValuePair <uint, uint>(c.characterInfo.instanceID, c.characterInfo.hitId);
                            hitSkillQueue.Enqueue(hit);
                        }
                    }
                    e.Dispose();
                }
            }
            result.Clear();
            result = null;
            list.Clear();
            list = null;
        }
Beispiel #28
0
 public void Dispose()
 {
     dictionary = null;
     enumerator.Dispose();
 }
Beispiel #29
0
    private void UpdateActiveInjuries()
    {
        this.m_SanityDictionary.Clear();
        PlayerSanityModule playerSanityModule = PlayerSanityModule.Get();

        for (int i = 0; i < this.m_Injuries.Count; i++)
        {
            Injury injury = this.m_Injuries[i];
            if (!injury.m_Healing)
            {
                this.m_DamageInfo.m_Damager = base.gameObject;
                float num = 1f;
                if (SleepController.Get().IsActive() && !SleepController.Get().IsWakingUp())
                {
                    num = Player.GetSleepTimeFactor();
                    this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * num;
                }
                else
                {
                    this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * Time.deltaTime * num;
                }
                if (injury.m_State == InjuryState.Infected)
                {
                    this.m_DamageInfo.m_DamageType = DamageType.Infection;
                }
                else if (injury.m_PoisonLevel > 0)
                {
                    if (injury.m_Type == InjuryType.SnakeBite)
                    {
                        this.m_DamageInfo.m_DamageType = DamageType.SnakePoison;
                    }
                    else
                    {
                        this.m_DamageInfo.m_DamageType = DamageType.VenomPoison;
                    }
                }
                else
                {
                    this.m_DamageInfo.m_DamageType = DamageType.None;
                }
                this.m_DamageInfo.m_FromInjury      = true;
                this.m_DamageInfo.m_PlayDamageSound = false;
                this.m_Player.TakeDamage(this.m_DamageInfo);
                int num2 = 0;
                if (this.m_SanityDictionary.TryGetValue((int)injury.m_Type, out num2))
                {
                    Dictionary <int, int> sanityDictionary = this.m_SanityDictionary;
                    int type = (int)injury.m_Type;
                    int num3 = sanityDictionary[type];
                    sanityDictionary[type] = num3 + 1;
                }
                else
                {
                    this.m_SanityDictionary.Add((int)injury.m_Type, 1);
                }
            }
            injury.Update();
        }
        Dictionary <int, int> .Enumerator enumerator = this.m_SanityDictionary.GetEnumerator();
        while (enumerator.MoveNext())
        {
            KeyValuePair <int, int> keyValuePair = enumerator.Current;
            switch (keyValuePair.Key)
            {
            case 0:
            {
                PlayerSanityModule playerSanityModule2 = playerSanityModule;
                PlayerSanityModule.SanityEventType evn = PlayerSanityModule.SanityEventType.SmallWoundAbrassion;
                keyValuePair = enumerator.Current;
                playerSanityModule2.OnEvent(evn, keyValuePair.Value);
                break;
            }

            case 1:
            {
                PlayerSanityModule playerSanityModule3  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn2 = PlayerSanityModule.SanityEventType.SmallWoundScratch;
                keyValuePair = enumerator.Current;
                playerSanityModule3.OnEvent(evn2, keyValuePair.Value);
                break;
            }

            case 2:
            {
                PlayerSanityModule playerSanityModule4  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn3 = PlayerSanityModule.SanityEventType.Laceration;
                keyValuePair = enumerator.Current;
                playerSanityModule4.OnEvent(evn3, keyValuePair.Value);
                break;
            }

            case 3:
            {
                PlayerSanityModule playerSanityModule5  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn4 = PlayerSanityModule.SanityEventType.LacerationCat;
                keyValuePair = enumerator.Current;
                playerSanityModule5.OnEvent(evn4, keyValuePair.Value);
                break;
            }

            case 4:
            {
                PlayerSanityModule playerSanityModule6  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn5 = PlayerSanityModule.SanityEventType.Rash;
                keyValuePair = enumerator.Current;
                playerSanityModule6.OnEvent(evn5, keyValuePair.Value);
                break;
            }

            case 5:
            {
                PlayerSanityModule playerSanityModule7  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn6 = PlayerSanityModule.SanityEventType.Worm;
                keyValuePair = enumerator.Current;
                playerSanityModule7.OnEvent(evn6, keyValuePair.Value);
                break;
            }

            case 6:
            {
                PlayerSanityModule playerSanityModule8  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn7 = PlayerSanityModule.SanityEventType.WormHole;
                keyValuePair = enumerator.Current;
                playerSanityModule8.OnEvent(evn7, keyValuePair.Value);
                break;
            }

            case 7:
            {
                PlayerSanityModule playerSanityModule9  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn8 = PlayerSanityModule.SanityEventType.Leech;
                keyValuePair = enumerator.Current;
                playerSanityModule9.OnEvent(evn8, keyValuePair.Value);
                break;
            }

            case 8:
            {
                PlayerSanityModule playerSanityModule10 = playerSanityModule;
                PlayerSanityModule.SanityEventType evn9 = PlayerSanityModule.SanityEventType.LeechHole;
                keyValuePair = enumerator.Current;
                playerSanityModule10.OnEvent(evn9, keyValuePair.Value);
                break;
            }

            case 9:
            {
                PlayerSanityModule playerSanityModule11  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn10 = PlayerSanityModule.SanityEventType.VenomBite;
                keyValuePair = enumerator.Current;
                playerSanityModule11.OnEvent(evn10, keyValuePair.Value);
                break;
            }

            case 10:
            {
                PlayerSanityModule playerSanityModule12  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn11 = PlayerSanityModule.SanityEventType.SnakeBite;
                keyValuePair = enumerator.Current;
                playerSanityModule12.OnEvent(evn11, keyValuePair.Value);
                break;
            }
            }
        }
        enumerator.Dispose();
    }
Beispiel #30
0
 protected override void DisposeResources()
 {
     Dictionary?.Dispose();
 }
Beispiel #31
0
 public void Dispose()
 {
     keys.Dispose();
 }
Beispiel #32
0
        IEnumerator DogfightCompetitionModeRoutine(float distance)
        {
            competitionStarting = true;
            competitionStatus   = "Competition: Pilots are taking off.";
            Dictionary <BDArmorySetup.BDATeams, List <IBDAIControl> > pilots =
                new Dictionary <BDArmorySetup.BDATeams, List <IBDAIControl> >();

            pilots.Add(BDArmorySetup.BDATeams.A, new List <IBDAIControl>());
            pilots.Add(BDArmorySetup.BDATeams.B, new List <IBDAIControl>());
            List <Vessel> .Enumerator loadedVessels = BDATargetManager.LoadedVessels.GetEnumerator();
            while (loadedVessels.MoveNext())
            {
                if (loadedVessels.Current == null)
                {
                    continue;
                }
                if (!loadedVessels.Current.loaded)
                {
                    continue;
                }
                IBDAIControl pilot = null;
                IEnumerator <IBDAIControl> ePilots = loadedVessels.Current.FindPartModulesImplementing <IBDAIControl>().AsEnumerable().GetEnumerator();
                while (ePilots.MoveNext())
                {
                    pilot = ePilots.Current;
                    break;
                }
                ePilots.Dispose();
                if (pilot == null || !pilot.weaponManager)
                {
                    continue;
                }

                pilots[BDATargetManager.BoolToTeam(pilot.weaponManager.team)].Add(pilot);
                pilot.CommandTakeOff();
                if (pilot.weaponManager.guardMode)
                {
                    pilot.weaponManager.ToggleGuardMode();
                }
            }
            loadedVessels.Dispose();

            //clear target database so pilots don't attack yet
            BDATargetManager.ClearDatabase();

            if (pilots[BDArmorySetup.BDATeams.A].Count == 0 || pilots[BDArmorySetup.BDATeams.B].Count == 0)
            {
                Debug.Log("[BDArmory]: Unable to start competition mode - one or more teams is empty");
                competitionStatus = "Competition: Failed!  One or more teams is empty.";
                yield return(new WaitForSeconds(2));

                competitionStarting = false;
                yield break;
            }

            IBDAIControl aLeader = pilots[BDArmorySetup.BDATeams.A][0];
            IBDAIControl bLeader = pilots[BDArmorySetup.BDATeams.B][0];

            aLeader.weaponManager.wingCommander.CommandAllFollow();
            bLeader.weaponManager.wingCommander.CommandAllFollow();


            //wait till the leaders are ready to engage (airborne for PilotAI)
            while (aLeader != null && bLeader != null && (!aLeader.CanEngage() || !bLeader.CanEngage()))
            {
                yield return(null);
            }

            if (aLeader == null || bLeader == null)
            {
                StopCompetition();
            }

            competitionStatus = "Competition: Sending pilots to start position.";
            Vector3 aDirection =
                Vector3.ProjectOnPlane(aLeader.vessel.CoM - bLeader.vessel.CoM, aLeader.vessel.upAxis).normalized;
            Vector3 bDirection =
                Vector3.ProjectOnPlane(bLeader.vessel.CoM - aLeader.vessel.CoM, bLeader.vessel.upAxis).normalized;

            Vector3 center       = (aLeader.vessel.CoM + bLeader.vessel.CoM) / 2f;
            Vector3 aDestination = center + (aDirection * (distance + 1250f));
            Vector3 bDestination = center + (bDirection * (distance + 1250f));

            aDestination = VectorUtils.WorldPositionToGeoCoords(aDestination, FlightGlobals.currentMainBody);
            bDestination = VectorUtils.WorldPositionToGeoCoords(bDestination, FlightGlobals.currentMainBody);

            aLeader.CommandFlyTo(aDestination);
            bLeader.CommandFlyTo(bDestination);

            Vector3 centerGPS = VectorUtils.WorldPositionToGeoCoords(center, FlightGlobals.currentMainBody);

            //wait till everyone is in position
            bool waiting = true;

            while (waiting)
            {
                waiting = false;

                if (aLeader == null || bLeader == null)
                {
                    StopCompetition();
                }

                if (Vector3.Distance(aLeader.transform.position, bLeader.transform.position) < distance * 1.95f)
                {
                    waiting = true;
                }
                else
                {
                    Dictionary <BDArmorySetup.BDATeams, List <IBDAIControl> > .KeyCollection.Enumerator keys = pilots.Keys.GetEnumerator();
                    while (keys.MoveNext())
                    {
                        List <IBDAIControl> .Enumerator ePilots = pilots[keys.Current].GetEnumerator();
                        while (ePilots.MoveNext())
                        {
                            if (ePilots.Current == null)
                            {
                                continue;
                            }
                            if (ePilots.Current.currentCommand != PilotCommands.Follow ||
                                !(Vector3.ProjectOnPlane(
                                      ePilots.Current.vessel.CoM - ePilots.Current.commandLeader.vessel.CoM,
                                      VectorUtils.GetUpDirection(ePilots.Current.commandLeader.vessel.transform.position)
                                      ).sqrMagnitude > 1000f * 1000f))
                            {
                                continue;
                            }
                            competitionStatus = "Competition: Waiting for teams to get in position.";
                            waiting           = true;
                        }
                        ePilots.Dispose();
                    }
                    keys.Dispose();
                }

                yield return(null);
            }

            //start the match
            Dictionary <BDArmorySetup.BDATeams, List <IBDAIControl> > .KeyCollection.Enumerator pKeys = pilots.Keys.GetEnumerator();
            while (pKeys.MoveNext())
            {
                List <IBDAIControl> .Enumerator pPilots = pilots[pKeys.Current].GetEnumerator();
                while (pPilots.MoveNext())
                {
                    if (pPilots.Current == null)
                    {
                        continue;
                    }

                    //enable guard mode
                    if (!pPilots.Current.weaponManager.guardMode)
                    {
                        pPilots.Current.weaponManager.ToggleGuardMode();
                    }

                    //report all vessels
                    if (BDATargetManager.BoolToTeam(pPilots.Current.weaponManager.team) == BDArmorySetup.BDATeams.B)
                    {
                        BDATargetManager.ReportVessel(pPilots.Current.vessel, aLeader.weaponManager);
                    }
                    else
                    {
                        BDATargetManager.ReportVessel(pPilots.Current.vessel, bLeader.weaponManager);
                    }

                    //release command
                    pPilots.Current.ReleaseCommand();
                    pPilots.Current.CommandAttack(centerGPS);
                }
            }
            pKeys.Dispose();
            competitionStatus = "Competition starting!  Good luck!";
            yield return(new WaitForSeconds(2));

            competitionStarting = false;
        }
Beispiel #33
0
 /** Reset from IDictionaryEnumerator */
 public void Reset()
 {
     CurrentImpl.Dispose();
 }
Beispiel #34
0
 public void Dispose()
 {
     mCurrent.Dispose();
 }
 public void Dispose()
 {
     inner.Dispose();
     Monitor.Exit(_plugins);
 }
Beispiel #36
0
    private void Update()
    {
        if (LoadingScreen.Get().m_Active)
        {
            return;
        }
        List <StaticObjectClass> objectsInRadius = this.m_QuadTree.GetObjectsInRadius(Player.Get().gameObject.transform.position, 10f, false);

        for (int i = 0; i < objectsInRadius.Count; i++)
        {
            StaticObjectClass staticObjectClass = objectsInRadius[i];
            if (staticObjectClass.m_GameObject.activeSelf && staticObjectClass.m_State != 1 && !this.m_ObjectsRemovedFromStatic.Contains(staticObjectClass))
            {
                StaticObjectsReplace staticObjectsReplace = null;
                if (this.m_ReplaceMap.TryGetValue(staticObjectClass.m_GameObject.name, out staticObjectsReplace))
                {
                    staticObjectClass.m_GameObject.SetActive(false);
                    this.m_ObjectsRemovedFromStatic.Add(staticObjectClass);
                    GameObject gameObject;
                    if (this.m_EnablePooling)
                    {
                        if (this.m_Pool[staticObjectsReplace.m_PrefabName].Count > 0)
                        {
                            gameObject = this.m_Pool[staticObjectsReplace.m_PrefabName].ElementAt(0);
                            this.m_Pool[staticObjectsReplace.m_PrefabName].RemoveAt(0);
                        }
                        else
                        {
                            gameObject = UnityEngine.Object.Instantiate <GameObject>(staticObjectsReplace.m_Prefab);
                            this.m_TempItemList.Clear();
                            gameObject.GetComponents <Item>(this.m_TempItemList);
                            if (this.m_TempItemList.Count > 0)
                            {
                                this.m_TempItemList[0].m_CanSaveNotTriggered = false;
                            }
                        }
                        gameObject.SetActive(true);
                    }
                    else
                    {
                        gameObject = UnityEngine.Object.Instantiate <GameObject>(staticObjectsReplace.m_Prefab);
                        this.m_TempItemList.Clear();
                        gameObject.GetComponents <Item>(this.m_TempItemList);
                        if (this.m_TempItemList.Count > 0)
                        {
                            this.m_TempItemList[0].m_CanSaveNotTriggered = false;
                        }
                    }
                    this.m_ReplacedMap.Add(staticObjectClass, gameObject);
                    gameObject.transform.position   = staticObjectClass.m_GameObject.transform.parent.position;
                    gameObject.transform.rotation   = staticObjectClass.m_GameObject.transform.parent.rotation;
                    gameObject.transform.localScale = staticObjectClass.m_GameObject.transform.parent.localScale;
                    Item component = gameObject.GetComponent <Item>();
                    if (component)
                    {
                        component.Initialize(false);
                    }
                }
            }
        }
        int j = 0;

        while (j < this.m_ObjectsRemovedFromStatic.Count)
        {
            StaticObjectClass staticObjectClass2 = this.m_ObjectsRemovedFromStatic[j];
            if (!objectsInRadius.Contains(staticObjectClass2))
            {
                GameObject gameObject2 = null;
                if (this.m_ReplacedMap.TryGetValue(staticObjectClass2, out gameObject2))
                {
                    if (gameObject2 != null)
                    {
                        if (this.m_EnablePooling)
                        {
                            gameObject2.transform.position = this.m_PoolPosition;
                            gameObject2.SetActive(false);
                            this.m_Pool[this.m_ReplaceMap[staticObjectClass2.m_GameObject.name].m_PrefabName].Add(gameObject2);
                            staticObjectClass2.m_GameObject.SetActive(true);
                        }
                        else
                        {
                            UnityEngine.Object.Destroy(gameObject2);
                            if (staticObjectClass2.m_GameObject == null)
                            {
                                this.m_ObjectsRemovedFromStatic.Remove(staticObjectClass2);
                                continue;
                            }
                            staticObjectClass2.m_GameObject.SetActive(true);
                        }
                    }
                    else
                    {
                        if (staticObjectClass2.m_GameObject == null)
                        {
                            this.m_ObjectsRemovedFromStatic.Remove(staticObjectClass2);
                            continue;
                        }
                        staticObjectClass2.m_State = 1;
                        if (staticObjectClass2.m_GameObject.transform.parent != null)
                        {
                            staticObjectClass2.m_GameObject.transform.parent.gameObject.SetActive(false);
                        }
                    }
                    this.m_ReplacedMap.Remove(staticObjectClass2);
                    this.m_ObjectsRemovedFromStatic.Remove(staticObjectClass2);
                }
                else
                {
                    j++;
                }
            }
            else
            {
                j++;
            }
        }
        if (this.m_ReplacedMap.Count > 0)
        {
            Dictionary <StaticObjectClass, GameObject> .Enumerator enumerator = this.m_ReplacedMap.GetEnumerator();
            if (enumerator.MoveNext())
            {
                KeyValuePair <StaticObjectClass, GameObject> keyValuePair = enumerator.Current;
                if (keyValuePair.Key.m_GameObject == null)
                {
                    Dictionary <StaticObjectClass, GameObject> replacedMap = this.m_ReplacedMap;
                    keyValuePair = enumerator.Current;
                    replacedMap.Remove(keyValuePair.Key);
                }
            }
            enumerator.Dispose();
        }
    }
Beispiel #37
0
        // 有改变返回true
        public bool UpdateToRemoveFiles(ResListFile.ResDiffInfo[] newDiffInfos)
        {
            if (newDiffInfos == null)
            {
                return(false);
            }

            if (newDiffInfos.Length <= 0)
            {
                RemoveAllDowningFiles();
                Clear();
                return(true);
            }

            bool             ret     = false;
            HashSet <string> hashSet = new HashSet <string>();

            for (int i = 0; i < newDiffInfos.Length; ++i)
            {
                string contentMd5 = newDiffInfos[i].fileContentMd5;
                if (string.IsNullOrEmpty(contentMd5))
                {
                    continue;
                }

                hashSet.Add(contentMd5);
                if (!m_Dict.ContainsKey(contentMd5))
                {
                    AutoUpdateCfgItem item = new AutoUpdateCfgItem();
                    item.fileContentMd5 = contentMd5;
                    item.isDone         = false;
                    item.readBytes      = 0;
                    m_Dict.Add(contentMd5, item);
                    ret = true;
                }
            }

            List <string> delMd5List = new List <string>();
            string        writePath  = AutoUpdateMgr.Instance.WritePath;

            if (!string.IsNullOrEmpty(writePath))
            {
                Dictionary <string, AutoUpdateCfgItem> .Enumerator iter = m_Dict.GetEnumerator();
                while (iter.MoveNext())
                {
                    string contentMd5 = iter.Current.Value.fileContentMd5;
                    if (hashSet.Contains(contentMd5))
                    {
                        continue;
                    }

                    delMd5List.Add(contentMd5);
                }
                iter.Dispose();
            }

            if (delMd5List.Count > 0)
            {
                ret = true;
                for (int i = 0; i < delMd5List.Count; ++i)
                {
                    string contentMd5 = delMd5List[i];
                    m_Dict.Remove(contentMd5);
                    string fileName = string.Format("{0}/{1}", writePath, contentMd5);
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                }
            }

            return(ret);
        }
        /// <summary>
        /// Request Resource processing on a ProtoVessel.
        /// If the ProtoVessel is not known or resources not cached for the ProtoVessel will automatically add them to the Cached data.
        /// </summary>
        /// <param name="vessel">ProtoVessel reference</param>
        /// <param name="resourceName">Name of the Resource we want to process</param>
        /// <param name="amount">The amount of the resource we want to process</param>
        /// <param name="amountReceived">returns the amount processed for the request in this variable</param>
        /// <param name="pushing">default of false (which means take resource). If true will push (put resource)</param>
        public static void RequestResource(ProtoVessel vessel, string resourceName, double amount, out double amountReceived, bool pushing = false)
        {
            amountReceived = 0d;
            if (UnloadedResources.InterestedVessels == null)
            {
                UnloadedResources.InterestedVessels = new DictionaryValueList <ProtoVessel, InterestedVessel>();
            }
            //If there are no cachedResources for the vessel create one.
            if (!UnloadedResources.InterestedVessels.Contains(vessel))
            {
                CacheResources.CreatecachedVesselResources(vessel);
            }

            //Double check, not really necessary. Now find the resource amounts if in the vessel.
            if (UnloadedResources.InterestedVessels.Contains(vessel))
            {
                List <CacheResources.CacheResource> vslresources = UnloadedResources.InterestedVessels[vessel].CachedResources;
                for (int i = 0; i < vslresources.Count; i++)
                {
                    CacheResources.CacheResource cacheResource = vslresources[i];
                    if (cacheResource.resourceName == resourceName)
                    {
                        if (!pushing)  //We are taking resource
                        {
                            if (cacheResource.amount > 0 || cacheResource.timeWarpOverflow.totalAmount > 0)
                            {
                                if (cacheResource.timeWarpOverflow.totalAmount > 0 && TimeWarp.fetch != null && TimeWarp.CurrentRateIndex > CacheResources.timeWarpStep) //If we have timewarp Overflow check that first.
                                {
                                    double amountTaken = 0;
                                    cacheResource.timeWarpOverflow.Take(amount, out amountTaken);
                                    amountReceived += amountTaken;
                                    amount         -= amountTaken;
                                    if (amount <= 0) //Did we get all we need already? If so return.
                                    {
                                        return;
                                    }
                                }
                                //TimewarpOverflow didn't have enough or didn't have what we need. so now the partResrouceSnapshot
                                Dictionary <string, ProtoPartResourceSnapshot> .Enumerator ppRSenumerator = cacheResource.protoPartResourceSnapshot.GetDictEnumerator();
                                while (ppRSenumerator.MoveNext())
                                {
                                    ProtoPartResourceSnapshot partResourceSnapshot = ppRSenumerator.Current.Value;

                                    if (partResourceSnapshot.amount > 0)
                                    {
                                        if (partResourceSnapshot.amount <= amount) //Not enough but take what it has
                                        {
                                            amountReceived             += partResourceSnapshot.amount;
                                            amount                     -= partResourceSnapshot.amount;
                                            cacheResource.amount       -= partResourceSnapshot.amount;
                                            partResourceSnapshot.amount = 0;
                                        }
                                        else //this part has more than we need.
                                        {
                                            amountReceived              += amount;
                                            cacheResource.amount        -= amount;
                                            partResourceSnapshot.amount -= amount;
                                            amount = 0;
                                        }
                                    }
                                    if (amount <= 0) //Did we get all we wanted? if so return.
                                    {
                                        ppRSenumerator.Dispose();
                                        return;
                                    }
                                }
                                ppRSenumerator.Dispose();
                            }
                        }
                        else  //We are putting a resource
                        {
                            //Get how much space there is in this part.
                            double spaceAvailable = cacheResource.maxAmount - cacheResource.amount;
                            if (spaceAvailable > 0) //If we have space put some in.
                            {
                                Dictionary <string, ProtoPartResourceSnapshot> .Enumerator ppRSenumerator = cacheResource.protoPartResourceSnapshot.GetDictEnumerator();
                                while (ppRSenumerator.MoveNext())
                                {
                                    ProtoPartResourceSnapshot partResourceSnapshot = ppRSenumerator.Current.Value;
                                    double partspaceAvailable = partResourceSnapshot.maxAmount - partResourceSnapshot.amount;
                                    if (partspaceAvailable > 0)
                                    {
                                        if (amount > partspaceAvailable) //If we can't fit it all in this part. Put what we can.
                                        {
                                            partResourceSnapshot.amount = partResourceSnapshot.maxAmount;
                                            cacheResource.amount       += partspaceAvailable;
                                            amount         -= partspaceAvailable;
                                            amountReceived += partspaceAvailable;
                                        }
                                        else //If we can fit it all in this part, put it in.
                                        {
                                            partResourceSnapshot.amount += amount;
                                            cacheResource.amount        += amount;
                                            amountReceived += amount;
                                            amount          = 0;
                                        }
                                        if (amount <= 0) //Did we get all we wanted? if so return.
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                            //If we get here we had more than can fit in the parts... But if TimeWarp is too high, we put it in the overflow.
                            if (TimeWarp.fetch != null && amount > 0)
                            {
                                if (TimeWarp.CurrentRateIndex > CacheResources.timeWarpStep) //But only if timewarp rate is high enough.
                                {
                                    cacheResource.timeWarpOverflow.Add(amount);
                                    amountReceived += amount;
                                    amount          = 0;
                                    return;
                                }
                            }
                        }
                    }
                } //End For loop all vessel resources.
            }
        }
Beispiel #39
0
 void IDisposable.Dispose()
 {
     _nonControlledEnum.Dispose();
     _controlledEnum.Dispose();
 }