コード例 #1
0
        // attributes from class (and prepared entity)
        protected virtual IEnumerable <PopupAttributes> GetPreparedAttributes()
        {
            var master = GetAttributesForMasterEntity().Where(a => a.Value != null).ToList();

            return(CRAttribute
                   .EntityAttributes(typeof(TTarget), FilterInfo.Current?.ClassID)
                   .Where(a => a.Required)
                   .Select(a => (entity: a, master: master.FirstOrDefault(_a => _a.AttributeID == a.ID)))
                   .Select((a, i) => new PopupAttributes
            {
                Selected = false,
                CacheName = typeof(TTarget).FullName,
                Name = a.entity.ID + "_Attributes",
                DisplayName = a.entity.Description,
                AttributeID = a.entity.ID,
                Value = a.master?.Value ?? a.entity.DefaultValue,
                Order = i,
                Required = true
            }));
        }
コード例 #2
0
 void Start()
 {
     _navMeshAgent = GetComponent<NavMeshAgent>();
     _speed = GetComponent<CRController>().creature.attributeManager.GetAttribute(CRAttributeType.MOVE_SPEED);
     _conditionManager = GetComponent<CRController>().creature.conditionManager;
 }
        protected IEnumerable <CSAnswers> SelectInternal(PXGraph graph, object row)
        {
            if (row == null)
            {
                yield break;
            }

            var noteId = GetNoteId(row);

            if (!noteId.HasValue)
            {
                yield break;
            }

            var answerCache = graph.Caches[typeof(CSAnswers)];
            var entityCache = graph.Caches[row.GetType()];

            List <CSAnswers> answerList;

            var status = entityCache.GetStatus(row);

            if (status == PXEntryStatus.Inserted || status == PXEntryStatus.InsertedDeleted)
            {
                answerList = answerCache.Inserted.Cast <CSAnswers>().Where(x => x.RefNoteID == noteId).ToList();
            }
            else
            {
                answerList = PXSelect <CSAnswers, Where <CSAnswers.refNoteID, Equal <Required <CSAnswers.refNoteID> > > >
                             .Select(graph, noteId).FirstTableItems.ToList();
            }

            var classId = base.GetClassId(row);

            CRAttribute.ClassAttributeList classAttributeList = new CRAttribute.ClassAttributeList();

            if (classId != null)
            {
                classAttributeList = CRAttribute.EntityAttributes(base.GetEntityTypeFromAttribute(row), classId);
            }
            //when coming from Import scenarios there might be attributes which don't belong to entity's current attribute class or the entity might not have any attribute class at all
            if (graph.IsImport && PXView.SortColumns.Any() && PXView.Searches.Any())
            {
                var columnIndex = Array.FindIndex(PXView.SortColumns,
                                                  x => x.Equals(typeof(CSAnswers.attributeID).Name, StringComparison.OrdinalIgnoreCase));

                if (columnIndex >= 0 && columnIndex < PXView.Searches.Length)
                {
                    var searchValue = PXView.Searches[columnIndex];

                    if (searchValue != null)
                    {
                        //searchValue can be either AttributeId or Description
                        var attributeDefinition = CRAttribute.Attributes[searchValue.ToString()] ??
                                                  CRAttribute.AttributesByDescr[searchValue.ToString()];

                        if (attributeDefinition == null)
                        {
                            throw new PXSetPropertyException(PX.Objects.CR.Messages.AttributeNotValid);
                        }
                        //avoid duplicates
                        else if (classAttributeList[attributeDefinition.ToString()] == null)
                        {
                            classAttributeList.Add(new CRAttribute.AttributeExt(attributeDefinition, null, false, true));
                        }
                    }
                }
            }

            if (answerList.Count == 0 && classAttributeList.Count == 0)
            {
                yield break;
            }

            //attribute identifiers that are contained in CSAnswers cache/table but not in class attribute list
            List <string> attributeIdListAnswers =
                answerList.Select(x => x.AttributeID)
                .Except(classAttributeList.Select(x => x.ID))
                .Distinct()
                .ToList();

            //attribute identifiers that are contained in class attribute list but not in CSAnswers cache/table
            List <string> attributeIdListClass =
                classAttributeList.Select(x => x.ID)
                .Except(answerList.Select(x => x.AttributeID))
                .ToList();

            //attribute identifiers which belong to both lists
            List <string> attributeIdListIntersection =
                classAttributeList.Select(x => x.ID)
                .Intersect(answerList.Select(x => x.AttributeID))
                .Distinct()
                .ToList();


            var cacheIsDirty = answerCache.IsDirty;

            List <CSAnswers> output = new List <CSAnswers>();

            //attributes contained only in CSAnswers cache/table should be added "as is"
            output.AddRange(answerList.Where(x => attributeIdListAnswers.Contains(x.AttributeID)));

            //attributes contained only in class attribute list should be created and initialized with default value
            foreach (var attributeId in attributeIdListClass)
            {
                var classAttributeDefinition = classAttributeList[attributeId];

                if (PXSiteMap.IsPortal && classAttributeDefinition.IsInternal)
                {
                    continue;
                }

                if (!classAttributeDefinition.IsActive)
                {
                    continue;
                }

                CSAnswers answer = (CSAnswers)answerCache.CreateInstance();
                answer.AttributeID = classAttributeDefinition.ID;
                answer.RefNoteID   = noteId;
                answer.Value       = GetDefaultAnswerValue(classAttributeDefinition);
                if (classAttributeDefinition.ControlType == CSAttribute.CheckBox)
                {
                    bool value;
                    if (bool.TryParse(answer.Value, out value))
                    {
                        answer.Value = Convert.ToInt32(value).ToString(CultureInfo.InvariantCulture);
                    }
                    else if (answer.Value == null)
                    {
                        answer.Value = 0.ToString();
                    }
                }

                answer.IsRequired = classAttributeDefinition.Required;

                Dictionary <string, object> keys = new Dictionary <string, object>();
                foreach (string key in answerCache.Keys.ToArray())
                {
                    keys[key] = answerCache.GetValue(answer, key);
                }

                if (answerCache.Locate(keys) == 0)
                {
                    answer = (CSAnswers)(answerCache.Locate(answer) ?? answerCache.Insert(answer));
                    output.Add(answer);
                }
            }

            //attributes belonging to both lists should be selected from CSAnswers cache/table with and additional IsRequired check against class definition
            foreach (CSAnswers answer in answerList.Where(x => attributeIdListIntersection.Contains(x.AttributeID)).ToList())
            {
                var classAttributeDefinition = classAttributeList[answer.AttributeID];

                if (PXSiteMap.IsPortal && classAttributeDefinition.IsInternal)
                {
                    continue;
                }

                if (!classAttributeDefinition.IsActive)
                {
                    continue;
                }

                if (answer.Value == null && classAttributeDefinition.ControlType == CSAttribute.CheckBox)
                {
                    answer.Value = bool.FalseString;
                }

                if (answer.IsRequired == null || classAttributeDefinition.Required != answer.IsRequired)
                {
                    answer.IsRequired = classAttributeDefinition.Required;

                    var fieldState = View.Cache.GetValueExt <CSAnswers.isRequired>(answer) as PXFieldState;
                    var fieldValue = fieldState != null && ((bool?)fieldState.Value).GetValueOrDefault();

                    answer.IsRequired = classAttributeDefinition.Required || fieldValue;
                }



                output.Add(answer);
            }

            answerCache.IsDirty = cacheIsDirty;

            output =
                output.OrderBy(
                    x =>
                    classAttributeList.Contains(x.AttributeID)
                            ? classAttributeList.IndexOf(x.AttributeID)
                            : (x.Order ?? 0))
                .ThenBy(x => x.AttributeID)
                .ToList();

            short attributeOrder = 0;

            foreach (CSAnswers answer in output)
            {
                answer.Order = attributeOrder++;
                yield return(answer);
            }
        }
