示例#1
0
 public void setAttributes(string _name, AttributeBase _base)
 {
     if (this.dictionary != null)
     {
         if(!this.dictionary.ContainsKey(_name))
             this.dictionary.Add(_name, _base);
     }
 }
示例#2
0
        /// <summary>
        /// Convert a NameValueCollection-Like List to a Dictionary of IAttributes
        /// </summary>
        public static Dictionary<string, IAttribute> GetTypedDictionaryForSingleLanguage(IDictionary<string, object> attributes, string titleAttributeName)
        {
            var result = new Dictionary<string, IAttribute>(StringComparer.OrdinalIgnoreCase);

            foreach (var attribute in attributes)
            {
                var attributeType = GetAttributeTypeName(attribute.Value);
                var baseModel = new AttributeBase(attribute.Key, attributeType, attribute.Key == titleAttributeName, attributeId: 0, sortOrder: 0);
                var attributeModel = GetAttributeManagementModel(baseModel);
                var valuesModelList = new List<IValue>();
                if (attribute.Value != null)
                {
                    var valueModel = Value.GetValueModel(baseModel.Type, attribute.Value.ToString());
                    valuesModelList.Add(valueModel);
                }

                attributeModel.Values = valuesModelList;

                result[attribute.Key] = attributeModel;
            }

            return result;
        }
示例#3
0
        private void CreateReport(string reportName, IEnumerable <Doc> docs, BizTableReport reportData)
        {
            // adding page header
            var pageHeaderString = reportData.PageHeaders.Aggregate("", (current, pageHeader) => current + pageHeader + "\n");

            _report.AddPageHeader(pageHeaderString, Position.Centre);

            // adding page footer
            var pageFooterString = reportData.PageFooters.Aggregate("", (current, pageFooter) => current + pageFooter + "\n");

            _report.AddPageFooter(pageFooterString, Position.Centre);

            // adding empty rows for logo
            _report.AddEmptyRows(6);

            // report header
            foreach (string reportHeader in reportData.ReportHeaders)
            {
                var headerRow = _report.GetNextRow();
                _report.AddCell(reportHeader, 0, headerRow, TextStyle.Header2);
            }

            // Report table
            Row row = _report.GetNextRow();

            _report.AddCell(reportName, 0, row, TextStyle.Header1);
            _report.SetRowHeight(row, 22);

            if (reportData.ReportDetails != null)
            {
                foreach (BizReportDetail repDetail in reportData.ReportDetails)
                {
                    int rowShift = _report.CurrentRowIndex + 2;
                    for (int rowIndex = 0; rowIndex < repDetail.ChildrenCountLevels; rowIndex++)
                    {
                        for (int columnIndex = 0; columnIndex < repDetail.LeafCount; columnIndex++)
                        {
                            _report.AddCell("", columnIndex, rowShift + rowIndex, TextStyle.TableHeaderGreyCenterdBorder);
                        }
                    }
                    WriteReportDetail(repDetail, rowShift - 1, repDetail.ChildrenCountLevels, 0);

                    foreach (Doc doc in docs)
                    {
                        Row tableRow = _report.GetNextRow();

                        int colIndex = 0;
                        foreach (ReportColumn col in GetColumns(repDetail))
                        {
                            Guid attrId = col.AttributeId;
                            IEnumerable <AttributeBase> findAttrQuery = from a in doc.Attributes
                                                                        where a.AttrDef.Id == attrId
                                                                        select a;
                            if (findAttrQuery.Any())
                            {
                                AttributeBase findedAttr = findAttrQuery.First();
                                if (findedAttr is EnumAttribute)
                                {
                                    var enumAttribute = findedAttr as EnumAttribute;
                                    if (enumAttribute.Value.HasValue)
                                    {
                                        string enumValue =
                                            _enumRepository.GetEnumValue(enumAttribute.AttrDef.EnumDefType.Id,
                                                                         enumAttribute.Value.Value);
                                        _report.AddCell(enumValue, colIndex, tableRow, TextStyle.TableRowNormal);
                                    }
                                }
                                else
                                {
                                    _report.AddCell(findedAttr.ObjectValue, colIndex, tableRow, TextStyle.TableRowNormal);
                                }
                            }
                            else
                            {
                                _report.AddCell("", colIndex, tableRow, TextStyle.TableRowNormal);
                            }
                            colIndex++;
                        }
                    }

                    Row aggregatesRow = _report.GetNextRow();
                    int aggrColIndex  = 0;
                    foreach (ReportColumn col in GetColumns(repDetail))
                    {
                        /*  atr.AttrDef.Type.Id
                         *  1	Int
                         *  2	Currency
                         *  3	Text
                         *  4	Float
                         *  5	Enum
                         *  6	Doc
                         *  7	DocList
                         *  8	Bool
                         *  9	DateTime
                         */
                        Guid attrId = col.AttributeId;
                        IEnumerable <AttributeBase> attrQuery = from atr in docs.SelectMany(d => d.Attributes)
                                                                where atr.AttrDef.Id == attrId
                                                                select atr;

                        object aggregateValue;
                        switch (col.AggregateOperation)
                        {
                        case AggregateOperation.Count:
                            aggregateValue = attrQuery.Count();
                            break;

                        case AggregateOperation.Avg:
                            var q1 = attrQuery.Where(atr => (new[] { 1, 2, 4 }).Contains(atr.AttrDef.Type.Id));
                            aggregateValue = q1.Any() ? q1.Average(a => double.Parse((a.ObjectValue ?? 0).ToString())) : 0;
                            break;

                        case AggregateOperation.Sum:
                            var q2 = attrQuery.Where(atr => (new[] { 1, 2, 4 }).Contains(atr.AttrDef.Type.Id));
                            aggregateValue = q2.Any() ? q2.Sum(a => double.Parse((a.ObjectValue ?? 0).ToString())) : 0;
                            break;

                        case AggregateOperation.Max:
                            aggregateValue =
                                attrQuery.Where(atr => (new[] { 1, 2, 4, 9 }).Contains(atr.AttrDef.Type.Id)).Max(
                                    a => a.ObjectValue);
                            break;

                        case AggregateOperation.Min:
                            aggregateValue =
                                attrQuery.Where(atr => (new[] { 1, 2, 4, 9 }).Contains(atr.AttrDef.Type.Id)).Min(
                                    a => a.ObjectValue);
                            break;

                        default:
                            aggregateValue = "";
                            break;
                        }

                        _report.AddCell(aggrColIndex == 0 ? "Итог" : aggregateValue,
                                        aggrColIndex, aggregatesRow, TextStyle.TableTotal);

                        aggrColIndex++;
                    }
                }
            }

            _report.AddEmptyRow();
            // report footer
            foreach (string reportFooter in reportData.ReportFooters)
            {
                var headerRow = _report.GetNextRow();
                _report.AddCell(reportFooter, 0, headerRow, TextStyle.Header2);
            }

            // report logo
            // adding logo after all other operations, because it can be resized.
            _report.AddLogo(0, 0);
        }
