public void CreateSlot2(Player player) { bool first = false; bool second = false; if (page2) { for (int x = 0; x < 18; x++) { if (player.Inv[x, 0] == recipes[page, 1].requirements[0, 0] && player.Inv[x, 1] >= recipes[page, 1].requirements[0, 1] && !first) { first = true; } else { first = false; } if (player.Inv[x, 0] == recipes[page, 1].requirements[1, 0] && player.Inv[x, 1] >= recipes[page, 1].requirements[1, 1]) { second = true; break; } else { second = false; } } if (first && second) { for (int num = recipes[page, 1].requirements[0, 1]; num > 0; num--) { player.InvDel(recipes[page, 1].requirements[0, 0]); } for (int num = recipes[page, 1].requirements[1, 1]; num > 0; num--) { player.InvDel(recipes[page, 1].requirements[1, 0]); } player.InvAddItem(recipes[page, 1].itemIndex); } } }
public void BlockModifier(string situation, Player player, GameTime gameTime) { bool dig = false; digTimer += gameTime.ElapsedGameTime.TotalSeconds; if (digTimer < .5 && digTimer > 0) { digIndex = 0; } else if (digTimer < 1.0 && digTimer > .5) { digIndex = 1; } else if (digTimer < 1.5 && digTimer > 1.0) { digIndex = 2; } else if (digTimer < 2 && digTimer > 1.5) { digIndex = 3; dig = true; } Random random = new Random(); int MouseCordX; int MouseCordY; MouseState mouse = Mouse.GetState(); //Vector2 mouseDistance; // calculate distance from player's center //mouseDistance.X = Math.Abs(mouse.X - (player.playerPosition.X + 16)); //mouseDistance.Y = Math.Abs(mouse.Y - (player.playerPosition.Y + 24)); //MouseCordX = (((mouse.X + 86) - (int)(smallDifference.X * 16f)) / 16); //MouseCordY = (((mouse.Y + 86) - (int)(smallDifference.Y * 16f)) / 16); Vector2 MouseCord = MouseCoord(); digLocation = new Vector2(MouseCord.X, MouseCord.Y); if (dig || situation == "Add") { //int BlockID = 1; // temprorary hardcoded value int BlockID = 0; // prevents the player from placing/removing blocks that are far away if (MouseInRange()) { switch (situation) { case "Delete": digTimer = 0; digLocation.X = -1; digLocation.Y = -1; // 28, 21 BlockID = MouseIndex(); player.InvAdd(BlockID); Global.world[(int)(MouseCord.X + difference.X), (int)(MouseCord.Y + difference.Y), 0] = 0; break; case "Add": BlockID = player.Inv[player.selectedInvSlot, 0]; if (BlockID != 0) { if (player.InvDel(BlockID) && area[(int)MouseCord.X, (int)MouseCord.Y, 0] == 0) { if ((BlockID == 1)) //Dirt { BlockID = random.Next(1, 4); } else if (BlockID == 4) { BlockID = random.Next(4, 7); } Global.world[(int)(MouseCord.X + difference.X), (int)(MouseCord.Y + difference.Y), 0] = BlockID; } } break; } } } }
public void BlockModifier(string situation, Player player, GameTime gameTime) { bool dig = false; digTimer += gameTime.ElapsedGameTime.TotalSeconds; if (digTimer < .5 && digTimer > 0) { digIndex = 0; } else if(digTimer < 1.0 && digTimer > .5) { digIndex = 1; } else if (digTimer < 1.5 && digTimer > 1.0) { digIndex = 2; } else if (digTimer < 2 && digTimer > 1.5) { digIndex = 3; dig = true; } Random random = new Random(); int MouseCordX; int MouseCordY; MouseState mouse = Mouse.GetState(); //Vector2 mouseDistance; // calculate distance from player's center //mouseDistance.X = Math.Abs(mouse.X - (player.playerPosition.X + 16)); //mouseDistance.Y = Math.Abs(mouse.Y - (player.playerPosition.Y + 24)); //MouseCordX = (((mouse.X + 86) - (int)(smallDifference.X * 16f)) / 16); //MouseCordY = (((mouse.Y + 86) - (int)(smallDifference.Y * 16f)) / 16); Vector2 MouseCord = MouseCoord(); digLocation = new Vector2(MouseCord.X, MouseCord.Y); if (dig || situation == "Add") { //int BlockID = 1; // temprorary hardcoded value int BlockID = 0; // prevents the player from placing/removing blocks that are far away if (MouseInRange()) { switch (situation) { case "Delete": digTimer = 0; digLocation.X = -1; digLocation.Y = -1; // 28, 21 BlockID = MouseIndex(); player.InvAdd(BlockID); Global.world[(int)(MouseCord.X + difference.X), (int)(MouseCord.Y + difference.Y), 0] = 0; break; case "Add": BlockID = player.Inv[player.selectedInvSlot, 0]; if (BlockID != 0) { if (player.InvDel(BlockID) && area[(int)MouseCord.X, (int)MouseCord.Y, 0] == 0) { if ((BlockID == 1))//Dirt { BlockID = random.Next(1, 4); } else if (BlockID == 4) { BlockID = random.Next(4, 7); } Global.world[(int)(MouseCord.X + difference.X), (int)(MouseCord.Y + difference.Y), 0] = BlockID; } } break; } } } }
public void CreateSlot2(Player player) { bool first = false; bool second = false; if (page2) { for (int x = 0; x < 18; x++) { if (player.Inv[x, 0] == recipes[page, 1].requirements[0, 0] && player.Inv[x, 1] >= recipes[page, 1].requirements[0, 1] && !first) { first = true; } else { first = false; } if (player.Inv[x, 0] == recipes[page, 1].requirements[1, 0] && player.Inv[x, 1] >= recipes[page, 1].requirements[1, 1]) { second = true; break; } else { second = false; } } if (first && second) { for (int num = recipes[page, 1].requirements[0, 1]; num > 0; num--) { player.InvDel(recipes[page, 1].requirements[0, 0]); } for (int num = recipes[page, 1].requirements[1, 1]; num > 0; num--) { player.InvDel(recipes[page, 1].requirements[1, 0]); } player.InvAddItem(recipes[page, 1].itemIndex); } } }