Exemplo n.º 1
0
        public bool Equals(IndexDetailV1 other)
        {
            if (other == null)
            {
                return(false);
            }

            bool equal = Name.Equals(other.Name) &&
                         Version == other.Version &&
                         Unique == other.Unique &&
                         Sparse == other.Sparse &&
                         Namespace.Equals(other.Name) &&
                         Keys == other.Keys &&
                         Keys?.Count == other?.Keys.Count;

            if (!equal)
            {
                return(false);
            }

            if (Keys?.Count() > 0)
            {
                return(Keys
                       .OrderBy(x => x.FieldName)
                       .Zip(other.Keys.OrderBy(x => x.FieldName), (f, s) => new { F = s, S = s })
                       .All(x => x.F.Equals(x.S)));
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool IsSame(EncodedList other)
        {
            if (other == null)
            {
                return(false);
            }

            var arr1 = Keys.ToArray();
            var arr2 = other.Keys.ToArray();

            var len = arr1.Length;

            if (arr1.Length != arr2.Length)
            {
                Logger.Debug("Keys are not same length");
                return(false);
            }

            if (HashedValue != other.HashedValue)
            {
                Logger.Debug("HashedValues do not match");
                return(false);
            }

            for (var i = 0; i < Keys.Count(); i++)
            {
                if (arr1[i] != arr2[i])
                {
                    Logger.DebugFormat("Values at position {0} do not match", i);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
 public IInfrastructure.Models.Purchase.Po GetModel(params object[] Keys)
 {
     if (Keys.Count() <= 0)
     {
         throw new Exception("请传入单号!");
     }
     return(Mapper.Map <IInfrastructure.Models.Purchase.Po>(_entities.FirstOrDefault(p => p.PONUM.Equals(Keys[0]))));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Compares the contents of keys and values of this <see cref="ConfigDictionary"/> with the <paramref name="other"/> dictionary to determine whether they contain exactly the same configuration.
 /// </summary>
 /// <param name="other">The other <see cref="ConfigDictionary"/> to compare</param>
 /// <returns>True if both dictionaries are equivalent (contain exactly the same key-value pairs). False otherwise.</returns>
 public bool Equals(ConfigDictionary other)
 {
     if (Keys.Except(other.Keys).Count() == 0 && //the set of keys is the same
         Keys.Count(key => this[key] != other[key]) == 0) //values assigned to the keys are equal
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
        public void LogWallet()
        {
            string path = Path.Combine(_folder, "wallet.log");

            using (var fs = File.Create(path))
            {
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    var numKeys = Keys.Count((k) => k.Consumed.Equals(true));
                    writer.WriteLine("Wallet Id: " + this.Name);
                    writer.WriteLine("Wallet Name: " + this.DisplayName);
                    writer.WriteLine("Wallet Balance: " + this.BalanceDisplay + " BTC");
                    writer.WriteLine("Wallet Network: " + this.NetworkChoice);
                    writer.WriteLine("Wallet Folder: " + _folder);
                    writer.WriteLine("Num. Private Keys: " + numKeys);
                    writer.WriteLine(Environment.NewLine);
                    writer.WriteLine("Public Keys");
                    writer.WriteLine("Num. Public Keys: " + numKeys);
                    writer.WriteLine("=========================");
                    writer.WriteLine(Environment.NewLine);
                    foreach (var key in Keys.Where((k) => k.Consumed.Equals(true)))
                    {
                        writer.WriteLine("Pub. Key: " + key.PublicKey.ToHex());
                        writer.WriteLine("Address: " + key.Address);
                        writer.WriteLine(Environment.NewLine);
                    }
                    writer.WriteLine("=========================");
                    writer.WriteLine(Environment.NewLine);
                    writer.WriteLine("Spendable Outputs");
                    writer.WriteLine("=========================");
                    writer.WriteLine(Environment.NewLine);
                    foreach (var output in _spendableOutputs)
                    {
                        writer.WriteLine("Amount: " + output.Amount.ToString() + " || " + "Address: " + output.ScriptPubKey.GetDestinationAddress(this.NetworkChoice));
                    }
                    writer.WriteLine("=========================");
                    writer.WriteLine(Environment.NewLine);
                    writer.WriteLine("Transactions");
                    writer.WriteLine("Num. Transactions: " + this.Txs.Count);
                    writer.WriteLine("Num. Sent Transactions: " + this.GetAllSentTransactions().Length);
                    writer.WriteLine("Num. Received Transactions: " + this.GetAllReceiveTransactions().Length);
                    writer.WriteLine("=========================");
                    writer.WriteLine(Environment.NewLine);
                    foreach (var tx in this.Txs)
                    {
                        writer.WriteLine("Tx. Hash: " + tx.Transaction.GetHash());
                        writer.WriteLine("Timestamp: " + TextTools.FormatFullDate(tx.UnconfirmedSeen));
                        writer.WriteLine("Value: " + tx.Balance.ToString() + " BTC");
                        writer.WriteLine(Environment.NewLine);
                    }
                    writer.WriteLine("=========================");
                    writer.WriteLine("END OF WALLET LOG");
                    writer.Close();
                }
            }
        }
Exemplo n.º 6
0
        public void SetActivator(Keys[] keySet)
        {
            if (keySet.Count() != 4)
                throw new Exception("Key-Set for DirectionInput is invalid.");

            _keyUp = keySet[0];
            _keyLeft = keySet[1];
            _keyDown = keySet[2];
            _keyRight = keySet[3];
        }
Exemplo n.º 7
0
        public bool InRange(int index)
        {
            if (index == 0 && !Keys.Any())
            {
                return(true);
            }

            var last = Keys.Count() - 1;

            return(index > 0 || index <= last);
        }
Exemplo n.º 8
0
        public bool InRange(int index)
        {
            if (index == 0 && Keys.Count() == 0)
            {
                return(true);
            }

            int last = Keys.Count() - 1;

            return(index > 0 || index <= last);
        }
Exemplo n.º 9
0
        public override void Bind(string expression)
        {
            base.Bind(expression);

            if (Keys.Count() > 1)
            {
                // Should be 0 (static value) or 1 key for a bindable preperty
                // Log and keep going
                Logger.Log(new InvalidOperationException($"More than one variable was specified for a bindable property {expression}"));
            }
        }
Exemplo n.º 10
0
        public void RunAlgorithmTest()
        {
            // Initialise Space
            ISpace <int> space = new Space <int>(new Possible()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            for (int i = 1; i < 82; i++)
            {
                space.Add(i, new Possible()
                {
                    1, 2, 3, 4, 5, 6, 7, 8, 9
                });
            }

            // Initialise one group (top row)
            Keys <int> group = new Keys <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };
            IPuzzle <int>       puzzle = new PuzzleBase <int>(space);
            IPuzzleEngine <int> engine = new PuzzleEngine <int>(puzzle);

            // Action
            space[1].SetValue(1);
            Keys <int> keysInner = new Keys <int>()
            {
                1
            };
            int jobsAdded = ConstraintMutuallyExclusive <int> .CreateCompleteSetActions(keysInner, group, engine);


            // Test
            Keys <int> expectedK = new Keys <int>()
            {
                2, 3, 4, 5, 6, 7, 8, 9
            };
            Possible expectedV = new Possible()
            {
                1
            };
            IJobFilter <int> job    = engine.Peek() as IJobFilter <int>;
            Keys <int>       actual = job.Keys;
            IPossible        filter = job.Filter;

            // Check the algorithm returned 8 changes
            Assert.AreEqual(8, actual.Count(), "Algorithm Eliminate did not return 8 changes");
            Assert.IsTrue(expectedK.SetEquals(actual));
            Assert.AreEqual(1, filter.Count, "Filter value incorrect");
            Assert.IsTrue(expectedV.SetEquals(filter), "Filter values incorrect");
        }
Exemplo n.º 11
0
        /// <summary>
        /// This finds all constraints at the specified keys
        /// It finds the keys in that constraint that intersect with the keys that have changed
        /// and creates a job for each
        /// </summary>
        /// <param name="keysChangedIn">The set of keys that have just changed</param>
        /// <returns>The set of jobs created</returns>
        public int CreateSearchJobs(Keys <TKey> keysChanged, IPuzzleEngine <TKey> engine)
        {
            int added = 0;

            if (keysChanged.Count() > 0)
            {
                foreach (IConstraint <TKey> constraint in this)
                {
                    added += constraint.CreateSearchJobs(keysChanged, engine);
                }
            }
            return(added);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets all entities of type TEntity or a list according to the passed in Guid Keys
        /// </summary>
        /// <param name="keys">The keys of the entities to be returned</param>
        /// <returns>A collection of entities</returns>
        public IEnumerable <TEntity> GetAll(params Guid[] Keys)
        {
            if (Keys.Any())
            {
                var entities = new List <TEntity>();

                foreach (var key in Keys)
                {
                    var entity = _cache.GetCacheItem(GetCacheKey(key));
                    if (entity != null)
                    {
                        entities.Add((TEntity)entity);
                    }
                }

                if (entities.Count().Equals(Keys.Count()) && entities.Any(x => x.Equals(default(TEntity))) == false)
                {
                    return(entities);
                }
            }
            else
            {
                var allEntities = _cache.GetCacheItemsByKeySearch(typeof(TEntity).Name + ".").ToArray();


                if (allEntities.Any())
                {
                    var query      = this.GetBaseQuery(true);
                    var totalCount = PerformCount(query);

                    if (allEntities.Count() == totalCount)
                    {
                        return(allEntities.Select(x => (TEntity)x));
                    }
                }
            }

            var entityCollection = PerformGetAll(Keys).ToArray();

            foreach (var entity in entityCollection)
            {
                if (!entity.Equals(default(TEntity)))
                {
                    var en = entity;
                    _cache.GetCacheItem(GetCacheKey(entity.Key), () => en);
                }
            }

            return(entityCollection);
        }
Exemplo n.º 13
0
 //Set a custom list of keys to choose from, if no custom list is given, listen to all keys
 /// <summary>
 /// Set what keys to return if pressed. If no keys are set, all keys will be listened to.
 /// </summary>
 /// <param name="ListenKeys">A list of Xna.Framework.Input.Keys that holds a group of non-duplicated keys to return if pressed</param>
 public void SetListenKeys(Keys[] ListenKeys)
 {
     if (ListenKeys.Count() == ListenKeys.Distinct<Keys>().Count()) //Checks for duplicates
     {
     foreach (Keys Key in ListenKeys)
     {
             listen_keys.Add(new Keystroke(Key, 0));
     }
     }
     else
     {
     throw new System.ArgumentException("Argument has duplicates", "ListenKeys"); //Duplicates will cause problems to happen with the key buffer.
     }
 }
Exemplo n.º 14
0
        public string ToString(int numberOfTabs)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Message: \r\n" + getTabs(numberOfTabs) + "Encrypted: " + Encrypted.ToString());

            if (Nonces.Count != 0)
            {
                sb.Append("\r\n" + getTabs(numberOfTabs) + "Nonce(s): ");
                foreach (Nonce nonce in Nonces)
                {
                    sb.Append(nonce.id);
                }
            }

            if (Keys.Count() != 0)
            {
                sb.Append("\r\n" + getTabs(numberOfTabs) + "Key(s): ");
                foreach (Key key in Keys)
                {
                    sb.Append(key.ToString());
                }
            }

            if (Messages.Count() != 0)
            {
                sb.Append("\r\n" + getTabs(numberOfTabs) + "Message(s): ");
                foreach (Message m in Messages)
                {
                    sb.Append(m.ToString(numberOfTabs + 1));
                }
            }

            if (Agents.Count() != 0)
            {
                sb.Append("\r\n" + getTabs(numberOfTabs) + "Agent(s): ");
                foreach (Agent a in Agents)
                {
                    sb.Append(a.Id);
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 15
0
        public PubKey GetNewPubKey()
        {
            Logger.WriteLine("WalletModel::GetNewPubKey");


            var newPubKeyIndex = (uint)Keys.Count((key) => key.Consumed.Equals(true));

            Logger.WriteLine("newPubKeyIndex => " + newPubKeyIndex);
            if (newPubKeyIndex >= _private_key_pool_size)
            {
                Logger.WriteLine("newPubKeyIndex is greater than private_key_pool_size...");
                Logger.WriteLine("generating new walletkey");
                this.GenerateNextWalletKey();
            }

            var newPubKey = Keys.First((key) => key.MatchKeyPath(newPubKeyIndex)).PublicKey;

            return(newPubKey);
        }
Exemplo n.º 16
0
        public string GetJsonString(List <string[]> values)
        {
            if (_jsonStringGenerationAction == null)
            {
                _jsonStringGenerationAction = GetJsonStringGenerationAction();
            }

            if (values.Count != Keys.Count(x => !NonSaKeys.Contains(x)))
            {
                throw new UserErrorException("Please provide one and only one value for each JSON key.");
            }

            var sb         = StringBuilderCache.Acquire();
            var jsonObject = new JsonObject(sb);

            _jsonStringGenerationAction(jsonObject, values);

            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Exemplo n.º 17
0
        private void Work_Timer_Tick(object state)
        {
            TryCount++;

            if (IsPermission && this.cursor != null)
            {
                workTimer.Dispose();
                workTimer = null;

                string mmsId = string.Empty;

                Coupon coupon = new Coupon();

                try
                {
                    foreach (var key in Keys.Where(x => x.Value == false))
                    {
                        if (Values.TryGetValue(key.Key, out coupon))
                        {
                            coupon.Bind();
                            if (coupon.IsBinding)
                            {
                                Sender.Enqueue(coupon);
                            }
                        }

                        Keys.AddOrUpdate(key.Key, true, (x, y) => true);
                    }

                    progressText.Text = $"{Sender.Count()} / {Values.Count()} / {Keys.Count()}";
                    workTimer         = new Timer(Work_Timer_Tick, null, WorkingTime, Timeout.Infinite);
                }
                catch (System.Exception ex)
                {
                    msgText.Text = ex.Message;
                }
                finally
                {
                    postionText.Text = $"Count : {this.TryCount}";
                }
            }
        }
Exemplo n.º 18
0
        public virtual void KeyStartTimer(Mobile from)
        {
            if (m_KeyResetTimer != null)
            {
                m_KeyResetTimer.Stop();
            }

            m_KeyResetTimer = Timer.DelayCall(TimeSpan.FromSeconds(30 * Keys.Count()), () =>
            {
                from.SendLocalizedMessage(1072679); // Your realm offering has reset. You will need to start over.

                if (Owner != null)
                {
                    Owner = null;
                }

                KeyValidation = null;

                ClearContainer();
            });
        }
Exemplo n.º 19
0
        static public int CreateCompleteSetActions(Keys <TKey> group1, Keys <TKey> group2, IPuzzleEngine <TKey> engine)
        {
            int added = 0;
            // This works out possibleInner (go to space and union all values);
            IPossible possibleInner = engine.Puzzle.Space.AllValuesAt(group1);

            // If the values in the set are equal to the
            // available spaces in the solution then we consider this set
            // complete and can eliminate it from the rest of the group
            // (e.g. 1 value in 1 cell, or 8 values in 8 cells)
            if (possibleInner.Values.Count == group1.Count())
            {
                // This finds the working group of locations (excludes the changed set)
                Keys <TKey> workingGroup = new Keys <TKey>(group2);
                workingGroup.ExceptWith(group1);

                IJob <TKey> job = new JobFilter <TKey>("CompleteSet", workingGroup, possibleInner);
                engine.Add(job);
                added++;
                // Get all the possible values from key and filter them out of the group
            }
            return(added);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Scan a possible parameter string and populate whatever possible
        /// </summary>
        /// <param name="parameters">String possibly representing parameters</param>
        /// <returns></returns>
        protected override bool ValidateAndSetParameters(string parameters)
        {
            // The string has to be valid by itself first
            if (string.IsNullOrWhiteSpace(parameters))
            {
                return(false);
            }

            // Now split the string into parts for easier validation
            // https://stackoverflow.com/questions/14655023/split-a-string-that-has-white-spaces-unless-they-are-enclosed-within-quotes
            parameters = parameters.Trim();
            List <string> parts = Regex.Matches(parameters, @"[\""].+?[\""]|[^ ]+")
                                  .Cast <Match>()
                                  .Select(m => m.Value)
                                  .ToList();

            // Determine what the commandline should look like given the first item
            int start = 0;

            BaseCommand = Converters.StringToCommand(parts[0]);
            if (BaseCommand != Command.NONE)
            {
                start = 1;
            }

            // Loop through all auxilary flags, if necessary
            int i = 0;

            for (i = start; i < parts.Count; i++)
            {
                // Flag read-out values
                long?  longValue   = null;
                string stringValue = null;

                // Keep a count of keys to determine if we should break out to filename handling or not
                int keyCount = Keys.Count();

                #region Boolean flags

                // Progress
                ProcessBooleanParameter(parts, FlagStrings.Progress, Flag.Progress, ref i);

                // Size
                ProcessBooleanParameter(parts, FlagStrings.Size, Flag.Size, ref i);

                #endregion

                #region Int64 flags

                // Block Size
                longValue = ProcessInt64Parameter(parts, FlagStrings.BlockSize, Flag.BlockSize, ref i);
                if (longValue == Int64.MinValue)
                {
                    return(false);
                }
                else if (longValue != null)
                {
                    BlockSizeValue = longValue;
                }

                // Count
                longValue = ProcessInt64Parameter(parts, FlagStrings.Count, Flag.Count, ref i);
                if (longValue == Int64.MinValue)
                {
                    return(false);
                }
                else if (longValue != null)
                {
                    CountValue = longValue;
                }

                // Seek
                longValue = ProcessInt64Parameter(parts, FlagStrings.Seek, Flag.Seek, ref i);
                if (longValue == Int64.MinValue)
                {
                    return(false);
                }
                else if (longValue != null)
                {
                    SeekValue = longValue;
                }

                // Skip
                longValue = ProcessInt64Parameter(parts, FlagStrings.Skip, Flag.Skip, ref i);
                if (longValue == Int64.MinValue)
                {
                    return(false);
                }
                else if (longValue != null)
                {
                    SkipValue = longValue;
                }

                #endregion

                #region String flags

                // Filter (fixed, removable, disk, partition)
                stringValue = ProcessStringParameter(parts, FlagStrings.Filter, Flag.Filter, ref i);
                if (!string.IsNullOrEmpty(stringValue))
                {
                    FilterValue = stringValue;
                }

                // Input File
                stringValue = ProcessStringParameter(parts, FlagStrings.InputFile, Flag.InputFile, ref i);
                if (string.Equals(stringValue, string.Empty))
                {
                    return(false);
                }
                else if (stringValue != null)
                {
                    InputFileValue = stringValue;
                }

                // Output File
                stringValue = ProcessStringParameter(parts, FlagStrings.OutputFile, Flag.OutputFile, ref i);
                if (string.Equals(stringValue, string.Empty))
                {
                    return(false);
                }
                else if (stringValue != null)
                {
                    OutputFileValue = stringValue;
                }

                #endregion
            }

            return(true);
        }
Exemplo n.º 21
0
        public void RunAlgorithmEliminateTest1()
        {
            // Initialise Possible
            IPossible possibleAll = new Possible()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };

            // Initialise Space
            ISpace <int> space = new Space <int>(new Possible()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            for (int i = 1; i < 82; i++)
            {
                space.Add(i, new Possible(possibleAll));
            }

            // Initialise one group (top row)
            Keys <int> group = new Keys <int>();

            for (int i = 1; i < 10; i++)
            {
                group.Add(i);
            }
            IPuzzle <int>       puzzle = new PuzzleBase <int>(space);
            IPuzzleEngine <int> engine = new PuzzleEngine <int>(puzzle);

            // Action
            Possible values2To9 = new Possible(possibleAll);

            values2To9.Remove(1);
            Keys <int> keysInner = new Keys <int>();

            for (int j = 2; j < 10; j++)
            {
                keysInner.Add(j);
                space[j] = new Possible(values2To9);
            }
            int jobsAdded = ConstraintMutuallyExclusive <int> .CreateCompleteSetActions(keysInner, group, engine);

            Assert.AreEqual(1, engine.Count);

            // Test
            Keys <int> expectedK = new Keys <int>()
            {
                1
            };
            IPossible expectedV = new Possible()
            {
                2, 3, 4, 5, 6, 7, 8, 9
            };

            IJobFilter <int> job    = engine.Peek() as IJobFilter <int>;
            Keys <int>       actual = job.Keys;
            IPossible        filter = job.Filter;

            Assert.AreEqual(1, actual.Count(), "Algorithm Eliminate did not return 8 changes");
            Assert.IsTrue(expectedK.SetEquals(actual));
            Assert.AreEqual(8, filter.Count, "Filter value incorrect");
            Assert.IsTrue(expectedV.SetEquals(filter), "Filter values incorrect");
        }
Exemplo n.º 22
0
        public void update(float delta)
        {
            //On ajoute delta aux chronos
            lastSpawnTime += delta;
            lastChange    += delta;
            float timeRatio = (SpriteButton.speed / SpriteButton.baseSpeed);

            if (lastSpawnTime * timeRatio > spawnTime)
            {
                //On doit ajouter un bouton
                addButton();
                lastSpawnTime = 0;
            }

            if (lastChange * timeRatio > changeTime)
            {
                //On doit changer le temps entre chaque spawn de bouton
                //On sélectionne un nombre au hasard entre 0.30 et 0.33 secondes
                spawnTime = Math.Max((float)rand.Next(200) / 1000.0f, 0.33f);
                //On change la durée de la phase avant le prochain changement
                changeTime = (float)rand.Next(10000) / 1000.0f;
                lastChange = 0;
            }

            //On regarde si les touches sont appuyées quand le bouton est proche de la fin
            Keys[] inputs = new Keys[] { Keys.D, Keys.F, Keys.J, Keys.K };
            //Les boutons les plus proches sont ceux qui sont les premiers dans la liste
            //On vérifie les 4 premier boutons au cas où on en aurait 4 en même temps
            List <SpriteButton> premiersBoutons = new List <SpriteButton>();
            float lastY = 0;

            for (int i = 0; i < Math.Min(4, buttons.Count); i++)
            {
                if (i == 0)
                {
                    lastY = buttons[i].position.Y;
                    premiersBoutons.Add(buttons[i]);
                }

                if (buttons[i].position.Y == lastY)
                {
                    premiersBoutons.Add(buttons[i]);
                }
            }

            for (int j = 0; j < inputs.Count(); j++)
            {
                //Si la touche est appuyée à l'instant on regarde
                if (Keyboard.GetState().IsKeyDown(inputs[j]) && !lastState.IsKeyDown(inputs[j]))
                {
                    for (int i = 0; i < premiersBoutons.Count(); i++)
                    {
                        if (premiersBoutons[i].column == j)
                        {
                            float distance = OTRGame.getInstance().getHeight() - (premiersBoutons[i].position.Y + premiersBoutons[i].texture.Height + 156);
                            //On a appuyé sur la touche correspondante au bouton, on vérifie si il est proche (- de 150px)
                            if (distance < 150)
                            {
                                //Il est proche. On calcule le score que l'on obtient.
                                int scoreTouche = Math.Abs(50 * ((int)(distance % 3) + 1));
                                score += scoreTouche;

                                fails = (fails <= 0) ? 0 : fails - 1;

                                buttons.Remove(premiersBoutons[i]);
                                break;
                            }
                        }
                    }
                }
            }


            //On met à jour les boutons et on vérifie que les boutons ne descendent pas trop bas, sinon on les détruits
            for (int i = buttons.Count - 1; i >= 0; i--)
            {
                SpriteButton button = buttons[i];
                button.update(delta);

                if ((button.position.Y) > (OTRGame.getInstance().getHeight() - 156))
                {
                    buttons.Remove(button);
                    fails++;

                    if (fails >= maxFails)
                    {
                        OTRGame.getInstance().setScreen(new PerduScreen(score));
                    }
                }
            }

            //On met à jour les effets des touches
            foreach (SpriteLight light in lightSprites)
            {
                light.update(delta);
            }

            //On change la vitesse du niveau si on vient d'appuyer sur F3 (baisser vitesse) ou F4 (augmenter vitesse)
            float pallier = (50.0f);

            if (Keyboard.GetState().IsKeyDown(Keys.F3) && !lastState.IsKeyDown(Keys.F3))
            {
                if (SpriteButton.speed <= (50.0f))
                {
                    SpriteButton.speed = (50.0f);
                }
                else
                {
                    SpriteButton.speed -= pallier;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.F4) && !lastState.IsKeyDown(Keys.F4))
            {
                SpriteButton.speed += pallier;
            }

            lastState = Keyboard.GetState();
        }
Exemplo n.º 23
0
        protected IList <IList <IKeyedRegions <TKey> > > CreateXWing(IRegion <TKey> isolatedSet, IPuzzleEngine <TKey> engine)
        {
            List <IList <IKeyedRegions <TKey> > > xwings = new List <IList <IKeyedRegions <TKey> > >();

            // Check each of our isolated set values
            foreach (int value in isolatedSet.Value)
            {
                IList <IKeyedRegions <TKey> > xwing = new List <IKeyedRegions <TKey> >();
                xwing.Add(new KeyedRegions <TKey>());
                xwing.Add(new KeyedRegions <TKey>());
                xwing[0].Value = new Possible()
                {
                    value
                };
                xwing[1].Value = new Possible()
                {
                    value
                };
                int perpSetId = 0;

                foreach (TKey key in isolatedSet.Keys) // Two isolated keys only
                {
                    // Find other constraints passing through "key"
                    IConstraints <TKey> perpConstraints = engine.Puzzle.Constraints.FindOtherConstraintsContainingAllKeys(
                        new Keys <TKey>()
                    {
                        key
                    },
                        new HashSet <ConstraintType>()
                    {
                        this.Type
                    },
                        new Constraints <TKey>()
                    {
                        this
                    });

                    foreach (IConstraint <TKey> perpConstraint in perpConstraints)
                    {
                        // Check each location in other set
                        Keys <TKey> otherKeys = new Keys <TKey>();
                        foreach (TKey constraintKey in perpConstraint.Keys)
                        {
                            if (!constraintKey.Equals(key))
                            {
                                // check if the spaces have the same values as our reducedset visitor combination
                                if (engine.Puzzle.Space[constraintKey].Contains(value))
                                {
                                    // TODO need two xwing groups. One for each constraint (linked contraint is different)
                                    otherKeys.Add(constraintKey);
                                }
                            }
                        }
                        if (otherKeys.Count() > 0)
                        {
                            xwing[perpSetId].OtherKeys.Add(otherKeys);
                            xwing[perpSetId].Keys.Add(key);
                        }
                    }
                    perpSetId++;
                }
                xwings.Add(xwing);
            }
            return(xwings);
        }
Exemplo n.º 24
0
        public void enterkey(Keys[] keys)
        {
            Console.WriteLine(keys[0].ToString());

               if ((keys.Count()>1))
                    {
                   bool shift = false;
                   Keys key = Keys.None;

                   #region shift
                   if (keys[0] == Keys.LeftShift || keys[0] == Keys.RightShift) { shift = true; key = keys[1]; }
                   if (keys[1] == Keys.LeftShift || keys[1] == Keys.RightShift) { shift = true; key = keys[0]; }
                   switch (key)
                        {
                            case Keys.D0: text += 0.ToString();
                                break;
                            case Keys.D1: text += 1.ToString();
                                break;
                            case Keys.D2: text += 2.ToString();
                                break;
                            case Keys.D3: text += 3.ToString();
                                break;
                            case Keys.D4: text += 4.ToString();
                                break;
                            case Keys.D5: text += 5.ToString();
                                break;
                            case Keys.D6: text += 6.ToString();
                                break;
                            case Keys.D7: text += 7.ToString();
                                break;
                            case Keys.D8: text += 8.ToString();
                                break;
                            case Keys.D9: text += 9.ToString();
                                break;
                            case Keys.A: text +="A";
                                break;
                            case Keys.B: text += "B";
                                break;
                            case Keys.C: text += "C";
                                break;
                            case Keys.D: text += "D";
                                break;
                            case Keys.E: text += "E";
                                break;
                            case Keys.F: text += "F";
                                break;
                            case Keys.G: text += "G";
                                break;
                            case Keys.H: text += "H";
                                break;
                            case Keys.I: text += "I";
                                break;
                            case Keys.J: text += "J";
                                break;
                            case Keys.K: text += "K";
                                break;
                            case Keys.L: text += "L";
                                break;
                            case Keys.M: text += "M";
                                break;
                            case Keys.N: text += "N";
                                break;
                            case Keys.O: text += "O";
                                break;
                            case Keys.P: text += "P";
                                break;
                            case Keys.Q: text += "Q";
                                break;
                            case Keys.R: text += "R";
                                break;
                            case Keys.S: text += "S";
                                break;
                            case Keys.T: text += "T";
                                break;
                            case Keys.U: text += "U";
                                break;
                            case Keys.V: text += "V";
                                break;
                            case Keys.W: text += "W";
                                break;
                            case Keys.X: text += "X";
                                break;
                            case Keys.Y: text += "Y";
                                break;
                            case Keys.Z: text += "Z";
                                break;
                            case Keys.OemPlus: text += "+";
                                break;
                            case Keys.OemBackslash: text += ">";
                                break;
                            case Keys.OemTilde: text += "%";
                                break;

                        }
                   #endregion

                   #region altgr
                   bool altgr = false;
                   if (keys[0] == Keys.LeftControl) { altgr = true; key = keys[1]; }
                   if (keys[1] == Keys.LeftControl) { altgr = true; key = keys[0]; }
                   if (altgr)
                   {
                       switch (key)
                       {
                           case Keys.A:
                               break;
                           case Keys.Add:
                               break;
                           case Keys.Apps:
                               break;
                           case Keys.Attn:
                               break;
                           case Keys.B:
                               break;
                           case Keys.Back:
                               break;
                           case Keys.BrowserBack:
                               break;
                           case Keys.BrowserFavorites:
                               break;
                           case Keys.BrowserForward:
                               break;
                           case Keys.BrowserHome:
                               break;
                           case Keys.BrowserRefresh:
                               break;
                           case Keys.BrowserSearch:
                               break;
                           case Keys.BrowserStop:
                               break;
                           case Keys.C:
                               break;
                           case Keys.CapsLock:
                               break;
                           case Keys.ChatPadGreen:
                               break;
                           case Keys.ChatPadOrange:
                               break;
                           case Keys.Crsel:
                               break;
                           case Keys.D:
                               break;
                           case Keys.D0: text += "@";
                               break;
                           case Keys.D1:
                               break;
                           case Keys.D2: text += "~";
                               break;
                           case Keys.D3: text += "#";
                               break;
                           case Keys.D4: text += "{";
                               break;
                           case Keys.D5: text += "[";
                               break;
                           case Keys.D6: text += "|";
                               break;
                           case Keys.D7: text += "`";
                               break;
                           case Keys.D8: text += "\\";
                               break;
                           case Keys.D9: text += "^";
                               break;
                           case Keys.Decimal:
                               break;
                           case Keys.Delete:
                               break;
                           case Keys.Divide:
                               break;
                           case Keys.Down:
                               break;
                           case Keys.E: text += "€";
                               break;
                           case Keys.End:
                               break;
                           case Keys.Enter:
                               break;
                           case Keys.EraseEof:
                               break;
                           case Keys.Escape:
                               break;
                           case Keys.Execute:
                               break;
                           case Keys.Exsel:
                               break;
                           case Keys.F:
                               break;
                           case Keys.F1:
                               break;
                           case Keys.F10:
                               break;
                           case Keys.F11:
                               break;
                           case Keys.F12:
                               break;
                           case Keys.F13:
                               break;
                           case Keys.F14:
                               break;
                           case Keys.F15:
                               break;
                           case Keys.F16:
                               break;
                           case Keys.F17:
                               break;
                           case Keys.F18:
                               break;
                           case Keys.F19:
                               break;
                           case Keys.F2:
                               break;
                           case Keys.F20:
                               break;
                           case Keys.F21:
                               break;
                           case Keys.F22:
                               break;
                           case Keys.F23:
                               break;
                           case Keys.F24:
                               break;
                           case Keys.F3:
                               break;
                           case Keys.F4:
                               break;
                           case Keys.F5:
                               break;
                           case Keys.F6:
                               break;
                           case Keys.F7:
                               break;
                           case Keys.F8:
                               break;
                           case Keys.F9:
                               break;
                           case Keys.G:
                               break;
                           case Keys.H:
                               break;
                           case Keys.Help:
                               break;
                           case Keys.Home:
                               break;
                           case Keys.I:
                               break;
                           case Keys.ImeConvert:
                               break;
                           case Keys.ImeNoConvert:
                               break;
                           case Keys.Insert:
                               break;
                           case Keys.J:
                               break;
                           case Keys.K:
                               break;
                           case Keys.Kana:
                               break;
                           case Keys.Kanji:
                               break;
                           case Keys.L:
                               break;
                           case Keys.LaunchApplication1:
                               break;
                           case Keys.LaunchApplication2:
                               break;
                           case Keys.LaunchMail:
                               break;
                           case Keys.Left:
                               break;
                           case Keys.LeftAlt:
                               break;
                           case Keys.LeftControl:
                               break;
                           case Keys.LeftShift:
                               break;
                           case Keys.LeftWindows:
                               break;
                           case Keys.M:
                               break;
                           case Keys.MediaNextTrack:
                               break;
                           case Keys.MediaPlayPause:
                               break;
                           case Keys.MediaPreviousTrack:
                               break;
                           case Keys.MediaStop:
                               break;
                           case Keys.Multiply:
                               break;
                           case Keys.N:
                               break;
                           case Keys.None:
                               break;
                           case Keys.NumLock:
                               break;
                           case Keys.NumPad0:
                               break;
                           case Keys.NumPad1:
                               break;
                           case Keys.NumPad2:
                               break;
                           case Keys.NumPad3:
                               break;
                           case Keys.NumPad4:
                               break;
                           case Keys.NumPad5:
                               break;
                           case Keys.NumPad6:
                               break;
                           case Keys.NumPad7:
                               break;
                           case Keys.NumPad8:
                               break;
                           case Keys.NumPad9:
                               break;
                           case Keys.O:
                               break;
                           case Keys.Oem8:
                               break;
                           case Keys.OemAuto:
                               break;
                           case Keys.OemBackslash:
                               break;
                           case Keys.OemClear:
                               break;
                           case Keys.OemCloseBrackets:
                               break;
                           case Keys.OemComma:
                               break;
                           case Keys.OemCopy:
                               break;
                           case Keys.OemEnlW:
                               break;
                           case Keys.OemMinus:
                               break;
                           case Keys.OemOpenBrackets:
                               break;
                           case Keys.OemPeriod:
                               break;
                           case Keys.OemPipe:
                               break;
                           case Keys.OemPlus: text += "}";
                               break;
                           case Keys.OemQuestion:
                               break;
                           case Keys.OemQuotes:
                               break;
                           case Keys.OemSemicolon:
                               break;
                           case Keys.OemTilde:
                               break;
                           case Keys.P:
                               break;
                           case Keys.Pa1:
                               break;
                           case Keys.PageDown:
                               break;
                           case Keys.PageUp:
                               break;
                           case Keys.Pause:
                               break;
                           case Keys.Play:
                               break;
                           case Keys.Print:
                               break;
                           case Keys.PrintScreen:
                               break;
                           case Keys.ProcessKey:
                               break;
                           case Keys.Q:
                               break;
                           case Keys.R:
                               break;
                           case Keys.Right:
                               break;
                           case Keys.RightAlt:
                               break;
                           case Keys.RightControl:
                               break;
                           case Keys.RightShift:
                               break;
                           case Keys.RightWindows:
                               break;
                           case Keys.S:
                               break;
                           case Keys.Scroll:
                               break;
                           case Keys.Select:
                               break;
                           case Keys.SelectMedia:
                               break;
                           case Keys.Separator:
                               break;
                           case Keys.Sleep:
                               break;
                           case Keys.Space:
                               break;
                           case Keys.Subtract:
                               break;
                           case Keys.T:
                               break;
                           case Keys.Tab:
                               break;
                           case Keys.U:
                               break;
                           case Keys.Up:
                               break;
                           case Keys.V:
                               break;
                           case Keys.VolumeDown:
                               break;
                           case Keys.VolumeMute:
                               break;
                           case Keys.VolumeUp:
                               break;
                           case Keys.W:
                               break;
                           case Keys.X:
                               break;
                           case Keys.Y:
                               break;
                           case Keys.Z:
                               break;
                           case Keys.Zoom:
                               break;
                           default:
                               break;
                       }
                   }

                        #endregion

                    }
                    else
               {
                   #region normal
                   switch (keys[0])
                        {
                            case Keys.A: text += "a";
                                break;
                            case Keys.Add:
                                break;
                            case Keys.Apps:
                                break;
                            case Keys.Attn:
                                break;
                            case Keys.B: text += "b";
                                break;
                            case Keys.Back: if (text.Length >= 1)
                                {
                                    text = text.Substring(0, text.Length - 1);
                                }
                                break;
                            case Keys.BrowserBack:
                                break;
                            case Keys.BrowserFavorites:
                                break;
                            case Keys.BrowserForward:
                                break;
                            case Keys.BrowserHome:
                                break;
                            case Keys.BrowserRefresh:
                                break;
                            case Keys.BrowserSearch:
                                break;
                            case Keys.BrowserStop:
                                break;
                            case Keys.C: text += "c";
                                break;
                            case Keys.CapsLock:
                                break;
                            case Keys.ChatPadGreen:
                                break;
                            case Keys.ChatPadOrange:
                                break;
                            case Keys.Crsel:
                                break;
                            case Keys.D: text += "d";
                                break;
                            case Keys.D0: //text += "à";
                                break;
                            case Keys.D1: text += "&";
                                break;
                            case Keys.D2:// text += "é";
                                break;
                            case Keys.D3: text += "\"";
                                break;
                            case Keys.D4: text += "'";
                                break;
                            case Keys.D5: text += "(";
                                break;
                            case Keys.D6: text += "-";
                                break;
                            case Keys.D7: //text += "è";
                                break;
                            case Keys.D8: text += "_";
                                break;
                            case Keys.D9: //text += "ç";
                                break;
                            case Keys.Decimal:
                                break;
                            case Keys.Delete:
                                break;
                            case Keys.Divide:
                                break;
                            case Keys.Down:
                                break;
                            case Keys.E: text += "e";
                                break;
                            case Keys.End:
                                break;
                            case Keys.Enter: activate();
                                break;
                            case Keys.EraseEof:
                                break;
                            case Keys.Escape:
                                break;
                            case Keys.Execute:
                                break;
                            case Keys.Exsel:
                                break;
                            case Keys.F: text += "f";
                                break;
                            case Keys.F1:
                                break;
                            case Keys.F10:
                                break;
                            case Keys.F11:
                                break;
                            case Keys.F12:
                                break;
                            case Keys.F13:
                                break;
                            case Keys.F14:
                                break;
                            case Keys.F15:
                                break;
                            case Keys.F16:
                                break;
                            case Keys.F17:
                                break;
                            case Keys.F18:
                                break;
                            case Keys.F19:
                                break;
                            case Keys.F2:
                                break;
                            case Keys.F20:
                                break;
                            case Keys.F21:
                                break;
                            case Keys.F22:
                                break;
                            case Keys.F23:
                                break;
                            case Keys.F24:
                                break;
                            case Keys.F3:
                                break;
                            case Keys.F4:
                                break;
                            case Keys.F5:
                                break;
                            case Keys.F6:
                                break;
                            case Keys.F7:
                                break;
                            case Keys.F8:
                                break;
                            case Keys.F9:
                                break;
                            case Keys.G: text += "g";
                                break;
                            case Keys.H: text += "h";
                                break;
                            case Keys.Help:
                                break;
                            case Keys.Home:
                                break;
                            case Keys.I: text += "i";
                                break;
                            case Keys.ImeConvert:
                                break;
                            case Keys.ImeNoConvert:
                                break;
                            case Keys.Insert:
                                break;
                            case Keys.J: text += "j";
                                break;
                            case Keys.K: text += "k";
                                break;
                            case Keys.Kana:
                                break;
                            case Keys.Kanji:
                                break;
                            case Keys.L: text += "l";
                                break;
                            case Keys.LaunchApplication1:
                                break;
                            case Keys.LaunchApplication2:
                                break;
                            case Keys.LaunchMail:
                                break;
                            case Keys.Left:
                                break;
                            case Keys.LeftAlt:
                                break;
                            case Keys.LeftControl:
                                break;
                            case Keys.LeftShift:
                                break;
                            case Keys.LeftWindows:
                                break;
                            case Keys.M: text += "m";
                                break;
                            case Keys.MediaNextTrack:
                                break;
                            case Keys.MediaPlayPause:
                                break;
                            case Keys.MediaPreviousTrack:
                                break;
                            case Keys.MediaStop:
                                break;
                            case Keys.Multiply:
                                break;
                            case Keys.N: text += "n";
                                break;
                            case Keys.None:
                                break;
                            case Keys.NumLock:
                                break;
                            case Keys.NumPad0:
                                break;
                            case Keys.NumPad1:
                                break;
                            case Keys.NumPad2:
                                break;
                            case Keys.NumPad3:
                                break;
                            case Keys.NumPad4:
                                break;
                            case Keys.NumPad5:
                                break;
                            case Keys.NumPad6:
                                break;
                            case Keys.NumPad7:
                                break;
                            case Keys.NumPad8:
                                break;
                            case Keys.NumPad9:
                                break;
                            case Keys.O: text += "o";
                                break;
                            case Keys.Oem8:
                                break;
                            case Keys.OemAuto:
                                break;
                            case Keys.OemBackslash: text += "<";
                                break;
                            case Keys.OemClear:
                                break;
                            case Keys.OemCloseBrackets:
                                break;
                            case Keys.OemComma:
                                break;
                            case Keys.OemCopy:
                                break;
                            case Keys.OemEnlW:
                                break;
                            case Keys.OemMinus:
                                break;
                            case Keys.OemOpenBrackets: text += ")";
                                break;
                            case Keys.OemPeriod:
                                break;
                            case Keys.OemPipe: text += "*";
                                break;
                            case Keys.OemPlus: text += "=";
                                break;
                            case Keys.OemQuestion: text += "/";
                                break;
                            case Keys.OemQuotes:
                                break;
                            case Keys.OemSemicolon:
                                break;
                            case Keys.OemTilde:
                                break;
                            case Keys.P: text += "p";
                                break;
                            case Keys.Pa1:
                                break;
                            case Keys.PageDown:
                                break;
                            case Keys.PageUp:
                                break;
                            case Keys.Pause:
                                break;
                            case Keys.Play:
                                break;
                            case Keys.Print:
                                break;
                            case Keys.PrintScreen:
                                break;
                            case Keys.ProcessKey:
                                break;
                            case Keys.Q: text += "q";
                                break;
                            case Keys.R: text += "r";
                                break;
                            case Keys.Right:
                                break;
                            case Keys.RightAlt:
                                break;
                            case Keys.RightControl:
                                break;
                            case Keys.RightShift:
                                break;
                            case Keys.RightWindows:
                                break;
                            case Keys.S: text += "s";
                                break;
                            case Keys.Scroll:
                                break;
                            case Keys.Select:
                                break;
                            case Keys.SelectMedia:
                                break;
                            case Keys.Separator:
                                break;
                            case Keys.Sleep:
                                break;
                            case Keys.Space: text += " ";
                                break;
                            case Keys.Subtract:
                                break;
                            case Keys.T: text += "t";
                                break;
                            case Keys.Tab:
                                break;
                            case Keys.U: text += "u";
                                break;
                            case Keys.Up:
                                break;
                            case Keys.V: text += "v";
                                break;
                            case Keys.VolumeDown:
                                break;
                            case Keys.VolumeMute:
                                break;
                            case Keys.VolumeUp:
                                break;
                            case Keys.W: text += "w";
                                break;
                            case Keys.X: text += "x";
                                break;
                            case Keys.Y: text += "y";
                                break;
                            case Keys.Z: text += "z";
                                break;
                            case Keys.Zoom:
                                break;
                            default:
                                break;
                        }
                   #endregion
               }
        }
Exemplo n.º 25
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (Owner != null && Owner != from)
            {
                if (Peerless != null && Peerless.CheckAlive())
                {
                    from.SendLocalizedMessage(1075213); // The master of this realm has already been summoned and is engaged in combat.  Your opportunity will come after he has squashed the current batch of intruders!
                }
                else
                {
                    from.SendLocalizedMessage(1072683, Owner.Name); // ~1_NAME~ has already activated the Prism, please wait...
                }
                return(false);
            }

            if (IsKey(dropped) && MasterKeys.Count() == 0)
            {
                if (KeyValidation == null)
                {
                    KeyValidation = new List <PeerlessKeyArray>();

                    Keys.ToList().ForEach(x => KeyValidation.Add(new PeerlessKeyArray {
                        Key = x, Active = false
                    }));
                }

                if (KeyValidation.Any(x => x.Active == true))
                {
                    if (KeyValidation.Any(x => x.Key == dropped.GetType() && x.Active == false))
                    {
                        KeyValidation.Find(s => s.Key == dropped.GetType()).Active = true;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1072682); // This is not the proper key.
                        return(false);
                    }
                }
                else
                {
                    Owner = from;
                    KeyStartTimer(from);
                    from.SendLocalizedMessage(1074575); // You have activated this object!
                    KeyValidation.Find(s => s.Key == dropped.GetType()).Active = true;
                }

                if (KeyValidation.Where(x => x.Active == true).Count() == Keys.Count())
                {
                    KeyStopTimer();

                    from.SendLocalizedMessage(1072678); // You have awakened the master of this realm. You need to hurry to defeat it in time!
                    BeginSequence(from);

                    for (int k = 0; k < KeyCount; k++)
                    {
                        from.SendLocalizedMessage(1072680); // You have been given the key to the boss.

                        MasterKey key = MasterKey;

                        if (key != null)
                        {
                            key.Altar = this;
                            key._Map  = Map;

                            if (!from.AddToBackpack(key))
                            {
                                key.MoveToWorld(from.Location, from.Map);
                            }

                            MasterKeys.Add(key);
                        }
                    }

                    Timer.DelayCall(TimeSpan.FromSeconds(1), () => ClearContainer());
                    KeyValidation = null;
                }
            }
            else
            {
                from.SendLocalizedMessage(1072682); // This is not the proper key.
                return(false);
            }

            return(base.OnDragDrop(from, dropped));
        }