public void CharacterSelected(IndexData indexData)
    {
        // check for invalid inputs
        if (indexData.IndexValue < 0 || indexData.IndexValue >= GameManager.numberOfCharacters)
        {
            Debug.LogWarning("index passed for characterselected is out of range");
            return;
        }

        battleSceneController.battleGUIManager.CharacterHasBeenSelected();

        gmInstance.SetSelectedCharacterByIndex(indexData.IndexValue);

        // Warning: order matters for player muts be started before enemy. Enemy requires a reference to the players stats_component

        // player setup
        battleSceneController.PlayerBegin();
        characterBlur.gameObject.SetActive(false);

        // enemy setup, prevents the enemy from refreshing if the player swap'd characters
        if (!enemyBeenSetup)
        {
            battleSceneController.EnemyBegin();
            enemyBlur.gameObject.SetActive(false);
            enemyBeenSetup = true;
        }


        // Close selection widnow
        CloseSelectionWindow();
    }
Exemplo n.º 2
0
        protected virtual void SetupVertices()
        {
            Texture    texture    = Style.Texture;
            VertexData vertexData = VertexData;
            IndexData  indexData  = IndexData;

            indexData.NumIndices = 0;
            indexData.AddQuad(0, 1, 2, 3);

            if (vertexData.NumVertices != 4)
            {
                vertexData.NumVertices = 4;
            }

            if (Texture != null)
            {
                texture.SetupVertexPositions(vertexData, 0, _bounds);
                texture.SetupTextureCoordinates(vertexData);
            }
            else
            {
                vertexData.SetPoint(0, _bounds.Left, _bounds.Top);
                vertexData.SetPoint(1, _bounds.Right, _bounds.Top);
                vertexData.SetPoint(2, _bounds.Left, _bounds.Bottom);
                vertexData.SetPoint(3, _bounds.Right, _bounds.Bottom);

                vertexData.SetTexCoords(0, 0.0f, 0.0f);
                vertexData.SetTexCoords(1, 1.0f, 0.0f);
                vertexData.SetTexCoords(2, 0.0f, 1.0f);
                vertexData.SetTexCoords(3, 1.0f, 1.0f);
            }

            SetRequiresRedraw();
        }
Exemplo n.º 3
0
        public BillboardChain(string name, int maxElements, int numberOfChains, bool useTextureCoords, bool useColors,
                              bool dynamic)
            : base(name)
        {
            this.maxElementsPerChain = maxElements;
            this.chainCount          = numberOfChains;
            this.useTexCoords        = useTextureCoords;
            this.useVertexColor      = useColors;
            this.dynamic             = dynamic;

            this.vertexDeclDirty       = true;
            this.buffersNeedRecreating = true;
            this.boundsDirty           = true;
            this.indexContentDirty     = true;
            this.radius            = 0.0f;
            this.texCoordDirection = TexCoordDirection.U;

            this.vertexData = new VertexData();
            this.indexData  = new IndexData();

            this.otherTexCoordRange[0] = 0.0f;
            this.otherTexCoordRange[1] = 1.0f;

            SetupChainContainers();

            this.vertexData.vertexStart = 0;
            // index data setup later
            // set basic white material
            MaterialName = "BaseWhiteNoLighting";
        }
Exemplo n.º 4
0
    public void HealCharacter(IndexData index)
    {
        if (!potionActive)
        {
            return;
        }

        switch (index.IndexValue)
        {
        case 0:
            assassinHealable = false;
            assassin.Heal();
            StartCoroutine(characterGuiSetup.assassinHealthBar.BeginHealing(assassin.Stats_Component.MaxHp));
            break;

        case 1:
            guardianHealable = false;
            guardian.Heal();
            StartCoroutine(characterGuiSetup.guardianHealthBar.BeginHealing(guardian.Stats_Component.MaxHp));
            break;

        case 2:
            wizardHealable = false;
            wizard.Heal();
            StartCoroutine(characterGuiSetup.wizardHealthBar.BeginHealing(wizard.Stats_Component.MaxHp));
            break;

        default:
            print("Backpack: Out of range value for potion characters");
            return;
        }

        DeactivateAll();
        UpdatePotion();
    }
