/// <summary> /// Sets the item sprites by calling the SpriteList dictionary with key as the item type. /// </summary> /// <returns><c>true</c>, if item sprites was set, <c>false</c> otherwise.</returns> /// <param name="seed">Seed.</param> /// <param name="type">Type.</param> /// <param name="item">Item.</param> /// <param name="useSeed">If set to <c>true</c> uses seed.</param> private static void SetItemSprites(int seed, string type, GameItem item, bool useSeed) { Random random = GetRandom(seed, useSeed); //Set the sprites for the object using a sprite list dictionary if (itemSpriteLists == null) //load default sprites if not set yet { LoadItemSprites(); } SpriteList typeSpriteList = itemSpriteLists.GetSpriteList(type); if (typeSpriteList == null) { throw new Exception("ApplyNameModifiers: invalid sprite list key (type): '" + type + "'"); } int numSprites = typeSpriteList.namedSprites.Length; string key = random.Next(0, numSprites).ToString(); //(incl, excl] UnityEngine.Sprite itemSprite = typeSpriteList.GetSprite(key); if (itemSprite == null) { throw new Exception("ApplyNameModifiers: invalid sprite key '" + key + "'"); } item.GroundSprite = itemSprite; item.GuiSprite = itemSprite; }
public void Paste() { Clear(); for (int i = 0; i < copyList.Count; i++) { GameObject g = Instantiate(placeablePrefab, copyList[i].position, Quaternion.identity, placeable); g.GetComponent <SpriteRenderer>().sprite = sl.GetSprite(copyList[i].spriteName); list.Add(g.transform); g.GetComponent <SpriteRenderer>().color = Color.blue; } print("Copied " + copyList.Count + " objects"); }
public void Load() { string level = PlayerPrefs.GetString(Level.chosenLevel.ToString(), string.Empty); if (level == string.Empty) { return; } Clear(); string[] res = Regex.Split(level, " "); print("TAMANHO " + res.Length + ": " + res[0]); for (int i = 0; i < res.Length; i += 3) { if (res[i] == "Zumbi01") { res[i] = "Enemy01"; } else if (res[i] == "Zumbi02") { res[i] = "Enemy02"; } else if (res[i] == "Zumbi03") { res[i] = "Enemy03"; } else if (res[i] == "Zumbi04") { res[i] = "Enemy04"; } else if (res[i] == "Zumbi05") { res[i] = "Enemy05"; } else if (res[i] == "Dove01") { res[i] = "Enemy06"; } Collection.instance.SpawnPlaceable(spriteList.GetSprite(res[i]), new Vector2(float.Parse(res[i + 1]), float.Parse(res[i + 2]))); } }
public void UpdateUI(int bid) { GetComponent <SpriteRenderer>().sprite = HandSprites.GetSprite(bid); }