Пример #1
0
		public override void InitializeGUI()
		{
			title.text = GetName().SplitCamelCase();
			button.onClick.AddListener( OnClick );

			enumNames = System.Enum.GetNames(declaringType);
			enumValues = System.Enum.GetValues(declaringType);
		}
Пример #2
0
    private void OnEnable()
    {
      valuePalletes = System.Enum.GetValues(typeof(SpriteColorRampPalettes));
      currentPallete = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);

      textureRamp = Resources.Load<Texture2D>("Textures/SpriteColorRamps");

      texturePallete = new Texture2D[5];

      InstantiateFigure(Random.Range(0, figures.Count));

      for (int i = 0; i < 5; ++i)
        texturePallete[i] = MakeTexture(32, 16, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPallete));
    }
Пример #3
0
    private void OnEnable()
    {
      currentPalletes = new SpriteColorRampPalettes[3];

      valuePalletes = System.Enum.GetValues(typeof(SpriteColorRampPalettes));
      currentPalletes[0] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);
      currentPalletes[1] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);
      currentPalletes[2] = (SpriteColorRampPalettes)Random.Range(0, valuePalletes.Length);

      spriteColorMaskFX = gameObject.GetComponent<SpriteColorRampMask>();

      textureRamp = Resources.Load<Texture2D>("Textures/SpriteColorRamps");

      texturePalletes = new Texture2D[3, 5];
      for (int i = 0; i < 5; ++i)
        for (int j = 0; j < 3; ++j)
          texturePalletes[j, i] = MakeTexture(14, 14, textureRamp.GetPixel((textureRamp.width / 5) * (i + 1), (int)currentPalletes[j]));
    }
Пример #4
0
        public void System_Blockchain_GetBlock()
        {
            var tx = new Transaction()
            {
                Script          = new byte[] { 0x01 },
                Attributes      = Array.Empty <TransactionAttribute>(),
                Signers         = Array.Empty <Signer>(),
                NetworkFee      = 0x02,
                SystemFee       = 0x03,
                Nonce           = 0x04,
                ValidUntilBlock = 0x05,
                Version         = 0x06,
                Witnesses       = new Witness[] { new Witness()
                                                  {
                                                      VerificationScript = new byte[] { 0x07 }
                                                  } },
            };

            var block = new TrimmedBlock()
            {
                Header = new Header
                {
                    Index     = 0,
                    Timestamp = 2,
                    Witness   = new Witness()
                    {
                        InvocationScript   = Array.Empty <byte>(),
                        VerificationScript = Array.Empty <byte>()
                    },
                    PrevHash      = UInt256.Zero,
                    MerkleRoot    = UInt256.Zero,
                    PrimaryIndex  = 1,
                    NextConsensus = UInt160.Zero,
                },
                Hashes = new[] { tx.Hash }
            };

            var snapshot = TestBlockchain.GetTestSnapshot();

            using ScriptBuilder script = new();
            script.EmitDynamicCall(NativeContract.Ledger.Hash, "getBlock", block.Hash.ToArray());

            // Without block

            var engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot, settings: TestBlockchain.TheNeoSystem.Settings);

            engine.LoadScript(script.ToArray());

            Assert.AreEqual(engine.Execute(), VMState.HALT);
            Assert.AreEqual(1, engine.ResultStack.Count);
            Assert.IsTrue(engine.ResultStack.Peek().IsNull);

            // Not traceable block

            const byte Prefix_Transaction  = 11;
            const byte Prefix_CurrentBlock = 12;

            var height = snapshot[NativeContract.Ledger.CreateStorageKey(Prefix_CurrentBlock)].GetInteroperable <HashIndexState>();

            height.Index = block.Index + ProtocolSettings.Default.MaxTraceableBlocks;

            UT_SmartContractHelper.BlocksAdd(snapshot, block.Hash, block);
            snapshot.Add(NativeContract.Ledger.CreateStorageKey(Prefix_Transaction, tx.Hash), new StorageItem(new TransactionState
            {
                BlockIndex  = block.Index,
                Transaction = tx
            }));

            engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot, settings: TestBlockchain.TheNeoSystem.Settings);
            engine.LoadScript(script.ToArray());

            Assert.AreEqual(engine.Execute(), VMState.HALT);
            Assert.AreEqual(1, engine.ResultStack.Count);
            Assert.IsTrue(engine.ResultStack.Peek().IsNull);

            // With block

            height.Index = block.Index;

            engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot, settings: TestBlockchain.TheNeoSystem.Settings);
            engine.LoadScript(script.ToArray());

            Assert.AreEqual(engine.Execute(), VMState.HALT);
            Assert.AreEqual(1, engine.ResultStack.Count);

            var array = engine.ResultStack.Pop <VM.Types.Array>();

            Assert.AreEqual(block.Hash, new UInt256(array[0].GetSpan()));
        }