Exemplo n.º 5
0
    public void EtherCharacter(IndexData index)
    {
        if (!etherActive)
        {
            return;
        }

        switch (index.IndexValue)
        {
        case 0:
            assassinEtherable = false;
            assassin.EtherUsed();
            characterGuiSetup.UpdateAbilities(assassin);
            break;

        case 1:
            guardianEtherable = false;
            guardian.EtherUsed();
            characterGuiSetup.UpdateAbilities(guardian);
            break;

        case 2:
            wizardEtherable = false;
            wizard.EtherUsed();
            characterGuiSetup.UpdateAbilities(wizard);
            break;

        default:
            print("Backpack: Out of range value for ether character");
            return;
        }

        DeactivateAll();
        UpdateEther();
    }
Exemplo n.º 6
0
            public static ObjectHeader Read(BinaryReader aReader, InfoHeader aInfo)
            {
                var objectSection = new ObjectHeader();

                objectSection.ReadBase(aReader);

                var address = aReader.ReadAddress(aInfo);

                objectSection.Flag = aReader.ReadUInt32();

                aReader.BaseStream.Position = address;

                objectSection.Position = aReader.ReadVector3();
                objectSection.Radius   = aReader.ReadSingle();

                UInt32 material_parts_count   = aReader.ReadUInt32();
                UInt32 material_parts_address = aReader.ReadAddress(aInfo);;
                UInt32 vertex_parts_count     = aReader.ReadUInt32();
                UInt32 vertex_parts_address   = aReader.ReadAddress(aInfo);;
                UInt32 index_parts_count      = aReader.ReadUInt32();
                UInt32 index_parts_address    = aReader.ReadAddress(aInfo);;
                UInt32 bone_parts_count       = aReader.ReadUInt32();
                UInt32 bone_set_address       = aReader.ReadAddress(aInfo);;
                UInt32 mesh_count             = aReader.ReadUInt32();
                UInt32 mesh_address           = aReader.ReadAddress(aInfo);

                objectSection.TextureCount = aReader.ReadUInt32();

                objectSection.IndexDatas = IndexData.Read(aReader, aInfo, index_parts_address, index_parts_count);

                objectSection.GoToEnd(aReader);
                return(objectSection);
            }
Exemplo n.º 7
0
        public Color RetrieveColor(IndexData indexData, IList <Color> palette)
        {
            var alphaIndexData = (AlphaIndexData)indexData;
            var color          = palette[alphaIndexData.Index];

            return(Color.FromArgb(alphaIndexData.Alpha, color.R, color.G, color.B));
        }
Exemplo n.º 8
0
        internal void AddObject(int IndexID, IIndex <T> index, Oid obj, QueryParameters queryParameters)
        {
            IndexData indexStorage = IndexStorageManager.IndexStorageManager <T> .GetIndexData(IndexID);

            try
            {
                DateTime  indexStart      = DateTime.Now;
                IndexData newIndexStorage = index.AddObject(indexStorage ?? index.EmptyIndexData, obj, queryParameters);
                IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID,
                                                                                 IndexCostInformation.OneObjectIndexAdd,
                                                                                 (float)
                                                                                 (DateTime.Now.Ticks - indexStart.Ticks) /
                                                                                 10000000);

                IndexStorageManager.IndexStorageManager <T> .UpdateIndexData(IndexID, newIndexStorage);
            }
            catch (Exception ex)
            {
                if (MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger() != null)
                {
                    MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger()
                    .Log("IndexMechanism", string.Format("Index {0} throwed exception\n{1}", index.GetType(), ex),
                         MessageLevel.Error);
                }
                throw ex;
            }
        }
Exemplo n.º 9
0
        public void TestColor()
        {
            VertexData vertexData = new VertexData();

            vertexData.NumVertices = 3;

            IndexData indexData = new IndexData();

            indexData.AddTriangle(0, 1, 2);

            Mesh mesh = new Mesh(vertexData, indexData);

            mesh.SetVertexColor(0, 0xff0000);
            mesh.SetVertexColor(1, 0x00ff00);
            mesh.SetVertexColor(2, 0x0000ff);

            Assert.AreEqual(0xff0000, mesh.GetVertexColor(0));
            Assert.AreEqual(0x00ff00, mesh.GetVertexColor(1));
            Assert.AreEqual(0x0000ff, mesh.GetVertexColor(2));

            mesh.Color = 0xf0f0f0;

            for (int i = 0; i < 3; ++i)
            {
                Assert.AreEqual(0xf0f0f0, mesh.GetVertexColor(i));
            }
        }
