private void updateSpriteLocation(PC.NPC inNPC) { Rectangle rect; switch (inNPC.facing) { case PC.FacingDirection.North: rect = new Rectangle(5, 5, 32, 32); break; case PC.FacingDirection.East: rect = new Rectangle(5, 116, 32, 32); break; case PC.FacingDirection.South: rect = new Rectangle(5, 42, 32, 32); break; case PC.FacingDirection.West: rect = new Rectangle(5, 79, 32, 32); break; default: rect = new Rectangle(5, 116, 32, 32); break; } inNPC.spritePosition = rect; }
private void exportTrainerToolStripMenuItem_Click(object sender, EventArgs e) { try { //The image is copied into the Overworlds Sprites directory. //Will overwrite old file String pathToSprite = Directory.GetCurrentDirectory() + "\\Content\\Sprites\\NPCs\\Overworlds\\" + Path.GetFileName(NPCImageToUse); try { File.Copy(NPCImageToUse, pathToSprite, true); } catch (Exception ex) { MessageBox.Show(ex.Message); } NPC tempNPC = CreateNPC(); game.world.currentArea.trainerList.Add(tempNPC); tempNPC = null; ResetNPCTab(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public NPC CreateNPC() { NPC tempNPC = new NPC(); if (cbox_IsTrainer.Checked) { tempNPC = new Trainer(); ((Trainer)tempNPC).money = Int32.Parse(tbox_TrainerPayout.Text); foreach (ListViewItem lvi in lview_TrainerActivePokemon.Items) { if (lvi.Tag != null && (lvi.Tag.GetType() == typeof(ActivePokemon))) //if the object is not null and is an ActivePokemon { ((ActivePokemon)(lvi.Tag)).trainer = (Trainer)tempNPC; //set the activepokemon's trainer to the one currently being used } } } //dump the rest of the npc tab's info into the tempNPC tempNPC.name = tbox_NPCName.Text; tempNPC.isMale = cbox_IsMale.Checked; if (rbtn_NPCFacingDirection_DOWN.Checked) { tempNPC.facing = FacingDirection.South; } if (rbtn_NPCFacingDirection_UP.Checked) { tempNPC.facing = FacingDirection.North; } if (rbtn_NPCFacingDirection_LEFT.Checked) { tempNPC.facing = FacingDirection.West; } if (rbtn_NPCFacingDirection_RIGHT.Checked) { tempNPC.facing = FacingDirection.East; } tempNPC.spriteSheet = Path.GetFileName(NPCImageToUse); //the tag will be a string that contains the image to use //copy the sprite over to the content folder if (!String.IsNullOrWhiteSpace(NPCImageToUse)) { String destination = Directory.GetCurrentDirectory() + "\\Content\\Sprites\\NPCs\\Overworlds\\" + tempNPC.spriteSheet; try { File.Copy(NPCImageToUse, destination, true); } catch (IOException e) { } } tempNPC.spritePosition = new Microsoft.Xna.Framework.Rectangle(5, 5, 32, 32); tempNPC.spritesheetSize = new Microsoft.Xna.Framework.Rectangle(0, 0, 116, 153); tempNPC.zoneLocation = game.world.currentArea.zoneName; tempNPC.interactScript = NPCScriptBox.Text; tempNPC.Update(); return(tempNPC); }