示例#1
0
    public static void Initialise()
    {
        if (started)
        {
            return;
        }
        started = true;

        Players        = new List <Player>();
        Continents     = new List <Continent>();
        RemainingCards = new List <DangerCard>();
        CreateContinents();
        SetInternalMovement();
        SetExternalMovement();
        CreateDangerCards();
        CheckPlayers();

        if (Ready == null)
        {
        }
        else
        {
            Debug.LogWarning("Invoked");
            startedSuccessfully = true;
            Ready.Invoke(null, new ReadyEventArgs(startedSuccessfully));
        }

        InitialStartGame();
    }
示例#2
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            foreach (KeyValuePair <Object, Object> pair in SeedMakers)
            {
                Object seedMaker  = pair.Key;
                Object heldItem   = pair.Value;
                bool   wasHolding = heldItem != null;
                if (HasHeldItem(seedMaker) && (!wasHolding || heldItem != GetHeldItem(seedMaker)))
                {
                    if (HeldItemAdded != null)
                    {
                        HeldItemAdded.Invoke(null, new SeedMakerEventArgs(seedMaker, GetHeldItem(seedMaker)));
                    }
                }
                if (wasHolding && (!HasHeldItem(seedMaker) || GetHeldItem(seedMaker) != heldItem))
                {
                    if (HeldItemRemoved != null)
                    {
                        HeldItemRemoved.Invoke(null, new SeedMakerEventArgs(seedMaker, heldItem));
                    }
                }
            }

            foreach (Object seedMaker in new List <Object>(SeedMakers.Keys))
            {
                SeedMakers[seedMaker] = GetHeldItem(seedMaker);
            }
        }
        public int?Next()
        {
            InitializeGeneratedInts();
            int num;

            do
            {
                if (generatedInts.Count == int.MaxValue - 1)
                {
                    NoPossibleNumber?.Invoke(this, System.EventArgs.Empty); return(null);
                }
                num = random.Next();
            } while (generatedInts.Contains(num));
            generatedInts.Add(num);
            return(num);
        }
示例#4
0
    private void Perform(GameObject prefab)
    {
        if (this == null)
        {
            return;
        }

        if (prefab == null)
        {
            Trace.Error("AsynGameObject: prefab is null");
            return;
        }

        GameObject go = ResNode.InstantiateRes(prefab) as GameObject;

        go.transform.parent        = gameObject.transform;
        go.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
        go.transform.localRotation = Quaternion.identity;
        go.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
        //go.transform.rotation = gameObject.transform.rotation;
        //go.transform.SetPosition( gameObject.transform.position;

        if (callback != null)
        {
            callback.Invoke(gameObject, null);
        }
    }
示例#5
0
    void SetNewPlayerCharacter(int characterID, Vector3 position, Quaternion rotation)
    {
        GameObject newCharacter = Instantiate(characterList[characterID], position, rotation, transform);

        clickToMove.SetNavMeshAgent(newCharacter.GetComponent <UnityEngine.AI.NavMeshAgent>());
        characterChanged?.Invoke(this, new CharacterChangedEventArgs(newCharacter));
    }
        private void PaintAt(Vector2 screenPosition, bool preview, float pressure, object owner)
        {
            var camera = P3dHelper.GetCamera(_camera);

            if (camera != null)
            {
                if (touchOffset != 0.0f && Input.touchCount > 0)
                {
                    screenPosition.y += touchOffset * P3dInputManager.ScaleFactor;
                }

                var ray = camera.ScreenPointToRay(screenPosition);
                var hit = default(RaycastHit);

                if (Physics.Raycast(ray, out hit, float.PositiveInfinity, layers) == true)
                {
                    var finalUp       = orientation == OrientationType.CameraUp ? camera.transform.up : Vector3.up;
                    var finalPosition = hit.point + hit.normal * offset;
                    var finalNormal   = normal == NormalType.HitNormal ? -hit.normal : ray.direction;
                    var finalRotation = Quaternion.LookRotation(finalNormal, finalUp);

                    hitCache.InvokeRaycast(gameObject, preview, priority, hit, pressure);

                    SubmitPoint(preview, priority, hit.collider, finalPosition, finalRotation, pressure, owner);
                    if (!preview)
                    {
                        onFingerHitUpdate?.Invoke(this, finalPosition);
                    }
                    return;
                }
            }

            BreakHits(owner);
        }