Exemplo n.º 10
0
        internal Guid[] FindObjects(int IndexID, IIndex <T> index, DynamicRole dynamicRole)
        {
            IndexData indexStorage = IndexStorageManager.IndexStorageManager <T> .GetIndexData(IndexID);

            try
            {
                DateTime indexStart = DateTime.Now;
                int?     operations;
                Guid[]   ret = index.FindObjects(indexStorage ?? index.EmptyIndexData, dynamicRole, out operations);
                IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID, IndexCostInformation.OneRoleSearch,
                                                                                 ((float)
                                                                                  (DateTime.Now.Ticks - indexStart.Ticks) /
                                                                                  10000000) / ret.Length == 0
                        ? 1
                        : ret.Length);

                if ((operations ?? 0) > 0)
                {
                    IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID, IndexCostInformation.HitRatio,
                                                                                     ret.Length / (float)operations);
                }
                return(ret);
            }
            catch (Exception ex)
            {
                if (MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger() != null)
                {
                    MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger()
                    .Log("IndexMechanism", string.Format("Index {0} throwed exception\n{1}", index.GetType(), ex),
                         MessageLevel.Error);
                }
                throw ex;
            }
        }
Exemplo n.º 11
0
        internal bool RebuildIndexWithRoles(int IndexID, IIndex <T> index, Dictionary <Oid, DynamicRole[]> objects)
        {
            IndexData indexStorage = IndexStorageManager.IndexStorageManager <T> .GetIndexData(IndexID);

            try
            {
                DateTime  indexStart      = DateTime.Now;
                IndexData newIndexStorage = index.rebuildIndex(indexStorage ?? index.EmptyIndexData, objects);
                IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID,
                                                                                 IndexCostInformation.OneObjectIndexRefresh,
                                                                                 ((float)
                                                                                  (DateTime.Now.Ticks - indexStart.Ticks) /
                                                                                  10000000) / objects.Keys.Count);

                IndexStorageManager.IndexStorageManager <T> .UpdateIndexData(IndexID, newIndexStorage);

                return(true);
            }
            catch (Exception ex)
            {
                if (MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger() != null)
                {
                    MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger()
                    .Log("IndexMechanism", string.Format("Index {0} throwed exception\n{1}", index.GetType(), ex),
                         MessageLevel.Error);
                }
                throw ex;
            }
        }
Exemplo n.º 12
0
        internal void RemoveDynamicRole(int IndexID, IIndex <T> index, Oid obj, DynamicRole role, String[] attributes)
        {
            IndexData indexStorage = IndexStorageManager.IndexStorageManager <T> .GetIndexData(IndexID);

            try
            {
                DateTime  indexStart      = DateTime.Now;
                IndexData newIndexStorage = index.RemoveDynamicRole(indexStorage ?? index.EmptyIndexData, obj, role,
                                                                    attributes);
                IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID,
                                                                                 IndexCostInformation.OneRoleIndexRemove,
                                                                                 (float)
                                                                                 (DateTime.Now.Ticks - indexStart.Ticks) /
                                                                                 10000000);

                IndexStorageManager.IndexStorageManager <T> .UpdateIndexData(IndexID, newIndexStorage);
            }
            catch (Exception ex)
            {
                if (MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger() != null)
                {
                    MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger()
                    .Log("IndexMechanism", string.Format("Index {0} throwed exception\n{1}", index.GetType(), ex),
                         MessageLevel.Error);
                }
                throw ex;
            }
        }
Exemplo n.º 13
0
        internal void AddDynamicRoles(int IndexID, IIndex <T> index, Oid[] obj, DynamicRole role)
        {
            IndexData indexStorage = IndexStorageManager.IndexStorageManager <T> .GetIndexData(IndexID);

            try
            {
                foreach (Oid oid in obj)
                {
                    DateTime indexStart = DateTime.Now;
                    indexStorage = index.AddDynamicRole(indexStorage ?? index.EmptyIndexData, oid, role);
                    IndexManager.IndexManager <T> .GetInstance().includeInStatistics(IndexID,
                                                                                     IndexCostInformation.OneRoleIndexing,
                                                                                     (float)
                                                                                     (DateTime.Now.Ticks - indexStart.Ticks) /
                                                                                     10000000);
                }
            }
            catch (Exception ex)
            {
                if (MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger() != null)
                {
                    MUTDOD.Server.Common.IndexMechanism.IndexMechanism <T> .GetLoger()
                    .Log("IndexMechanism", string.Format("Index {0} throwed exception\n{1}", index.GetType(), ex),
                         MessageLevel.Error);
                }
                throw ex;
            }
            IndexStorageManager.IndexStorageManager <T> .UpdateIndexData(IndexID, indexStorage);
        }