示例#4
0
    public void ShootProjectile(Transform projectileLauncher, string weaponSlotType, string soundPath, bool isGun)
    {
        //if (isGun && (!entityVehicle.HasGun() || !entityVehicle.HasGunAmmo()))
        if (isGun && !entityVehicle.HasGunAmmo())
        {
            GameManager.ShowTooltip(entityVehicle.player, "No Vehicle Gun Ammo");
            return;
        }
        //if (!isGun && (!entityVehicle.HasExplosiveLauncher() || !entityVehicle.HasExplosiveLauncherAmmo()))
        if (!isGun && !entityVehicle.HasExplosiveLauncherAmmo())
        {
            GameManager.ShowTooltip(entityVehicle.player, "No Vehicle Explosive Ammo");
            return;
        }

        ItemValue ammoItem   = entityVehicle.GetWeaponAmmoType(weaponSlotType);
        ItemStack itemStack  = new ItemStack(ammoItem, 1);
        Transform projectile = ammoItem.ItemClass.CloneModel(GameManager.Instance.World, ammoItem, Vector3.zero, null, false, false);

        if (projectileLauncher != null)
        {
            projectile.parent        = projectileLauncher;
            projectile.localPosition = Vector3.zero;
            projectile.localRotation = Quaternion.identity;
        }
        else
        {
            projectile.parent = null;
        }

        ItemValue launcherValue;

        if (isGun)
        {
            launcherValue = entityVehicle.GetGunItemValue();
            //DebugMsg("Gun: Quality = " + launcherValue.Quality.ToString() + " | UseTimes = " + launcherValue.UseTimes.ToString() + " | MaxUseTimes = " + launcherValue.MaxUseTimes.ToString() + " | GetHealthPercentage = " + entityVehicle.gunPart.GetHealthPercentage().ToString());
            // Change weapons UseTimes (degrade weapon)
            launcherValue.UseTimes += AttributeBase.GetVal <AttributeDegradationRate>(launcherValue, 1);
            entityVehicle.gunPart.SetItemValue(launcherValue);
        }
        else
        {
            launcherValue = entityVehicle.GetExplosiveLauncherItemValue();
            //DebugMsg("Explosive Launcher: Quality = " + launcherValue.Quality.ToString() + " | UseTimes = " + launcherValue.UseTimes.ToString() + " | MaxUseTimes = " + launcherValue.MaxUseTimes.ToString() + " | GetHealthPercentage = " + entityVehicle.explosiveLauncherPart.GetHealthPercentage().ToString());
            // Change weapons UseTimes (degrade weapon)
            launcherValue.UseTimes += AttributeBase.GetVal <AttributeDegradationRate>(launcherValue, 1);
            entityVehicle.explosiveLauncherPart.SetItemValue(launcherValue);
        }

        Utils.SetLayerRecursively(projectile.gameObject, (!(projectileLauncher != null)) ? 0 : projectileLauncher.gameObject.layer);
        BlockProjectileMoveScript blockProjectileMoveScript = projectile.gameObject.AddComponent <BlockProjectileMoveScript>();

        blockProjectileMoveScript.itemProjectile      = ammoItem.ItemClass;
        blockProjectileMoveScript.itemValueProjectile = ammoItem;
        //blockProjectileMoveScript.itemValueLauncher = ItemValue.None.Clone();
        blockProjectileMoveScript.itemValueLauncher    = launcherValue;
        blockProjectileMoveScript.itemActionProjectile = (ItemActionProjectile)((!(ammoItem.ItemClass.Actions[0] is ItemActionProjectile)) ? ammoItem.ItemClass.Actions[1] : ammoItem.ItemClass.Actions[0]);
        //blockProjectileMoveScript.AttackerEntityId = 0;
        blockProjectileMoveScript.AttackerEntityId = entityVehicle.player.entityId;

        //Vector3 target = headlightTargetPos - projectileLauncher.position;
        Ray        ray       = Camera.main.ScreenPointToRay(Input.mousePosition);
        float      rayOffset = Vector3.Distance(entityVehicle.player.GetThirdPersonCameraTransform().position, projectileLauncher.position) + 2f;
        Vector3    rayStart  = ray.GetPoint(rayOffset);
        RaycastHit hit;

        if (Physics.Raycast(rayStart, ray.direction, out hit))
        {
            //Vector3 crossHairPos = ray.GetPoint(1000);// + (Vector3.up * 20);
            //Vector3 targetScreenPos = player.playerCamera.WorldToScreenPoint(crossHairPos);     //headlightTargetPos
            blockProjectileMoveScript.Fire(projectileLauncher.position, hit.point - projectileLauncher.position, entityVehicle.player, 0);
            //blockProjectileMoveScript.Fire(projectileLauncher.position, ray.direction, player, 0);
        }
        else
        {
            Vector3 rayEnd = ray.GetPoint(200f);
            blockProjectileMoveScript.Fire(projectileLauncher.position, rayEnd - projectileLauncher.position, entityVehicle.player, 0);
        }


        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        if (isGun)
        {
            ParticleEffect pe         = new ParticleEffect("nozzleflash_ak", projectileLauncher.position, Quaternion.Euler(0f, 180f, 0f), 1f, Color.white, "Pistol_Fire", projectileLauncher);
            float          lightValue = GameManager.Instance.World.GetLightBrightness(World.worldToBlockPos(projectileLauncher.position)) / 2f;
            ParticleEffect pe2        = new ParticleEffect("nozzlesmokeuzi", projectileLauncher.position, lightValue, new Color(1f, 1f, 1f, 0.3f), null, projectileLauncher, false);
            SpawnParticleEffect(pe, -1);
            SpawnParticleEffect(pe2, -1);
            //entityVehicle.playerInventory.RemoveItem(itemStack);
            uiforPlayer.xui.PlayerInventory.RemoveItem(itemStack);
            return;
        }

        //entityVehicle.playerInventory.RemoveItem(itemStack);
        uiforPlayer.xui.PlayerInventory.RemoveItem(itemStack);

        //if (Steam.Network.IsServer)
        {
            Audio.Manager.BroadcastPlay(projectileLauncher.position, soundPath);
        }
    }