示例#7
0
    public void Stop()
    {
        Debug.Log("Stopped");

        navMeshAgent.isStopped = true;
        walking = false;
        WalkingStop?.Invoke(this, new WalkingStopEventArgs(transform.position, nowTarget));
    }
示例#8
0
 public void RemoveItem(string id)
 {
     if (HasItem(id))
     {
         items.RemoveAll(x => x.id == id);
     }
     args = new InventoryEventArgs(id);
     OnItemRemoved?.Invoke(this, args);
 }
示例#9
0
        /// <summary>
        /// Main download method.
        /// </summary>
        private async void download()
        {
            dlTimer.Start();
            dsTimer.Start();
            // Set 'cancelDownload' to false, so that method can stop again.
            cancelDownload = false;

            req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
            // check if downloaded-length!=0 and !overwrite so the user want to resume.
            if (dLength > 0 && !overwrite)
            {
                req.AddRange(dLength);      // add range to the 'req' to change the point of start download.
            }
            isDownloading = true;
            using (res = (System.Net.HttpWebResponse) await req.GetResponseAsync())
            {
                fLength = res.ContentLength + dLength;                                               // get the total-size of the file.
                eSize.Invoke(null, View.Size.getlength.GetLengthString(FileSize));                   // update the total-size.
                eDownloadedSize.Invoke(null, View.Size.getlength.GetLengthString(DownloadedLength)); // update the downloaded-length.
                dt = System.DateTime.Now;                                                            // get the current time ( point of start downloading ).
                using (stream = res.GetResponseStream())
                {
                    await System.Threading.Tasks.Task.Run(() =>     // await task so the winform don't freezing.
                    {
                        // update the download-state.
                        eDownloadState.Invoke(null, "Downloading");
                        // while not 'cancelDownload' and file doesn't end do:
                        while (!cancelDownload && ((bufferReader = stream.Read(buffer, 0, buffer.Length)) > 0))
                        {
                            fStream.Write(buffer, 0, bufferReader); // write byte to the file on harddisk.
                            dLength += bufferReader;                // update downloaded-length value.
                            cLength += bufferReader;                // update current-downloaded-length value.
                        }
                    });
                }
            }
            dlTimer.Stop();
            dsTimer.Stop();
            isDownloading = false;
            // eSpeed.Invoke(null, "0.0 Kb/s");    // update downloading-speed to 0.0 kb/s.
            eDownloadedSize.Invoke(null, View.Size.getlength.GetLengthString(DownloadedLength)); // update downloaded-size.
            eDownloadState.Invoke(null, DownloadState);                                          // update download-state.
            fStream.Dispose();                                                                   // free file on harddisk by dispose 'fStream'.
        }
示例#10
0
 public void OnClick()
 {
     if (player.def.type != PlayerDef.Type.AI && ChatManager.instance != null && GD.thePlayer != null && GD.thePlayer.ID != player.def.id)
     {
         ChatManager.instance.StartChatWith(player.def.id, player.def.name, player.def.avatar);
     }
     OnAlterPlayer?.Invoke(this, new AlterPlayerEvent {
         enemy = this
     });
 }
 private void ClearLineRenderers()
 {
     foreach (LineRenderer lineRenderer in LineRenderers)
     {
         lineRenderer.positionCount = 0;
     }
     if (LinesCleared != null)
     {
         LinesCleared.Invoke(this, System.EventArgs.Empty);
     }
 }
示例#12
0
 public void AddItem(Item item)
 {
     if (HasItem(item.id))
     {
         Debug.LogError($"Item [{item.id}] is already in inventory");
         return;
     }
     items.Add(item);
     args = new InventoryEventArgs(item.id);
     OnItemAdded?.Invoke(this, args);
 }