Exemplo n.º 14
0
        /// <exception cref="System.IO.IOException"></exception>
        protected internal Index(ByteBuffer tableBuffer, IList <IndexData> indexDatas, JetFormat
                                 format)
        {
            ByteUtil.Forward(tableBuffer, format.SKIP_BEFORE_INDEX_SLOT);
            //Forward past Unknown
            _indexNumber = tableBuffer.GetInt();
            int indexDataNumber = tableBuffer.GetInt();
            // read foreign key reference info
            byte relIndexType       = tableBuffer.Get();
            int  relIndexNumber     = tableBuffer.GetInt();
            int  relTablePageNumber = tableBuffer.GetInt();
            byte cascadeUpdatesFlag = tableBuffer.Get();
            byte cascadeDeletesFlag = tableBuffer.Get();

            _indexType = tableBuffer.Get();
            if ((_indexType == FOREIGN_KEY_INDEX_TYPE) && (relIndexNumber != INVALID_INDEX_NUMBER
                                                           ))
            {
                _reference = new Index.ForeignKeyReference(relIndexType, relIndexNumber, relTablePageNumber
                                                           , (cascadeUpdatesFlag == CASCADE_UPDATES_FLAG), (cascadeDeletesFlag == CASCADE_DELETES_FLAG
                                                                                                            ));
            }
            else
            {
                _reference = null;
            }
            ByteUtil.Forward(tableBuffer, format.SKIP_AFTER_INDEX_SLOT);
            //Skip past Unknown
            _data = indexDatas[indexDataNumber];
            _data.AddIndex(this);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Add field values into the index data
 /// </summary>
 /// <param name="values">Values to add</param>
 /// <param name="encoded">set to true if values are already XML encoded (for example RTF content)</param>
 /// <param name="targetField">Configuration for the target (search index) field</param>
 public virtual void AddToData(IList <string> values, bool encoded, IndexField targetField = null)
 {
     foreach (var value in values)
     {
         bool processed = false;
         //Title is a special case
         if (targetField != null && targetField.Name == "title")
         {
             if (String.IsNullOrEmpty(this.Title))
             {
                 this.Title = value;
                 processed  = true;
             }
         }
         else if (targetField != null && (targetField.IsMultiValue || IndexData.SelectSingleNode("/*/*[local-name()='custom']/*[local-name()='" + targetField.Name + "']") == null))
         {
             SetCustomFieldValue(targetField.Name, value, encoded);
             processed = true;
         }
         if (!processed)
         {
             IndexData.SelectSingleNode("*/*[local-name()='body']").AppendChild(CreateElement(null, encoded, value));
         }
     }
 }
Exemplo n.º 16
0
        MeshPtr CreateMesh(string Name, string Group, IndexData IndexDataArg, VertexData VertexDataArg, AxisAlignedBox BoundingBox)
        {
            Mogre.MeshPtr mMesh   = Mogre.MeshManager.Singleton.CreateManual(Name, Group);
            SubMesh       SubMesh = mMesh.CreateSubMesh();

            //Shallow copy the IndexBuffer argument into the SubMesh's indexData property
            SubMesh.indexData.indexBuffer = IndexDataArg.indexBuffer;
            SubMesh.indexData.indexCount  = IndexDataArg.indexCount;

            //Deep copy the VertexData argument into the Mesh's sharedVertexData
            SubMesh.useSharedVertices = true;
            mMesh.sharedVertexData    = new VertexData();
            mMesh.sharedVertexData.vertexBufferBinding.SetBinding(0, VertexDataArg.vertexBufferBinding.GetBuffer(0));
            VertexDeclaration vdc = new VertexDeclaration();

            VertexDataArg.vertexDeclaration.CopyTo(vdc);
            mMesh.sharedVertexData.vertexDeclaration = vdc;
            mMesh.sharedVertexData.vertexCount       = VertexDataArg.vertexCount;

            mMesh._setBounds(BoundingBox);

            mMesh.Load();

            return(mMesh);
        }
Exemplo n.º 17
0
                private static IndexData Read(BinaryReader aReader, InfoHeader aInfo, IndexEntry aEntry)
                {
                    var indexData = new IndexData();

                    aReader.BaseStream.Position = aEntry.Address;

                    var indexCount   = aReader.ReadUInt32();
                    var morphCount   = aReader.ReadUInt32();
                    var morphAddress = aReader.ReadAddress(aInfo);
                    var indexAddress = aReader.ReadAddress(aInfo);


                    // Then comes an array of morphCount StripSizes at morphAddress
                    aReader.BaseStream.Position = morphAddress;

                    foreach (var index in Enumerable.Range(0, (int)morphCount))
                    {
                        indexData.StripSizes.Add(aReader.ReadUInt16());
                    }

                    foreach (var stripSize in indexData.StripSizes)
                    {
                    }

                    return(indexData);
                }
Exemplo n.º 18
0
        private void CreateBuffers(ushort[] indices, short[] vertices)
        {
            var numIndices  = (uint)indices.Length;
            var numVertices = (uint)vertices.Length;

            _vertexDeclaration = HardwareBufferManager.Singleton.CreateVertexDeclaration();
            _vertexDeclaration.AddElement(0, 0, VertexElementType.VET_SHORT2, VertexElementSemantic.VES_POSITION);
            _ib = HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT, numIndices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            _vb = HardwareBufferManager.Singleton.CreateVertexBuffer(_vertexDeclaration.GetVertexSize(0), numVertices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY, false);

            unsafe
            {
                fixed(ushort *x = indices)
                _ib.WriteData(0, numIndices * sizeof(ushort), x, true);

                fixed(short *x = vertices)
                _vb.WriteData(0, numVertices * sizeof(ushort), x, true);
            }

            var binding = new VertexBufferBinding();

            binding.SetBinding(0, _vb);

            VertexData             = new VertexData(_vertexDeclaration, binding);
            VertexData.vertexCount = numVertices;
            VertexData.vertexStart = 0;

            IndexData             = new IndexData();
            IndexData.indexBuffer = _ib;
            IndexData.indexCount  = numIndices;
            IndexData.indexStart  = 0;
        }
Exemplo n.º 19
0
        public IndexData RemoveObject(IndexData indexData, Oid obj, string[] attributes, QueryParameters queryParameters)
        {
            IntBinaryTree BT = getStorageData(indexData);

            FieldInfo[] objFields = obj.GetType().GetFields();

            foreach (String attribute in attributes)
            {
                if (objFields.Count(p => p.Name == attribute) != 1)
                {
                    throw new WrongAttributeException <Type>(obj.GetType(), attribute,
                                                             "Nie odnaleziono podanego atrybutu w wskazanym obiekcie");
                }
                //else if (objFields.Single(p => p.Name == attribute).GetType() != typeof(int))
                //    throw new WrongTypeToIndexException(objFields.Single(p => p.Name == attribute).GetType(), string.Format("Unnsupported type of attribiute {0}", attribute));
            }

            foreach (String attribute in attributes)
            {
                if (objFields.Single(p => p.Name == attribute).GetType() == typeof(int))
                {
                    int attributeValue = (int)objFields.Where(p => p.Name == attribute).Single().GetValue(obj);
                    BT.RemoveFromBTvalue(obj, attribute, attributeValue);
                }
            }

            return(BT);
        }
Exemplo n.º 20
0
        internal IndexData GetIndexData(IIndexable indexable, IProviderUpdateContext context)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            Assert.ArgumentNotNull(context, "context");
            Assert.Required((index.Configuration.DocumentOptions as AzureDocumentBuilderOptions), "IDocumentBuilderOptions of wrong type for this crawler");
            AzureDocumentBuilder documentBuilder = (AzureDocumentBuilder)ReflectionUtil.CreateObject(context.Index.Configuration.DocumentBuilderType, new object[2]
            {
                indexable,
                context
            });

            if (documentBuilder == null)
            {
                CrawlingLog.Log.Error("Unable to create document builder (" + context.Index.Configuration.DocumentBuilderType + "). Please check your configuration. We will fallback to the default for now.", (Exception)null);
                documentBuilder = new AzureDocumentBuilder(indexable, context);
            }
            documentBuilder.AddSpecialFields();
            documentBuilder.AddItemFields();
            documentBuilder.AddComputedIndexFields();
            documentBuilder.AddBoost();
            var indexData = new IndexData(index, indexable, documentBuilder);

            index.AzureSchema.AddAzureIndexFields(indexData.Fields.Where(f => f.Name != indexData.UpdateTerm.Name).ToList());
            index.AzureSchema.BuildAzureIndexSchema(indexData.UpdateTerm, indexData.FullUpdateTerm);
            return(indexData);
        }