示例#5
0
        private void CreateReport(string reportName, IEnumerable <Doc> docs, Doc docTemplate)
        {
            _report.AddEmptyRows(6);

            Row row = _report.GetNextRow();

            _report.AddCell(reportName, 0, row, TextStyle.Header1);
            _report.SetRowHeight(row, 22);

            if (docs == null)
            {
                return;
            }
            var enumerable = docs as Doc[] ?? docs.ToArray();

            if (!enumerable.Any())
            {
                return;
            }

            Row rowHeader   = _report.GetNextRow();
            int columnIndex = 0;

            foreach (AttributeBase attribute in docTemplate.Attributes)
            {
                AttributeBase attribute1 = attribute;

                _report.AddCell(attribute1.AttrDef.Name, columnIndex, rowHeader, TextStyle.TableHeaderGreyCenterdBorder);

                int colWidth = enumerable.SelectMany(d => d.Attributes)
                               .Where(a => a.AttrDef.Id == attribute1.AttrDef.Id && a.ObjectValue != null)
                               .Select(aa => aa.ObjectValue.ToString().Length).Max();

                _report.SetColumnWidth(columnIndex, colWidth);

                columnIndex++;
            }

            foreach (Doc doc in enumerable)
            {
                var tableRow = _report.GetNextRow();

                var colIndex = 0;
                foreach (var attr in docTemplate.Attributes)
                {
                    var attr1         = attr;
                    var findAttrQuery = (from a in doc.Attributes
                                         where a.AttrDef.Id == attr1.AttrDef.Id
                                         select a).ToList();

                    if (findAttrQuery.Any())
                    {
                        var findedAttr = findAttrQuery.First();
                        if (findedAttr is EnumAttribute)
                        {
                            var enumAttribute = findedAttr as EnumAttribute;
                            if (enumAttribute.Value.HasValue)
                            {
                                string enumValue = _enumRepository.GetEnumValue(enumAttribute.AttrDef.EnumDefType.Id,
                                                                                enumAttribute.Value.Value);
                                _report.AddCell(enumValue, colIndex, tableRow, TextStyle.NormalText);
                            }
                        }
                        else
                        {
                            _report.AddCell(findedAttr.ObjectValue, colIndex, tableRow, TextStyle.NormalText);
                        }
                    }
                    colIndex++;
                }
            }

            _report.AddLogo(0, 0);
        }
