Beispiel #1
0
        private void findAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckDelegate <int, String> d = new CheckDelegate <int, String>(EqualStrings);
            IMap <int, string>          b = MapUtils.FindAll <int, string>(a, d, MapUtils.LinkedMapConstructor <int, string>());

            a = b;
        }
Beispiel #2
0
        /////////////////////////////////////

        public SpecifyParametersForm(string caption, object optionalObjectProvider, CheckDelegate checkHandler = null, OKDelegate okHandler = null)
        {
            this.checkHandler = checkHandler;
            this.okHandler    = okHandler;

            InitializeComponent();

            if (optionalObjectProvider != null)
            {
                hierarchicalContainer1.SetData(null, new object[] { optionalObjectProvider });
            }
            else
            {
                hierarchicalContainer1.SetData(null, new object[] { objectImpl });
            }

            if (string.IsNullOrEmpty(caption))
            {
                Text = EngineInfo.NameWithVersion;
            }
            else
            {
                Text = caption;
            }

            labelError.Text = "";

            DarkThemeUtility.ApplyToForm(this);
        }
Beispiel #3
0
    void Start()
    {
        if (this.PlayerPrefKey != null && this.PlayerPrefKey != "")
        {
            _toggled = PlayerPrefs.GetInt(this.PlayerPrefKey, 1);
        }
        else
        {
            _toggled = 1;
        }

        if (!this.CheckInput)
        {
            _check = noCheck;
        }
        else if (this.UseMenuInput)
        {
            _check = menuCheck;
        }
        else
        {
            _check = gameplayCheck;
        }

        toggle();
    }
Beispiel #4
0
        private static void TimedTargetInteract(CheckDelegate check,
                                                object[] param_list, out string[] res, int wait, string err)
        {
            res = null;
            bool     f  = false;
            DateTime dt = DateTime.Now;

            while (!f && (DateTime.Now - dt).
                   TotalMilliseconds <= ProcessManager.AppConfig.MaxNpcInteractTime)
            {
                Thread.Sleep(wait);
                f = check(param_list, out res);
            }

            if (!f)
            {
                if (err == null)
                {
                    throw new NpcInteractException();
                }
                else
                {
                    throw new NpcInteractException(err);
                }
            }
        }
Beispiel #5
0
    virtual public void InitializeEnemy()
    {
        //creating variables to initialize the monster
        //this code is for testing purposes, final product will pull this information from the database scripts
        var headInfo     = PartFactory.GetHeadPartInfo(monsterName);
        var torsoInfo    = PartFactory.GetTorsoPartInfo(monsterName);
        var rightArmInfo = PartFactory.GetArmPartInfo(monsterName, Helper.PartType.RightArm);
        var leftArmInfo  = PartFactory.GetArmPartInfo(monsterName, Helper.PartType.LeftArm);
        var legPartInfo  = PartFactory.GetLegPartInfo(monsterName);

        rightArmInfo.equippedWeapon = equippedWeapon;

        attackDelegate  = Attack;
        abilityDelegate = Ability;

        //adding methods to be run in fixed update to the check delegate
        //this allows multiple methods that need to constantly check some status of the Enemy
        //to be run in FixedUpdate without filling it with method calls
        checkDelegate += UpdateCooldowns;
        checkDelegate += CheckLineOfSight;
        checkDelegate += CheckAggro;
        checkDelegate += FollowTarget;

        monster.InitializeMonster(headInfo, torsoInfo, rightArmInfo, leftArmInfo, legPartInfo);
        //setting the cooldown timers so that the player can use the inputs as soon as the game loads
        attackCooldownTimer  = attackCooldown;
        abilityCooldownTimer = abilityCooldown;

        SetFacingDirection(transform.localScale.x);
    }
Beispiel #6
0
        //

        public OKCancelTextBoxForm(string labelText, string textBoxText, string caption, CheckDelegate checkHandler, OKDelegate okHandler)
        {
            this.checkHandler = checkHandler;
            this.okHandler    = okHandler;

            InitializeComponent();

            this.labelText.Text = labelText;
            textBoxName.Text    = textBoxText;

            if (string.IsNullOrEmpty(caption))
            {
                Text = EngineInfo.NameWithVersion;
            }
            else
            {
                Text = caption;
            }

            labelError.Text = "";

            EditorThemeUtility.ApplyDarkThemeToForm(this);

            buttonOK.Text     = EditorLocalization.Translate("General", buttonOK.Text);
            buttonCancel.Text = EditorLocalization.Translate("General", buttonCancel.Text);
        }