Exemplo n.º 21
0
        public KeyInfo NewKey(string key, IndexData data)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            CheckDisposed();

            var keyBuffer = Encoding.UTF8.GetBytes(key);
            var newKey    = new KeyInfo {
                Offset = _cursor, Size = keyBuffer.Length
            };

            newKey.SetKey(key);
            var newKeySize = Sizes.IndexDataSize + keyBuffer.Length;

            EnsureCapacity(_cursor, newKeySize);
            using (var writer = _indexFile.CreateViewStream(_cursor, newKeySize, MemoryMappedFileAccess.Write)) {
                writer.Write(keyBuffer, 0, keyBuffer.Length);
                // Write index data after key
                WriteIndexData(writer, data);
            }
            _cursor += newKeySize;

            return(newKey);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Add custom field values to the index data XML
 /// </summary>
 /// <param name="fieldName">Custom field name</param>
 /// <param name="values">values to add</param>
 /// <param name="encoded">set to true if values are already XML encoded (for example RTF content)</param>
 public virtual void SetCustomFieldValues(string fieldName, List <object> values, bool encoded = false)
 {
     foreach (var val in values)
     {
         IndexData.SelectSingleNode("/*/*[local-name()='custom']").AppendChild(CreateElement(fieldName, encoded, val.ToString()));
     }
 }