示例#6
0
	private static AttributeBase[] InitializeAttributes()
	{
		AttributeBase[] _tempCharAttribute = new AttributeBase[CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_COUNT];

		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Damage] = 
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Damage], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Damage,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};

		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Ammo] = 
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Ammo], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.Ammo,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};	

		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticChance] = 		
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticChance], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticChance,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};

		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticMultiplier] = 
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticMultiplier], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.CriticMultiplier,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};

		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.FireRate] = 
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.FireRate], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.FireRate,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};
		
		_tempCharAttribute[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.ReloadSpeed] = 
			new AttributeBase(){ 			
			Name = CONSTANTS.ATTRIBUTES.WEAPON_ATTRIBUTE_NAMES[(int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.ReloadSpeed], 
			AttributeType = (int)ENUMERATORS.Attribute.WeaponAttributeTypeEnum.ReloadSpeed,
			Max = 0,
			MaxModifiers = 0,
			Current = 0,
			CurrentModifiers = 0,
			DisplayOrder = 0,
			AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Weapon};

		return _tempCharAttribute;
	}
示例#7
0
        /// <summary>
        /// Allows Object Identification by moving the mouse over a node or edge.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Viewer_ObjectUnderMouseCursorChanged(object sender, ObjectUnderMouseCursorChangedEventArgs e)
        {
            //////viewer.ObjectUnderMouseCursor vs viewer.SelectedObject??
            if (viewer.SelectedObject != null && viewer.SelectedObject is DrawingNode)
            {
                viewer.Focus();
                //    // toolTip1.SetToolTip(viewer, (viewer.SelectedObject as Microsoft.Msagl.Drawing.Node).Id);
                //    viewer.SetToolTip(toolTip1, getTip(e.NewObject.DrawingObject.UserData));
                selectedNode = (viewer.SelectedObject as DrawingNode).Id;
                //    lblSelectedNode.Text = "Selected Node: " + selectedNode;
            }
            //else
            //{
            //    viewer.SetToolTip(toolTip1, "");
            //}
            selectedObject = e.OldObject != null ? e.OldObject.DrawingObject : null;
            //Clear Selected Object
            if (selectedObject != null && Form.ModifierKeys != Keys.Control)
            {
                RestoreSelectedObjAttr();
                viewer.Invalidate(e.OldObject);
                selectedObject = null;
            }

            if (viewer.ObjectUnderMouseCursor == null)
            {
                lblSelectedNode.Text = "Selected Object: ";
                viewer.SetToolTip(toolTip1, "");
                infoTip1.ClearData();
                RemoveHighlightedPath();
            }
            else
            {
                selectedObject = viewer.ObjectUnderMouseCursor.DrawingObject;


                if (selectedObject is DrawingEdge && Form.ModifierKeys != Keys.Control)
                {
                    DrawingEdge edge = selectedObject as DrawingEdge;
                    selectedObjectAttr = edge.Attr.Clone();
                    //edge.Attr.Color = DrawingColor.Blue;
                    edge.Attr.LineWidth += 3;
                    viewer.Invalidate(e.NewObject);
                    lblSelectedNode.Text = "Selected Edge: " + selectedObject.ToString();
                    //         here we can use e.Attr.Id or e.UserData to get back to the user data
                    // viewer.SetToolTip(toolTip1, String.Format("edge from {0} to {1}", edge.Source, edge.Target));
                }
                if (selectedObject is DrawingNode && Form.ModifierKeys != Keys.Control)
                {
                    DrawingNode node = selectedObject as DrawingNode;
                    selectedObjectAttr = node.Attr.Clone();

                    //node.Attr.Color = DrawingColor.Blue;
                    node.Attr.LineWidth += 4;
                    // //   here you can use e.Attr.Id to get back to your data
                    infoTip1.SetData(e.NewObject.DrawingObject.UserData);
                    //viewer.SetToolTip(toolTip1, getTip(e.NewObject.DrawingObject.UserData));

                    selectedNode         = (viewer.SelectedObject as DrawingNode).Id;
                    lblSelectedNode.Text = "Selected Node: " + selectedNode;
                    //viewer.SetToolTip(toolTip1,
                    //                   String.Format("node {0}",
                    //                                 (selectedObject as Microsoft.Msagl.Drawing.Node).Attr.Id));
                    viewer.Invalidate(e.NewObject);


                    RemoveHighlightedPath();             //Remove last path - Incase traveled by edge to this node.
                    HighlightFullPath(node, true, true); // Recursive
                    foreach (IViewerObject ee in viewer.Entities.Where(ee => ee is IViewerEdge))
                    {
                        viewer.Invalidate(ee);
                    }
                }
            }
        }
	public static void CleanAttributesModifiers(ref AttributeBase[] attributes_)
	{
		for(int i = 0; i < attributes_.Length; i++)
		{
			attributes_[i].CurrentModifiers = 0;
			attributes_[i].MaxModifiers = 0;
		}		
	}
