protected override void AddChestDrops(Chest chest, int chestNum, bool isMonsterChest, bool isEnchantChest) { // Gold if (!isMonsterChest) chest.Add(Item.Create(id: 2000, amountMin: 100, amountMax: 250)); // Enchant if (isEnchantChest) { int prefix = 0, suffix = 0; switch (Random(10)) { case 0: case 1: case 2: case 3: prefix = 20205; break; // Restfull case 4: case 5: case 6: prefix = 20204; break; // Foggy case 7: case 8: suffix = 30501; break; // Giant case 9: suffix = 30602; break; // Healer } chest.Add(Item.CreateEnchanted(62005, prefix, suffix)); } }
protected override void AddChestDrops(Chest chest, int chestNum, bool isMonsterChest, bool isEnchantChest) { // Gold if (!isMonsterChest) chest.Add(Item.Create(id: 2000, amountMin: 100, amountMax: 250)); // Enchant if (isEnchantChest) { var enchant = 0; switch (Random(10)) { case 0: case 1: case 2: case 3: enchant = 20205; break; // Restfull (Prefix) case 4: case 5: case 6: enchant = 20204; break; // Foggy (Prefix) case 7: case 8: enchant = 30501; break; // Giant (Suffix) case 9: enchant = 30602; break; // Healer (Suffix) } chest.Add(Item.CreateEnchant(enchant)); } }
public Events(int level) { var rand = new Random(); TypeEvent = rand.Next(EventsN) + 1; Actions = new List<Action>(); switch (TypeEvent) { case (int)eTypeEvent.Enemy: var enemy = new Enemy(level); EventName = "Enemy!"; Event = enemy; Level = enemy.Rating(); Actions.Add(new Action("Attack", ConsoleKey.A)); Actions.Add(new Action("Retreat", ConsoleKey.B)); break; case (int)eTypeEvent.Rain: var rain = new Rain(level); EventName = "Rain!"; Event = rain; Level = rain.Level(); Actions.Add(new Action("Ok", ConsoleKey.A)); break; case (int)eTypeEvent.Chest: var chest = new Chest(level); EventName = "Chest!"; Event = chest; Level = chest.Level(); Actions.Add(new Action("Ok", ConsoleKey.A)); break; } }
public MainWindow() { InitializeComponent(); IRenderer renderer = new Renderer(Canvas); Chest chest = new Chest(200, 100, 100); var image = new Image(); image.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/Images/chest.png")); renderer.Render(chest); }
private void ClearWindow() { chest.OnMouseUp(); Screen.lockCursor = true; playerObj.GetComponent<MouseLook> ().enabled = true; Camera.mainCamera.GetComponent<MouseLook> ().enabled = true; chest = null; displayWindow = false; }
protected virtual void AddChestDrops(Chest chest) { switch (Random(5)) { case 0: chest.Add(Item.Create(id: 63002, amountMin: 1, amountMax: 5)); break; // Firewood case 1: chest.Add(Item.Create(id: 60005, amountMin: 1, amountMax: 5)); break; // Bandage case 2: chest.Add(Item.Create(id: 51001, amountMin: 1, amountMax: 2)); break; // HP 10 Potion case 3: chest.Add(Item.Create(id: 52002, amountMin: 1, amountMax: 3)); break; // Small Gem case 4: chest.Add(Item.Create(id: 50009, amountMin: 1, amountMax: 3)); break; // Egg } }
public override void OnPuzzleCreate(Puzzle puzzle) { var lockedPlace = puzzle.GetPlace("LockedPlace"); var key = puzzle.LockPlace(lockedPlace, "Boss"); var chest = new Chest(puzzle, "KeyChest"); lockedPlace.AddProp(chest, Placement.Center); chest.Info.Direction = MabiMath.DegreeToRadian(90); chest.Add(Item.Create(GoddessPass)); chest.Add(key); }
public override void OnPuzzleCreate(Puzzle puzzle) { var lockedPlace = puzzle.GetPlace("LockedPlace"); var chestPlace = puzzle.GetPlace("ChestPlace"); puzzle.LockPlace(lockedPlace, "Lock"); var chest = new Chest(puzzle, "KeyChest"); AddChestDrops(chest); chestPlace.AddProp(chest, Placement.Random); }
protected virtual void AddChestDrops(Chest chest) { if (Random(100) != 0) { for (int i = 0; i < 2; ++i) chest.Add(Item.Create(id: 2000, amountMin: 10, amountMax: 50)); } else { for (int i = 0; i < 5; ++i) chest.Add(Item.Create(id: 2000, amountMin: 100, amountMax: 200)); } }
public override void OnPuzzleCreate(Puzzle puzzle) { var lockedPlace = puzzle.GetPlace("LockedPlace"); var chestPlace = puzzle.GetPlace("ChestPlace"); var key = puzzle.LockPlace(lockedPlace, "Lock"); var chest = new Chest(puzzle, "KeyChest"); chest.Add(Item.Create(id: 2000, amountMin: 10, amountMax: 30)); chest.Add(key); chestPlace.AddProp(chest, Placement.Corner4); chestPlace.SpawnSingleMob("Trap", "Mob3", Placement.Corner4); chestPlace.SpawnSingleMob("ChestMob1", "Mob1"); lockedPlace.SpawnSingleMob("ChestMob2", "Mob2"); }
void ToggleChestNearby(Collider collider) { Chest chest = collider.GetComponentInParent<Chest>(); if (chest) { isChestNearby = !isChestNearby; if (isChestNearby) { nearbyChest = chest; chest.playersInRange++; } else { nearbyChest.SetFill(0); nearbyChest = null; chest.playersInRange--; } } }
public void GenerateChests(Floor floor) { bool finished = false; while (!finished) { int randomIndex = Random.Range (0, PossibleChestLocations (floor).Count); Chest chest = new Chest (PossibleChestLocations (floor)[randomIndex]); AddChest (chest); if (allChests.Count == numChests || PossibleChestLocations (floor).Count == 0) { finished = true; } } }
void recreateItem(){ if(selectedItem == healthIndex){ sell[selectedItem] = new HealthPotion(); } else if(selectedItem == manaIndex){ sell[selectedItem] = new ManaPotion(); } else if(selectedItem == swordIndex){ sell[selectedItem] = new Sword(); } else if(selectedItem == axeIndex){ sell[selectedItem] = new Axe(); } else if(selectedItem == chestIndex){ sell[selectedItem] = new Chest(); } else if(selectedItem == bootsIndex){ sell[selectedItem] = new Boots(); } }
public void GenerateDen(int x, int y) { //QwertyMethods.BreakTiles(x - (denLength-1)/2, y, denLength, denLowerHeight); for (int l = 0; l < denLength; l++) { for (int h = 0; h < denUpperHeight; h++) { if (!Main.tile[(x - ((denLength - 1) / 2)) + l, y - h].active()) { WorldGen.PlaceTile((x - ((denLength - 1) / 2)) + l, y - h, TileID.IceBlock); } Main.tile[x - ((denLength - 1) / 2) + l, y - h].liquid = 0; } int ceilingHeight = (int)((float)Math.Sin(((float)l / (float)denLength) * (float)Math.PI) * (float)denUpperHeight); for (int h = 0; h < ceilingHeight; h++) { WorldGen.KillTile(x - ((denLength - 1) / 2) + l, y - h, false, false, true); WorldGen.KillWall(x - ((denLength - 1) / 2) + l, y - h, false); WorldGen.PlaceWall(x - ((denLength - 1) / 2) + l, y - h, WallID.IceUnsafe); if (l % 4 == 0 && h == ceilingHeight - 5) { WorldGen.PlaceTile(x - ((denLength - 1) / 2) + l, y - h, TileID.Torches, false, false, -1, 9); } if (Math.Abs((x - ((denLength - 1) / 2) + l) - x) >= 10 && Math.Abs((x - ((denLength - 1) / 2) + l) - x) <= 19 && h == 15) { WorldGen.PlaceTile(x - ((denLength - 1) / 2) + l, y - h, TileID.Platforms, style: 35); } } for (int h = 0; h < denLowerHeight; h++) { WorldGen.PlaceTile(x - ((denLength - 1) / 2) + l, y + h, TileID.IceBlock); } } for (int l = 0; l < denLength; l++) { int ceilingHeight = (int)((float)Math.Sin(((float)l / (float)denLength) * (float)Math.PI) * (float)denUpperHeight); for (int h = 0; h < ceilingHeight; h++) { if (l == 35 && h == 16) { Chest chest = Main.chest[WorldGen.PlaceChest(x - ((denLength - 1) / 2) + l, y - h, style: 11)]; int slot = 0; chest.item[slot].SetDefaults(ItemID.SnowballCannon, false); slot++; chest.item[slot].SetDefaults(ItemID.Snowball, false); chest.item[slot].stack = Main.rand.Next(500, 1000); slot++; chest.item[slot].SetDefaults(ItemID.IceTorch, false); chest.item[slot].stack = Main.rand.Next(20, 100); slot++; chest.item[slot].SetDefaults(ItemID.LesserHealingPotion, false); chest.item[slot].stack = Main.rand.Next(4, 11); slot++; if (Main.rand.Next(5) == 0) { chest.item[slot].SetDefaults(ItemID.IceMirror, false); slot++; } slot++; } if (l == 64 && h == 16) { Chest chest = Main.chest[WorldGen.PlaceChest(x - ((denLength - 1) / 2) + l, y - h, style: 11)]; int slot = 0; switch (Main.rand.Next(3)) { case 0: chest.item[slot].SetDefaults(ItemID.IceSkates, false); slot++; break; case 1: chest.item[slot].SetDefaults(ItemID.FlurryBoots, false); slot++; break; case 2: chest.item[slot].SetDefaults(ItemID.BlizzardinaBottle, false); slot++; break; } chest.item[slot].SetDefaults(ItemID.IceTorch, false); chest.item[slot].stack = Main.rand.Next(20, 100); slot++; chest.item[slot].SetDefaults(ItemID.LesserHealingPotion, false); chest.item[slot].stack = Main.rand.Next(4, 11); slot++; if (Main.rand.Next(5) == 0) { chest.item[slot].SetDefaults(ItemID.IceMirror, false); slot++; } } } } //int[] rocks = new int[] { 97, 92, 81, 60 }; for (int i = 0; i < 10; i++) { /* * switch(Main.rand.Next(2)) * { * case 0: * WorldGen.PlaceTile(x - ((denLength - 1) / 2) + Main.rand.Next(denLength), y-1, 185, style:Main.rand.Next(42, 48)); * break; * case 1: * WorldGen.PlaceTile(x - ((denLength - 1) / 2) + Main.rand.Next(denLength), y-2, 186, style: Main.rand.Next(26, 32)); * break; * * } */ if (Main.rand.Next(2) == 0) { WorldGen.PlaceSmallPile(x - ((denLength - 1) / 2) + Main.rand.Next(denLength), y - 1, Main.rand.Next(42, 48), 0); } else { WorldGen.PlaceSmallPile(x - ((denLength - 1) / 2) + Main.rand.Next(denLength), y - 1, Main.rand.Next(25, 31), 1); } } }
/// <summary> /// Try open chest, return if success /// </summary> /// <param name="chest"></param> /// <returns></returns> bool TryOpen(Chest chest, Int32[] ownKeys) { bool succeed = false; if ( ownKeys[chest.LockType] > 0) { succeed = true; ownKeys[chest.LockType]--; this.LootAllKeys(ownKeys, chest.Keys); } return succeed; }
public static ClipboardBuffer LoadOld(string filename) { using (var stream = new FileStream(filename, FileMode.Open)) { using (var reader = new BinaryReader(stream)) { string name = reader.ReadString(); int version = reader.ReadInt32(); int maxx = reader.ReadInt32(); int maxy = reader.ReadInt32(); var buffer = new ClipboardBuffer(new Vector2Int32(maxx, maxy)); buffer.Name = string.IsNullOrWhiteSpace(name) ? Path.GetFileNameWithoutExtension(filename) : name; try { for (int x = 0; x < buffer.Size.X; x++) { for (int y = 0; y < buffer.Size.Y; y++) { var tile = new Tile(); tile.IsActive = reader.ReadBoolean(); if (tile.IsActive) { tile.Type = reader.ReadByte(); if (tile.Type == (int)TileType.Platform) { tile.U = 0; tile.V = 0; } else if (World.TileProperties[tile.Type].IsFramed) { tile.U = reader.ReadInt16(); tile.V = reader.ReadInt16(); } else { tile.U = -1; tile.V = -1; } } // trash old lighted value reader.ReadBoolean(); if (reader.ReadBoolean()) { tile.Wall = reader.ReadByte(); } if (reader.ReadBoolean()) { tile.LiquidType = LiquidType.Water; tile.LiquidAmount = reader.ReadByte(); if (reader.ReadBoolean()) // lava { tile.LiquidType = LiquidType.Lava; } } buffer.Tiles[x, y] = tile; } } } catch (Exception) { for (int x = 0; x < buffer.Size.X; x++) { for (int y = 0; y < buffer.Size.Y; y++) { if (buffer.Tiles[x, y] == null) { buffer.Tiles[x, y] = new Tile(); } } } return(buffer); } for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { if (reader.ReadBoolean()) { var chest = new Chest(); chest.X = reader.ReadInt32(); chest.Y = reader.ReadInt32(); for (int slot = 0; slot < 20; slot++) { byte stackSize = reader.ReadByte(); if (stackSize > 0) { string itemName = reader.ReadString(); chest.Items[slot].SetFromName(itemName); chest.Items[slot].StackSize = stackSize; } } //Chests[chestIndex] = chest; buffer.Chests.Add(chest); } } for (int signIndex = 0; signIndex < 1000; signIndex++) { if (reader.ReadBoolean()) { string signText = reader.ReadString(); int x = reader.ReadInt32(); int y = reader.ReadInt32(); if (buffer.Tiles[x, y].IsActive && Tile.IsSign(buffer.Tiles[x, y].Type)) // validate tile location { var sign = new Sign(x, y, signText); //Signs[signIndex] = sign; buffer.Signs.Add(sign); } } } int checkx = reader.ReadInt32(); int checky = reader.ReadInt32(); if (checkx == maxx && checky == maxy) { return(buffer); } } } return(null); }
/// ************************************************************************************************************************************************** /// ROUTINE METHODS /// The constructor initiates everything we need to get the fridge running. public ExpandedFridgeHub() : base(true) { // get the location of the fridge if (Game1.IsMasterGame) { this.location = Game1.getLocationFromName("FarmHouse") as FarmHouse; } else { foreach (GameLocation location in ModEntry.HelperInstance.Multiplayer.GetActiveLocations()) { if (location is Cabin && (location as Cabin).owner == Game1.player) { this.location = location as FarmHouse; } } } // check if location can have a fridge if (this.location.upgradeLevel > 0) { this.remoteOpen = false; this.connectedChests = new List <Chest>(); // save normal fridge this.normalFridge = this.location.fridge.Value; // replace normal fridge in location with this this.location.fridge.Value = this; // setup fridge values from saved data in normal fridge SetupUpgradesFromData(this.normalFridge.chestType.Value); // get marked chests in our location List <ChestAndPosition> markedChests = GetAllMarkedChestsInLocation(); // determine how many marked chests there should be int targetChests = this.location.upgradeLevel * 2 + this.upgradeStorage + ModEntry.cheatStorage; if (targetChests > 12) { targetChests = 12; } // ensure we have enough marked chests according to house level if (markedChests.Count < targetChests) { for (int i = markedChests.Count; i < targetChests; i++) { CreateNewChestInLocation(i); } markedChests = GetAllMarkedChestsInLocation(); } // set connected chests foreach (ChestAndPosition cap in markedChests) { connectedChests.Add(cap.c); } // remove the marked chests from our location ClearChestsInLocation(); // we make sure the order of the connected chests are in order of their chest type strings this.connectedChests.Sort((a, b) => (int.Parse(a.chestType.Value.Split(':')[1]).CompareTo(int.Parse(b.chestType.Value.Split(':')[1])))); // set selected chest this.selectedChest = this.connectedChests[0]; // setup button clickable texture const int fbscale = 2; this.remoteButton = new ClickableTextureComponent( new Rectangle(0, 0, ModEntry.FridgeTexture.Width * fbscale, ModEntry.FridgeTexture.Height * fbscale), ModEntry.FridgeTexture, new Rectangle(0, 0, ModEntry.FridgeTexture.Width, ModEntry.FridgeTexture.Height), fbscale, false); // setup button clickable texture this.remoteButtonTab = new ClickableTextureComponent( new Rectangle(0, 0, 64, 64), Game1.mouseCursors, new Rectangle(16, 368, 16, 16), 4f, false); // setup references in infinite storage FillReferences(); // setup callbacks for expanded fridge SetupEventCallbacks(); } }
public void UpdateChest() { _openChest = GetOpenChest(); }
public static ClipboardBuffer Load3(string filename, bool frame19 = false) { bool failed = false; try { using (var stream = new FileStream(filename, FileMode.Open)) { using (var br = new BinaryReader(stream)) { string name = br.ReadString(); int version = br.ReadInt32(); int sizeX = br.ReadInt32(); int sizeY = br.ReadInt32(); var buffer = new ClipboardBuffer(new Vector2Int32(sizeX, sizeY)); buffer.Name = name; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { var curTile = new Tile(); curTile.IsActive = br.ReadBoolean(); if (curTile.IsActive) { curTile.Type = br.ReadByte(); if (curTile.Type == (int)TileType.Platform) { curTile.U = 0; curTile.V = 0; if (frame19) { curTile.U = br.ReadInt16(); curTile.V = br.ReadInt16(); } } else if (World.TileProperties[curTile.Type].IsFramed) { curTile.U = br.ReadInt16(); curTile.V = br.ReadInt16(); if (curTile.Type == (int)TileType.Timer) { curTile.V = 0; } } else { curTile.U = -1; curTile.V = -1; } } if (br.ReadBoolean()) { curTile.Wall = br.ReadByte(); } if (br.ReadBoolean()) { curTile.LiquidType = LiquidType.Water; curTile.LiquidAmount = br.ReadByte(); if (br.ReadBoolean()) // lava byte { curTile.LiquidType = LiquidType.Lava; } } curTile.WireRed = br.ReadBoolean(); buffer.Tiles[x, y] = curTile; } } for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { if (br.ReadBoolean()) { var curChest = new Chest(br.ReadInt32(), br.ReadInt32()); for (int j = 0; j < 20; ++j) { curChest.Items[j].StackSize = br.ReadByte(); if (curChest.Items[j].StackSize > 0) { if (version >= 3) { curChest.Items[j].NetId = br.ReadInt32(); } else { curChest.Items[j].SetFromName(br.ReadString()); } curChest.Items[j].Prefix = br.ReadByte(); } else { curChest.Items[j].SetFromName("[empty]"); } } buffer.Chests.Add(curChest); } } for (int signIndex = 0; signIndex < 1000; signIndex++) { if (br.ReadBoolean()) { string text = br.ReadString(); int x = br.ReadInt32(); int y = br.ReadInt32(); buffer.Signs.Add(new Sign(x, y, text)); } } if (buffer.Name != br.ReadString() || version != br.ReadInt32() || buffer.Size.X != br.ReadInt32() || buffer.Size.Y != br.ReadInt32()) { if (!frame19) { br.Close(); return(Load3(filename, true)); } else { System.Windows.MessageBox.Show("Verification failed. Some schematic data may be missing.", "Legacy Schematic Version"); } } br.Close(); return(buffer); } } } catch (Exception) { failed = true; } if (failed && !frame19) { return(Load3(filename, true)); } return(null); }
// IEnumerator Teleport(Vector2 targetPos, float aTime) // { // float alpha = GetComponent<Renderer>().material.color.a; // //The character disappear // for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime) // { // Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 0f, t)); // GetComponent<Renderer>().material.color = newColor; // yield return null; // } // //Now me teleport it // transform.position = targetPos; // //Now it fades back to reality // for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime) { // Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 1f, t)); // GetComponent<Renderer>().material.color = newColor; // yield return null; // } // } //A method that handle doors : Return true if you can move on the tile, false otherwise. //If the door can be opened, opens it. //TO ADD : Levered Doors. private bool CollisionCheck(Vector2 targetCell) { Collider2D coll = WhatsThere(targetCell); //No obstacle, we can walk there if (coll == null) { return(true); } //If there's a door in front of the character if (coll.tag == "Door") { Door door = coll.gameObject.GetComponent <Door>(); //If the door is locked and we can unlock it if (door.isLocked) { if (goldKeyCount > 0) { AdjustKeys(-1); door.Unlock(); } return(false); } else if (door.isClosed) { door.Open(); return(true); } else if (!door.isClosed) //If it's already opened { return(true); } else //If it's locked. { return(false); } } // //if there's a levered door in front of the character. // else if (coll.tag == "LeveredDoor") // { // Debug.Log("LeveredDoor detected!"); // LeveredDoor door = coll.gameObject.GetComponent<LeveredDoor>(); // //If the door is open // if (door.isOpen) // return true; // //If the door is close. // else // return false; // } else if (coll.tag == "Chest") { Chest chest = coll.gameObject.GetComponent <Chest>(); // if (!chest.isUnlocked) { // chest.Unlock(); if (!chest.isOpened) { if (chest.isLocked) { if (GameManager.instance.currentGoldKeys > 0) { AdjustKeys(-1); chest.Unlock(); } else { GameMenu.instance.Notification("You need a key."); } } else if (!chest.isLocked) { chest.Open(); } } else if (!chest.isLooted) { chest.Loot(); } //We interact with the chest, but can't move there, so we return false. return(false); } else if (coll.tag == "Key") { return(true); } else if (coll.tag == "Transition") { return(true); } else if (coll.tag == "Enemy") { inBattle = true; return(false); } else { return(false); } }
public Chest BuyChest(int instanceId, Chest.ChestType type) { var chests = Csv.Tables.Get(Csv.Files.TreasureChests); var mainchest = chests.GetDataWithInstanceId <TreasureChests>(instanceId); var baseChest = chests.GetData <TreasureChests>(mainchest.BaseChest); var random = new Random(); var chest = new Chest { ChestId = instanceId, IsDraft = mainchest.DraftChest, Type = type }; // Common { if (type == Chest.ChestType.Shop) { for (var i = 0; i < random.Next(2, 5); i++) { if (random.Next(1, 2) == 1) { var card = Cards.Random(Card.Rarity.Common); card.Count = random.Next(50, 100); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } else { for (var i = 0; i < random.Next(2, 4); i++) { if (random.Next(1, 2) == 1) { var card = Cards.Random(Card.Rarity.Common); card.Count = random.Next(15, 25); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } } // Rare { if (type == Chest.ChestType.Shop) { for (var i = 0; i < random.Next(1, 4); i++) { if (random.Next(1, 2) == 1) { var card = Cards.Random(Card.Rarity.Rare); card.Count = random.Next(15, 35); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } else { for (var i = 0; i < random.Next(1, 2); i++) { if (random.Next(1, 4) == 1) { var card = Cards.Random(Card.Rarity.Rare); card.Count = random.Next(8, 18); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } } // Epic { if (type == Chest.ChestType.Shop) { for (var i = 0; i < random.Next(1, 2); i++) { if (random.Next(1, 3) == 1) { var card = Cards.Random(Card.Rarity.Epic); card.Count = random.Next(2, 10); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } else { if (random.Next(1, 20) == 1) { var card = Cards.Random(Card.Rarity.Epic); card.Count = random.Next(1, 5); card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } // Legendary { if (type == Chest.ChestType.Shop) { if (random.Next(1, 10) == 1) { var card = Cards.Random(Card.Rarity.Legendary); card.Count = 1; card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } else { if (random.Next(1, 50) == 1) { var card = Cards.Random(Card.Rarity.Legendary); card.Count = 1; card.IsNew = true; chest.Add(card); Home.Deck.Add(card); } } } if (type == Chest.ChestType.Shop) { // TODO: Cost if (random.Next(1, 5) == 1) { chest.Gems = random.Next(5, 15); } if (random.Next(1, 4) == 1) { chest.Gold = random.Next(100, 250); } } else { if (random.Next(1, 10) == 1) { chest.Gems = random.Next(1, 5); } if (random.Next(1, 8) == 1) { chest.Gold = random.Next(10, 75); } } Home.Gold += chest.Gold; Home.Diamonds += chest.Gems; /*var price = * ((baseChest.ShopPriceWithoutSpeedUp * Home.Arena.GetCurrentArenaData().ChestShopPriceMultiplier) / 100); * * Console.WriteLine(RoundPrice(price));*/ return(chest); }
public override void SetupShop(Chest shop, ref int nextSlot) { if (shop1) { Mod calamityMod = ModLoader.GetMod("CalamityMod"); shop.item[nextSlot].SetDefaults(ItemType <Items.Tiles.Statues.C>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); nextSlot++; Mod clamMod = ModLoader.GetMod("CalamityMod"); //this is to get calamity mod, you have to add 'weakReferences = [email protected]' (without the '') in your build.txt for this to work if (clamMod != null) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <WulfrumGlobe>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 10, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("LaboratoryConsoleItem")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <AgedRustGamingTable>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 15, 0, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <RustGamingTable>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 15, 0, 0); ++nextSlot; if ((bool)clamMod.Call("GetInZone", Main.player[Main.myPlayer], "sulphursea") || (bool)clamMod.Call("GetBossDowned", "acidrainscourge")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.SulphurGeyser>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 10, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.SulphurColumn>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 5, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Ribrod>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 50, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "giantclam")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.SunkenLamp>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 50, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.Anemone>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.BrainCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.FanCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.SSCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.BrainCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.TableCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 20, 0); ++nextSlot; } if (Main.hardMode == true) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.MonolithPot>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 95, 0); nextSlot++; } if ((bool)clamMod.Call("GetBossDowned", "acidrainscourge")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Items.Tiles.Plants.BelchingCoral>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); ++nextSlot; } if (NPC.downedPlantBoss || ((bool)clamMod.Call("GetBossDowned", "calamitas"))) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <VeilBanner>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 5, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "astrumaureus") && Main.expertMode) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <AstralOldPurple>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 0, 0, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModContent.ItemType <AstralOldYellow>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 0, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "providence")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Provibust>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 50, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "stormweaver")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Tesla>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 75, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "ceaselessvoid")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <VoidPortal>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 75, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "signus")) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <NetherTree>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 5, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "polterghast") && Main.expertMode) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <EidolonTree>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 50, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "oldduke") && Main.expertMode) { shop.item[nextSlot].SetDefaults(ModContent.ItemType <Help>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(76, 0, 0, 0); ++nextSlot; } } } else if (shop2) { Mod calamityMod = ModLoader.GetMod("CalamityMod"); Mod clamMod = ModLoader.GetMod("CalamityMod"); //this is to get calamity mod, you have to add 'weakReferences = [email protected]' (without the '') in your build.txt for this to work if (clamMod != null) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("LaboratoryPlating")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("LaboratoryPanels")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("HazardChevronPanels")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("RustedPlating")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("RustedPipes")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("LaboratoryPipePlating")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 25); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("SulphurousSandstone")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 35); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("HardenedSulphurousSandstone")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 50); ++nextSlot; if ((bool)clamMod.Call("GetBossDowned", "giantclam")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("EutrophicSand")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 5, 5); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("SmoothNavystone")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 2, 5); ++nextSlot; } if (NPC.downedBoss3) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("AbyssGravel")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 2, 5); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "slimegod")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("StatigelBlock")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 3, 5); ++nextSlot; } if (Main.hardMode == true) { shop.item[nextSlot].SetDefaults(ItemType <AstralGrass>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 10); nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("AstralMonolith")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 2, 5); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "brimstoneelemental")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("BrimstoneSlag")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 3, 5); ++nextSlot; } if (NPC.downedGolemBoss) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("Voidstone")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 10, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "plaguebringergoliath")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("PlaguedPlate")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 30, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ItemType <PlagueHiveWand>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 40, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ItemType <PlagueHiveWall>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 0, 10); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "ravager")) { shop.item[nextSlot].SetDefaults(ItemType <Necrostone>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 40, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "providence")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("UelibloomBrick")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 50, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("ProfanedRock")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 66, 66); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("ProfanedCrystal")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 66, 66); ++nextSlot; shop.item[nextSlot].SetDefaults(ItemType <ChiseledBloodstone>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 80, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "polterghast")) { shop.item[nextSlot].SetDefaults(ItemType <PhantowaxBlock>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 90, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ItemType <EidolicSlab>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("StratusBricks")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "devourerofgods")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("CosmiliteBrick")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); ++nextSlot; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("OccultStone")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "buffedmothron")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("CalamityMod").ItemType("SilvaCrystal")); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 5, 0, 0); ++nextSlot; } if ((bool)clamMod.Call("GetBossDowned", "yharon")) { shop.item[nextSlot].SetDefaults(ItemType <AuricBrick>()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 30, 0, 0); ++nextSlot; } } } }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 48, 32, mod.ItemType("RazewoodLantern")); Chest.DestroyChest(i, j); }
public override bool NewRightClick(int i, int j) { Player player = Main.LocalPlayer; Tile tile = Main.tile[i, j]; Main.mouseRightRelease = false; int left = i; int top = j; if (tile.frameX % 36 != 0) { left--; } if (tile.frameY != 0) { top--; } if (player.sign >= 0) { Main.PlaySound(SoundID.MenuClose); player.sign = -1; Main.editSign = false; Main.npcChatText = ""; } if (Main.editChest) { Main.PlaySound(SoundID.MenuTick); Main.editChest = false; Main.npcChatText = ""; } if (player.editedChestName) { NetMessage.SendData(33, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); player.editedChestName = false; } bool isLocked = IsLockedChest(left, top); if (Main.netMode == NetmodeID.MultiplayerClient && !isLocked) { if (left == player.chestX && top == player.chestY && player.chest >= 0) { player.chest = -1; Recipe.FindRecipes(); Main.PlaySound(SoundID.MenuClose); } else { NetMessage.SendData(31, -1, -1, null, left, top, 0f, 0f, 0, 0, 0); Main.stackSplit = 600; } } else { if (isLocked) { int key = ModContent.ItemType <Items.Usable.InfernoKey>(); if (player.ConsumeItem(key) && Chest.Unlock(left, top)) { if (Main.netMode == NetmodeID.MultiplayerClient) { NetMessage.SendData(MessageID.Unlock, -1, -1, null, player.whoAmI, 1f, left, top); } } } else { int chest = Chest.FindChest(left, top); if (chest >= 0) { Main.stackSplit = 600; if (chest == player.chest) { player.chest = -1; Main.PlaySound(SoundID.MenuClose); } else { player.chest = chest; Main.playerInventory = true; Main.recBigList = false; player.chestX = left; player.chestY = top; Main.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); } Recipe.FindRecipes(); } } } return(true); }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 32, 32, mod.ItemType("InfernoChest")); Chest.DestroyChest(i, j); }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 48, 32, mod.ItemType("DoomChandelier")); Chest.DestroyChest(i, j); }
public void recreateFighterItem(int x, int y, int i){ Item item; if(PlayerPrefs.GetString("Fighter Item type" + i) == "ManaPotion"){ item = new ManaPotion(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "HealthPotion"){ item = new HealthPotion(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Axe"){ item = new Axe(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Ring"){ item = new Ring(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Chest"){ item = new Chest(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Boots"){ item = new Boots(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Amulet"){ item = new Amulet(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Sword"){ item = new Sword(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } }
void Start() { chest = FindObjectOfType <Chest>(); isColliding = false; }
internal static void DestroyChest(int x, int y) => DestroyChest(Chest.FindChest(x, y), x, y);
public void GetName(string name) { var chest = new Chest(Vector.Zero, name, new Item[0]); Assert.That(chest.Name, Is.EqualTo(name)); }
public ChestCloseEvent(Player player, Chest chest, API.Server server) : base(chest, server) { Player = player; }
public void GetPosition(int x, int y) { var chest = new Chest(new Vector(x, y), "", new Item[0]); Assert.That(chest.Position, Is.EqualTo(new Vector(x, y))); }
public static ClipboardBuffer Load4(string filename) { using (var stream = new FileStream(filename, FileMode.Open)) { using (var b = new BinaryReader(stream)) { string name = b.ReadString(); int version = b.ReadInt32(); int sizeX = b.ReadInt32(); int sizeY = b.ReadInt32(); var buffer = new ClipboardBuffer(new Vector2Int32(sizeX, sizeY)); buffer.Name = name; for (int x = 0; x < sizeX; ++x) { for (int y = 0; y < sizeY; y++) { var tile = new Tile(); tile.IsActive = b.ReadBoolean(); TileProperty tileProperty = null; if (tile.IsActive) { tile.Type = b.ReadByte(); tileProperty = World.TileProperties[tile.Type]; if (tile.Type == (int)TileType.IceByRod) { tile.IsActive = false; } if (tileProperty.IsFramed) { tile.U = b.ReadInt16(); tile.V = b.ReadInt16(); if (tile.Type == (int)TileType.Timer) { tile.V = 0; } } else { tile.U = -1; tile.V = -1; } if (b.ReadBoolean()) { tile.TileColor = b.ReadByte(); } } if (b.ReadBoolean()) { tile.Wall = b.ReadByte(); if (b.ReadBoolean()) { tile.WallColor = b.ReadByte(); } } if (b.ReadBoolean()) { tile.LiquidType = LiquidType.Water; tile.LiquidAmount = b.ReadByte(); bool IsLava = b.ReadBoolean(); if (IsLava) { tile.LiquidType = LiquidType.Lava; } bool IsHoney = b.ReadBoolean(); if (IsHoney) { tile.LiquidType = LiquidType.Honey; } } tile.WireRed = b.ReadBoolean(); tile.WireGreen = b.ReadBoolean(); tile.WireBlue = b.ReadBoolean(); bool isHalfBrick = b.ReadBoolean(); var brickByte = b.ReadByte(); if (tileProperty == null || !tileProperty.HasSlopes) { tile.BrickStyle = 0; } else { tile.BrickStyle = (BrickStyle)brickByte; } tile.Actuator = b.ReadBoolean(); tile.InActive = b.ReadBoolean(); // read complete, start compression buffer.Tiles[x, y] = tile; int rle = b.ReadInt16(); if (rle < 0) { throw new ApplicationException("Invalid Tile Data!"); } if (rle > 0) { for (int k = y + 1; k < y + rle + 1; k++) { var tcopy = (Tile)tile.Clone(); buffer.Tiles[x, k] = tcopy; } y = y + rle; } } } for (int i = 0; i < 1000; i++) { if (b.ReadBoolean()) { var chest = new Chest(b.ReadInt32(), b.ReadInt32()); for (int slot = 0; slot < Chest.MaxItems; slot++) { if (slot < Chest.MaxItems) { int stackSize = (int)b.ReadInt16(); chest.Items[slot].StackSize = stackSize; if (chest.Items[slot].StackSize > 0) { chest.Items[slot].NetId = b.ReadInt32(); chest.Items[slot].StackSize = stackSize; chest.Items[slot].Prefix = b.ReadByte(); } } } buffer.Chests.Add(chest); } } for (int i = 0; i < 1000; i++) { if (b.ReadBoolean()) { Sign sign = new Sign(); sign.Text = b.ReadString(); sign.X = b.ReadInt32(); sign.Y = b.ReadInt32(); if (buffer.Tiles[sign.X, sign.Y].IsActive && Tile.IsSign(buffer.Tiles[sign.X, sign.Y].Type)) { buffer.Signs.Add(sign); } } } string verifyName = b.ReadString(); int verifyVersion = b.ReadInt32(); int verifyX = b.ReadInt32(); int verifyY = b.ReadInt32(); if (buffer.Name == verifyName && version == verifyVersion && buffer.Size.X == verifyX && buffer.Size.Y == verifyY) { // valid; return(buffer); } b.Close(); return(null); } } }
public override void PostWorldGen() { oretypesprehardmode[0] = WorldGen.CopperTierOre; oretypesprehardmode[1] = WorldGen.IronTierOre; oretypesprehardmode[2] = WorldGen.SilverTierOre; oretypesprehardmode[3] = WorldGen.GoldTierOre; oretypeshardmode[0] = WorldGen.oreTier1; oretypeshardmode[1] = WorldGen.oreTier2; oretypeshardmode[2] = WorldGen.oreTier3; int[] itemsToPlaceInOvergrownChestsSecond = new int[] { mod.ItemType(WorldGen.crimson ? "ForagersBlade" : "RustworkBlade"), mod.ItemType(WorldGen.crimson ? "GuerrillaPistol" : "RustyRifle"), mod.ItemType("AversionCharm"), mod.ItemType("RustedBulwark") }; int itemsToPlaceInOvergrownChestsChoiceSecond = 0; List <Chest> Chests = Main.chest.Where(checkfor => checkfor != null).ToList(); Chests = Chests.OrderBy(orderBy => WorldGen.genRand.Next(0, 100) + (Main.tile[orderBy.x, orderBy.y].frameX / 36 == 13 ? 0 : 10000)).ToList(); for (int i = 0; i < WorldGen.genRand.Next(2, 4); i += 1) { if (Chests.Count > 0) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (Chests[0].item[inventoryIndex].IsAir) { Chests[0].item[inventoryIndex].SetDefaults(mod.ItemType("StarCollector")); Chests[0].item[inventoryIndex].stack = 1; break; } } Chests.RemoveAt(0); } } Chests = Chests.OrderBy(orderBy => WorldGen.genRand.Next(0, 100) + (Main.tile[orderBy.x, orderBy.y].frameX / 36 == 17 ? 0 : 10000)).ToList(); for (int i = 0; i < WorldGen.genRand.Next(3, 6); i += 1) { if (Chests.Count > 0) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (Chests[0].item[inventoryIndex].IsAir && Main.tile[Chests[0].x, Chests[0].y].frameX / 36 == 17) { Chests[0].item[inventoryIndex].SetDefaults(mod.ItemType("BottledLiquidEssence")); Chests[0].item[inventoryIndex].stack = 1; break; } } Chests.RemoveAt(0); } } for (int chestIndexx = 0; chestIndexx < 1000; chestIndexx++) { Chest chest = Main.chest[chestIndexx]; if (chest != null && (WorldGen.genRand.Next(0, 100) < 25) && ((WorldGen.genRand.Next(0, 100) < 25 && TileLoader.GetTile(Main.tile[chest.x, chest.y].type) == null) || Main.tile[chest.x, chest.y].wall == mod.WallType("SwampWall"))) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (chest.item[inventoryIndex].IsAir) { itemsToPlaceInOvergrownChestsChoiceSecond = Main.rand.Next(itemsToPlaceInOvergrownChestsSecond.Length); chest.item[inventoryIndex].SetDefaults(itemsToPlaceInOvergrownChestsSecond[itemsToPlaceInOvergrownChestsChoiceSecond]); break; } } } } for (int i = 0; i < 3; i++) { itemsToPlaceInOvergrownChestsSecond = new int[] { mod.ItemType("DecayedMoss"), mod.ItemType("DecayedMoss"), mod.ItemType("DecayedMoss"), mod.ItemType("DecayedMoss"), mod.ItemType("Biomass"), mod.ItemType("Biomass") }; itemsToPlaceInOvergrownChestsChoiceSecond = 0; for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { Chest chest = Main.chest[chestIndex]; if (i == 0 && chest != null) { if (WorldGen.genRand.Next(0, 100) < (Main.tile[chest.x, chest.y].frameX / 36 == 17 ? 50 : (Main.tile[chest.x, chest.y].frameX / 36 == 1 ? 15 : Main.tile[chest.x, chest.y].frameX / 36 == 0 ? 10 : 5))) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (chest.item[inventoryIndex].IsAir) { chest.item[inventoryIndex].SetDefaults(mod.ItemType("PocketRocks")); chest.item[inventoryIndex].stack = 1; break; } } } if (Main.tile[chest.x, chest.y].frameX / 36 == 50 || Main.tile[chest.x, chest.y].frameX / 36 == 51) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (chest.item[inventoryIndex].IsAir) { chest.item[inventoryIndex].SetDefaults(Main.tile[chest.x, chest.y].frameX / 36 == 51 ? mod.ItemType("CrackedMirror") : mod.ItemType("GraniteMagnet")); chest.item[inventoryIndex].stack = 1; break; } } } } if (chest != null && (WorldGen.genRand.Next(0, 100) < 15 || Main.tile[chest.x, chest.y - 1].wall == mod.TileType("SwampWall"))) { if (WorldGen.genRand.Next(0, 100) < 5) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { if (chest.item[inventoryIndex].IsAir) { chest.item[inventoryIndex].SetDefaults(WorldGen.genRand.Next(0, 2) == 0 ? mod.ItemType("DragonsMightPotion") : mod.ItemType("TimePotion")); chest.item[inventoryIndex].stack = WorldGen.genRand.Next(1, Main.rand.Next(1, 3)); break; } } } for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { //mod.ItemType("DragonsMightPotion"), mod.ItemType("TimePotion"), if (chest.item[inventoryIndex].IsAir) { itemsToPlaceInOvergrownChestsChoiceSecond = WorldGen.genRand.Next(itemsToPlaceInOvergrownChestsSecond.Length); chest.item[inventoryIndex].SetDefaults(itemsToPlaceInOvergrownChestsSecond[itemsToPlaceInOvergrownChestsChoiceSecond]); chest.item[inventoryIndex].stack = WorldGen.genRand.Next(3, 4 + WorldGen.genRand.Next(6)); break; } } } } } }
public static ClipboardBuffer Load2(string filename) { using (var stream = new FileStream(filename, FileMode.Open)) { using (var reader = new BinaryReader(stream)) { string name = reader.ReadString(); int version = reader.ReadInt32(); int maxx = reader.ReadInt32(); int maxy = reader.ReadInt32(); var buffer = new ClipboardBuffer(new Vector2Int32(maxx, maxy)); buffer.Name = string.IsNullOrWhiteSpace(name) ? Path.GetFileNameWithoutExtension(filename) : name; try { for (int x = 0; x < maxx; x++) { for (int y = 0; y < maxy; y++) { var curTile = new Tile(); curTile.IsActive = reader.ReadBoolean(); if (curTile.IsActive) { curTile.Type = reader.ReadByte(); if (curTile.Type == (int)TileType.Platform) { curTile.U = 0; curTile.V = 0; } else if (World.TileProperties[curTile.Type].IsFramed) { curTile.U = reader.ReadInt16(); curTile.V = reader.ReadInt16(); if (curTile.Type == (int)TileType.Timer) { curTile.V = 0; } } else { curTile.U = -1; curTile.V = -1; } } if (reader.ReadBoolean()) { curTile.Wall = reader.ReadByte(); } if (reader.ReadBoolean()) { curTile.LiquidAmount = reader.ReadByte(); bool lava = reader.ReadBoolean(); curTile.LiquidType = lava ? LiquidType.Lava : LiquidType.Water; } curTile.WireRed = reader.ReadBoolean(); buffer.Tiles[x, y] = curTile; } } } catch (Exception) { for (int x = 0; x < buffer.Size.X; x++) { for (int y = 0; y < buffer.Size.Y; y++) { if (buffer.Tiles[x, y] == null) { buffer.Tiles[x, y] = new Tile(); } } } return(buffer); } for (int chestIndex = 0; chestIndex < 1000; chestIndex++) { if (reader.ReadBoolean()) { var chest = new Chest(); chest.X = reader.ReadInt32(); chest.Y = reader.ReadInt32(); for (int slot = 0; slot < 20; slot++) { byte stackSize = reader.ReadByte(); if (stackSize > 0) { string itemName = reader.ReadString(); chest.Items[slot].SetFromName(itemName); chest.Items[slot].StackSize = stackSize; } } //Chests[chestIndex] = chest; buffer.Chests.Add(chest); } } for (int signIndex = 0; signIndex < 1000; signIndex++) { if (reader.ReadBoolean()) { string signText = reader.ReadString(); int x = reader.ReadInt32(); int y = reader.ReadInt32(); if (buffer.Tiles[x, y].IsActive && Tile.IsSign(buffer.Tiles[x, y].Type)) // validate tile location { var sign = new Sign(x, y, signText); //Signs[signIndex] = sign; buffer.Signs.Add(sign); } } } string checkName = reader.ReadString(); int checkversion = reader.ReadInt32(); int checkx = reader.ReadInt32(); int checky = reader.ReadInt32(); if (checkName != buffer.Name || checkversion != version || checkx != maxx || checky != maxy) { System.Windows.MessageBox.Show("Verification failed. Some schematic data may be missing.", "Legacy Schematic Version"); } return(buffer); } } }
void GetChest(int x, int y, int plr) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Account, BankID, Flags, ID, Items, Password, RefillTime FROM Chests WHERE X = @0 AND Y = @1 AND WorldID = @2", x, y, Main.worldID)) { if (reader.Read()) { chest = new Chest { Account = reader.Get<string>("Account"), BankID = reader.Get<int>("BankID"), Flags = (ChestFlags)reader.Get<int>("Flags"), ID = reader.Get<int>("ID"), Items = reader.Get<string>("Items"), HashedPassword = reader.Get<string>("Password"), RefillTime = reader.Get<int>("RefillTime") }; } } using (QueryResult reader = Database.QueryReader("SELECT Items FROM BankChests WHERE Account = @0 AND BankID = @1", chest.Account, chest.BankID)) { if (reader.Read()) chest.Items = reader.Get<string>("Items"); } var info = Infos[plr]; TSPlayer player = TShock.Players[plr]; if (chest != null) { switch (info.Action) { case ChestAction.GetInfo: player.SendInfoMessage("X: {0} Y: {1} Account: {2} {3}Bank: {4} Refill: {5} ({6} second{7}) Region: {8}", x, y, chest.Account ?? "N/A", chest.Flags.HasFlag(ChestFlags.Public) ? "(public) " : "", chest.BankID, chest.Flags.HasFlag(ChestFlags.Refill), chest.RefillTime, chest.RefillTime == 1 ? "" : "s", chest.Flags.HasFlag(ChestFlags.Region)); break; case ChestAction.Protect: if (!String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is already protected."); break; } Database.Query("UPDATE Chests SET Account = @0 WHERE ID = @1", player.User.Name, chest.ID); player.SendSuccessMessage("This chest is now protected."); break; case ChestAction.TogglePublic: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } Database.Query("UPDATE Chests SET Flags = ((~(Flags & 1)) & (Flags | 1)) WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest is now p{0}.", chest.IsPublic ? "rivate" : "ublic"); break; case ChestAction.ToggleRegion: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } Database.Query("UPDATE Chests SET Flags = ((~(Flags & 2)) & (Flags | 2)) WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest is no{0} region shared.", chest.IsRegion ? " longer" : "w"); break; case ChestAction.SetBank: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } if (info.BankID == -1) { Database.Query("UPDATE Chests SET BankID = 0, Flags = Flags & 7 WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest is no longer a bank chest.", chest.BankID); } else { bool exists = false; using (var reader = Database.QueryReader("SELECT * FROM BankChests WHERE Account = @0 AND BankID = @1", chest.Account, info.BankID)) { exists = reader.Read(); } if (!exists) { Database.Query("INSERT INTO BankChests (Account, BankID, Items) VALUES (@0, @1, @2)", chest.Account, info.BankID, "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," + "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"); } Database.Query("UPDATE Chests SET BankID = @0, Flags = Flags | 8 WHERE ID = @1", info.BankID, chest.ID); player.SendSuccessMessage("This chest is now bank ID {0}.", info.BankID); } break; case ChestAction.SetPassword: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } if (String.Equals(info.Password, "remove", StringComparison.CurrentCultureIgnoreCase)) { Database.Query("UPDATE Chests SET Password = '' WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest is no longer password protected.", info.Password); } else { Database.Query("UPDATE Chests SET Password = @0 WHERE ID = @1", TShock.Utils.HashPassword(info.Password), chest.ID); player.SendSuccessMessage("This chest is now password protected with password '{0}'.", info.Password); } break; case ChestAction.SetRefill: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } if (info.RefillTime > 0) { Database.Query("UPDATE Chests SET Flags = Flags | 4, RefillTime = @0 WHERE ID = @1", info.RefillTime, chest.ID); player.SendSuccessMessage("This chest will now refill with a delay of {0} second{1}.", info.RefillTime, info.RefillTime == 1 ? "" : "s"); } else { Database.Query("UPDATE Chests SET Flags = (~(Flags & 4)) & (Flags | 4) WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest will no{0} refill.", chest.IsRefill ? " longer" : "w"); } break; case ChestAction.Unprotect: if (String.IsNullOrEmpty(chest.Account)) { player.SendErrorMessage("This chest is not protected."); break; } if (chest.Account != player.User.Name && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is not yours."); break; } Database.Query("UPDATE Chests SET Account = NULL, BankID = 0, Flags = 0 WHERE ID = @0", chest.ID); player.SendSuccessMessage("This chest is now un-protected."); break; default: #if !MULTI_USE if (Infos.Any(p => p.X == x && p.Y == y)) { player.SendErrorMessage("This chest is already in use."); return; } #endif bool isFree = String.IsNullOrEmpty(chest.Account); bool isOwner = chest.Account == player.User.Name || player.Group.HasPermission("infchests.admin.editall"); bool isRegion = chest.IsRegion && TShock.Regions.CanBuild(x, y, player); if (!isFree && !isOwner && !chest.IsPublic && !isRegion) { if (String.IsNullOrEmpty(chest.HashedPassword)) { player.SendErrorMessage("This chest is protected."); break; } else if (TShock.Utils.HashPassword(info.Password) != chest.HashedPassword) { player.SendErrorMessage("This chest is password protected."); break; } else { player.SendSuccessMessage("Chest unlocked."); info.Password = ""; } } lock (Timers) { int timeLeft; if (Timers.TryGetValue(new Point(x, y), out timeLeft) && timeLeft > 0) { player.SendErrorMessage("This chest will refill in {0} second{1}.", timeLeft, timeLeft == 1 ? "" : "s"); break; } } int[] itemArgs = new int[120]; string[] split = chest.Items.Split(','); for (int i = 0; i < 120; i++) itemArgs[i] = Convert.ToInt32(split[i]); byte[] raw = new byte[] { 11, 0, 32, 0, 0, 255, 255, 255, 255, 255, 255 }; for (int i = 0; i < 40; i++) { raw[5] = (byte)i; raw[6] = (byte)itemArgs[i * 3 + 1]; raw[7] = (byte)(itemArgs[i * 3 + 1] >> 8); raw[8] = (byte)itemArgs[i * 3 + 2]; raw[9] = (byte)itemArgs[i * 3]; raw[10] = (byte)(itemArgs[i * 3] >> 8); player.SendRawData(raw); } byte[] raw2 = new byte[] { 10, 0, 33, 0, 0, 255, 255, 255, 255, 0 }; Buffer.BlockCopy(BitConverter.GetBytes((short)x), 0, raw2, 5, 2); Buffer.BlockCopy(BitConverter.GetBytes((short)y), 0, raw2, 7, 2); player.SendRawData(raw2); player.SendData(PacketTypes.ChestName, "", 0, x, y); info.X = x; info.Y = y; break; } info.Action = ChestAction.None; } else player.SendErrorMessage("This chest is corrupted. Please destroy it."); }
public virtual void rebuild(Dictionary <string, string> additionalSaveData, object replacement) { Chest chest = (Chest)replacement; }
void ModChest(int plr, byte slot, int ID, int stack, byte prefix) { lock (Database) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Account, BankID, Flags, ID, Items, RefillTime FROM Chests WHERE X = @0 AND Y = @1 AND WorldID = @2", Infos[plr].X, Infos[plr].Y, Main.worldID)) { if (reader.Read()) { chest = new Chest { Account = reader.Get<string>("Account"), BankID = reader.Get<int>("BankID"), Flags = (ChestFlags)reader.Get<int>("Flags"), ID = reader.Get<int>("ID"), Items = reader.Get<string>("Items"), RefillTime = reader.Get<int>("RefillTime") }; } } TSPlayer player = TShock.Players[plr]; if (player == null) { DecrementTransactions(plr); return; } if (chest == null) { DecrementTransactions(plr); player.SendErrorMessage("This chest is corrupted. Please remove it."); return; } if (chest.IsBank) { using (QueryResult reader = Database.QueryReader("SELECT Items FROM BankChests WHERE Account = @0 AND BankID = @1", chest.Account, chest.BankID)) { if (reader.Read()) chest.Items = reader.Get<string>("Items"); else { DecrementTransactions(plr); player.SendErrorMessage("This bank chest was corrupted."); return; } } } var info = Infos[plr]; if (chest.IsRefill) { lock (Timers) { if (!Timers.ContainsKey(new Point(info.X, info.Y))) Timers.Add(new Point(info.X, info.Y), chest.RefillTime); } } else { int[] itemArgs = new int[120]; string[] split = chest.Items.Split(','); for (int i = 0; i < 120; i++) itemArgs[i] = Convert.ToInt32(split[i]); itemArgs[slot * 3] = ID; itemArgs[slot * 3 + 1] = stack; itemArgs[slot * 3 + 2] = prefix; StringBuilder newItems = new StringBuilder(); for (int i = 0; i < 120; i++) newItems.Append(itemArgs[i]).Append(","); if (chest.IsBank) { Database.Query("UPDATE BankChests SET Items = @0 WHERE Account = @1 AND BankID = @2", newItems.ToString(0, newItems.Length - 1), chest.Account, chest.BankID); } else { Database.Query("UPDATE Chests SET Items = @0 WHERE ID = @1", newItems.ToString(0, newItems.Length - 1), chest.ID); #if MULTI_USE byte[] raw = new byte[] { 11, 0, 32, 0, 0, slot, (byte)stack, (byte)(stack >> 8), prefix, (byte)ID, (byte)(ID >> 8) }; foreach (int i in Infos.Where(i => i.X == info.X && i.Y == info.Y && i != info).Select(i => i.Index)) TShock.Players[i].SendRawData(raw); #endif } } DecrementTransactions(plr); } }
public override void SetupShop(int type, Chest shop, ref int nextSlot) { if (ModLoader.GetLoadedMods().Contains("Tremor")) { if (type == ModLoader.GetMod("Tremor").NPCType("Lady Moon")) { shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("DarkMass")); shop.item[nextSlot].shopCustomPrice = 7500; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("CarbonSteel")); shop.item[nextSlot].shopCustomPrice = 10000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("Doomstone")); shop.item[nextSlot].shopCustomPrice = 25000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("NightmareBar")); shop.item[nextSlot].shopCustomPrice = 25000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("VoidBar")); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("AngryShard")); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("Phantaplasm")); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("ClusterShard")); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("DragonCapsule")); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("HuskofDusk")); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("NightCore")); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("GoldenClaw")); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("StoneDice")); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("ConcentratedEther")); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("Squorb")); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("ToothofAbraxas")); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("CosmicFuel")); shop.item[nextSlot].shopCustomPrice = 1000000; nextSlot++; shop.item[nextSlot].SetDefaults(ModLoader.GetMod("Tremor").ItemType("EyeofOblivion")); shop.item[nextSlot].shopCustomPrice = 3000000; nextSlot++; } } }
internal void Apply(Player player = null) { foreach (var kv in changedTiles) { var k = kv.Key; var x = k >> 16; var y = k & 0xffff; var t = kv.Value; if (t >= 0) { Main.tile.data[x, y] = tiles[t]; } } foreach (var eff in sideEffects) { if (eff == null || eff.Cancel) { continue; } switch (eff.EffectType) { case SideEffectType.ADD_WATER: { Terraria_Server.Liquid.AddWater(null, null, eff.X, eff.Y); //Applying => Normal Tile References break; } case SideEffectType.SMASH_SHADOW_ORB: { WorldModify.shadowOrbSmashed = true; WorldModify.shadowOrbCount++; if (WorldModify.shadowOrbCount >= 3) { WorldModify.shadowOrbCount = 0; var ctx = new HookContext { Connection = player.Connection, Sender = player, Player = player, }; var args = new HookArgs.PlayerTriggeredEvent { X = (int)(player.Position.X / 16), Y = (int)(player.Position.Y / 16), Type = WorldEventType.BOSS, Name = "Eater of Worlds", }; HookPoints.PlayerTriggeredEvent.Invoke(ref ctx, ref args); if (!ctx.CheckForKick() && ctx.Result != HookResult.IGNORE) { //ProgramLog.Users.Log ("{0} @ {1}: Eater of Worlds summoned by {2}.", player.IPAddress, player.whoAmi, player.Name); //NetMessage.SendData (Packet.PLAYER_CHAT, -1, -1, string.Concat (player.Name, " has summoned the Eater of Worlds!"), 255, 255, 128, 150); NPC.SpawnOnPlayer(player.whoAmi, (int)NPCType.N13_EATER_OF_WORLDS_HEAD); } } else { string text = "A horrible chill goes down your spine..."; if (WorldModify.shadowOrbCount == 2) { text = "Screams echo around you..."; } NetMessage.SendData(25, -1, -1, text, 255, 50f, 255f, 130f, 0); } break; } case SideEffectType.NEW_ITEM: { Item.NewItem(eff.X, eff.Y, eff.Width, eff.Height, eff.Type, eff.Stack, eff.NoBroadcast); break; } case SideEffectType.KILL_SIGN: { Sign.KillSign(eff.X, eff.Y); break; } case SideEffectType.DESTROY_CHEST: { Chest.DestroyChest(eff.X, eff.Y); break; } case SideEffectType.FALLING_BLOCK_PROJECTILE: { int p = Projectile.NewProjectile((float)(eff.X * 16 + 8), (float)(eff.Y * 16 + 8), 0f, 0.41f, eff.Type, 10, 0f, 255); var proj = Main.projectile[p]; proj.Creator = player; proj.Velocity.Y = 0.5f; proj.Position.Y += 2f; proj.ai[0] = 1f; NetMessage.SendTileSquare(-1, eff.X, eff.Y, 1); break; } } } }
private void CreateWorld() { Texture2D tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset1"); Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 32, 32); tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset2"); Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32); MapLayer layer = new MapLayer(100, 100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0, 100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x, y, tile); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); TileMap map = new TileMap(tileset1, layer); map.AddTileset(tileset2); map.AddLayer(splatter); Level level = new Level(map); ChestData chestData = Game.Content.Load<ChestData>(@"Game\Chests\Plain Chest"); Chest chest = new Chest(chestData); BaseSprite chestSprite = new BaseSprite( containers, new Rectangle(0, 0, 32, 32), new Point(10, 10)); ItemSprite itemSprite = new ItemSprite( chest, chestSprite); level.Chests.Add(itemSprite); World world = new World(GameRef, GameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
void GetChest(int X, int Y, int plr) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Account, Flags, Items, Password FROM Chests WHERE X = @0 AND Y = @1 and WorldID = @2", X, Y, Main.worldID)) { if (reader.Read()) { chest = new Chest { account = reader.Get<string>("Account"), flags = (ChestFlags)reader.Get<int>("Flags"), items = reader.Get<string>("Items"), password = reader.Get<string>("Password") }; } } TSPlayer player = TShock.Players[plr]; if (chest != null) { switch (Infos[plr].action) { case ChestAction.INFO: player.SendMessage(string.Format("X: {0} Y: {1} Account: {2} {3}Refill: {4} ({5} second{6}) Region: {7}", X, Y, chest.account == "" ? "N/A" : chest.account, ((chest.flags & ChestFlags.PUBLIC) != 0) ? "(public) " : "", (chest.flags & ChestFlags.REFILL) != 0, (int)chest.flags / 8, (int)chest.flags / 8 == 1 ? "" : "s", (chest.flags & ChestFlags.REGION) != 0), Color.Yellow); break; case ChestAction.PROTECT: if (chest.account != "") { player.SendMessage("This chest is already protected.", Color.Red); break; } Database.Query("UPDATE Chests SET Account = @0 WHERE X = @1 AND Y = @2 AND WorldID = @3", player.UserAccountName, X, Y, Main.worldID); player.SendMessage("This chest is now protected.", Color.Green); break; case ChestAction.PUBLIC: if (chest.account == "") { player.SendMessage("This chest is not protected.", Color.Red); break; } if (chest.account != player.UserAccountName) { player.SendMessage("This chest is not yours.", Color.Red); break; } Database.Query("UPDATE Chests SET Flags = ((~(Flags & 1)) & (Flags | 1)) WHERE X = @0 AND Y = @1 AND WorldID = @2", X, Y, Main.worldID); player.SendMessage(string.Format("This chest is now {0}.", (chest.flags & ChestFlags.PUBLIC) != 0 ? "private" : "public"), Color.Green); break; case ChestAction.REFILL: if (chest.account != player.UserAccountName && chest.account != "") { player.SendMessage("This chest is not yours.", Color.Red); break; } if (Infos[plr].time > 0) { Database.Query("UPDATE Chests SET Flags = @0 WHERE X = @1 AND Y = @2 AND WorldID = @3", ((int)chest.flags & 3) + (Infos[plr].time * 8) + 4, X, Y, Main.worldID); player.SendMessage(string.Format("This chest will now refill with a delay of {0} second{1}.", Infos[plr].time, Infos[plr].time == 1 ? "" : "s"), Color.Green); } else { Database.Query("UPDATE Chests SET Flags = ((~(Flags & 4)) & (Flags | 4)) & 7 WHERE X = @0 AND Y = @1 AND WorldID = @2", X, Y, Main.worldID); player.SendMessage(string.Format("This chest will {0} refill.", (chest.flags & ChestFlags.REFILL) != 0 ? "no longer" : "now"), Color.Green); } break; case ChestAction.REGION: if (chest.account == "") { player.SendMessage("This chest is not protected.", Color.Red); break; } if (chest.account != player.UserAccountName) { player.SendMessage("This chest is not yours.", Color.Red); break; } Database.Query("UPDATE Chests SET Flags = ((~(Flags & 2)) & (Flags | 2)) WHERE X = @0 AND Y = @1 AND WorldID = @2", X, Y, Main.worldID); player.SendMessage(string.Format("This chest is {0} region shared.", (chest.flags & ChestFlags.REGION) != 0 ? "no longer" : "now"), Color.Green); break; case ChestAction.SETPASS: if (chest.account == "") { player.SendMessage("This chest is not protected.", Color.Red); break; } if (chest.account != player.UserAccountName) { player.SendMessage("This chest is not yours.", Color.Red); break; } Database.Query("UPDATE Chests SET Password = @0 WHERE X = @1 AND Y = @2 AND WorldID = @3", TShock.Utils.HashPassword(Infos[plr].password), X, Y, Main.worldID); player.SendMessage("This chest is now password protected.", Color.Green); break; case ChestAction.UNPROTECT: if (chest.account == "") { player.SendMessage("This chest is not protected.", Color.Red); break; } if (chest.account != player.UserAccountName && !player.Group.HasPermission("removechestprotection")) { player.SendMessage("This chest is not yours.", Color.Red); break; } Database.Query("UPDATE Chests SET Account = '' WHERE X = @0 AND Y = @1 AND WorldID = @2", X, Y, Main.worldID); player.SendMessage("This chest is now un-protected.", Color.Green); break; default: bool isFree = chest.account == ""; bool isOwner = chest.account == player.UserAccountName || player.Group.HasPermission("openallchests"); bool isPub = (chest.flags & ChestFlags.PUBLIC) == ChestFlags.PUBLIC; bool isRegion = (chest.flags & ChestFlags.REGION) == ChestFlags.REGION && TShock.Regions.CanBuild(X, Y, player); if (!isFree && !isOwner && !isPub && !isRegion) { if (String.IsNullOrEmpty(chest.password)) { player.SendMessage("This chest is protected.", Color.Red); break; } else if (TShock.Utils.HashPassword(Infos[plr].password) != chest.password) { player.SendMessage("This chest is password protected.", Color.Red); break; } else { player.SendMessage("Chest unlocked.", Color.Green); Infos[plr].password = ""; } } if (Infos.Any(p => p.x == X && p.y == Y)) { player.SendMessage("This chest is in use.", Color.Red); break; } int timeLeft; if (Timer.TryGetValue(new Point(X, Y), out timeLeft) && timeLeft > 0) { player.SendMessage(string.Format("This chest will refill in {0} second{1}.", timeLeft, timeLeft == 1 ? "" : "s"), Color.Red); break; } int[] itemArgs = new int[60]; string[] split = chest.items.Split(','); for (int i = 0; i < 60; i++) { itemArgs[i] = Convert.ToInt32(split[i]); } byte[] raw = new byte[] { 8, 0, 0, 0, 32, 0, 0, 255, 255, 255, 255, 255 }; for (int i = 0; i < 20; i++) { raw[7] = (byte)i; raw[8] = (byte)itemArgs[i * 3 + 1]; raw[9] = (byte)itemArgs[i * 3 + 2]; raw[10] = (byte)itemArgs[i * 3]; raw[11] = (byte)(itemArgs[i * 3] >> 8); player.SendRawData(raw); } byte[] raw2 = new byte[] { 11, 0, 0, 0, 33, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255 }; Buffer.BlockCopy(BitConverter.GetBytes(X), 0, raw2, 7, 4); Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, raw2, 11, 4); player.SendRawData(raw2); Infos[plr].x = X; Infos[plr].y = Y; break; } Infos[plr].action = ChestAction.NONE; } }
void KillChest(int x, int y, int plr) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Account, Flags, ID, Items FROM Chests WHERE X = @0 AND Y = @1 AND WorldID = @2", x, y, Main.worldID)) { if (reader.Read()) { chest = new Chest { Account = reader.Get<string>("Account"), ID = reader.Get<int>("ID"), Flags = (ChestFlags)reader.Get<int>("Flags"), Items = reader.Get<string>("Items") }; } } TSPlayer player = TShock.Players[plr]; if (chest == null) { WorldGen.KillTile(x, y); TSPlayer.All.SendData(PacketTypes.Tile, "", 0, x, y + 1); } else if (chest.Account != player.User.Name && !String.IsNullOrEmpty(chest.Account) && !player.Group.HasPermission("infchests.admin.editall")) { player.SendErrorMessage("This chest is protected."); player.SendTileSquare(x, y, 3); } else if (chest.IsBank) { player.SendErrorMessage("This chest is a bank chest."); player.SendTileSquare(x, y, 3); } else if (chest.Items != "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," + "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") { player.SendTileSquare(x, y, 3); } else { WorldGen.KillTile(x, y); Database.Query("DELETE FROM Chests WHERE ID = @0", chest.ID); TSPlayer.All.SendData(PacketTypes.Tile, "", 0, x, y + 1); } }
void ModChest(int plr, byte slot, int ID, byte stack, byte prefix) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Flags, Items FROM Chests WHERE X = @0 AND Y = @1 AND WorldID = @2", Infos[plr].x, Infos[plr].y, Main.worldID)) { if (reader.Read()) { chest = new Chest { flags = (ChestFlags)reader.Get<int>("Flags"), items = reader.Get<string>("Items") }; } } TSPlayer player = TShock.Players[plr]; if (chest != null) { if ((chest.flags & ChestFlags.REFILL) != 0) { if (!Timer.ContainsKey(new Point(Infos[plr].x, Infos[plr].y))) { Timer.Add(new Point(Infos[plr].x, Infos[plr].y), (int)chest.flags >> 3); } } else { int[] itemArgs = new int[60]; string[] split = chest.items.Split(','); for (int i = 0; i < 60; i++) { itemArgs[i] = Convert.ToInt32(split[i]); } itemArgs[slot * 3] = ID; itemArgs[slot * 3 + 1] = stack; itemArgs[slot * 3 + 2] = prefix; StringBuilder newItems = new StringBuilder(); for (int i = 0; i < 60; i++) { newItems.Append(itemArgs[i]); if (i != 59) { newItems.Append(','); } } Database.Query("UPDATE Chests SET Items = @0 WHERE X = @1 AND Y = @2 AND WorldID = @3", newItems.ToString(), Infos[plr].x, Infos[plr].y, Main.worldID); for (int i = 0; i < 256; i++) { if (Infos[i].x == Infos[plr].x && Infos[i].y == Infos[plr].y && i != plr) { byte[] raw = new byte[] { 8, 0, 0, 0, 32, 0, 0, slot, stack, prefix, (byte)ID, (byte)(ID >> 8) }; TShock.Players[i].SendRawData(raw); } } } } }
/// <summary> /// Get task /// </summary> /// <param name="dataRaw"></param> /// <returns></returns> List<Task> GetTasks(List<string> dataRaw) { var data = ProblemSolverHelper.ConvertToDataLists<string>(dataRaw); int count = int.Parse(data[0][0]); List<Task> tasks = new List<Task>(count); for (int i = 1; i < data.Count; i++) { int startKeysCount = int.Parse(data[i][0]); int chestCount = int.Parse(data[i][1]); Task task = new Task(chestCount); // get keys for (int j = 0; j < startKeysCount; j++) { int key = int.Parse(data[i + 1][j]); task.Keys[key] += 1; } // get chests for (int j = 0; j < chestCount; j++) { int lockType = int.Parse(data[i + j + 2][0]); int size = int.Parse(data[i + j + 2][1]); Chest chest = new Chest(lockType, size); for (int k = 0; k < size; k++) { int key = int.Parse(data[i + j + 2][k + 2]); chest.Keys.Add(key); } task.Chests.Add(chest); } i += 1 + chestCount; tasks.Add(task); } return tasks; }
private static void LoadChests(BinaryReader reader) { int num = (int)reader.ReadInt16(); int num2 = (int)reader.ReadInt16(); int num3; int num4; if (num2 < 40) { num3 = num2; num4 = 0; } else { num3 = 40; num4 = num2 - 40; } int i; for (i = 0; i < num; i++) { Chest chest = new Chest(false); chest.x = reader.ReadInt32(); chest.y = reader.ReadInt32(); chest.name = reader.ReadString(); for (int j = 0; j < num3; j++) { short num5 = reader.ReadInt16(); Item item = new Item(); if (num5 > 0) { item.netDefaults(reader.ReadInt32()); item.stack = (int)num5; item.Prefix((int)reader.ReadByte()); } else if (num5 < 0) { item.netDefaults(reader.ReadInt32()); item.Prefix((int)reader.ReadByte()); item.stack = 1; } chest.item[j] = item; } for (int j = 0; j < num4; j++) { short num5 = reader.ReadInt16(); if (num5 > 0) { reader.ReadInt32(); reader.ReadByte(); } } Main.chest[i] = chest; } List<Point16> list = new List<Point16>(); for (int k = 0; k < i; k++) { if (Main.chest[k] != null) { Point16 item2 = new Point16(Main.chest[k].x, Main.chest[k].y); if (list.Contains(item2)) { Main.chest[k] = null; } else { list.Add(item2); } } } while (i < 1000) { Main.chest[i] = null; i++; } if (WorldFile.versionNumber < 115) { WorldFile.FixDresserChests(); } }
public void recreateEquipItem(int x, int y, int i){ Item item; if(PlayerPrefs.GetString("Equiped Item type" + i) == "Axe"){ item = new Axe(); item.useItem(player); //add item to axe slot } else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Ring"){ item = new Ring(); item.useItem(player); //add item to ring slot); } else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Chest"){ item = new Chest(); item.useItem(player); //add item to chest slot } else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Boots"){ item = new Boots(); item.useItem(player); //add item to boots slot } else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Amulet"){ item = new Amulet(); item.useItem(player); //add item to amulet slot } else if(PlayerPrefs.GetString("Equiped Item type" + i) == "Sword"){ item = new Sword(); item.useItem(player); //add item to sword slot } }
// Use this for initialization void Start() { //Initialize Abilities - TODO Should this be done statically? dStrike = new Decisive_Strike(); dStrike.setScript(this); courage = new Courage(); courage.setScript(this); judgement = new Judgement(); judgement.setScript(this); dJustice = new Demacian_Justice(); dJustice.setScript(this); valor = new Valor(); valor.setScript(this); level = 1; IconWidth = judgementTexture.width; IconHeight = judgementTexture.height; //Initially not running running = false; idling = true; a = gameObject.GetComponent(typeof(Animation)) as Animation; originalRotation = transform.localRotation; spinning = false; alive = true; inventory = new Item[inventorySize]; TwoHandedSword startingSword = new TwoHandedSword(); startingSword.randomizeWeapon(1, 1); awardItem(startingSword); Helm startingHelm = new Helm(); startingHelm.randomizeArmor(1, 1); awardItem(startingHelm); Chest startingChest = new Chest(); startingChest.randomizeArmor(1, 1); awardItem(startingChest); Gloves startingGloves = new Gloves(); startingGloves.randomizeArmor(1, 1); awardItem(startingGloves); Boots startingBoots = new Boots(); startingBoots.randomizeArmor(1, 1); awardItem(startingBoots); checkpointTexture = Resources.Load("CheckpointTexture/CheckpointMaybe") as Texture2D; playerPortrait = Resources.Load("CheckpointTexture/garen_circle") as Texture2D; playerManaTexture = Resources.Load("PlayerTextures/mana") as Texture2D; leftClickOverlay = Resources.Load("InstructionPage/leftclick") as Texture2D; rightClickOverlay = Resources.Load("InstructionPage/rightclick") as Texture2D; winTexture = Resources.Load("GUITextures/victoryFull") as Texture2D; lossTexture = Resources.Load("GUITextures/defeatFull") as Texture2D; continueButton = Resources.Load("InstructionPage/Continue") as Texture2D; continueButtonHighlighted = Resources.Load("InstructionPage/Continue2") as Texture2D; equipment = new Item[5]; //TODO decide on size equipmentRect = new Rect(50, 50, 300, 300); inventoryRect = new Rect(Screen.width - 350, 50, 300, Mathf.Ceil(inventorySize / 6) * 50 + 20); confirmRect = new Rect((Screen.width / 2) - 150, Screen.height / 4, 300, 300); continueRect = new Rect((Screen.width / 2) - (continueButton.width / 2), Screen.height * (3.0f/4.0f), continueButton.width, continueButton.height); movementSpeed = 1; recalculateStats(); if(PlayerPrefs.GetString("IsSaveGame") == "true"){ name = PlayerPrefs.GetString("SaveFileName"); Load(); } currentHealth = maxHealth; Save(); }
public override void SetupShop(Chest shop, ref int nextSlot) { //EVENTS if (Fargowiltas.instance.thoriumLoaded) { AddItem(NPC.downedBoss1, "ThoriumMod", "BloodMoonMedallion", 20000, ref shop, ref nextSlot); } if (Fargowiltas.instance.sacredToolsLoaded) { AddItem(NPC.downedBoss1, "SacredTools", "SandstormMedallion", 20000, ref shop, ref nextSlot); } if (Fargowiltas.instance.grealmLoaded) { AddItem(GRealmInvasion, "GRealm", "HordeStaff", 30000, ref shop, ref nextSlot); } shop.item[nextSlot].SetDefaults(ItemID.GoblinBattleStandard); shop.item[nextSlot].value = 50000; nextSlot++; if (Fargowiltas.instance.tremorLoaded) { AddItem(NPC.downedBoss2, "Tremor", "ScrollofUndead", 50000, ref shop, ref nextSlot); } if (Fargowiltas.instance.spiritLoaded) { AddItem(SpiritInvasion, "SpiritMod", "BlackPearl", 60000, ref shop, ref nextSlot); } if (Fargowiltas.instance.btfaLoaded) { AddItem(BtfaInvasion, "ForgottenMemories", "AncientLog", 50000, ref shop, ref nextSlot); } if (Main.hardMode) { shop.item[nextSlot].SetDefaults(ItemID.SnowGlobe); shop.item[nextSlot].value = 80000; nextSlot++; } if (NPC.downedPirates) { shop.item[nextSlot].SetDefaults(ItemID.PirateMap); shop.item[nextSlot].value = 100000; nextSlot++; } if (NPC.downedGolemBoss) { shop.item[nextSlot].SetDefaults(ItemID.SolarTablet); shop.item[nextSlot].value = 100000; nextSlot++; } AddItem(NPC.downedMartians, "Fargowiltas", "RunawayProbe", 100000, ref shop, ref nextSlot); if (NPC.downedHalloweenKing) { shop.item[nextSlot].SetDefaults(ItemID.PumpkinMoonMedallion); shop.item[nextSlot].value = 150000; nextSlot++; } if (NPC.downedChristmasIceQueen) { shop.item[nextSlot].SetDefaults(ItemID.NaughtyPresent); shop.item[nextSlot].value = 150000; nextSlot++; } if (Fargowiltas.instance.tremorLoaded) { AddItem(TremorInvasion, "Tremor", "AncientWatch", 200000, ref shop, ref nextSlot); } }
public DeliveryChest(Chest chest) : this(chest, LocationHelper.FindLocation(chest)) { }
private void ClearWindow() { //_lootItems.Clear(); //if (chest != null) if (chest != null) chest.OnMouseUp(); chest = null; _displayLootWindow = false; _displayDialogWindow = false; }
private void CreateWorld() { Texture2D tilesetTexture = Game.Content.Load <Texture2D>(@"Tilesets\tileset1"); Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 32, 32); tilesetTexture = Game.Content.Load <Texture2D>(@"Tilesets\tileset2"); Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32); List <Tileset> tilesets = new List <Tileset>(); tilesets.Add(tileset1); tilesets.Add(tileset2); MapLayer layer = new MapLayer(100, 100); for (int y = 0; y < layer.Height; y++) { for (int x = 0; x < layer.Width; x++) { Tile tile = new Tile(0, 0); layer.SetTile(x, y, tile); } } MapLayer splatter = new MapLayer(100, 100); Random random = new Random(); for (int i = 0; i < 100; i++) { int x = random.Next(0, 100); int y = random.Next(0, 100); int index = random.Next(2, 14); Tile tile = new Tile(index, 0); splatter.SetTile(x, y, tile); } splatter.SetTile(1, 0, new Tile(0, 1)); splatter.SetTile(2, 0, new Tile(2, 1)); splatter.SetTile(3, 0, new Tile(0, 1)); List <MapLayer> mapLayers = new List <MapLayer>(); mapLayers.Add(layer); mapLayers.Add(splatter); TileMap map = new TileMap(tilesets, mapLayers); Level level = new Level(map); ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest"); Chest chest = new Chest(chestData); BaseSprite chestSprite = new BaseSprite( containers, new Rectangle(0, 0, 32, 32), new Point(10, 10)); ItemSprite itemSprite = new ItemSprite( chest, chestSprite); level.Chests.Add(itemSprite); World world = new World(GameRef, GameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; GamePlayScreen.World = world; }
void KillChest(int X, int Y, int plr) { Chest chest = null; using (QueryResult reader = Database.QueryReader("SELECT Account, Items FROM Chests WHERE X = @0 AND Y = @1 AND WorldID = @2", X, Y, Main.worldID)) { if (reader.Read()) { chest = new Chest { account = reader.Get<string>("Account"), items = reader.Get<string>("Items") }; } } TSPlayer player = TShock.Players[plr]; if (chest != null && chest.account != player.UserAccountName && chest.account != "") { player.SendMessage("This chest is protected.", Color.Red); player.SendTileSquare(X, Y, 3); } else if (chest != null && chest.items != "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") { player.SendTileSquare(X, Y, 3); } else { WorldGen.KillTile(X, Y); Database.Query("DELETE FROM Chests WHERE X = @0 AND Y = @1 and WorldID = @2", X, Y, Main.worldID); TSPlayer.All.SendData(PacketTypes.Tile, "", 0, X, Y + 1); } }
public override void SetupShop(Chest shop, ref int nextSlot) { if (Shop == 1) { if (AlchemistNPCWorld.foundAglet) { shop.item[nextSlot].SetDefaults(ItemID.Aglet); shop.item[nextSlot].shopCustomPrice = 20000; nextSlot++; } if (AlchemistNPCWorld.foundAnklet) { shop.item[nextSlot].SetDefaults(ItemID.AnkletoftheWind); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundClimbingClaws) { shop.item[nextSlot].SetDefaults(ItemID.ClimbingClaws); shop.item[nextSlot].shopCustomPrice = 20000; nextSlot++; } if (AlchemistNPCWorld.foundShoeSpikes) { shop.item[nextSlot].SetDefaults(ItemID.ShoeSpikes); shop.item[nextSlot].shopCustomPrice = 30000; nextSlot++; } if (AlchemistNPCWorld.foundHermesBoots) { shop.item[nextSlot].SetDefaults(ItemID.HermesBoots); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundWWB) { shop.item[nextSlot].SetDefaults(ItemID.WaterWalkingBoots); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundFlowerBoots) { shop.item[nextSlot].SetDefaults(ItemID.FlowerBoots); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundIceSkates) { shop.item[nextSlot].SetDefaults(ItemID.IceSkates); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundTabi) { shop.item[nextSlot].SetDefaults(ItemID.Tabi); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundFrogLeg) { shop.item[nextSlot].SetDefaults(ItemID.FrogLeg); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundJFNeck) { shop.item[nextSlot].SetDefaults(ItemID.JellyfishNecklace); shop.item[nextSlot].shopCustomPrice = 30000; nextSlot++; } if (AlchemistNPCWorld.foundFlippers) { shop.item[nextSlot].SetDefaults(ItemID.Flipper); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundNeptuneShell) { shop.item[nextSlot].SetDefaults(ItemID.NeptunesShell); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundHorseshoe) { shop.item[nextSlot].SetDefaults(ItemID.LuckyHorseshoe); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundBalloon) { shop.item[nextSlot].SetDefaults(ItemID.ShinyRedBalloon); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundCloud) { shop.item[nextSlot].SetDefaults(ItemID.CloudinaBottle); shop.item[nextSlot].shopCustomPrice = 30000; nextSlot++; } if (AlchemistNPCWorld.foundBlizzard) { shop.item[nextSlot].SetDefaults(ItemID.BlizzardinaBottle); shop.item[nextSlot].shopCustomPrice = 40000; nextSlot++; } if (AlchemistNPCWorld.foundSandstorm) { shop.item[nextSlot].SetDefaults(ItemID.SandstorminaBottle); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundPuffer) { shop.item[nextSlot].SetDefaults(ItemID.BalloonPufferfish); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundTsunami) { shop.item[nextSlot].SetDefaults(ItemID.TsunamiInABottle); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundLavaCharm) { shop.item[nextSlot].SetDefaults(ItemID.LavaCharm); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundCMagnet) { shop.item[nextSlot].SetDefaults(ItemID.CelestialMagnet); shop.item[nextSlot].shopCustomPrice = 200000; nextSlot++; } if (AlchemistNPCWorld.foundPStone) { shop.item[nextSlot].SetDefaults(ItemID.PhilosophersStone); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundHTFL) { shop.item[nextSlot].SetDefaults(ItemID.HighTestFishingLine); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundAnglerEarring) { shop.item[nextSlot].SetDefaults(ItemID.AnglerEarring); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundTackleBox) { shop.item[nextSlot].SetDefaults(ItemID.TackleBox); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundGoldRing) { shop.item[nextSlot].SetDefaults(ItemID.GoldRing); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } if (AlchemistNPCWorld.foundLuckyCoin) { shop.item[nextSlot].SetDefaults(ItemID.LuckyCoin); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } if (AlchemistNPCWorld.foundDiscountCard) { shop.item[nextSlot].SetDefaults(ItemID.DiscountCard); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } } if (Shop == 2) { if (AlchemistNPCWorld.foundString) { shop.item[nextSlot].SetDefaults(ItemID.WhiteString); shop.item[nextSlot].shopCustomPrice = 30000; nextSlot++; } if (AlchemistNPCWorld.foundGreenCW) { shop.item[nextSlot].SetDefaults(ItemID.GreenCounterweight); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundYoyoGlove) { shop.item[nextSlot].SetDefaults(ItemID.YoYoGlove); shop.item[nextSlot].shopCustomPrice = 500000; nextSlot++; } if (AlchemistNPCWorld.foundBlindfold) { shop.item[nextSlot].SetDefaults(ItemID.Blindfold); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundArmorPolish) { shop.item[nextSlot].SetDefaults(ItemID.ArmorPolish); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundVitamins) { shop.item[nextSlot].SetDefaults(ItemID.Vitamins); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundBezoar) { shop.item[nextSlot].SetDefaults(ItemID.Bezoar); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundAdhesiveBandage) { shop.item[nextSlot].SetDefaults(ItemID.AdhesiveBandage); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundFastClock) { shop.item[nextSlot].SetDefaults(ItemID.FastClock); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundTrifoldMap) { shop.item[nextSlot].SetDefaults(ItemID.TrifoldMap); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundMegaphone) { shop.item[nextSlot].SetDefaults(ItemID.Megaphone); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundNazar) { shop.item[nextSlot].SetDefaults(ItemID.Nazar); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundSorcE) { shop.item[nextSlot].SetDefaults(ItemID.SorcererEmblem); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundWE) { shop.item[nextSlot].SetDefaults(ItemID.WarriorEmblem); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundRE) { shop.item[nextSlot].SetDefaults(ItemID.RangerEmblem); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundSumE) { shop.item[nextSlot].SetDefaults(ItemID.SummonerEmblem); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundFeralClaw) { shop.item[nextSlot].SetDefaults(ItemID.FeralClaws); shop.item[nextSlot].shopCustomPrice = 150000; nextSlot++; } if (AlchemistNPCWorld.foundTitanGlove) { shop.item[nextSlot].SetDefaults(ItemID.TitanGlove); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundMagmaStone) { shop.item[nextSlot].SetDefaults(ItemID.MagmaStone); shop.item[nextSlot].shopCustomPrice = 150000; nextSlot++; } if (AlchemistNPCWorld.foundSharkTooth) { shop.item[nextSlot].SetDefaults(ItemID.SharkToothNecklace); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundBlackBelt) { shop.item[nextSlot].SetDefaults(ItemID.BlackBelt); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundMoonCharm) { shop.item[nextSlot].SetDefaults(ItemID.MoonCharm); shop.item[nextSlot].shopCustomPrice = 300000; nextSlot++; } if (AlchemistNPCWorld.foundSunStone) { shop.item[nextSlot].SetDefaults(ItemID.SunStone); shop.item[nextSlot].shopCustomPrice = 350000; nextSlot++; } if (AlchemistNPCWorld.foundMoonStone) { shop.item[nextSlot].SetDefaults(ItemID.MoonStone); shop.item[nextSlot].shopCustomPrice = 350000; nextSlot++; } if (AlchemistNPCWorld.foundRifleScope) { shop.item[nextSlot].SetDefaults(ItemID.RifleScope); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundCobaltShield) { shop.item[nextSlot].SetDefaults(ItemID.CobaltShield); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundPaladinShield) { shop.item[nextSlot].SetDefaults(ItemID.PaladinsShield); shop.item[nextSlot].shopCustomPrice = 150000; nextSlot++; } if (AlchemistNPCWorld.foundFrozenTurtleShell) { shop.item[nextSlot].SetDefaults(ItemID.FrozenTurtleShell); shop.item[nextSlot].shopCustomPrice = 350000; nextSlot++; } if (AlchemistNPCWorld.foundPutridScent) { shop.item[nextSlot].SetDefaults(ItemID.PutridScent); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundFleshKnuckles) { shop.item[nextSlot].SetDefaults(ItemID.FleshKnuckles); shop.item[nextSlot].shopCustomPrice = 250000; nextSlot++; } if (AlchemistNPCWorld.foundMagicQuiver) { shop.item[nextSlot].SetDefaults(ItemID.MagicQuiver); shop.item[nextSlot].shopCustomPrice = 200000; nextSlot++; } if (AlchemistNPCWorld.foundPanicNecklace) { shop.item[nextSlot].SetDefaults(ItemID.PanicNecklace); shop.item[nextSlot].shopCustomPrice = 50000; nextSlot++; } if (AlchemistNPCWorld.foundCrossNecklace) { shop.item[nextSlot].SetDefaults(ItemID.CrossNecklace); shop.item[nextSlot].shopCustomPrice = 100000; nextSlot++; } if (AlchemistNPCWorld.foundStarCloak) { shop.item[nextSlot].SetDefaults(ItemID.StarCloak); shop.item[nextSlot].shopCustomPrice = 150000; nextSlot++; } if (AlchemistNPCWorld.foundObsidianRose) { shop.item[nextSlot].SetDefaults(ItemID.ObsidianRose); shop.item[nextSlot].shopCustomPrice = 150000; nextSlot++; } if (AlchemistNPCWorld.foundShackle) { shop.item[nextSlot].SetDefaults(ItemID.Shackle); shop.item[nextSlot].shopCustomPrice = 30000; nextSlot++; } if (AlchemistNPCWorld.foundHerculesBeetle) { shop.item[nextSlot].SetDefaults(ItemID.HerculesBeetle); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } if (AlchemistNPCWorld.foundPygmyNecklace) { shop.item[nextSlot].SetDefaults(ItemID.PygmyNecklace); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } if (AlchemistNPCWorld.foundNecromanticScroll) { shop.item[nextSlot].SetDefaults(ItemID.NecromanticScroll); shop.item[nextSlot].shopCustomPrice = 330000; nextSlot++; } } }
/// <summary> /// Modify a Chest object based on the data in a ModifiedChestEntry object. /// </summary> private void ModifyChest(Chest chest, ModifiedChestEntry modifiedChestEntry) { // check the parameters if ((chest == null) || (modifiedChestEntry == null)) { return; } // set the new gold amount chest.Gold = modifiedChestEntry.Gold; // remove all contents not found in the modified version chest.Entries.RemoveAll(delegate(ContentEntry<Gear> contentEntry) { return !modifiedChestEntry.ChestEntries.Exists( delegate(ContentEntry<Gear> modifiedTestEntry) { return (contentEntry.ContentName == modifiedTestEntry.ContentName); }); }); // set the new counts on the remaining content items foreach (ContentEntry<Gear> contentEntry in chest.Entries) { ContentEntry<Gear> modifiedGearEntry = modifiedChestEntry.ChestEntries.Find( delegate(ContentEntry<Gear> modifiedTestEntry) { return (contentEntry.ContentName == modifiedTestEntry.ContentName); }); if (modifiedGearEntry != null) { contentEntry.Count = modifiedGearEntry.Count; } } }
private void LoadWorld() { RpgLibrary.WorldClasses.LevelData levelData = Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level"); RpgLibrary.WorldClasses.MapData mapData = Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName); CharacterLayerData charData = Game.Content.Load <CharacterLayerData>(@"Game\Levels\Chars\Starting Level"); CharacterLayer characterLayer = new CharacterLayer(); MobLayer mobLayer = new MobLayer(); TileMap map = TileMap.FromMapData(mapData, Game.Content); foreach (var c in charData.Characters) { Character character; if (c.Value is NonPlayerCharacterData data) { Entity entity = new Entity(c.Value.Name, c.Value.EntityData, c.Value.Gender, EntityType.NPC); using (Stream stream = new FileStream(c.Value.TextureName, FileMode.Open, FileAccess.Read)) { Texture2D texture = Texture2D.FromStream(GraphicsDevice, stream); AnimatedSprite sprite = new AnimatedSprite(texture, AnimationManager.Instance.Animations) { Position = new Vector2(c.Key.X * Engine.TileWidth, c.Key.Y * Engine.TileHeight) }; character = new NonPlayerCharacter(entity, sprite); ((NonPlayerCharacter)character).SetConversation( data.CurrentConversation); } characterLayer.Characters.Add(c.Key, character); } } map.AddLayer(characterLayer); map.AddLayer(mobLayer); Level level = new Level(map); ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest"); Chest chest = new Chest(chestData); BaseSprite chestSprite = new BaseSprite( containers, new Rectangle(0, 0, 32, 32), new Point(10, 10)); ItemSprite itemSprite = new ItemSprite( chest, chestSprite); level.Chests.Add(itemSprite); World world = new World(GameRef, GameRef.ScreenRectangle); world.Levels.Add(level); world.CurrentLevel = 0; AnimatedSprite s = new AnimatedSprite( GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"), AnimationManager.Instance.Animations) { Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight) }; EntityData ed = new EntityData("Eliza", 1, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16", "0|0|0"); Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC); NonPlayerCharacter npc = new NonPlayerCharacter(e, s); npc.SetConversation("brenda1"); ((CharacterLayer)world.Levels[world.CurrentLevel].Map.Layers.Find(x => x is CharacterLayer)).Characters.Add(new Point(0, 5), npc); world.Levels[world.CurrentLevel].Characters.Add(npc); s = new AnimatedSprite( GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"), AnimationManager.Instance.Animations) { Position = new Vector2(10 * Engine.TileWidth, 0) }; ed = new EntityData("Barbra", 2, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16", "0|0|0"); e = new Entity("Barbra", ed, EntityGender.Female, EntityType.Merchant); Merchant m = new Merchant(e, s); Texture2D items = Game.Content.Load <Texture2D>("ObjectSprites/roguelikeitems"); m.Backpack.AddItem(GameItemManager.GetItem("Long Sword")); m.Backpack.AddItem(GameItemManager.GetItem("Short Sword")); m.Backpack.AddItem(GameItemManager.GetItem("Apprentice Staff")); m.Backpack.AddItem(GameItemManager.GetItem("Acolyte Staff")); m.Backpack.AddItem(GameItemManager.GetItem("Leather Armor")); m.Backpack.AddItem(GameItemManager.GetItem("Chain Mail")); m.Backpack.AddItem(GameItemManager.GetItem("Studded Leather Armor")); m.Backpack.AddItem(GameItemManager.GetItem("Light Robes")); m.Backpack.AddItem(GameItemManager.GetItem("Medium Robes")); world.Levels[world.CurrentLevel].Characters.Add(m); ((CharacterLayer)world.Levels[world.CurrentLevel].Map.Layers.Find(x => x is CharacterLayer)).Characters.Add(new Point(10, 0), m); GamePlayScreen.World = world; for (int i = 0; i < 25; i++) { ed = new EntityData("Bandit", 1, 10, 12, 12, 10, 10, 10, "20|CON|10", "12|WIL|12", "0|0|0"); e = new Entity("Bandit", ed, EntityGender.Male, EntityType.Monster); s = new AnimatedSprite( GameRef.Content.Load <Texture2D>(@"PlayerSprites/malerogue"), AnimationManager.Instance.Animations); Mob mob = new Bandit(e, s, GameRef); Rectangle r = new Rectangle(Mechanics.Random.Next(10, 50) * 32, Mechanics.Random.Next(10, 50) * 32, 32, 32); mob.Sprite.Position = new Vector2(r.X, r.Y); if (!mobLayer.Mobs.ContainsKey(r)) { mobLayer.Mobs.Add(r, mob); } mob.Entity.Equip(GameItemManager.GetItem("Short Sword")); mob.Drops.Add(GameItemManager.GetItem("Short Sword")); mob.Drops.Add(GameItemManager.GetItem("Minor Healing Potion")); } QuestStepData step = new QuestStepData() { StepType = QuestStepType.Fight, Level = 1, Source = "Eliza", Target = "Bandit" }; List <QuestStepData> steps = new List <QuestStepData> { step }; Reward reward = new Reward { Experience = 1000, Gold = 1000 }; reward.Items.Add("Minor Healing Potion"); Quest q = new Quest("Eliza", steps, reward); npc.Quests.Add(q); }
public bool Generate() { List<Tuple<int, Vector3>> chunkSave = cs.ListIdSave; // Generate elements if (this.step > -1 && this.step < this.ancres.Count) { int min = Mathf.Min(step + 3, this.ancres.Count); for (int i = step; i < min; i++) { Transform ancre = this.ancres[i]; if (ancre.CompareTag("Ancre")) if (this.posSave < chunkSave.Count && chunkSave[this.posSave].Item1 == i) { chunkSave[this.posSave].Item2 = ancre.position; this.rand.NextDouble(); this.rand.NextDouble(); this.posSave++; } else this.GenerateEntity(this.b.Chose(this.rand), ancre.gameObject, (int)(this.rand.NextDouble() * 360), i); else if (ancre.CompareTag("MainAncre")) if (this.isPrisme) this.GenerateEntity(EntityDatabase.IslandCore, ancre.gameObject, 0, i); GameObject.Destroy(ancre.gameObject); } this.step = min - 1; } else if (step == this.ancres.Count) { // Load IslandCore if (this.isPrisme) Prefab.GetComponent<SyncChunk>().FindCristal(); //Generate Worktop foreach (Triple<Element, Vector3, Vector3> worktop in cs.WorkTops) new Element(worktop.Item1).Spawn(worktop.Item2, Quaternion.Euler(worktop.Item3), Prefab.transform.FindChild("Elements"), -1, true); List<Quadruple<Element, Vector3, Vector3, ItemStack[,]>> copy = new List<Quadruple<Element, Vector3, Vector3, ItemStack[,]>>(cs.Chests); cs.Chests.Clear(); foreach (Quadruple<Element, Vector3, Vector3, ItemStack[,]> chest in copy) { Chest c = new Chest(chest.Item1 as Chest); c.Content = chest.Item4; c.Spawn(chest.Item2, Quaternion.Euler(chest.Item3), Prefab.transform.FindChild("Elements"), -1, false); } } else if (step == this.ancres.Count + 1) { // Generate Graph if (Prefab.GetComponent<SyncChunk>().MyGraph == null) Prefab.GetComponent<SyncChunk>().MyGraph = new Graph(this.posIslands.ToArray()); Prefab.GetComponent<SyncChunk>().MyGraph.GenerateGraph(300); if (!Prefab.GetComponent<SyncChunk>().MyGraph.IsFileEmpty) this.step--; } else if (step == this.ancres.Count + 2 && base.iD != EntityDatabase.Chunk0_Empty.iD) { // Generate Mobs foreach (Mob mob in EntityDatabase.Mobs) { bool biomeValid = false; foreach (int biomeId in mob.BiomesIDSpawnable) if (biomeId == this.b.ID) { biomeValid = true; break; } if (biomeValid) for (int i = 0; i < mob.SpawnProbability; i++) { if (UnityEngine.Random.Range(0, 6) == 0) { Node node = Prefab.GetComponent<SyncChunk>().MyGraph.ChoseRandomNode(); if (node.IsValid) new Mob(mob).Spawn(node.Position, Prefab.transform.FindChild("Mob")); } } } return true; } this.step++; return false; }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 48, 32, dresserDrop); Chest.DestroyChest(i, j); }
// private void PopulateChest(int x) { // for(int cnt = 0; cnt < x; cnt++) // _lootItems.Add(new Item()); // // _displayLootWindow = true; // } /// <summary> /// Close the loot window, and tell the lootable object that we have open that we are closing it. /// </summary> private void ClearWindow() { _displayLootWindow = false; //toggle the loot window display to off // _lootItems.Clear(); chest.OnMouseUp(); //let the lootable object that we currently have open to close chest = null; //clear the reference to a lootable object }
public override bool NewRightClick(int i, int j) { Player player = Main.LocalPlayer; if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 0) { Main.CancelClothesWindow(true); Main.mouseRightRelease = false; int left = Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18; left %= 3; left = Player.tileTargetX - left; int top = Player.tileTargetY - Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18; if (player.sign > -1) { Main.PlaySound(SoundID.MenuClose); player.sign = -1; Main.editSign = false; Main.npcChatText = string.Empty; } if (Main.editChest) { Main.PlaySound(SoundID.MenuTick); Main.editChest = false; Main.npcChatText = string.Empty; } if (player.editedChestName) { NetMessage.SendData(33, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); player.editedChestName = false; } if (Main.netMode == 1) { if (left == player.chestX && top == player.chestY && player.chest != -1) { player.chest = -1; Recipe.FindRecipes(); Main.PlaySound(SoundID.MenuClose); } else { NetMessage.SendData(31, -1, -1, null, left, top, 0f, 0f, 0, 0, 0); Main.stackSplit = 600; } } else { player.flyingPigChest = -1; int num213 = Chest.FindChest(left, top); if (num213 != -1) { Main.stackSplit = 600; if (num213 == player.chest) { player.chest = -1; Recipe.FindRecipes(); Main.PlaySound(SoundID.MenuClose); } else if (num213 != player.chest && player.chest == -1) { player.chest = num213; Main.playerInventory = true; Main.recBigList = false; Main.PlaySound(SoundID.MenuOpen); player.chestX = left; player.chestY = top; } else { player.chest = num213; Main.playerInventory = true; Main.recBigList = false; Main.PlaySound(SoundID.MenuTick); player.chestX = left; player.chestY = top; } Recipe.FindRecipes(); } } } else { Main.playerInventory = false; player.chest = -1; Recipe.FindRecipes(); Main.dresserX = Player.tileTargetX; Main.dresserY = Player.tileTargetY; Main.OpenClothesWindow(); } return(true); }