示例#13
0
 public void OnClick()
 {
     if (isUnlocked)
     {
         onClick?.Invoke(this, stageID);
     }
     else
     {
         SS.View.Manager.Add(PopupController.POPUP_SCENE_NAME, new PopupData(PopupType.OK, "You have to complete previous levels to unlock this."));
     }
     FirebaseManager.LogEvent("StageSelect_StageClick", "stage_number", stageID);
 }
示例#14
0
        public static bool GenerateLoot(DaggerfallLoot loot, int locationIndex)
        {
            string[] lootTableKeys =
            {
                "K", // Crypt
                "N", // Orc Stronghold
                "N", // Human Stronghold
                "N", // Prison
                "K", // Desecrated Temple
                "M", // Mine
                "M", // Natural Cave
                "Q", // Coven
                "K", // Vampire Haunt
                "U", // Laboratory
                "D", // Harpy Nest
                "N", // Ruined Castle
                "L", // Spider Nest
                "F", // Giant Stronghold
                "S", // Dragon's Den
                "N", // Barbarian Stronghold
                "M", // Volcanic Caves
                "L", // Scorpion Nest
                "N", // Cemetery
            };

            // Get loot table key
            if (locationIndex < lootTableKeys.Length)
            {
                DaggerfallLoot.GenerateItems(lootTableKeys[locationIndex], loot.Items);

                // Randomly add map
                char key           = lootTableKeys[locationIndex][0];
                int  alphabetIndex = key - 64;

                if (alphabetIndex >= 10 && alphabetIndex <= 15) // between keys J and O
                {
                    int[] mapChances = { 2, 1, 1, 2, 2, 15 };
                    int   mapChance  = mapChances[alphabetIndex - 10];
                    DaggerfallLoot.RandomlyAddMap(mapChance, loot.Items);
                    DaggerfallLoot.RandomlyAddPotion(4, loot.Items);
                    DaggerfallLoot.RandomlyAddPotionRecipe(2, loot.Items);
                }

                OnLootSpawned?.Invoke(null, new TabledLootSpawnedEventArgs {
                    LocationIndex = locationIndex, Key = lootTableKeys[locationIndex], Items = loot.Items
                });

                return(true);
            }
            return(false);
        }
    public static IEnumerator CoCheckAtlasExist(string name, System.EventHandler <bool> onComplete)
    {
        string atlasAddress = GetAtlasAddressFromPictureName(name);
        AsyncOperationHandle <IList <IResourceLocation> > handle = Addressables.LoadResourceLocationsAsync(atlasAddress);

        yield return(handle);

        bool isExist = handle.Result.Count > 0;

        Debug.Log($"Atlas Exist: {isExist}");
        onComplete?.Invoke(null, isExist);
        Addressables.Release(handle);
        yield return(isExist);
    }
    IEnumerator _StartGame()
    {
        yield return(new WaitForSeconds(3f));

        stateManager.StateNow = GameStateManager.State.GamePlaying;
        gaming    = true;
        startTime = Time.time;

        SetTimeText(totalSeconds);

        gameStart?.Invoke(this, new GameStartEventArgs());

        yield return(new WaitForSeconds(2f));

        startCountDownAnimator.SetBool("GameStart", false);
    }
示例#17
0
    public void PositionCards(System.EventHandler listener = null)
    {
        int counter = 3;
        var onReady = new System.EventHandler((object sender, System.EventArgs e) => {
            if (--counter == 0)
            {
                if (listener != null)
                {
                    listener.Invoke(sender, e);
                }
            }
        });

        PositionDeck(onReady);
        PositionHand(onReady);
        PositionDiscard(onReady);
    }
        private void UpdateLines()
        {
            int idx = Gesture.PathCount - 1;

            if (idx >= 0 && idx < LineRenderers.Length)
            {
                Vector3 worldPos = new Vector3(Gesture.FocusX, Gesture.FocusY, 0.0f);
                worldPos   = Camera.main.ScreenToWorldPoint(worldPos);
                worldPos.z = 0.0f;
                LineRenderers[idx].positionCount++;
                LineRenderers[idx].SetPosition(LineRenderers[idx].positionCount - 1, worldPos);
            }
            if (LinesUpdated != null)
            {
                LinesUpdated.Invoke(this, System.EventArgs.Empty);
            }
        }