示例#9
0
/*
 *
 *      /// <summary>
 *      ///
 *      /// </summary>
 *      /// <param name="attributeDefId"></param>
 *      /// <param name="docId">Идентификатор документа</param>
 *      /// <remarks>
 *      /// Если передать docId = Guid.Empty выдаст атрибуты без инициализации
 *      /// </remarks>
 *      /// <returns></returns>
 *      [Obsolete("Устаревший, неиспользуемый метод")]
 *      public AttributeBase GetAttributeById(Guid attributeDefId, Guid docId)
 *      {
 *          var en = DataContext.Entities;
 *          var attrDefQuery =
 *              en.Object_Defs.OfType<Attribute_Def>().Include("Document_Defs").Where(a => a.Id == attributeDefId);
 *          if (!attrDefQuery.Any())
 *          {
 *              return null;
 *          }
 *
 *          var dbAttrDef = attrDefQuery.First();
 *          var attrDef = new AttrDef
 *                            {
 *                                Id = dbAttrDef.Id,
 *                                Name = dbAttrDef.Name,
 *                                Type = new TypeDef
 *                                           {
 *                                               Id = dbAttrDef.Data_Types.Id,
 *                                               Name = dbAttrDef.Data_Types.Name
 *                                           }
 *                            };
 *
 *          switch ((CissaDataType) attrDef.Type.Id)
 *          {
 *              case CissaDataType.Int:
 *                  var intAttribute = new IntAttribute(attrDef);
 *                  var intQuery = en.Int_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (intQuery.Any())
 *                  {
 *                      var dbatr = intQuery.First();
 *                      intAttribute.Value = dbatr.Value;
 *                  }
 *                  return intAttribute;
 *
 *
 *              case CissaDataType.Float:
 *                  var floatAttribute = new FloatAttribute(attrDef);
 *                  var floatQuery =
 *                      en.Float_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (floatQuery.Any())
 *                  {
 *                      var dbatr = floatQuery.First();
 *                      floatAttribute.Value = dbatr.Value;
 *                  }
 *                  return floatAttribute;
 *
 *
 *              case CissaDataType.Currency:
 *                  var currencyAttribute = new CurrencyAttribute(attrDef);
 *                  var currencyQuery =
 *                      en.Currency_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (currencyQuery.Any())
 *                  {
 *                      var dbatr = currencyQuery.First();
 *                      currencyAttribute.Value = dbatr.Value;
 *                  }
 *                  return currencyAttribute;
 *
 *
 *              case CissaDataType.Text:
 *                  var txtAttribute = new TextAttribute(attrDef);
 *                  var txtQuery =
 *                      en.Text_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (txtQuery.Any())
 *                  {
 *                      var dbatr = txtQuery.First();
 *                      txtAttribute.Value = dbatr.Value;
 *                  }
 *                  return txtAttribute;
 *
 *              case CissaDataType.Bool:
 *                  var boolAttribute = new BoolAttribute(attrDef);
 *                  var boolQuery =
 *                      en.Boolean_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (boolQuery.Any())
 *                  {
 *                      var dbAttr = boolQuery.First();
 *                      boolAttribute.Value = dbAttr.Value;
 *                  }
 *                  return boolAttribute;
 *
 *
 *              case CissaDataType.Doc:
 *                  attrDef.DocDefType = new DocDef
 *                                           {
 *                                               Id = dbAttrDef.Document_Defs.Id,
 *                                               Name = dbAttrDef.Document_Defs.Name,
 *                                               Description = dbAttrDef.Document_Defs.Description,
 *                                               IsPublic = dbAttrDef.Document_Defs.Is_Public ?? false
 *                                           };
 *                  var docAttribute = new DocAttribute(attrDef);
 *                  var docQuery =
 *                      en.Document_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (docQuery.Any())
 *                  {
 *                      var dbatr = docQuery.First();
 *                      docAttribute.Value = dbatr.Value;
 *                  }
 *                  return docAttribute;
 *
 *              case CissaDataType.DocList:
 *                  attrDef.DocDefType = new DocDef
 *                                           {
 *                                               Id = dbAttrDef.Document_Defs.Id,
 *                                               Name = dbAttrDef.Document_Defs.Name,
 *                                               Description = dbAttrDef.Document_Defs.Description
 *                                           };
 *                  var doclistAttribute = new DocListAttribute(attrDef);
 *                  var doclistQuery =
 *                      en.DocumentList_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (doclistQuery.Any())
 *                  {
 *                      doclistAttribute.ItemsDocId = new List<Guid>();
 *                      foreach (DocumentList_Attribute item in doclistQuery)
 *                      {
 *                          doclistAttribute.ItemsDocId.Add(item.Value);
 *                      }
 *                  }
 *                  return doclistAttribute;
 *
 *              case CissaDataType.Enum:
 *                  using (var enumRepo = new EnumRepository(DataContext))
 *                  {
 *                      attrDef.EnumDefType = new EnumDef
 *                                            {
 *                                                Id = dbAttrDef.Enum_Defs.Id,
 *                                                Name = dbAttrDef.Enum_Defs.Name,
 *                                                Description = dbAttrDef.Enum_Defs.Description,
 *                                                EnumItems =
 *                                                    new List<EnumValue>(
 *                                                    enumRepo.GetEnumItems(dbAttrDef.Enum_Defs.Id))
 *                                            };
 *                  }
 *                  var enumAttribute = new EnumAttribute {AttrDef = attrDef};
 *                  var enumQuery =
 *                      en.Enum_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (enumQuery.Any())
 *                  {
 *                      var dbatr = enumQuery.First();
 *                      enumAttribute.Value = dbatr.Value;
 *                  }
 *                  return enumAttribute;
 *
 *              case CissaDataType.DateTime:
 *                  var dateAttribute = new DateTimeAttribute(attrDef);
 *                  var dateQuery =
 *                      en.Date_Time_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (dateQuery.Any())
 *                  {
 *                      var dbAttr = dateQuery.First();
 *                      dateAttribute.Value = dbAttr.Value;
 *                  }
 *                  return dateAttribute;
 *
 *              case CissaDataType.Organization:
 *                  var orgAttribute = new OrganizationAttribute(attrDef);
 *                  var orgQuery = en.Org_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (orgQuery.Any())
 *                  {
 *                      var dbatr = orgQuery.First();
 *                      orgAttribute.Value = dbatr.Value;
 *                  }
 *                  return orgAttribute;
 *
 *              case CissaDataType.DocumentState:
 *                  var docStateAttribute = new DocumentStateAttribute(attrDef);
 *                  var docStateQuery =
 *                      en.Doc_State_Attributes.Where(a => a.Document_Id == docId && a.Def_Id == attributeDefId);
 *                  if (docStateQuery.Any())
 *                  {
 *                      var dbatr = docStateQuery.First();
 *                      docStateAttribute.Value = dbatr.Value;
 *                  }
 *                  return docStateAttribute;
 *          }
 *          return null;
 *      }
 */

        public static bool SameAttributeValue(AttributeBase attr1, AttributeBase attr2)
        {
            if (attr1 == null)
            {
                throw new ArgumentNullException("attr1");
            }
            if (attr2 == null)
            {
                throw new ArgumentNullException("attr2");
            }

            var val1 = attr1.ObjectValue;
            var val2 = attr2.ObjectValue;

//            if (val1 == null || val2 == null) return false;
            if (attr1.AttrDef.Type.Id != attr2.AttrDef.Type.Id)
            {
                return(false);
            }

            if (attr1.AttrDef.Type.Id == (short)CissaDataType.DocList)
            {
                var dlAttr1 = (DocListAttribute)attr1;
                var dlAttr2 = (DocListAttribute)attr2;

                var list1 = dlAttr1.AddedDocIds != null ? new List <Guid>(dlAttr1.AddedDocIds) : new List <Guid>();
                var list2 = dlAttr2.AddedDocIds != null ? new List <Guid>(dlAttr2.AddedDocIds) : new List <Guid>();
                foreach (var id in list1)
                {
                    if (!list2.Contains(id))
                    {
                        return(false);
                    }
                    list2.Remove(id);
                }

                if (list2.Count > 0)
                {
                    return(false);
                }

                var list11 = dlAttr1.AddedDocs != null ? new List <Doc>(dlAttr1.AddedDocs) : new List <Doc>();
                var list22 = dlAttr2.AddedDocs != null ? new List <Doc>(dlAttr2.AddedDocs) : new List <Doc>();
                foreach (var doc in list11)
                {
                    var doc1 = doc;
                    var doc2 = list22.FirstOrDefault(d => d.Id == doc1.Id);
                    if (doc2 == null)
                    {
                        return(false);
                    }
                    list22.Remove(doc2);
                }

                if (list22.Count > 0)
                {
                    return(false);
                }

                return(true);
            }

            if (val1 == null && val2 == null)
            {
                return(true);
            }

            if (attr1.AttrDef.Type.Id == (short)CissaDataType.Text)
            {
                var txt1 = val1 != null?val1.ToString() : String.Empty;

                var txt2 = val2 != null?val2.ToString() : String.Empty;

                if (String.IsNullOrEmpty(txt1) && String.IsNullOrEmpty(txt2))
                {
                    return(true);
                }
                return(String.CompareOrdinal(txt1, txt2) == 0);
            }
            if (attr1.AttrDef.Type.Id == (short)CissaDataType.Blob)
            {
                var blobAttr1 = attr1 as BlobAttribute;
                var blobAttr2 = attr2 as BlobAttribute;

                if (blobAttr1 == null || blobAttr2 == null)
                {
                    return(false);
                }
                if (String.CompareOrdinal(blobAttr1.FileName, blobAttr2.FileName) != 0)
                {
                    return(false);
                }
                if (blobAttr1.HasValue != blobAttr2.HasValue)
                {
                    return(false);
                }
                if (blobAttr1.Value == null && blobAttr2.Value == null)
                {
                    return(true);
                }
                if (blobAttr1.Value != null && blobAttr2.Value != null)
                {
                    return(blobAttr1.Value.SequenceEqual(blobAttr2.Value));
                }
                return(false);
            }

            if (val1 == null || val2 == null)
            {
                return(false);
            }
            switch (attr1.AttrDef.Type.Id)
            {
            case (short)CissaDataType.Int:
                return(((int)val1) == ((int)val2));

            case (short)CissaDataType.Float:
                return(Math.Abs(((double)val1) - ((double)val2)) < 0.00000000001);

            case (short)CissaDataType.Currency:
                return(((decimal)val1) == ((decimal)val2));

            case (short)CissaDataType.DateTime:
                return(((DateTime)val1) == ((DateTime)val2));

            case (short)CissaDataType.Doc:
            case (short)CissaDataType.Enum:
            case (short)CissaDataType.Organization:
            case (short)CissaDataType.DocumentState:
                return(((Guid)val1) == ((Guid)val2));
            }
            return(false);
        }