コード例 #4
0
ファイル: CRDefence.cs プロジェクト: silantzis/quest
    public void Start()
    {
        _creature = GetComponent<CRCreature>();

        if (_creature)
        {
            CRAttributeManager attributeManager = _creature.attributeManager;

            if (attributeManager)
            {
                _mitigation    = attributeManager.GetAttribute(CRAttributeType.MITIGATION);
                _avoidChance   = attributeManager.GetAttribute(CRAttributeType.AVOID_CHANCE);
                _dodgeChance   = attributeManager.GetAttribute(CRAttributeType.DODGE_CHANCE);
                _parryChance   = attributeManager.GetAttribute(CRAttributeType.PARRY_CHANCE);
                _blockChance   = attributeManager.GetAttribute(CRAttributeType.AVOID_CHANCE);
                _deflectChance = attributeManager.GetAttribute(CRAttributeType.DEFLECT_CHANCE);
                _reflectChance = attributeManager.GetAttribute(CRAttributeType.REFLECT_CHANCE);

                _armorRating   = attributeManager.GetAttribute(CRAttributeType.ARMOR_RATING);
                _avoidRating   = attributeManager.GetAttribute(CRAttributeType.AVOID_RATING);
                _dodgeRating   = attributeManager.GetAttribute(CRAttributeType.DODGE_RATING);
                _parryRating   = attributeManager.GetAttribute(CRAttributeType.PARRY_RATING);
                _blockRating   = attributeManager.GetAttribute(CRAttributeType.AVOID_RATING);
                _deflectRating = attributeManager.GetAttribute(CRAttributeType.DEFLECT_RATING);
                _reflectRating = attributeManager.GetAttribute(CRAttributeType.REFLECT_RATING);
            }
        }
    }
コード例 #5
0
ファイル: CROffence.cs プロジェクト: silantzis/quest
    public void Start()
    {
        _creature = GetComponent<CRCreature>();
        CRAttributeManager attributeManager = _creature.attributeManager;

        if (attributeManager)
        {
            _missChance   = attributeManager.GetAttribute(CRAttributeType.MISS_CHANCE);
            _critChance   = attributeManager.GetAttribute(CRAttributeType.CRIT_CHANCE);
            _crushChance  = attributeManager.GetAttribute(CRAttributeType.CRUSH_CHANCE);
            _doubleChance = attributeManager.GetAttribute(CRAttributeType.DOUBLE_ATK_CHANCE);
            _tripleChance = attributeManager.GetAttribute(CRAttributeType.TRIPLE_ATK_CHANCE);
            _haste	      = attributeManager.GetAttribute(CRAttributeType.HASTE);

            _attackRating = attributeManager.GetAttribute(CRAttributeType.ATTACK_RATING);
            _hitRating    = attributeManager.GetAttribute(CRAttributeType.HIT_RATING);
            _critRating   = attributeManager.GetAttribute(CRAttributeType.CRIT_RATING);
            _crushRating  = attributeManager.GetAttribute(CRAttributeType.CRUSH_RATING);
            _doubleRating = attributeManager.GetAttribute(CRAttributeType.DOUBLE_ATK_RATING);
            _tripleRating = attributeManager.GetAttribute(CRAttributeType.TRIPLE_ATK_RATING);
            _hasteRating  = attributeManager.GetAttribute(CRAttributeType.HASTE_RATING);

            _magicRating  = attributeManager.GetAttribute(CRAttributeType.MAGIC_RATING);

            _damage 	  = attributeManager.GetAttribute(CRAttributeType.DAMAGE);
        }
    }