Пример #5
0
 public void CopyTo(System.Array array, int index)
 {
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) return;

            property.isExpanded = EditorGUI.Foldout(new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight), property.isExpanded, GUIContent.none);

            if (property.isExpanded)
            {
                _keys = GetKeys(property);
                if (_keys == null)
                {
                    EditorGUI.LabelField(position, "Failed to determine enum key type.");
                    return;
                }

                var valuesProp = property.FindPropertyRelative(PROP_VALUES);
                if (valuesProp.arraySize != _keys.Length) valuesProp.arraySize = _keys.Length;

                this.BeginProperty(property, label);
                _lst.DoList(position);
                this.EndProperty();
            }
            else
            {
                ReorderableListHelper.DrawRetractedHeader(position, label);
            }
        }
Пример #7
0
        public void StockShopShelf(PlayerGPS.DiscoveredBuilding buildingData)
        {
            stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now);
            items.Clear();

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;
            int shopQuality = buildingData.quality;

            Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
            byte[] itemGroups = { 0 };

            switch (buildingType)
            {
            case DFLocation.BuildingTypes.Alchemist:
                itemGroups = DaggerfallLootDataTables.itemGroupsAlchemist;
                RandomlyAddPotionRecipe(25, items);
                break;

            case DFLocation.BuildingTypes.Armorer:
                itemGroups = DaggerfallLootDataTables.itemGroupsArmorer;
                break;

            case DFLocation.BuildingTypes.Bookseller:
                itemGroups = DaggerfallLootDataTables.itemGroupsBookseller;
                break;

            case DFLocation.BuildingTypes.ClothingStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsClothingStore;
                break;

            case DFLocation.BuildingTypes.GemStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGemStore;
                break;

            case DFLocation.BuildingTypes.GeneralStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGeneralStore;
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Horse));
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart));
                break;

            case DFLocation.BuildingTypes.PawnShop:
                itemGroups = DaggerfallLootDataTables.itemGroupsPawnShop;
                break;

            case DFLocation.BuildingTypes.WeaponSmith:
                itemGroups = DaggerfallLootDataTables.itemGroupsWeaponSmith;
                break;
            }

            for (int i = 0; i < itemGroups.Length; i += 2)
            {
                ItemGroups itemGroup = (ItemGroups)itemGroups[i];
                int        chanceMod = itemGroups[i + 1];
                if (itemGroup == ItemGroups.MensClothing && playerEntity.Gender == Game.Entity.Genders.Female)
                {
                    itemGroup = ItemGroups.WomensClothing;
                }
                if (itemGroup == ItemGroups.WomensClothing && playerEntity.Gender == Game.Entity.Genders.Male)
                {
                    itemGroup = ItemGroups.MensClothing;
                }

                if (itemGroup != ItemGroups.Furniture && itemGroup != ItemGroups.UselessItems1)
                {
                    if (itemGroup == ItemGroups.Books)
                    {
                        int qualityMod = (shopQuality + 3) / 5;
                        if (qualityMod >= 4)
                        {
                            --qualityMod;
                        }
                        qualityMod++;
                        for (int j = 0; j <= qualityMod; ++j)
                        {
                            items.AddItem(ItemBuilder.CreateRandomBook());
                        }
                    }
                    else
                    {
                        System.Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup);
                        for (int j = 0; j < enumArray.Length; ++j)
                        {
                            DaggerfallConnect.FallExe.ItemTemplate itemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(itemGroup, j);
                            if (itemTemplate.rarity <= shopQuality)
                            {
                                int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100;
                                if (Dice100.SuccessRoll(stockChance))
                                {
                                    DaggerfallUnityItem item = null;
                                    if (itemGroup == ItemGroups.Weapons)
                                    {
                                        item = ItemBuilder.CreateWeapon(j + Weapons.Dagger, ItemBuilder.RandomMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, j + Armor.Cuirass, ItemBuilder.RandomArmorMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.MensClothing)
                                    {
                                        item          = ItemBuilder.CreateMensClothing(j + MensClothing.Straps, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.WomensClothing)
                                    {
                                        item          = ItemBuilder.CreateWomensClothing(j + WomensClothing.Brassier, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.MagicItems)
                                    {
                                        item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race);
                                    }
                                    else
                                    {
                                        item = new DaggerfallUnityItem(itemGroup, j);
                                        if (DaggerfallUnity.Settings.PlayerTorchFromItems && item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Oil))
                                        {
                                            item.stackCount = Random.Range(5, 20 + 1);  // Shops stock 5-20 bottles
                                        }
                                    }
                                    items.AddItem(item);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
 /// <summary>
 /// 获取utf8字符串
 /// </summary>
 /// <param name="bytes"></param>
 /// <returns></returns>
 public static string GetUTF8String(System.Array bytes)
 {
     return(System.Text.Encoding.UTF8.GetString((byte[])bytes));
 }
Пример #9
0
 public override void AddRange(System.Array values)
 {
 }
 public static bool NotEmpty(this System.Array container)
 {
     return(container != null && container.Length > 0);
 }
Пример #11
0
        public void GetEnumerableWithTypePasses()
        {
            System.Array arr = Enumerable.Range(0, 5).ToArray();

            AssertionUtils.AssertEnumerable(Enumerable.Range(0, 5), arr.GetEnumerable <int>().Select(_o => (int)_o), "");
        }
 public static int IndexOf(this System.Array lst, object obj)
 {
     return(System.Array.IndexOf(lst, obj));
 }
 /// <summary>
 ///     Searches for the specified object and returns the index of the last occurrence within the range of elements
 ///     in the one-dimensional  that contains the specified number of elements and ends at the specified index.
 /// </summary>
 /// <param name="array">The one-dimensional  to search.</param>
 /// <param name="value">The object to locate in .</param>
 /// <param name="startIndex">The starting index of the backward search.</param>
 /// <param name="count">The number of elements in the section to search.</param>
 /// <returns>
 ///     The index of the last occurrence of  within the range of elements in  that contains the number of elements
 ///     specified in  and ends at , if found; otherwise, the lower bound of the array minus 1.
 /// </returns>
 public static int LastIndexOf(this System.Array array, object value, int startIndex, int count)
 {
     return(System.Array.LastIndexOf(array, value, startIndex, count));
 }
Пример #14
0
 public void SortByKeys(System.Array keys)
 {
 }
 /// <summary>
 ///     Searches for the specified object and returns the index of the last occurrence within the entire one-
 ///     dimensional .
 /// </summary>
 /// <param name="array">The one-dimensional  to search.</param>
 /// <param name="value">The object to locate in .</param>
 /// <returns>
 ///     The index of the last occurrence of  within the entire , if found; otherwise, the lower bound of the array
 ///     minus 1.
 /// </returns>
 public static int LastIndexOf(this System.Array array, object value)
 {
     return(System.Array.LastIndexOf(array, value));
 }
        protected virtual void Dispatch(string line)
        {
            //[email protected]( "event: " + line );
            string[] elements = GetEventElements(line);
            if (elements == null || elements[0] == null)
            {
                Console.Error.WriteLine("unknown debug event: " + line);
                return;
            }
            if (elements[0].Equals("enterRule"))
            {
                listener.EnterRule(elements[1], elements[2]);
            }
            else if (elements[0].Equals("exitRule"))
            {
                listener.ExitRule(elements[1], elements[2]);
            }
            else if (elements[0].Equals("enterAlt"))
            {
                listener.EnterAlt(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("enterSubRule"))
            {
                listener.EnterSubRule(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("exitSubRule"))
            {
                listener.ExitSubRule(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("enterDecision"))
            {
                listener.EnterDecision(int.Parse(elements[1]), elements[2].Equals("true"));
            }
            else if (elements[0].Equals("exitDecision"))
            {
                listener.ExitDecision(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("location"))
            {
                listener.Location(int.Parse(elements[1]),
                                  int.Parse(elements[2]));
            }
            else if (elements[0].Equals("consumeToken"))
            {
                ProxyToken t = DeserializeToken(elements, 1);
                if (t.TokenIndex == previousTokenIndex)
                {
                    tokenIndexesInvalid = true;
                }
                previousTokenIndex = t.TokenIndex;
                listener.ConsumeToken(t);
            }
            else if (elements[0].Equals("consumeHiddenToken"))
            {
                ProxyToken t = DeserializeToken(elements, 1);
                if (t.TokenIndex == previousTokenIndex)
                {
                    tokenIndexesInvalid = true;
                }
                previousTokenIndex = t.TokenIndex;
                listener.ConsumeHiddenToken(t);
            }
            else if (elements[0].Equals("LT"))
            {
                IToken t = DeserializeToken(elements, 2);
                listener.LT(int.Parse(elements[1]), t);
            }
            else if (elements[0].Equals("mark"))
            {
                listener.Mark(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("rewind"))
            {
                if (elements[1] != null)
                {
                    listener.Rewind(int.Parse(elements[1]));
                }
                else
                {
                    listener.Rewind();
                }
            }
            else if (elements[0].Equals("beginBacktrack"))
            {
                listener.BeginBacktrack(int.Parse(elements[1]));
            }
            else if (elements[0].Equals("endBacktrack"))
            {
                int level    = int.Parse(elements[1]);
                int successI = int.Parse(elements[2]);
                listener.EndBacktrack(level, successI == DebugEventListenerConstants.True);
            }
            else if (elements[0].Equals("exception"))
            {
#if true
                throw new System.NotImplementedException();
#else
                string excName  = elements[1];
                string indexS   = elements[2];
                string lineS    = elements[3];
                string posS     = elements[4];
                Class  excClass = null;
                try
                {
                    excClass = Class.forName(excName);
                    RecognitionException e =
                        (RecognitionException)excClass.newInstance();
                    e.index = int.Parse(indexS);
                    e.line  = int.Parse(lineS);
                    e.charPositionInLine = int.Parse(posS);
                    listener.recognitionException(e);
                }
                catch (ClassNotFoundException cnfe)
                {
                    Console.Error.println("can't find class " + cnfe);
                    cnfe.printStackTrace(Console.Error);
                }
                catch (InstantiationException ie)
                {
                    Console.Error.println("can't instantiate class " + ie);
                    ie.printStackTrace(Console.Error);
                }
                catch (IllegalAccessException iae)
                {
                    Console.Error.println("can't access class " + iae);
                    iae.printStackTrace(Console.Error);
                }
#endif
            }
            else if (elements[0].Equals("beginResync"))
            {
                listener.BeginResync();
            }
            else if (elements[0].Equals("endResync"))
            {
                listener.EndResync();
            }
            else if (elements[0].Equals("terminate"))
            {
                listener.Terminate();
            }
            else if (elements[0].Equals("semanticPredicate"))
            {
                bool   result        = bool.Parse(elements[1]);
                string predicateText = elements[2];
                predicateText = UnEscapeNewlines(predicateText);
                listener.SemanticPredicate(result,
                                           predicateText);
            }
            else if (elements[0].Equals("consumeNode"))
            {
                ProxyTree node = DeserializeNode(elements, 1);
                listener.ConsumeNode(node);
            }
            else if (elements[0].Equals("LN"))
            {
                int       i    = int.Parse(elements[1]);
                ProxyTree node = DeserializeNode(elements, 2);
                listener.LT(i, node);
            }
            else if (elements[0].Equals("createNodeFromTokenElements"))
            {
                int    ID   = int.Parse(elements[1]);
                int    type = int.Parse(elements[2]);
                string text = elements[3];
                text = UnEscapeNewlines(text);
                ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
                listener.CreateNode(node);
            }
            else if (elements[0].Equals("createNode"))
            {
                int ID         = int.Parse(elements[1]);
                int tokenIndex = int.Parse(elements[2]);
                // create dummy node/token filled with ID, tokenIndex
                ProxyTree  node  = new ProxyTree(ID);
                ProxyToken token = new ProxyToken(tokenIndex);
                listener.CreateNode(node, token);
            }
            else if (elements[0].Equals("nilNode"))
            {
                int       ID   = int.Parse(elements[1]);
                ProxyTree node = new ProxyTree(ID);
                listener.NilNode(node);
            }
            else if (elements[0].Equals("errorNode"))
            {
                // TODO: do we need a special tree here?
                int    ID   = int.Parse(elements[1]);
                int    type = int.Parse(elements[2]);
                string text = elements[3];
                text = UnEscapeNewlines(text);
                ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
                listener.ErrorNode(node);
            }
            else if (elements[0].Equals("becomeRoot"))
            {
                int       newRootID = int.Parse(elements[1]);
                int       oldRootID = int.Parse(elements[2]);
                ProxyTree newRoot   = new ProxyTree(newRootID);
                ProxyTree oldRoot   = new ProxyTree(oldRootID);
                listener.BecomeRoot(newRoot, oldRoot);
            }
            else if (elements[0].Equals("addChild"))
            {
                int       rootID  = int.Parse(elements[1]);
                int       childID = int.Parse(elements[2]);
                ProxyTree root    = new ProxyTree(rootID);
                ProxyTree child   = new ProxyTree(childID);
                listener.AddChild(root, child);
            }
            else if (elements[0].Equals("setTokenBoundaries"))
            {
                int       ID   = int.Parse(elements[1]);
                ProxyTree node = new ProxyTree(ID);
                listener.SetTokenBoundaries(
                    node,
                    int.Parse(elements[2]),
                    int.Parse(elements[3]));
            }
            else
            {
                Console.Error.WriteLine("unknown debug event: " + line);
            }
        }
Пример #17
0
 public static void CopyToTexturePlugin(Texture2D rt, System.Array data, int num_data, DataConversion conv)
 {
     System.IntPtr dataptr = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
     CopyToTexture(rt.GetNativeTexturePtr(), rt.width, rt.height, dataptr, num_data, conv);
 }
Пример #18
0
 extern public static byte[] EncodeArrayToJPG(System.Array array, GraphicsFormat format, uint width, uint height, uint rowBytes = 0, int quality = 75);
 public static bool InBounds(this System.Array arr, int index)
 {
     return(index >= 0 && index <= arr.Length - 1);
 }
Пример #20
0
 extern public static byte[] EncodeArrayToEXR(System.Array array, GraphicsFormat format, uint width, uint height, uint rowBytes = 0, Texture2D.EXRFlags flags = Texture2D.EXRFlags.None);
Пример #21
0
        /// <summary>
        /// Replaces all the references in the supplied array (does not work with internal properties).
        /// </summary>
        /// <param name="find">Find.</param>
        /// <param name="replaceWith">Replace with.</param>
        /// <param name="spriteRenderersOnly">If set to <c>true</c> sprite renderers only.</param>
        /// <returns>The replaced references count.</returns>
        public static int ReplaceReferences(Component[] components, Sprite find, Sprite replaceWith, bool spriteRenderersOnly)
        {
            if (components == null || components.Length == 0)
            {
                return(0);
            }

            int count = 0;

            foreach (Object comp in components)
            {
                // Handle sprite renderers differently
                if (comp is SpriteRenderer)
                {
                    if ((comp as SpriteRenderer).sprite == find)
                    {
                        (comp as SpriteRenderer).sprite = replaceWith;
                        count++;
                    }
                }
                else if (comp is UnityEngine.UI.Image)
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                    {
                        continue;
                    }

                    if ((comp as UnityEngine.UI.Image).sprite == find)
                    {
                        (comp as UnityEngine.UI.Image).sprite = replaceWith;
                        count++;
                    }
                }
                else if (comp is UnityEngine.UI.Selectable)
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                    {
                        continue;
                    }

                    UnityEngine.UI.Selectable  selectable = (comp as UnityEngine.UI.Selectable);
                    UnityEngine.UI.SpriteState ss         = selectable.spriteState;

                    if (ss.highlightedSprite == find)
                    {
                        ss.highlightedSprite = replaceWith;
                        count++;
                    }
                    if (ss.pressedSprite == find)
                    {
                        ss.pressedSprite = replaceWith;
                        count++;
                    }
                    if (ss.disabledSprite == find)
                    {
                        ss.disabledSprite = replaceWith;
                        count++;
                    }

                    selectable.spriteState = ss;
                }
                else
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                    {
                        continue;
                    }

                    // Get the fileds info
                    FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (fieldInfo == null)
                        {
                            continue;
                        }

                        object fieldValue = fieldInfo.GetValue(comp);

                        // Handle arrays
                        if (fieldInfo.FieldType.IsArray)
                        {
                            var fieldValueArray = fieldValue as System.Array;

                            if (fieldValueArray == null || fieldValueArray.GetType() != typeof(Sprite[]))
                            {
                                continue;
                            }

                            bool         changed  = false;
                            System.Array newArray = new System.Array[fieldValueArray.Length];
                            fieldValueArray.CopyTo(newArray, 0);

                            for (int i = 0; i < newArray.Length; i++)
                            {
                                object element = newArray.GetValue(i);

                                if (element != null && element.GetType() == typeof(Sprite))
                                {
                                    Sprite o = element as Sprite;

                                    // Check if the value is what we are looking for
                                    if (o == find)
                                    {
                                        newArray.SetValue((replaceWith as object), i);
                                        changed = true;
                                        count++;
                                    }
                                }
                            }

                            // Repalce the array
                            if (changed)
                            {
                                fieldInfo.SetValue(comp, newArray);
                            }
                        }
                        // Handle structs
                        else if (fieldInfo.FieldType.IsValueType && !fieldInfo.FieldType.IsEnum && !fieldInfo.IsLiteral)
                        {
                            FieldInfo[] structFields = fieldInfo.FieldType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                            foreach (FieldInfo structFieldInfo in structFields)
                            {
                                if (structFieldInfo == null)
                                {
                                    continue;
                                }

                                if (structFieldInfo.FieldType == typeof(Sprite))
                                {
                                    Sprite structFieldValue = structFieldInfo.GetValue(fieldValue) as Sprite;

                                    // Check if the value is what we are looking for
                                    if (structFieldValue == find)
                                    {
                                        // Replace
                                        structFieldInfo.SetValue(fieldValue, (replaceWith as object));
                                        count++;
                                    }
                                }
                            }

                            fieldInfo.SetValue(comp, fieldValue);
                        }
                        // Handle direct sprites
                        else if (fieldInfo.FieldType == typeof(Sprite))
                        {
                            // Check if the value is what we are looking for
                            if ((fieldValue as Sprite) == find)
                            {
                                // Replace
                                fieldInfo.SetValue(comp, (replaceWith as object));
                                count++;
                            }
                        }
                    }
                }

                if (PrefabUtility.GetPrefabType((comp as Component).gameObject) != PrefabType.None)
                {
                    EditorUtility.SetDirty((comp as Component));
                }
            }

            return(count);
        }
Пример #22
0
 public override void CopyTo(System.Array array, int index)
 {
 }
 public virtual void CopyTo(System.Array destination, int index)
 {
 }
 public static bool Empty(this System.Array container)
 {
     return(container == null || container.Length <= 0);
 }
Пример #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rnd"></param>
 /// <param name="array"></param>
 /// <returns></returns>
 public static object Get(this System.Random rnd, System.Array array)
 {
     return(array.GetValue(rnd.Next() % array.Length));
 }
Пример #26
0
        public void StockHouseContainer(PlayerGPS.DiscoveredBuilding buildingData)
        {
            stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now);
            items.Clear();

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;
            uint modelIndex = (uint)TextureRecord;

            //int buildingQuality = buildingData.quality;
            byte[] privatePropertyList = null;
            DaggerfallUnityItem item   = null;

            Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            if (buildingType < DFLocation.BuildingTypes.House5)
            {
                if (modelIndex >= 2)
                {
                    if (modelIndex >= 4)
                    {
                        if (modelIndex >= 11)
                        {
                            if (modelIndex >= 15)
                            {
                                privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels15AndUp[(int)buildingType];
                            }
                            else
                            {
                                privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels11to14[(int)buildingType];
                            }
                        }
                        else
                        {
                            privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels4to10[(int)buildingType];
                        }
                    }
                    else
                    {
                        privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels2to3[(int)buildingType];
                    }
                }
                else
                {
                    privatePropertyList = DaggerfallLootDataTables.privatePropertyItemsModels0to1[(int)buildingType];
                }
                if (privatePropertyList == null)
                {
                    return;
                }
                int        randomChoice   = Random.Range(0, privatePropertyList.Length);
                ItemGroups itemGroup      = (ItemGroups)privatePropertyList[randomChoice];
                int        continueChance = 100;
                bool       keepGoing      = true;
                while (keepGoing)
                {
                    if (itemGroup != ItemGroups.MensClothing && itemGroup != ItemGroups.WomensClothing)
                    {
                        if (itemGroup == ItemGroups.MagicItems)
                        {
                            item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race);
                        }
                        else if (itemGroup == ItemGroups.Books)
                        {
                            item = ItemBuilder.CreateRandomBook();
                        }
                        else
                        {
                            if (itemGroup == ItemGroups.Weapons)
                            {
                                item = ItemBuilder.CreateRandomWeapon(playerEntity.Level);
                            }
                            else if (itemGroup == ItemGroups.Armor)
                            {
                                item = ItemBuilder.CreateRandomArmor(playerEntity.Level, playerEntity.Gender, playerEntity.Race);
                            }
                            else
                            {
                                System.Array enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(itemGroup);
                                item = new DaggerfallUnityItem(itemGroup, Random.Range(0, enumArray.Length));
                            }
                        }
                    }
                    else
                    {
                        item = ItemBuilder.CreateRandomClothing(playerEntity.Gender, playerEntity.Race);
                    }
                    continueChance >>= 1;
                    if (DFRandom.rand() % 100 > continueChance)
                    {
                        keepGoing = false;
                    }
                    items.AddItem(item);
                }
            }
        }
 public static int GetRandomIndex(this System.Array array)
 {
     return(Random.Range(0, array.Length));
 }
 void System.Collections.ICollection.CopyTo(System.Array array, int index)
 {
     CodeFluent.Runtime.Utilities.ConvertUtilities.CopyTo(this, array, index);
 }
Пример #29
0
 public static System.Collections.JsDictionary ToJsDictionary(CustomObject value)
 {
     if ((value == null))
     {
         return null;
     }
     System.Collections.JsDictionary returnValue = new System.Collections.JsDictionary();
     returnValue["Add"] = EnumConverters.ConvertNullableSomeEnumToString(value.Add);
     returnValue["Property1"] = value.Property1;
     returnValue["Property2"] = value.Property2;
     returnValue["Property3"] = new System.Array();
     for (int i = 0; (i < value.Property3.Count); i = (i + 1))
     {
         System.Script.Reinterpret<System.Array>(returnValue["Property3"])[i] = CustomObject.ToJsDictionary(value.Property3[i]);
     }
     returnValue["Property4"] = CustomObject2.ToJsDictionary(value.Property4);
     returnValue["Property5"] = EnumConverters.ConvertSomeEnumToString(value.Property5);
     return returnValue;
 }
Пример #30
0
 void System.Collections.ICollection.CopyTo(System.Array array, int index)
 {
 }
 // Methods
 public virtual void CopyTo(System.Array array, int arrayIndex)
 {
 }
Пример #32
0
 public void CopyTo(System.Array array, int offset)
 {
 }
 /// <summary>
 ///     An Array extension method that clears the array.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 public static void ClearAll(this System.Array @this)
 {
     System.Array.Clear(@this, 0, @this.Length);
 }
Пример #34
0
 private System.Collections.Generic.Dictionary<string, object> GetParametersForTestMethod(System.Nullable<double> operand1, int operand2, bool simulateLatency, string something, CustomObject Add, System.Collections.Generic.List<string> somethingElse, System.Collections.Generic.List<int> somethingElseAgain, System.Collections.Generic.List<System.Nullable<int>> somethingElseNullable, System.Collections.Generic.List<CustomObject> somethingElseAgain2)
 {
     System.Collections.Generic.Dictionary<string, object> parameters = new System.Collections.Generic.Dictionary<string, object>();
     System.Array tempArray;
     parameters.Add("operand1", operand1);
     parameters.Add("operand2", operand2);
     parameters.Add("simulateLatency", simulateLatency);
     parameters.Add("something", something);
     parameters.Add("Add", CustomObject.ToJsDictionary(Add));
     tempArray = new System.Array();
     if ((somethingElse != null))
     {
         for (int i = 0; (i < somethingElse.Count); i = (i + 1))
         {
             tempArray[i] = somethingElse[i];
         }
     }
     parameters.Add("somethingElse", tempArray);
     tempArray = new System.Array();
     if ((somethingElseAgain != null))
     {
         for (int i = 0; (i < somethingElseAgain.Count); i = (i + 1))
         {
             tempArray[i] = somethingElseAgain[i];
         }
     }
     parameters.Add("somethingElseAgain", tempArray);
     tempArray = new System.Array();
     if ((somethingElseNullable != null))
     {
         for (int i = 0; (i < somethingElseNullable.Count); i = (i + 1))
         {
             tempArray[i] = somethingElseNullable[i];
         }
     }
     parameters.Add("somethingElseNullable", tempArray);
     tempArray = new System.Array();
     if ((somethingElseAgain2 != null))
     {
         for (int i = 0; (i < somethingElseAgain2.Count); i = (i + 1))
         {
             tempArray[i] = CustomObject.ToJsDictionary(somethingElseAgain2[i]);
         }
     }
     parameters.Add("somethingElseAgain2", tempArray);
     return parameters;
 }
Пример #35
0
 extern public static byte[] EncodeArrayToPNG(System.Array array, GraphicsFormat format, uint width, uint height, uint rowBytes = 0);
Пример #36
0
        /// <summary>
        /// Replaces all the references in the supplied array (does not work with internal properties).
        /// </summary>
        /// <param name="find">Find.</param>
        /// <param name="replaceWith">Replace with.</param>
        /// <param name="spriteRenderersOnly">If set to <c>true</c> sprite renderers only.</param>
        /// <returns>The replaced references count.</returns>
        public static int ReplaceReferences(Component[] components, Sprite find, Sprite replaceWith, bool spriteRenderersOnly)
        {
            if (components == null || components.Length == 0)
                return 0;

            int count = 0;
            foreach (Object comp in components)
            {
                // Handle sprite renderers differently
                if (comp is SpriteRenderer)
                {
                    if ((comp as SpriteRenderer).sprite == find)
                    {
                        (comp as SpriteRenderer).sprite = replaceWith;
                        count++;
                    }
                }
                else if (comp is UnityEngine.UI.Image)
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                        continue;

                    if ((comp as UnityEngine.UI.Image).sprite == find)
                    {
                        (comp as UnityEngine.UI.Image).sprite = replaceWith;
                        count++;
                    }
                }
                else if (comp is UnityEngine.UI.Selectable)
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                        continue;

                    UnityEngine.UI.Selectable selectable = (comp as UnityEngine.UI.Selectable);
                    UnityEngine.UI.SpriteState ss = selectable.spriteState;

                    if (ss.highlightedSprite == find)
                    {
                        ss.highlightedSprite = replaceWith;
                        count++;
                    }
                    if (ss.pressedSprite == find)
                    {
                        ss.pressedSprite = replaceWith;
                        count++;
                    }
                    if (ss.disabledSprite == find)
                    {
                        ss.disabledSprite = replaceWith;
                        count++;
                    }

                    selectable.spriteState = ss;
                }
                else
                {
                    // If this component is not a sprite renderer
                    if (spriteRenderersOnly)
                        continue;

                    // Get the fileds info
                    FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (fieldInfo == null)
                            continue;

                        object fieldValue = fieldInfo.GetValue(comp);

                        // Handle arrays
                        if (fieldInfo.FieldType.IsArray)
                        {
                            var fieldValueArray = fieldValue as System.Array;

                            if (fieldValueArray == null || fieldValueArray.GetType() != typeof(Sprite[]))
                                continue;

                            bool changed = false;
                            System.Array newArray = new System.Array[fieldValueArray.Length];
                            fieldValueArray.CopyTo(newArray, 0);

                            for (int i = 0; i < newArray.Length; i++)
                            {
                                object element = newArray.GetValue(i);

                                if (element != null && element.GetType() == typeof(Sprite))
                                {
                                    Sprite o = element as Sprite;

                                    // Check if the value is what we are looking for
                                    if (o == find)
                                    {
                                        newArray.SetValue((replaceWith as object), i);
                                        changed = true;
                                        count++;
                                    }
                                }
                            }

                            // Repalce the array
                            if (changed)
                            {
                                fieldInfo.SetValue(comp, newArray);
                            }
                        }
                        // Handle structs
                        else if (fieldInfo.FieldType.IsValueType && !fieldInfo.FieldType.IsEnum && !fieldInfo.IsLiteral)
                        {
                            FieldInfo[] structFields = fieldInfo.FieldType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                            foreach (FieldInfo structFieldInfo in structFields)
                            {
                                if (structFieldInfo == null)
                                    continue;

                                if (structFieldInfo.FieldType == typeof(Sprite))
                                {
                                    Sprite structFieldValue = structFieldInfo.GetValue(fieldValue) as Sprite;

                                    // Check if the value is what we are looking for
                                    if (structFieldValue == find)
                                    {
                                        // Replace
                                        structFieldInfo.SetValue(fieldValue, (replaceWith as object));
                                        count++;
                                    }
                                }
                            }

                            fieldInfo.SetValue(comp, fieldValue);
                        }
                        // Handle direct sprites
                        else if (fieldInfo.FieldType == typeof(Sprite))
                        {
                            // Check if the value is what we are looking for
                            if ((fieldValue as Sprite) == find)
                            {
                                // Replace
                                fieldInfo.SetValue(comp, (replaceWith as object));
                                count++;
                            }
                        }
                    }
                }

                if (PrefabUtility.GetPrefabType((comp as Component).gameObject) != PrefabType.None)
                    EditorUtility.SetDirty((comp as Component));
            }

            return count;
        }
Пример #37
0
 // Methods
 public virtual void CopyTo(System.Array ar, int index)
 {
 }