示例#10
0
 Tuple <string, VoidDelegate>[] ChangeColorDialog(AttributeBase attr)
 {
     return(new[] { ColorChangeMenuTuple(attr) });
 }
示例#11
0
 public ControllerAttributeValidateFailedEventArgs(string controllerName, AttributeBase faildAttribte)
     : base(controllerName)
 {
     this._FailedAttribute = faildAttribte;
 }
示例#12
0
 public ActionAttributeValidateFailedEventArgs(
     string controllerName, string actionName, AttributeBase faildAttribute)
     : base(controllerName, actionName)
 {
     this._FailedAttribute = faildAttribute;
 }
        public static bool IsIntAttribute(this AttributeBase attributeBase)
        {
            ArgumentValidator.EnsureNotNull(nameof(attributeBase), attributeBase);

            return(attributeBase is IntAttribute);
        }
	public static void ApplyAttributesModifiers(ref AttributeBase[] attributes, ref AttributeModifier[] attributeModifiers_, Effects effects_)
	{
		int _attributeTypeIndex;

		for (int i = 0; i < attributeModifiers_.Length; i++)
		{
			if (attributeModifiers_[i] != null)
			{
				_attributeTypeIndex = (int)attributeModifiers_[i].AttributeType;

				switch(attributeModifiers_[i].CalcType)
				{
				case ENUMERATORS.Attribute.AttributeModifierCalcTypeEnum.Percent:

					switch(attributeModifiers_[i].ApplyTo)
					{
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Max:

						switch (attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].MaxModifiers += (attributes[_attributeTypeIndex].Max * attributeModifiers_[i].Value / 100);
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Max += (attributes[_attributeTypeIndex].Max * attributeModifiers_[i].Value / 100);

							break;
						}
						break;
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Current:

						switch (attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].CurrentModifiers += (attributes[_attributeTypeIndex].Current * attributeModifiers_[i].Value / 100);							
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Current += (attributes[_attributeTypeIndex].Current * attributeModifiers_[i].Value / 100);		// PERCENTUAL SEMPRE EM CIMA DO MAXIMO
							break;							
						}

						break;
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Both:

						switch (attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].MaxModifiers += (attributes[_attributeTypeIndex].Max * attributeModifiers_[i].Value / 100);
							attributes[_attributeTypeIndex].CurrentModifiers += (attributes[_attributeTypeIndex].Current * attributeModifiers_[i].Value / 100);
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Max += (attributes[_attributeTypeIndex].Max * attributeModifiers_[i].Value / 100);
							attributes[_attributeTypeIndex].Current += (attributes[_attributeTypeIndex].Max * attributeModifiers_[i].Value / 100);	// PERCENTUAL SEMPRE EM CIMA DO MAXIMO
							break;
						}
						break;
					}

					break;
				case ENUMERATORS.Attribute.AttributeModifierCalcTypeEnum.Value:

					switch(attributeModifiers_[i].ApplyTo)
					{
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Max:

						switch(attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].MaxModifiers += attributeModifiers_[i].Value;
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Max += attributeModifiers_[i].Value;
							break;
						}

						break;
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Current:

						switch(attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].CurrentModifiers += attributeModifiers_[i].Value;
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Current += attributeModifiers_[i].Value;
							break;
						}

						break;
					case ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Both:

						switch(attributeModifiers_[i].ApplyAs)
						{
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Temporary:
							attributes[_attributeTypeIndex].MaxModifiers += attributeModifiers_[i].Value;
							attributes[_attributeTypeIndex].CurrentModifiers += attributeModifiers_[i].Value;
							break;
						case ENUMERATORS.Attribute.AttributeModifierApplyAsEnum.Constant:
							attributes[_attributeTypeIndex].Max += attributeModifiers_[i].Value;
							attributes[_attributeTypeIndex].Current += attributeModifiers_[i].Value;							
							break;
						}

						break;
					}

					break;
				}

				// Marca o atributo como consumido
				attributeModifiers_[i].Consumed = true;

				// Aplica os valores maximos caso o modificador de atributo esteja configurado para nao exceder
				if (!attributeModifiers_[i].CanSetToCurrentExceedMax && 
					attributes[(int)attributeModifiers_[i].AttributeType].Current > attributes[(int)attributeModifiers_[i].AttributeType].Max)
				{
					attributes[(int)attributeModifiers_[i].AttributeType].Current = attributes[(int)attributeModifiers_[i].AttributeType].Max;
				}

				// Aplica os efeitos atrelados ao modificador
				ApplyEffect(effects_, attributeModifiers_[i]);
			}
		}
	}
 public static KeyValuePair <string, List <ProductValue> > CreateValues(this AttributeBase attribute, params ProductValue[] productValues)
 {
     return(new KeyValuePair <string, List <ProductValue> >(attribute.Code, productValues.ToList()));
 }