Exemplo n.º 23
0
        public IndexData AddObject(IndexData indexData, Oid obj, string[] attributes)
        {
            ListData <int> ld = getStorageData(indexData);

            FieldInfo[] objFields = obj.GetType().GetFields();

            foreach (String attribute in attributes)
            {
                if (objFields.Count(p => p.Name == attribute) != 1)
                {
                    throw new WrongAttributeException(obj.GetType(), attribute,
                                                      "Nie odnaleziono podanego atrybutu w wskazanym obiekcie");
                }
                else if (objFields.Single(p => p.Name == attribute).GetValue(obj).GetType() != typeof(int))
                {
                    throw new WrongTypeToIndexException(objFields.Single(p => p.Name == attribute).GetType(),
                                                        string.Format("Unnsupported type of attribiute {0}", attribute));
                }
            }

            foreach (String attribute in attributes)
            {
                int attributeValue = (int)objFields.Where(p => p.Name == attribute).Single().GetValue(obj);
                ld.Data.Add(new storeItem <int>
                {
                    val = attributeValue, attribiute = attribute, type = obj.GetType(), ID = obj.Id
                });
            }

            return(ld);
        }
Exemplo n.º 24
0
        public WarningCellData(IndexData matchIndex, string message)
        {
            MatchIndexes = new List <IndexData>();
            MatchIndexes.Add(matchIndex);

            Message = message;
        }
Exemplo n.º 25
0
        public Guid[] FindObjects(IndexData indexData, Type OIDClass, bool complexExtension, out int?readedObjects)
        {
            int ro;
            StringBinaryTree BT  = getStorageData(indexData);
            List <Guid>      ret = BT.GetObjectsFromBT(OIDClass, out ro);

            readedObjects = ro;

            if (complexExtension)
            {
                foreach (Type t in BT.GetObjectsTypesFromBT().Where(t => t != OIDClass))
                {
                    bool found    = false;
                    Type baseType = t.BaseType;
                    while (baseType != null && !found)
                    {
                        if (baseType == OIDClass)
                        {
                            ret.AddRange(BT.GetObjectsFromBT(OIDClass, out ro));
                            readedObjects += ro;
                            found          = true;
                        }
                        baseType = baseType.BaseType;
                    }
                }
            }

            return(ret.Distinct().ToArray());
        }
Exemplo n.º 26
0
        public Guid[] FindObjects(IndexData indexData, Type OIDClass, bool complexExtension, out int?readedObjects)
        {
            List <Guid>    ret;
            ListData <int> ld = getStorageData(indexData);

            ret           = ld.Data.Where(p => p.type == OIDClass).Select(p => p.ID).Distinct().ToList();
            readedObjects = ret.Count();

            if (complexExtension)
            {
                foreach (Type t in ld.Data.Where(p => p.type != OIDClass).Select(p => p.type).Distinct())
                {
                    bool found    = false;
                    Type baseType = t.BaseType;
                    while (baseType != null && !found)
                    {
                        if (baseType == OIDClass)
                        {
                            List <Guid> r = ld.Data.Where(p => p.type == baseType).Select(p => p.ID).Distinct().ToList();
                            readedObjects += r.Count;
                            ret.AddRange(r);
                            found = true;
                        }
                        baseType = baseType.BaseType;
                    }
                }
            }


            return(ret.Distinct().ToArray());
        }
