public bool AggroCheck(Character Player, Character[] NPC) { int n = 0; while(n <= 15) { if(NPC[n] != null && NPC[n].Alive == true && NPC[n].Z_Location == Player.Z_Location && NPC[n].AggresiveState == true) { if(NPC[n].Direction == 0 && Player.X_Location == NPC[n].X_Location && Player.Y_Location > NPC[n].Y_Location) { NPCNumber = n; return true; } if (NPC[n].Direction == 1 && Player.X_Location < NPC[n].X_Location && Player.Y_Location == NPC[n].Y_Location) { NPCNumber = n; return true; } if (NPC[n].Direction == 2 && Player.X_Location > NPC[n].X_Location && Player.Y_Location == NPC[n].Y_Location) { NPCNumber = n; return true; } if (NPC[n].Direction == 3 && Player.X_Location == NPC[n].X_Location && Player.Y_Location < NPC[n].Y_Location) { NPCNumber = n; return true; } } n++; } return false; }
public void NPCList() { NPC[0] = new Character(); NPC[0].InitializeCharacter("Crab", "Male", "Beast", 1, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 4, 10, 224, 2, 0, true); NPC[0].Inventory[0] = new ItemData(); NPC[0].Inventory[0].SetItem(Items[0], 2); NPC[0].Companion[0] = new CompanionData(); NPC[0].Companion[0].SetType(Companion[1]); NPC[0].Companion[0].Level = 4; NPC[0].Companion[0].UpdateStats(); NPC[0].Companion[0].Rest(); NPC[1] = new Character(); NPC[1].InitializeCharacter("Crab", "Male", "Beast", 2, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 2, 5, 233, 2, 0, true); NPC[1].Inventory[0] = new ItemData(); NPC[1].Inventory[0].SetItem(Items[0], 1); NPC[1].Companion[0] = new CompanionData(); NPC[1].Companion[0].SetType(Companion[1]); NPC[1].Companion[0].Level = 1; NPC[1].Companion[0].UpdateStats(); NPC[1].Companion[0].Rest(); NPC[2] = new Character(); NPC[2].InitializeCharacter("Crab", "Male", "Beast", 3, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 8, 1, 234, 1, 0, true); NPC[2].Inventory[0] = new ItemData(); NPC[2].Inventory[0].SetItem(Items[0], 1); NPC[2].Companion[0] = new CompanionData(); NPC[2].Companion[0].SetType(Companion[1]); NPC[2].Companion[0].Level = 1; NPC[2].Companion[0].UpdateStats(); NPC[2].Companion[0].Rest(); NPC[3] = new Character(); NPC[3].InitializeCharacter("Crab", "Male", "Beast", 4, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 7, 2, 235, 0, 0, true); NPC[3].Inventory[0] = new ItemData(); NPC[3].Inventory[0].SetItem(Items[0], 1); NPC[3].Companion[0] = new CompanionData(); NPC[3].Companion[0].SetType(Companion[1]); NPC[3].Companion[0].Level = 1; NPC[3].Companion[0].UpdateStats(); NPC[3].Companion[0].Rest(); NPC[4] = new Character(); NPC[4].InitializeCharacter("Crab", "Male", "Beast", 5, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 4, 4, 232, 0, 0, true); NPC[4].Inventory[0] = new ItemData(); NPC[4].Inventory[0].SetItem(Items[0], 1); NPC[4].Companion[0] = new CompanionData(); NPC[4].Companion[0].SetType(Companion[1]); NPC[4].Companion[0].Level = 1; NPC[4].Companion[0].UpdateStats(); NPC[4].Companion[0].Rest(); NPC[5] = new Character(); NPC[5].InitializeCharacter("Crab", "Male", "Beast", 6, "GFX/Sprites/crab.bmp", "GFX/Sprites/knightP.bmp", 7, 6, 232, 0, 0, true); NPC[5].Inventory[0] = new ItemData(); NPC[5].Inventory[0].SetItem(Items[0], 1); NPC[5].Companion[0] = new CompanionData(); NPC[5].Companion[0].SetType(Companion[1]); NPC[5].Companion[0].Level = 1; NPC[5].Companion[0].UpdateStats(); NPC[5].Companion[0].Rest(); /*NPC[1] = new Character(); NPC[1].InitializeCharacter("Skeleton", "Male", "Human", 2, "GFX/Sprites/skeleton.bmp", "GFX/Sprites/skeletonP.bmp", 4, 12, 7, 1, 0); NPC[1].Companion[0] = new CompanionData(); NPC[1].Companion[0].SetType(Companion[3]); NPC[1].Companion[0].Level = 5; NPC[1].Companion[0].UpdateStats(); NPC[1].Companion[1] = new CompanionData(); NPC[1].Companion[1].SetType(Companion[4]); NPC[1].Companion[1].Level = 3; NPC[1].Companion[1].UpdateStats(); NPC[1].Companion[2] = new CompanionData(); NPC[1].Companion[2].SetType(Companion[5]); NPC[1].Companion[2].Level = 2; NPC[1].Companion[2].UpdateStats(); NPC[1].Companion[3] = new CompanionData(); NPC[1].Companion[3].SetType(Companion[6]); NPC[1].Companion[3].Level = 7; NPC[1].Companion[3].UpdateStats(); NPC[1].SetDialogue("I will kill you!!! Tremble before me!!");*/ }
public void LoadNPCState(string save) { int LN = 0; int CC = 0; int IC = 0; int NC = 0; int n = 0; int x = 0; var lines = File.ReadAllLines(save); CC = Convert.ToInt32(lines[14]); //Companion Count LN = 15; while (n < CC) { Player.Companion[n] = new CompanionData(); Player.Companion[n].SetType(Companion[Convert.ToInt32(lines[LN])]); Player.Companion[n].Level = Convert.ToInt32(lines[LN + 1]); Player.Companion[n].UpdateStats(); Player.Companion[n].CurrentHP = Convert.ToInt32(lines[LN + 2]); Player.Companion[n].CurrentStam = Convert.ToInt32(lines[LN + 3]); LN = LN + 4; n++; } n = 0; LN++; IC = Convert.ToInt32(lines[LN]); //Item Count LN++; while(n < IC) { Player.Inventory[n] = new ItemData(); Player.Inventory[n].SetItem(Items[Convert.ToInt32(lines[LN])], Convert.ToInt32(lines[LN + 1])); LN = LN + 2; n++; } n = 0; LN++; NC = Convert.ToInt32(lines[LN]); // NPC Count LN++; while (x < NC) { NPC[x] = new Character(); NPC[x].InitializeCharacter(lines[LN + 1], lines[LN + 2], lines[LN + 3], Convert.ToInt32(lines[LN + 4]), lines[LN + 5], lines[LN + 6], Convert.ToInt32(lines[LN + 7]), Convert.ToInt32(lines[LN + 8]), Convert.ToInt32(lines[LN + 9]), Convert.ToInt32(lines[LN + 10]), Convert.ToInt32(lines[LN + 11]), Convert.ToBoolean(lines[LN + 12])); NPC[x].Alive = Convert.ToBoolean(lines[LN + 13]); LN = LN + 15; CC = Convert.ToInt32(lines[LN]); //Companion Count LN++; while (n < CC) { NPC[x].Companion[n] = new CompanionData(); NPC[x].Companion[n].SetType(Companion[Convert.ToInt32(lines[LN])]); NPC[x].Companion[n].Level = Convert.ToInt32(lines[LN + 1]); NPC[x].Companion[n].UpdateStats(); NPC[x].Companion[n].CurrentHP = Convert.ToInt32(lines[LN + 2]); NPC[x].Companion[n].CurrentStam = Convert.ToInt32(lines[LN + 3]); LN = LN + 4; n++; } n = 0; LN++; IC = Convert.ToInt32(lines[LN]); //Item Count LN++; while (n < IC) { NPC[x].Inventory[n] = new ItemData(); NPC[x].Inventory[n].SetItem(Items[Convert.ToInt32(lines[LN])], Convert.ToInt32(lines[LN + 1])); LN = LN + 2; n++; } n = 0; x++; } }
public bool CollisionCheck(int direction, int MapNum, Character Player, Character[] NPC) { CheckNPC = false; int iX, iY; if (direction == 0) { iX = Player.X_Location; iY = Player.Y_Location + 1; if (File.ReadLines(@"DATA/mapcode.txt").Skip((MapNum - 1) * 261 + (iY * 16 + iX) + 6).Take(1).First() == "B") { return false; } int n = 0; while (n <= 15) { if (NPC[n] != null && NPC[n].Alive == true) { if (NPC[n].Z_Location == MapNum && NPC[n].Y_Location == iY && NPC[n].X_Location == iX) { CheckNPC = true; NPCNumber = n; return false; } } n++; } return true; } if (direction == 1) { iX = Player.X_Location - 1; iY = Player.Y_Location; if (File.ReadLines(@"DATA/mapcode.txt").Skip((MapNum - 1) * 261 + (iY * 16 + iX) + 6).Take(1).First() == "B") { return false; } int n = 0; while (n <= 15) { if (NPC[n] != null && NPC[n].Alive == true) { if (NPC[n].Z_Location == MapNum && NPC[n].Y_Location == iY && NPC[n].X_Location == iX) { CheckNPC = true; NPCNumber = n; return false; } } n++; } return true; } if (direction == 2) { iX = Player.X_Location + 1; iY = Player.Y_Location; if (File.ReadLines(@"DATA/mapcode.txt").Skip((MapNum - 1) * 261 + (iY * 16 + iX) + 6).Take(1).First() == "B") { return false; } int n = 0; while (n <= 15) { if (NPC[n] != null && NPC[n].Alive == true) { if (NPC[n].Z_Location == MapNum && NPC[n].Y_Location == iY && NPC[n].X_Location == iX) { CheckNPC = true; NPCNumber = n; return false; } } n++; } return true; } if (direction == 3) { iX = Player.X_Location; iY = Player.Y_Location - 1; if (File.ReadLines(@"DATA/mapcode.txt").Skip((MapNum - 1) * 261 + (iY * 16 + iX) + 6).Take(1).First() == "B") { return false; } int n = 0; while (n <= 15) { if (NPC[n] != null && NPC[n].Alive == true) { if (NPC[n].Z_Location == MapNum && NPC[n].Y_Location == iY && NPC[n].X_Location == iX) { CheckNPC = true; NPCNumber = n; return false; } } n++; } return true; } return true; }
public void LoadNPC(PictureBox [] NPCPicBox, Character [] NPC, PictureBox MapPictureBox) { int n = 0; while (n <= 15) { if (NPC[n] != null) { NPCPicBox[NPC[n].ID].Hide(); if (NPC[n].Z_Location == MapNumber && NPC[n].Alive == true) { NPC[n].DrawCharacter(NPCPicBox[NPC[n].ID], MapPictureBox); } } n++; } }