示例#16
0
    /// <summary>
    /// Metodo responsavel por inicializar a arvore de atributos
    /// </summary>
    private static AttributeBase[] InitializeAttributes()
    {
        AttributeBase[] _tempCharAttribute = new AttributeBase[CONSTANTS.ATTRIBUTES.CHARACTER_ATTRIBUTE_COUNT];

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Aggro] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Aggro],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Aggro,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Armor] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Armor],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Armor,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.HitPoint] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.HitPoint],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.HitPoint,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.EnergyPoint] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.EnergyPoint],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.EnergyPoint,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Speed] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Speed],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Speed,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        _tempCharAttribute[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Stamina] =
            new AttributeBase()
            {
                Name = CONSTANTS.ATTRIBUTES.CHARACTER_TYPE_NAMES[(int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Stamina],
                AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.Stamina,
                Max = 0,
                MaxModifiers = 0,
                Current = 0,
                CurrentModifiers = 0,
                DisplayOrder = 0,
                AttributeBaseType = ENUMERATORS.Attribute.AttributeBaseTypeEnum.Character
            };

        return _tempCharAttribute;
    }
示例#17
0
        public static StringAttribute AsStringAttribute(this AttributeBase attributeBase)
        {
            ArgumentValidator.EnsureNotNull(nameof(attributeBase), attributeBase);

            return((StringAttribute)attributeBase);
        }