Exemplo n.º 27
0
        public IndexData AddObject(IndexData indexData, Oid obj, string[] attributes)
        {
            StringBinaryTree BT = getStorageData(indexData);

            FieldInfo[] objFields = obj.GetType().GetFields();

            foreach (String attribute in attributes)
            {
                if (objFields.Count(p => p.Name == attribute) != 1)
                {
                    throw new WrongAttributeException(obj.GetType(), attribute,
                                                      "Nie odnaleziono podanego atrybutu w wskazanym obiekcie");
                }
                else if (objFields.Single(p => p.Name == attribute).GetValue(obj).GetType() != typeof(string))
                {
                    throw new WrongTypeToIndexException(objFields.Single(p => p.Name == attribute).GetType(),
                                                        string.Format("Unnsupported type of attribiute {0}", attribute));
                }
            }

            foreach (String attribute in attributes)
            {
                string attributeValue = objFields.Where(p => p.Name == attribute).Single().GetValue(obj).ToString();
                BT.AddToBTvalue(obj, attribute, attributeValue);
            }

            return(BT);
        }
Exemplo n.º 28
0
        private unsafe int ReadIndexData(int indexOffset, uint vertexOffset, IndexData indexData)
        {
            // get index data
            HardwareIndexBufferSharedPtr indexBuf = indexData.indexBuffer;

            HardwareIndexBuffer.IndexType indexType = indexBuf.Type;
            uint *  pLong  = (uint *)(indexBuf.Lock(HardwareBuffer.LockOptions.HBL_READ_ONLY));
            ushort *pShort = (ushort *)pLong;

            for (uint i = 0; i < indexData.indexCount; i++)
            {
                if (indexType == HardwareIndexBuffer.IndexType.IT_32BIT)
                {
                    _indices[indexOffset] = pLong[i] + vertexOffset;
                }
                else
                {
                    _indices[indexOffset] = pShort[i] + vertexOffset;
                }

                indexOffset++;
            }

            indexBuf.Unlock();
            // SGD :2013/6/8 13:42:42
            // 说明:销毁指针引用  防止.NET回收
            indexBuf.Dispose();
            return(indexOffset);
        }
Exemplo n.º 29
0
        public void Add_Duplicate_Test()
        {
            var key  = Guid.NewGuid().ToString();
            var data = new IndexData {
                Offset  = 1,
                Size    = 2,
                Md5Hash = Guid.NewGuid().ToByteArray()
            };

            var newData = new IndexData {
                Offset  = 3,
                Size    = 4,
                Md5Hash = Guid.NewGuid().ToByteArray()
            };

            using (var target = Create()) {
                target.Add(key, data);
            }

            using (var target = Create()) {
                try {
                    target.Add(key, newData);

                    Assert.Fail("Exception expected");
                }
                catch (DuplicateException) {
                }
            }

            using (var target = Create()) {
                var actual = target.Get(key);
                TestHelper.AreEqual(data, actual);
            }
        }
Exemplo n.º 30
0
        public void Get_Unknown_Test()
        {
            var key  = Guid.NewGuid().ToString();
            var data = new IndexData {
                Offset  = 1,
                Size    = 2,
                Md5Hash = Guid.NewGuid().ToByteArray()
            };

            using (var target = Create()) {
                target.Add(key, data);

                try {
                    target.Get(Guid.NewGuid().ToString());

                    Assert.Fail("Expected exception");
                }
                catch (KeyNotFoundException e) {
                    Console.WriteLine(e);
                }
            }

            using (var target = Create()) {
                try {
                    target.Get(Guid.NewGuid().ToString());

                    Assert.Fail("Expected exception");
                }
                catch (KeyNotFoundException e) {
                    Console.WriteLine(e);
                }
            }
        }
