Exemplo n.º 1
0
        public bool unPlug(int _number, CPlug.ReceiveMsgFunc _fun = null)
        {
            if (_fun == null) {
                return cmdPlugDic.Remove (_number);
            } else {
                // plug 集合
                if (!cmdPlugDic.TryGetValue (_number, out temp_plugSet)) {
                    return false;
                }
                //找出需删除的 plug
                CPlug plugWillDelete = null;
                foreach (CPlug plug in temp_plugSet) {
                    if (plug.output == _fun) {
                        plugWillDelete = plug;
                        break;
                    }
                }

                //删除
                if (plugWillDelete == null)
                    return false;
                else {
                    //UnityEngine.Debug.Log ("删除");
                    return temp_plugSet.Remove (plugWillDelete);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary> 设置插线板  </summary>
        public bool setPlug(int _number, CPlug.ReceiveMsgFunc _fun)
        {
            // plug 集合
            if (!cmdPlugDic.TryGetValue (_number, out temp_plugSet)) {
                temp_plugSet = new HashSet<CPlug> ();
                cmdPlugDic [_number] = temp_plugSet;
            }

            foreach (CPlug plug in temp_plugSet) {
                if (plug.output == _fun) {
                    return false;//已经存在
                }
            }

            //生成 plug
            temp_plug = new CPlug ();
            temp_plug.output = _fun;

            temp_plugSet.Add (temp_plug);

            return true;
        }