示例#19
0
        static StackObject *Invoke_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ILRuntime.Runtime.Intepreter.ILTypeInstance @e = (ILRuntime.Runtime.Intepreter.ILTypeInstance) typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Object @sender = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method = (System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.EventHandler <ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Invoke(@sender, @e);

            return(__ret);
        }
示例#20
0
        private void UpdateLines()
        {
            // play sound only once, when line is first starting to draw
            if (!soundPlayed)
            {
                SoundManager.instance.PlaySingle(SoundManager.combatDrawingSound);
                soundPlayed = true;
            }
            int idx = Gesture.PathCount - 1;

            if (idx >= 0 && idx < LineRenderers.Length)
            {
                Vector3 worldPos = new Vector3(Gesture.FocusX, Gesture.FocusY, 0.0f);
                worldPos   = Camera.main.ScreenToWorldPoint(worldPos);
                worldPos.z = 0.0f;
                LineRenderers[idx].positionCount++;
                LineRenderers[idx].SetPosition(LineRenderers[idx].positionCount - 1, worldPos);
            }
            if (LinesUpdated != null)
            {
                LinesUpdated.Invoke(this, System.EventArgs.Empty);
            }
        }
        public static ArchiveExtractResult FlatExtract(SharpCompress.Archives.IArchive extractor, string outputFolder, System.EventHandler <ExtractProgress> progress_callback)
        {
            Dictionary <bool, List <SharpCompress.Common.IEntry> > myList = new Dictionary <bool, List <SharpCompress.Common.IEntry> >();

            myList.Add(true, new List <SharpCompress.Common.IEntry>());
            myList.Add(false, new List <SharpCompress.Common.IEntry>());
            int    total          = extractor.Entries.Count();
            int    extractedindex = 0;
            string titit;

            FileSystem.CreateDirectory(outputFolder);
            using (var entries = extractor.ExtractAllEntries())
                while (entries.MoveToNextEntry())
                {
                    if (!entries.Entry.IsDirectory)
                    {
                        try
                        {
                            titit = Path.Combine(outputFolder, Path.GetFileName(entries.Entry.Key));
                            using (FileStream fs = File.Create(titit))
                            {
                                entries.WriteEntryTo(fs);
                                fs.Flush();
                            }
                            myList[true].Add(entries.Entry);
                        }
                        catch (System.Exception)
                        { myList[false].Add(entries.Entry); }
                    }
                    extractedindex++;
                    if (progress_callback != null)
                    {
                        syncContext.Post(new SendOrPostCallback(delegate { progress_callback?.Invoke(extractor, new ExtractProgress(total, extractedindex)); }), null);
                    }
                }
            return(new ArchiveExtractResult(myList));
        }