Beispiel #7
0
 private static void ShareCheckCompleted(IAsyncResult result)
 {
     //获取委托对象,调用EndInvoke方法获取运行结果
     AsyncResult   _result    = (AsyncResult)result;
     CheckDelegate myDelegate = (CheckDelegate)_result.AsyncDelegate;
     int           data       = myDelegate.EndInvoke(_result);
 }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     rb             = GetComponent <Rigidbody>();
     checkDelegate += CheckCameraToTopDown;
     checkDelegate += CheckCameraToSideScroll;
     checkDelegate += CheckMovement;
     checkDelegate += CheckCurrentPlatform;
 }
Beispiel #9
0
 /// <summary>
 /// 用于检测是否符合条件
 /// </summary>
 /// <param name="handler"></param>
 /// <returns></returns>
 public bool Check(CheckDelegate handler)
 {
     if (handler == null)
     {
         throw new Exception("查测的委托不能为空!");
     }
     return(handler());
 }
Beispiel #10
0
        protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Forward && IsDirty)
            {
                if (IsUri() && !Download())
                {
                    cancel = true;
                    return;
                }

                if (!PerformCheck(CheckIsSupportedType, CheckPathExists))
                {
                    cancel = true;
                    return;
                }

                string extension = Path.GetExtension(FilePath).ToLower();

                if (extension == ".gz")
                {
                    if (!PerformCheck(CheckSourceIsWritable) || !Uncompress())
                    {
                        cancel = true;
                        return;
                    }
                }

                CheckDelegate check = null;
                switch (TypeOfImport)
                {
                case ImportWizard.ImportType.Xva:
                    check = GetDiskCapacityXva;
                    break;

                case ImportWizard.ImportType.Ovf:
                    check = LoadAppliance;
                    break;

                case ImportWizard.ImportType.Vhd:
                    check = GetDiskCapacityImage;
                    break;
                }

                if (!PerformCheck(check))
                {
                    cancel = true;
                    return;
                }

                if (TypeOfImport == ImportWizard.ImportType.Ovf && OVF.HasEncryption(SelectedOvfEnvelope))
                {
                    cancel = true;
                    m_tlpEncryption.Visible = true;
                    m_buttonNextEnabled     = false;
                    OnPageUpdated();
                }
            }
        }
