public override void Update(GameTime gameTime) { // Don't delete this or the UIElements attached to this UIState will cease to function. base.Update(gameTime); if (partyslot1.Item.IsAir) { PokemonGoesHere.SetText("Place a Pokémon in the first slot."); mainPanel.RemoveChild(partyslot2); } else { if (partyslot1.Item.modItem is BaseCaughtClass pokeball) { var mon = TerramonMod.GetPokemon(pokeball.CapturedPokemon); if (mon != null && mon.CanEvolve) { if (mon.EvolveItem == EvolveItem.RareCandy) { //Set preference to RareCandy partyslot2.ValidItemFunc = item => item.IsAir || item.modItem is RareCandy; PokemonGoesHere.SetText($"Place {mon.EvolveCost} Rare Candies in the second slot."); mainPanel.Append(partyslot2); if (!partyslot2.Item.IsAir && partyslot2.Item.modItem is RareCandy && partyslot2.Item.stack == mon.EvolveCost) { PokemonGoesHere.SetText("Great! Press the evolve button!"); mainPanel.Append(SaveButton); } else { mainPanel.RemoveChild(SaveButton); } } else if (mon.EvolveItem == EvolveItem.LinkCable) { //Set preference to LinkCable partyslot2.ValidItemFunc = item => item.IsAir || item.modItem is LinkCable; PokemonGoesHere.SetText($"Place {mon.EvolveCost} Link Cable in the second slot."); mainPanel.Append(partyslot2); if (!partyslot2.Item.IsAir && partyslot2.Item.modItem is LinkCable && partyslot2.Item.stack == mon.EvolveCost) { PokemonGoesHere.SetText("Great! Press the evolve button!"); mainPanel.Append(SaveButton); } else { mainPanel.RemoveChild(SaveButton); } } } else { PokemonGoesHere.SetText("This Pokémon cannot evolve!"); } } } }
public override void UpdateInventory(Player player) { currentWaitTime++; if (currentWaitTime < WaitTime * 60) { return; } if (PokemonName == null || PokemonName == string.Empty) { item.TurnToAir();//This is invalid item return; } ParentPokemon hatchedPokemon = TerramonMod.GetPokemon(PokemonName); string pokemonName = hatchedPokemon?.GetType().Name; if (player.whoAmI != Main.myPlayer) { return; } switch (Main.netMode) { case NetmodeID.MultiplayerClient: { var packet = new BaseCatchPacket(); packet.Send((TerramonMod)mod, pokemonName, pokemonName, player.getRect(), ItemType <PokeballCaught>()); break; } case NetmodeID.Server: { BaseCaughtClass.writeDetour(pokemonName, pokemonName, GetSmallSpritePath(pokemonName), 1, "", false); //This force server to write data when SetDefault() was called Item.NewItem(player.position, ItemType <PokeballCaught>()); // Within this call SetDefault was called break; } default: { int pokeballIndex = Item.NewItem(player.position, ItemType <PokeballCaught>()); BaseCaughtClass pokeballItem = Main.item[pokeballIndex].modItem as BaseCaughtClass; pokeballItem.PokemonName = pokeballItem.CapturedPokemon = pokemonName; pokeballItem.SmallSpritePath = GetSmallSpritePath(pokemonName); break; } } Main.NewText(player.name + " the " + pokemonName + " Egg has hatched!", Color.Orange); player.ConsumeItem(item.type); currentWaitTime = 0; }
private void EvolveButtonClicked(UIMouseEvent evt, UIElement listeningElement) { int whicheverballtype = TerramonMod.PokeballFactory.GetPokeballType(partyslot1.Item.modItem); // stuff break if (partyslot1.Item.modItem is BaseCaughtClass pokeball) { var mon = TerramonMod.GetPokemon(pokeball.CapturedPokemon); if (mon == null) { Main.NewText("This Pokémon cannot evolve!"); return; } var evolved = TerramonMod.GetPokemon(mon.EvolveTo.Name); if (evolved == null) { Main.NewText("This Pokémon cannot evolve!"); return; } if (Main.netMode == NetmodeID.MultiplayerClient) { BaseCatchPacket packet = new BaseCatchPacket(); packet.Send(TerramonMod.Instance, evolved.GetType().Name, evolved.GetType().Name, Main.LocalPlayer.getRect(), whicheverballtype); } else { int index = Item.NewItem(Main.LocalPlayer.getRect(), whicheverballtype); if (index >= 400) { return; } if (Main.item[index].modItem is BaseCaughtClass item) { item.PokemonName = evolved.GetType().Name; item.CapturedPokemon = evolved.GetType().Name; } } } Visible = false; partyslot1.Item.TurnToAir(); partyslot2.Item.TurnToAir(); mainPanel.RemoveChild(SaveButton); Main.LocalPlayer.talkNPC = 0; }
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { if (SmallSpritePath == null) { var mon = TerramonMod.GetPokemon(CapturedPokemon); if (mon == null) { return(true); } SmallSpritePath = mon.IconName; } Texture2D pokemonTexture = ModContent.GetTexture(SmallSpritePath); Texture2D itemTexture = Main.itemTexture[item.type]; spriteBatch.Draw(itemTexture, position, frame, drawColor, 0f, origin, scale, SpriteEffects.None, 0); spriteBatch.Draw(pokemonTexture, position + itemTexture.Size() * Main.inventoryScale - new Vector2(4, 4), pokemonTexture.Frame(), drawColor, 0f, pokemonTexture.Size() / 2f, Main.inventoryScale, SpriteEffects.None, 0); return(false); }