示例#22
0
        /// <summary>
        /// Sets enemy career and prepares entity settings.
        /// </summary>
        public void SetEnemyCareer(MobileEnemy mobileEnemy, EntityTypes entityType)
        {
            // Try custom career first
            career = GetCustomCareerTemplate(mobileEnemy.ID);

            if (career != null)
            {
                // Custom enemy
                careerIndex = mobileEnemy.ID;
                stats.SetPermanentFromCareer(career);

                if (entityType == EntityTypes.EnemyMonster)
                {
                    // Default like a monster
                    level     = mobileEnemy.Level;
                    maxHealth = Random.Range(mobileEnemy.MinHealth, mobileEnemy.MaxHealth + 1);
                    for (int i = 0; i < ArmorValues.Length; i++)
                    {
                        ArmorValues[i] = (sbyte)(mobileEnemy.ArmorValue * 5);
                    }
                }
                else
                {
                    // Default like a class enemy
                    level     = GameManager.Instance.PlayerEntity.Level;
                    maxHealth = FormulaHelper.RollEnemyClassMaxHealth(level, career.HitPointsPerLevel);
                }
            }
            else if (entityType == EntityTypes.EnemyMonster)
            {
                careerIndex = mobileEnemy.ID;
                career      = GetMonsterCareerTemplate((MonsterCareers)careerIndex);
                stats.SetPermanentFromCareer(career);

                // Enemy monster has predefined level, health and armor values.
                // Armor values can be modified below by equipment.
                level     = mobileEnemy.Level;
                maxHealth = UnityEngine.Random.Range(mobileEnemy.MinHealth, mobileEnemy.MaxHealth + 1);
                for (int i = 0; i < ArmorValues.Length; i++)
                {
                    ArmorValues[i] = (sbyte)(mobileEnemy.ArmorValue * 5);
                }
            }
            else if (entityType == EntityTypes.EnemyClass)
            {
                careerIndex = mobileEnemy.ID - 128;
                career      = GetClassCareerTemplate((ClassCareers)careerIndex);
                stats.SetPermanentFromCareer(career);

                // Enemy class is levelled to player and uses similar health rules
                // City guards are 3 to 6 levels above the player
                level = GameManager.Instance.PlayerEntity.Level;
                if (careerIndex == (int)MobileTypes.Knight_CityWatch - 128)
                {
                    level += UnityEngine.Random.Range(3, 7);
                }

                maxHealth = FormulaHelper.RollEnemyClassMaxHealth(level, career.HitPointsPerLevel);
            }
            else
            {
                career      = new DFCareer();
                careerIndex = -1;
                return;
            }

            this.mobileEnemy = mobileEnemy;
            this.entityType  = entityType;
            name             = career.Name;
            minMetalToHit    = mobileEnemy.MinMetalToHit;
            team             = mobileEnemy.Team;

            short skillsLevel = (short)((level * 5) + 30);

            if (skillsLevel > 100)
            {
                skillsLevel = 100;
            }

            for (int i = 0; i <= DaggerfallSkills.Count; i++)
            {
                skills.SetPermanentSkillValue(i, skillsLevel);
            }

            // Generate loot table items
            DaggerfallLoot.GenerateItems(mobileEnemy.LootTableKey, items);

            // Enemy classes and some monsters use equipment
            if (careerIndex == (int)MonsterCareers.Orc || careerIndex == (int)MonsterCareers.OrcShaman)
            {
                SetEnemyEquipment(0);
            }
            else if (careerIndex == (int)MonsterCareers.Centaur || careerIndex == (int)MonsterCareers.OrcSergeant)
            {
                SetEnemyEquipment(1);
            }
            else if (careerIndex == (int)MonsterCareers.OrcWarlord)
            {
                SetEnemyEquipment(2);
            }
            else if (entityType == EntityTypes.EnemyClass)
            {
                SetEnemyEquipment(UnityEngine.Random.Range(0, 2)); // 0 or 1
            }

            // Assign spell lists
            if (entityType == EntityTypes.EnemyMonster)
            {
                if (careerIndex == (int)MonsterCareers.Imp)
                {
                    SetEnemySpells(ImpSpells);
                }
                else if (careerIndex == (int)MonsterCareers.Ghost)
                {
                    SetEnemySpells(GhostSpells);
                }
                else if (careerIndex == (int)MonsterCareers.OrcShaman)
                {
                    SetEnemySpells(OrcShamanSpells);
                }
                else if (careerIndex == (int)MonsterCareers.Wraith)
                {
                    SetEnemySpells(WraithSpells);
                }
                else if (careerIndex == (int)MonsterCareers.FrostDaedra)
                {
                    SetEnemySpells(FrostDaedraSpells);
                }
                else if (careerIndex == (int)MonsterCareers.FireDaedra)
                {
                    SetEnemySpells(FireDaedraSpells);
                }
                else if (careerIndex == (int)MonsterCareers.Daedroth)
                {
                    SetEnemySpells(DaedrothSpells);
                }
                else if (careerIndex == (int)MonsterCareers.Vampire)
                {
                    SetEnemySpells(VampireSpells);
                }
                else if (careerIndex == (int)MonsterCareers.DaedraSeducer)
                {
                    SetEnemySpells(SeducerSpells);
                }
                else if (careerIndex == (int)MonsterCareers.VampireAncient)
                {
                    SetEnemySpells(VampireAncientSpells);
                }
                else if (careerIndex == (int)MonsterCareers.DaedraLord)
                {
                    SetEnemySpells(DaedraLordSpells);
                }
                else if (careerIndex == (int)MonsterCareers.Lich)
                {
                    SetEnemySpells(LichSpells);
                }
                else if (careerIndex == (int)MonsterCareers.AncientLich)
                {
                    SetEnemySpells(AncientLichSpells);
                }
            }
            else if (entityType == EntityTypes.EnemyClass && (mobileEnemy.CastsMagic))
            {
                int spellListLevel = level / 3;
                if (spellListLevel > 6)
                {
                    spellListLevel = 6;
                }
                SetEnemySpells(EnemyClassSpells[spellListLevel]);
            }

            // Chance of adding map
            DaggerfallLoot.RandomlyAddMap(mobileEnemy.MapChance, items);

            if (!string.IsNullOrEmpty(mobileEnemy.LootTableKey))
            {
                // Chance of adding potion
                DaggerfallLoot.RandomlyAddPotion(3, items);
                // Chance of adding potion recipe
                DaggerfallLoot.RandomlyAddPotionRecipe(2, items);
            }

            OnLootSpawned?.Invoke(this, new EnemyLootSpawnedEventArgs {
                MobileEnemy = mobileEnemy, EnemyCareer = career, Items = items
            });

            FillVitalSigns();
        }
 public void FinishGaming()
 {
     stateManager.StateNow = GameStateManager.State.GameEnd;
     gaming = false;
     gameFinish?.Invoke(this, new GameFinishEventArgs());
 }
