コード例 #1
0
        private void Restriction_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            Restriction rest = sender as Restriction;

            Debug.Assert(rest != null);

            RestrictionInfo info = _settings.GetUserRestriction(
                rest.NetworkAttributeName);

            if (info != null)
            {
                // currently only Enabled property can be modified
                info.IsTurnedOn = rest.IsEnabled;
            }
            else
            {
                // add new restriction entry to config
                info             = new RestrictionInfo();
                info.Name        = rest.NetworkAttributeName;
                info.Description = rest.Description;
                info.IsEditable  = rest.IsEditable;
                info.IsTurnedOn  = rest.IsEnabled;
                _settings.AddRestriction(info);
            }
        }
コード例 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        private void _InitRestrictions(SolveInfoWrap settings,
                                       NetworkDescription netDesc)
        {
            Debug.Assert(settings != null);
            Debug.Assert(netDesc != null);

            Dictionary <string, Restriction> restrictions = new Dictionary <
                string, Restriction>();

            // add all available restrictions with default data
            foreach (NetworkAttribute attr in netDesc.NetworkAttributes)
            {
                if (attr.UsageType == NetworkAttributeUsageType.Restriction &&
                    !String.IsNullOrEmpty(attr.Name))
                {
                    restrictions.Add(attr.Name.ToLower(), new Restriction(
                                         attr.Name,
                                         String.Empty, // description
                                         true,         // editable is true by default
                                         _IsRestrictionEnabled(attr.Name,
                                                               netDesc.EnabledRestrictionNames)));
                }
            }

            // override restrictions according to settings
            foreach (string name in settings.RestrictionNames)
            {
                RestrictionInfo ri = settings.GetRestriction(name);
                if (ri != null)
                {
                    string key = name.ToLower();

                    Restriction rest = null;
                    if (restrictions.TryGetValue(key, out rest))
                    {
                        // override restriction
                        restrictions[key] = new Restriction(
                            rest.NetworkAttributeName, // NOTE: use name from server
                            ri.Description,
                            ri.IsEditable,
                            ri.IsTurnedOn);
                    }
                    else
                    {
                        Logger.Warning(String.Format(LOG_UNKNOWN_RESTRICTION, name));
                    }
                }
            }

            // attach to events
            foreach (Restriction rest in restrictions.Values)
            {
                rest.PropertyChanged += new PropertyChangedEventHandler(Restriction_PropertyChanged);
            }

            _restrictions.AddRange(restrictions.Values);
        }
コード例 #3
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        public RestrictionInfo GetRestriction(string name)
        {
            RestrictionInfo info = _FindRestriction(name, _userRestrictions);

            if (info == null)
            {
                info = _FindRestriction(name, _defaultRestrictions);
            }

            return(info);
        }
コード例 #4
0
        private void Start()
        {
            PieceSelectionManager.SequenceCompleted += SequenceCompleted;

            var currentLevel = LevelManager.Instance.GetNextLevel();

            _restriction = GameManager.Instance.Restriction;
            _restriction.Reset();

            _updateableRestriction = _restriction as IUpdateable;

            _restrictionInfo = GetComponentInParent <RestrictionInfo>();

            UpdateRestriction(0);
        }
コード例 #5
0
        private static RestrictionInfo _FindRestriction(string name,
                                                        List <RestrictionInfo> coll)
        {
            Debug.Assert(name != null);
            Debug.Assert(coll != null);

            RestrictionInfo info = null;

            foreach (RestrictionInfo ri in coll)
            {
                if (ri.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    info = ri;
                    break;
                }
            }

            return(info);
        }
コード例 #6
0
 public void AddRestriction(RestrictionInfo info)
 {
     Debug.Assert(info != null);
     _userRestrictions.Add(info);
 }