public void SetUp() { guns = new GunData[gunsSize]; outfits = new OutfitData[outfitsSize]; medKits = new MedKitData[medKitsSize]; ammoData = new AmmoData[ammoSize]; }
public OutfitData Serialize(Outfit outfit) { var outfitData = new OutfitData(); outfitData.outfitType = outfit.GetOutfitType(); outfitData.slotUiIndex = outfit.GetItemUi().GetItemUiSlotIndex(); return(outfitData); }
public Outfit Deserialize(OutfitData outfitData) { var outfit = new Outfit(outfitData.outfitType); var itemUiDataTransfer = new ItemUiDataTransfer(); itemUiDataTransfer.SetItemUiSlotIndex(outfitData.slotUiIndex); outfit.SetItemUi(itemUiDataTransfer); return(outfit); }
public void ResetData(OutfitData newData) { data = newData; if (name != null) { name.text = newData.name; } if (cost != null) { cost.text = "" + newData.cost; } if (sprite != null) { sprite.sprite = newData.sprite; } }
public void ChangeOutfitSlot(OutfitData outfit, OutfitData.OutfitPlacement placement, int positionIdx) { Inventory.ChangeOutfitSlot(outfit, placement, positionIdx); Vehicle.UpdateOutfit(); }
public SpriteSheet GetSpriteSheet(FrameGroupType groupType, OutfitData outfitData) { SpriteSheet rawSpriteSheet = this.GetSpriteSheet(groupType); FrameGroup group = this.ThingType.GetFrameGroup(groupType); if (group.Layers < 2) { return(rawSpriteSheet); } outfitData = outfitData == null ? OUTFIT_DATA : outfitData; int totalX = group.PatternZ * group.PatternX * group.Layers; int totalY = group.Frames * group.PatternY; int bitmapWidth = (totalX * group.Width) * Sprite.DefaultSize; int bitmapHeight = (totalY * group.Height) * Sprite.DefaultSize; int pixelsWidth = group.Width * Sprite.DefaultSize; int pixelsHeight = group.Height * Sprite.DefaultSize; Bitmap grayBitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Bitmap blendBitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Bitmap bitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Dictionary <int, Rect> rectList = new Dictionary <int, Rect>(); for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int x = 0; x < group.PatternX; x++) { int index = (((f % group.Frames * group.PatternZ + z) * group.PatternY) * group.PatternX + x) * group.Layers; rectList[index] = new Rect((z * group.PatternX + x) * pixelsWidth, f * pixelsHeight, pixelsWidth, pixelsHeight); } } } BitmapLocker grayLocker = new BitmapLocker(grayBitmap); BitmapLocker blendLocker = new BitmapLocker(blendBitmap); BitmapLocker bitmapLocker = new BitmapLocker(bitmap); grayLocker.LockBits(); blendLocker.LockBits(); bitmapLocker.LockBits(); for (int y = 0; y < group.PatternY; y++) { if (y == 0 || (outfitData.Addons & 1 << (y - 1)) != 0) { for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int x = 0; x < group.PatternX; x++) { // gets gray bitmap int i = (((f % group.Frames * group.PatternZ + z) * group.PatternY + y) * group.PatternX + x) * group.Layers; Rect rect = rawSpriteSheet.RectList[i]; int rx = rect.X; int ry = rect.Y; int rw = rect.Width; int rh = rect.Height; int index = (((f * group.PatternZ + z) * group.PatternY) * group.PatternX + x) * group.Layers; rect = rectList[index]; int px = rect.X; int py = rect.Y; grayLocker.CopyPixels(rawSpriteSheet.Bitmap, rx, ry, rw, rh, px, py); // gets blend bitmap i++; rect = rawSpriteSheet.RectList[i]; rx = rect.X; ry = rect.Y; rw = rect.Width; rh = rect.Height; blendLocker.CopyPixels(rawSpriteSheet.Bitmap, rx, ry, rw, rh, px, py); } } } bitmapLocker.ColorizePixels(grayLocker.Pixels, blendLocker.Pixels, outfitData.Head, outfitData.Body, outfitData.Legs, outfitData.Feet); } } grayLocker.UnlockBits(); grayLocker.Dispose(); blendLocker.UnlockBits(); blendLocker.Dispose(); bitmapLocker.UnlockBits(); bitmapLocker.Dispose(); grayBitmap.Dispose(); blendBitmap.Dispose(); return(new SpriteSheet(bitmap, rectList)); }
public Bitmap GetObjectImage(ushort id, Direction direction, OutfitData data) { return(this.GetObjectImage(id, direction, data, false)); }
public Bitmap GetObjectImage(ushort id, Direction direction, OutfitData data, bool mount) { ThingType thing = this.Things.GetThing(id, ThingCategory.Outfit); if (thing == null) { return(null); } FrameGroup group = thing.GetFrameGroup(FrameGroupType.Default); if (group.Layers < 2) { return(this.GetObjectImage(id, ThingCategory.Outfit, FrameGroupType.Default)); } int width = Sprite.DefaultSize * group.Width; int height = Sprite.DefaultSize * group.Height; Bitmap grayBitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); Bitmap blendBitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); BitmapLocker grayLocker = new BitmapLocker(grayBitmap); BitmapLocker blendLocker = new BitmapLocker(blendBitmap); BitmapLocker bitmapLocker = new BitmapLocker(bitmap); grayLocker.LockBits(); blendLocker.LockBits(); bitmapLocker.LockBits(); byte x = (byte)((byte)direction % group.PatternX); byte z = mount && group.PatternZ > 1 ? (byte)1 : (byte)0; for (int y = 0; y < group.PatternY; y++) { if (y == 0 || (data.Addons & 1 << (y - 1)) != 0) { for (byte w = 0; w < group.Width; w++) { for (byte h = 0; h < group.Height; h++) { int index = group.GetSpriteIndex(w, h, 0, x, y, z, 0); uint spriteId = group.SpriteIDs[index]; int px = (group.Width - w - 1) * Sprite.DefaultSize; int py = (group.Height - h - 1) * Sprite.DefaultSize; grayLocker.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px, py); index = group.GetSpriteIndex(w, h, 1, x, y, z, 0); spriteId = group.SpriteIDs[index]; blendLocker.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px, py); } } bitmapLocker.ColorizePixels(grayLocker.Pixels, blendLocker.Pixels, data.Head, data.Body, data.Legs, data.Feet); } } grayLocker.UnlockBits(); grayLocker.Dispose(); blendLocker.UnlockBits(); blendLocker.Dispose(); bitmapLocker.UnlockBits(); bitmapLocker.Dispose(); grayBitmap.Dispose(); blendBitmap.Dispose(); return(bitmap); }
public void GetPlayFabDecor() { Dictionary <string, ItemInstance> ownedItems = new Dictionary <string, ItemInstance>(); //getting the user's inventory GetUserInventoryRequest request = new GetUserInventoryRequest(); PlayFabClientAPI.GetUserInventory(request, result => { restaurants = new List <RestaurantData>(); foreach (ItemInstance i in result.Inventory) { if (i.ItemClass == "cat") { if (i.ItemId == "waiter_cat") { AddCat(null, new WaiterData(i)); } else if (i.ItemId == "chef_cat") { AddCat(new ChefData(i), null); } } else if (i.ItemClass == "Restaurant") { restaurants.Add(new RestaurantData(i)); } else { ownedItems.Add(i.ItemId, i); } } CatfePlayerScript.script.SetUpRestaurants(restaurants); }, error => {}); //getting the decor in the shop GetCatalogItemsRequest itemRequest = new GetCatalogItemsRequest(); itemRequest.CatalogVersion = "Items"; PlayFabClientAPI.GetCatalogItems(itemRequest, result => { List <CatalogItem> items = result.Catalog; foreach (CatalogItem i in items) { switch (i.ItemClass) { case "Decoration": DecorationData d = new DecorationData(i); GameObject newDecor = (GameObject)Instantiate(DecorPref); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { decor.Add(newDecor); GameObject inv = (GameObject)Instantiate(DecorInfoPrefab); d.numInInventory = (int)ownedItems[i.ItemId].RemainingUses; inv.GetComponent <Decoration>().ResetData(d); inv.transform.SetParent(InventoryDecorPanel.transform); } else { notPurchasedDecor.Add(newDecor); } newDecor.GetComponent <Decoration>().ResetData(d); newDecor.transform.SetParent(DecorPanel.transform); break; case "Recipe": Recipe r = new Recipe(i); GameObject newRecipe = (GameObject)Instantiate(RecipeInfoPrefab); recipes.Add(newRecipe); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { newRecipe.GetComponent <RecipePanelData>().ResetData(r); newRecipe.transform.SetParent(InventoryRecipePanel.transform); } //only put recipe panels in the store if they haven't been purchased else { newRecipe.GetComponent <RecipePanelData>().ResetData(r); newRecipe.transform.SetParent(RecipePanel.transform); } break; case "outfit": OutfitData o = new OutfitData(i); GameObject newOutfit = (GameObject)Instantiate(OutfitPrefab); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { newOutfit.GetComponent <Outfits>().ResetData(o); newOutfit.transform.SetParent(InventoryOutfitPanel.transform); } else { newOutfit.GetComponent <Outfits>().ResetData(o); newOutfit.transform.SetParent(OutfitPanel.transform); } GameObject dress = (GameObject)Instantiate(outfitDressupPanel); dress.GetComponent <Outfits>().ResetData(o); if (i.Tags[0] == "shirt") { dress.transform.SetParent(dressupPanels[0].transform); } else if (i.Tags[0] == "hat") { dress.transform.SetParent(dressupPanels[1].transform); } else if (i.Tags[0] == "glasses") { dress.transform.SetParent(dressupPanels[2].transform); } else if (i.Tags[0] == "arms") { dress.transform.SetParent(dressupPanels[3].transform); } else if (i.Tags[0] == "pants") { dress.transform.SetParent(dressupPanels[4].transform); } else if (i.Tags[0] == "feet") { dress.transform.SetParent(dressupPanels[5].transform); } break; default: break; } } }, error => {} ); }