示例#24
0
 public void KeyMethod2()
 {
     systemHandler.Invoke(this, System.EventArgs.Empty);
 }
        public static ArchiveExtractResult Unrar(RarArchive extractor, string outputFolder, System.EventHandler <ExtractProgress> progress_callback)
        {
            Dictionary <bool, List <SharpCompress.Common.IEntry> > myList = new Dictionary <bool, List <SharpCompress.Common.IEntry> >();

            myList.Add(true, new List <SharpCompress.Common.IEntry>());
            myList.Add(false, new List <SharpCompress.Common.IEntry>());
            int total          = extractor.Entries.Count;
            int extractedindex = 0;

            using (var entries = extractor.ExtractAllEntries())
                while (entries.MoveToNextEntry())
                {
                    try
                    {
                        FileInfo fi = new FileInfo(Path.Combine(outputFolder, entries.Entry.Key));
                        FileSystem.CreateDirectory(fi.DirectoryName);
                        using (FileStream fs = fi.Create())
                        {
                            entries.WriteEntryTo(fs);
                            fs.Flush();
                        }
                        myList[true].Add(entries.Entry);
                    }
                    catch (System.Exception)
                    { myList[false].Add(entries.Entry); }
                    extractedindex++;
                    if (progress_callback != null)
                    {
                        syncContext.Post(new System.Threading.SendOrPostCallback(delegate { progress_callback?.Invoke(extractor, new ExtractProgress(total, extractedindex)); }), null);
                    }
                }
            return(new ArchiveExtractResult(myList));
        }
        public static ArchiveExtractResult Extract7z(SharpCompress.Archives.SevenZip.SevenZipArchive extractor, string outputFolder, System.EventHandler <ExtractProgress> progress_callback)
        {
            Dictionary <bool, List <SharpCompress.Common.IEntry> > myList = new Dictionary <bool, List <SharpCompress.Common.IEntry> >();

            myList.Add(true, new List <SharpCompress.Common.IEntry>());
            myList.Add(false, new List <SharpCompress.Common.IEntry>());
            int total          = extractor.Entries.Count;
            int extractedindex = 0;

            using (var entries = extractor.ExtractAllEntries())
                while (entries.MoveToNextEntry())
                {
                    try
                    {
                        FileInfo fi = new FileInfo(Path.Combine(outputFolder, entries.Entry.Key));
                        FileSystem.CreateDirectory(fi.DirectoryName);
                        using (FileStream fs = fi.Create())
                        {
                            entries.WriteEntryTo(fs);
                            fs.Flush();
                        }
                        myList[true].Add(entries.Entry);
                    }
                    catch (System.Exception)
                    { myList[false].Add(entries.Entry); }
                    extractedindex++;
                    if (progress_callback != null)
                    {
                        syncContext.Post(new System.Threading.SendOrPostCallback(delegate { progress_callback?.Invoke(extractor, new ExtractProgress(total, extractedindex)); }), null);
                    }
                }
            return(new ArchiveExtractResult(myList));

            /*Dictionary<bool, List<ArchiveFileInfo>> myList = new Dictionary<bool, List<ArchiveFileInfo>>();
             * myList.Add(true, new List<ArchiveFileInfo>());
             * myList.Add(false, new List<ArchiveFileInfo>());
             * extractor.ExtractArchive(outputFolder);
             * if (progress_callback != null)
             *  extractor.Extracting += progress_callback;
             * foreach (var node in extractor.ArchiveFileData)
             * {
             *  if (!node.IsDirectory)
             *  {
             *      if (File.Exists(Path.Combine(outputFolder, node.FileName)))
             *          myList[true].Add(node);
             *      else
             *          myList[false].Add(node);
             *  }
             * }
             * return (new SevenZipExtractResult(myList));//*/
        }
 /// <summary>
 /// Raises the FancyControls.MoveableControl.PushedPixelAmountChanged event.
 /// </summary>
 /// <param name="e">
 /// A System.EventArgs that contains the event data.
 /// </param>
 protected void OnPushedPixelAmountChanged(System.EventArgs e)
 {
     PushedPixelAmountChanged?.Invoke(this, e);
 }
 /// <summary>
 /// Raises the FancyControls.MoveableControl.HoverPixelAmountChanged event.
 /// </summary>
 /// <param name="e">
 /// A System.EventArgs that contains the event data.
 /// </param>
 protected void OnHoverPixelAmountChanged(System.EventArgs e)
 {
     HoverPixelAmountChanged?.Invoke(this, e);
 }
        private void Paint(P3dInputManager.Finger finger, bool down, bool up)
        {
            var link = GetLink(finger);

            if (spacing > 0.0f)
            {
                var tail = finger.SmoothPositions[0];

                if (down == true)
                {
                    link.Distance = 0.0f;

                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(tail, false, finger.Pressure, link);
                    onFingerHitBegin?.Invoke(this, finger.PositionA);
                }

                for (var i = 1; i < finger.SmoothPositions.Count; i++)
                {
                    var head  = finger.SmoothPositions[i];
                    var dist  = Vector2.Distance(tail, head);
                    var steps = Mathf.FloorToInt((link.Distance + dist) / spacing);

                    for (var j = 0; j < steps; j++)
                    {
                        var remainder = spacing - link.Distance;

                        tail = Vector2.MoveTowards(tail, head, remainder);

                        PaintAt(tail, false, finger.Pressure, link);

                        dist -= remainder;

                        link.Distance = 0.0f;
                    }

                    link.Distance += dist;

                    tail = head;
                }
            }
            else
            {
                if (showPreview == true)
                {
                    if (up == true)
                    {
                        if (storeStates == true)
                        {
                            P3dStateManager.StoreAllStates();
                        }

                        PaintAt(finger.PositionA, false, finger.Pressure, link);
                    }
                    else
                    {
                        PaintAt(finger.PositionA, true, finger.Pressure, link);
                    }
                }
                else if (down == true)
                {
                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    PaintAt(finger.PositionA, false, finger.Pressure, link);
                }
            }

            if (up == true)
            {
                BreakHits(link);
                //ClearAll();
            }
        }
示例#30
0
 /// <summary>
 /// Method use to update download-speed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DsTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     // Download Speed In Kb/s = ( Downloaded-Length In KB ) / ( Total Seconds From Point Of Start ).
     dSpeed = (cLength) / ((System.DateTime.Now - dt).TotalSeconds);
     eSpeed.Invoke(null, DownloadingSpeed); // Call the event-handler.
 }