Exemplo n.º 31
0
        void CreateDecal()
        {
            Bounds bounds = Bounds.Cleared;
            foreach( Vertex vertex in vertices )
                bounds.Add( vertex.position );

            VertexData vertexData = new VertexData();
            IndexData indexData = new IndexData();

            //init vertexData
            VertexDeclaration declaration = vertexData.VertexDeclaration;
            declaration.AddElement( 0, 0, VertexElementType.Float3, VertexElementSemantic.Position );
            declaration.AddElement( 0, 12, VertexElementType.Float3, VertexElementSemantic.Normal );
            declaration.AddElement( 0, 24, VertexElementType.Float2,
                VertexElementSemantic.TextureCoordinates, 0 );
            declaration.AddElement( 0, 32, VertexElementType.Float3, VertexElementSemantic.Tangent );

            VertexBufferBinding bufferBinding = vertexData.VertexBufferBinding;
            HardwareVertexBuffer vertexBuffer = HardwareBufferManager.Instance.CreateVertexBuffer(
                44, vertices.Length, HardwareBuffer.Usage.StaticWriteOnly );
            bufferBinding.SetBinding( 0, vertexBuffer, true );
            vertexData.VertexCount = vertices.Length;

            //init indexData
            Trace.Assert( vertices.Length < 65536, "Decal: vertices.Length < 65536" );

            HardwareIndexBuffer indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer(
                HardwareIndexBuffer.IndexType._16Bit, indices.Length,
                HardwareBuffer.Usage.StaticWriteOnly );
            indexData.SetIndexBuffer( indexBuffer, true );
            indexData.IndexCount = indices.Length;

            //init material
            Material material = null;

            shaderBaseMaterial = HighLevelMaterialManager.Instance.
                GetMaterialByName( sourceMaterialName ) as ShaderBaseMaterial;
            //only default shader technique for ShaderBase material
            if( shaderBaseMaterial != null && !shaderBaseMaterial.IsDefaultTechniqueCreated() )
                shaderBaseMaterial = null;

            if( shaderBaseMaterial != null )
            {
                //ShaderBase material
                material = shaderBaseMaterial.BaseMaterial;
            }
            else
            {
                //standard material or fallback ShaderBase technique
                Material sourceMaterial = MaterialManager.Instance.GetByName( sourceMaterialName );
                if( sourceMaterial != null )
                {
                    //clone standard material
                    clonedStandardMaterial = MaterialManager.Instance.Clone( sourceMaterial,
                        MaterialManager.Instance.GetUniqueName( sourceMaterialName + "_Cloned" ) );
                    material = clonedStandardMaterial;
                }
            }

            staticMeshObject = SceneManager.Instance.CreateStaticMeshObject( bounds + Position,
                Position, Quat.Identity, new Vec3( 1, 1, 1 ), material, vertexData, indexData, true );
            staticMeshObject.AddToRenderQueue += StaticMeshObject_AddToRenderQueue;

            UpdateBuffers();
        }
Exemplo n.º 32
0
            private unsafe int ReadIndexData(int indexOffset, uint vertexOffset, IndexData indexData)
            {
                // get index data
                HardwareIndexBufferSharedPtr indexBuf = indexData.indexBuffer;
                HardwareIndexBuffer.IndexType indexType = indexBuf.Type;
                uint* pLong = (uint*)(indexBuf.Lock(HardwareBuffer.LockOptions.HBL_READ_ONLY));
                ushort* pShort = (ushort*)pLong;

                for (uint i = 0; i < indexData.indexCount; i++)
                {
                    if (indexType == HardwareIndexBuffer.IndexType.IT_32BIT)
                        indices[indexOffset] = pLong[i] + vertexOffset;
                    else
                        indices[indexOffset] = pShort[i] + vertexOffset;

                    indexOffset++;
                }

                indexBuf.Unlock();
                return indexOffset;
            }
Exemplo n.º 33
0
        private void CreateBuffers(ushort[] indices, short[] vertices)
        {
            var numIndices = (uint)indices.Length;
            var numVertices = (uint)vertices.Length;

            _vertexDeclaration = HardwareBufferManager.Singleton.CreateVertexDeclaration();
            _vertexDeclaration.AddElement(0, 0, VertexElementType.VET_SHORT2, VertexElementSemantic.VES_POSITION);
            _ib = HardwareBufferManager.Singleton.CreateIndexBuffer(HardwareIndexBuffer.IndexType.IT_16BIT, numIndices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY);
            _vb = HardwareBufferManager.Singleton.CreateVertexBuffer(_vertexDeclaration.GetVertexSize(0), numVertices, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY, false);

            unsafe
            {
                fixed (ushort* x = indices)
                    _ib.WriteData(0, numIndices * sizeof(ushort), x, true);

                fixed (short* x = vertices)
                    _vb.WriteData(0, numVertices * sizeof(ushort), x, true);
            }

            var binding = new VertexBufferBinding();
            binding.SetBinding(0, _vb);

            VertexData = new VertexData(_vertexDeclaration, binding);
            VertexData.vertexCount = numVertices;
            VertexData.vertexStart = 0;

            IndexData = new IndexData();
            IndexData.indexBuffer = _ib;
            IndexData.indexCount = numIndices;
            IndexData.indexStart = 0;
        }