Beispiel #11
0
 //проверяет существование элемента списка, удовлетворяещего условиям предиката
 public static bool Exists <T>(IList <T> list, CheckDelegate <T> check)
 {
     foreach (T item in list)
     {
         if (check(item))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #12
0
 public static bool Exists(IMap <K, V> map, CheckDelegate checkDelegate)
 {
     foreach (Entry <K, V> entry in map)
     {
         if (checkDelegate(entry))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #13
0
 public static TValue FindLast <TValue>(IList <TValue> list, CheckDelegate <TValue> delegete_func)
 {
     foreach (var item in list.Reverse())
     {
         if (delegete_func(item))
         {
             return(item);
         }
     }
     return(default(TValue));
 }
Beispiel #14
0
 public static bool CheckForAll <TValue>(IList <TValue> list, CheckDelegate <TValue> checkDelegate)
 {
     foreach (var item in list.Reverse())
     {
         if (!checkDelegate(item))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #15
0
 //возвращает элемент, удовлетворяющий условиям предиката
 public static T Find <T>(IList <T> list, CheckDelegate <T> check)
 {
     foreach (T item in list)
     {
         if (check(item))
         {
             return(item);
         }
     }
     throw new Exception("Can not find the element");
 }
Beispiel #16
0
 //возвращает индекс первого элемента списка, удовлетворяющего условиям предиката
 public static int FindIndex <T>(IList <T> list, CheckDelegate <T> check)
 {
     for (int i = 0; i < list.Count; ++i)
     {
         if (check(list[i]))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #17
0
 /// <summary>
 /// Проверка, существует ли в дереве узел, соответсвующий условию из check
 /// </summary>
 /// <param name="tree"></param>
 /// <param name="check"></param>
 /// <returns></returns>
 public static bool Excists(ITree <T> tree, CheckDelegate <T> check)
 {
     foreach (T node in tree)
     {
         if (check(node))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #18
0
 public static bool Exists <K, V>(IMap <K, V> sourcemap, CheckDelegate <K, V> del) where K : IComparable where V : IComparable
 {
     foreach (IEntry <K, V> i in sourcemap)
     {
         if (del(i))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #19
0
 /// <summary>
 /// Проверить, что все эл-ты дерева подчинены условию check
 /// </summary>
 /// <param name="tree"></param>
 /// <param name="check"></param>
 /// <returns></returns>
 public static bool CheckForAll(ITree <T> tree, CheckDelegate <T> check)
 {
     foreach (T node in tree)
     {
         if (!check(node))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #20
0
 public static bool CheckForAll <K, V>(IMap <K, V> map, CheckDelegate <K, V> checkDelegate)
 {
     foreach (Entry <K, V> entry in map)
     {
         if (!checkDelegate(entry))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #21
0
 public static bool CheckForAll <T>(IQueue <T> queue, CheckDelegate <T> check) where T : System.IComparable <T>
 {
     foreach (T elem in queue)
     {
         if (!check(elem))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #22
0
        /// <summary>
        /// Проверка на выполнение условия для всех элементов дерева
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="tree">Дерево</param>
        /// <param name="check">Делегат проверки</param>
        /// <returns></returns>
        public static bool CheckForAll <T>(ITree <T> tree, CheckDelegate <T> check)
        {
            foreach (var element in tree)
            {
                if (!check(element))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #23
0
        /// <summary>
        /// 线程执行校验单号函数
        /// </summary>
        /// <param name="updateBillItem"></param>
        public void CheckBillList(object updateBillItem)
        {
            var item = updateBillItem as LoadPrintMarkEntity;

            try
            {
                if (item != null)
                {
                    // 循环次数 65  2
                    var length = item.PrintBillEntities.Count > 50 ? Convert.ToInt32(Math.Ceiling(item.PrintBillEntities.Count / 50.0)) : 1;
                    // 每次循环单号个数 33
                    var listNo = item.PrintBillEntities.Count / length;

                    for (int i = 1; i < length + 1; i++)
                    {
                        List <ZtoPrintBillEntity> billCodeListSend;
                        if (i == 1)
                        {
                            billCodeListSend = item.PrintBillEntities.Skip((i - 1) * listNo).Take(listNo + 1).ToList();
                        }
                        else
                        {
                            billCodeListSend = item.PrintBillEntities.Skip((i - 1) * listNo + i - 1).Take(listNo + 1).ToList();
                        }
                        // 绑定大头笔信息
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in billCodeListSend)
                        {
                            // 如果大头笔已经有了就不用联网获取了
                            var selectedRemark = new List <string> {
                                ztoPrintBillEntity.SendProvince, ztoPrintBillEntity.SendCity, ztoPrintBillEntity.SendCounty
                            };
                            var selectedReceiveMark = new List <string> {
                                ztoPrintBillEntity.ReceiveProvince, ztoPrintBillEntity.ReceiveCity, ztoPrintBillEntity.ReceiveCounty
                            };
                            var printMark = BillPrintHelper.GetRemaike(string.Join(",", selectedRemark), ztoPrintBillEntity.SendAddress, string.Join(",", selectedReceiveMark), ztoPrintBillEntity.ReceiveAddress);
                            ztoPrintBillEntity.BigPen = printMark;
                            PrintBillEntities.Add(ztoPrintBillEntity);
                        }
                        BillCodeIndex += billCodeListSend.Count;
                        //指定委托方法
                        CheckDelegate refresh = Refresh;
                        Invoke(refresh, item.Code);
                    }
                }
            }
            catch (Exception ex)
            {
                lock (Obj)
                {
                    ProcessException(ex);
                }
            }
        }
Beispiel #24
0
        //возвращает индекс последнего элемента списка, удовлетворяющего условиям предиката
        public static int FindLastIndex <T>(IList <T> list, CheckDelegate <T> check)
        {
            int last = -1;

            for (int i = 0; i < list.Count; ++i)
            {
                if (check(list[i]))
                {
                    last = i;
                }
            }
            return(last);
        }
Beispiel #25
0
        private void existsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckDelegate <int, String> d = new CheckDelegate <int, String>(EqualStrings);

            if (MapUtils.Exists <int, string>(a, d))
            {
                MessageBox.Show("Элемент, удовлетворяющий условию, присутствует в множестве");
            }
            else
            {
                MessageBox.Show("Элемент, удовлетворяющий условию, отсутствует в множестве");
            }
        }
Beispiel #26
0
        private void forEachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckDelegate <int, String> d = new CheckDelegate <int, String>(EqualStrings);

            if (MapUtils.CheckForAll <int, string>(a, d))
            {
                MessageBox.Show("Все элементы множества удовлетворяют условию");
            }
            else
            {
                MessageBox.Show("Не все элементы множества удовлетворяют условию");
            }
        }
Beispiel #27
0
    private void TestB()
    {
        TestData t1 = new TestData(1, 1, 111);
        TestData t2 = new TestData(2, 2, 222);

        check = luaenv.Global.Get <CheckDelegate> ("check");
        int i = 0;

//		while (i < 1000) {
        check(t1, t2);
//			i++;
//		}
    }
Beispiel #28
0
        /// <summary>
        /// Поиск всех эл-тов в дереве по заданному условию
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="check"></param>
        /// <param name="constructor"></param>
        /// <returns></returns>
        public static ITree <T> FindAll(ITree <T> tree, CheckDelegate <T> check, TreeConstructor <T> constructor)
        {
            ITree <T> res = constructor();

            foreach (T ob in tree)
            {
                if (check(ob))
                {
                    res.Add(ob);
                }
            }
            return(res);
        }
Beispiel #29
0
        // Возвращает список элементов, проходящих проверку check по значению
        public static IQueue <T> FindAll <T>(IQueue <T> queue, CheckDelegate <T> check, QueueConstructorDelegate <T> getEmptyQueue) where T : System.IComparable <T>
        {
            IQueue <T> result = getEmptyQueue();

            foreach (T elem in queue)
            {
                if (check(elem))
                {
                    result.Push(elem);
                }
            }
            return(result);
        }
Beispiel #30
0
        public static IMap <K, V> FindAll <K, V>(IMap <K, V> sourcemap, CheckDelegate <K, V> checkdel, MapConstructorDelegate <K, V> constdel) where K : IComparable where V : IComparable
        {
            IMap <K, V> temp = constdel();

            foreach (IEntry <K, V> i in sourcemap)
            {
                if (checkdel(i))
                {
                    temp.Put(i.Key, i.Value);
                }
            }
            return(temp);
        }
       /// <summary>
       /// 以指定的时间间隔调用检测函数,若检测函数返回true,则执行运行函数,
       /// 若检测函数被调用一定次数后仍然返回false,则不执行运行函数。
       /// </summary>
       /// <param name="interval">间隔时间。每隔Interval毫秒,checkFunction就会被调用一次</param>
       /// <param name="checkFunction">检测函数。返回true代表检测成功,反之失败</param>
       /// <param name="runFunction">运行函数。</param>
       /// <param name="maxCheckCount">最大检测次数。如果超过了maxCheckCount,checkFunction仍然返回false,则runFunction不会被调用
       ///                     <para>当检测次数为0时,则为无限循环,直到checkFunction满足条件后方才退出</para></param>
       public CheckRunner(int interval, CheckDelegate checkFunction, RunDelegate runFunction, int maxCheckCount)
       {
           _attemptCount = maxCheckCount;
           if (_attemptCount == 0)
           {
               isInfiniteLoop = true;
           }
           _checkFunction = checkFunction;
           _runFunction = runFunction;

           _timer.Elapsed += new ElapsedEventHandler(delegate(object sender, ElapsedEventArgs e)
           {
               if (_isEnter)
               {
                   return;
               }
               _isEnter = true;

               if (!isInfiniteLoop)
               {
                   _attemptCount--;
               }

               if (_checkFunction())
               {
                   if (!_isRunned)
                   {
                       _runFunction();
                       _isRunned = true;
                   }
                   _timer.Enabled = false;
               }
               else if (_attemptCount <= 0 && !isInfiniteLoop)
               {
                   _timer.Enabled = false;
               }

               _isEnter = false;
           });
           _timer.Interval = interval;
           _timer.Enabled = true;
       }
Beispiel #32
0
        private bool Match(CheckDelegate check)
        {
            bool result = false;

            int ch = reader.Peek();
            if (ch != -1)
            {
                result = check((char)ch);
            }

            return result;
        }
 public void StopWhenTrue(CheckDelegate checkCallback,double interval)
 {
     checkTimer = new Timer(interval);
     checkTimer.Elapsed+=delegate {
                                 if(checkCallback())
                                 {
                                     checkTimer.Stop();
                                     runner.StopAll();
                                 }
                             };
 }
 public ConditionDelegate(CheckDelegate checkDelegate)
 {
     m_delegate = checkDelegate;
 }