Advertisement
Guest User

Untitled

a guest
May 5th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CreateNewPotion : MonoBehaviour {
  5.  
  6. // Call the class BasePotion and assign it the name newPotion
  7. private BasePotion newPotion;
  8.  
  9. // Use this for initialization
  10. void Start () {
  11. // Call the function CreatePotion
  12. CreatePotion();
  13. // This is for testing it out
  14. Debug.Log(newPotion.ItemName);
  15. Debug.Log(newPotion.PotionType.ToString());
  16. Debug.Log(newPotion.ItemID.ToString());
  17. Debug.Log(newPotion.ItemDescription);
  18. }
  19.  
  20. private void CreatePotion()
  21. {
  22. // Initialize the newPotion variable
  23. newPotion = new BasePotion();
  24. // Description can be given more work.
  25. // What the potion does obviously.
  26. newPotion.ItemDescription = "This is a potion";
  27. // Call the function ChoosePotion
  28. ChoosePotion();
  29. }
  30.  
  31. private void ChoosePotion()
  32. {
  33. // Create a temporary random variable that rolls the dice between 0 and 5
  34. // Actual numbers are 0, 1, 2, 3, and 4 - One for each Potion Type
  35. int randomTemp = Random.Range(0,5);
  36. // Attach the variable to a switch to determine what will happen
  37. switch (randomTemp)
  38. {
  39. case 0:
  40. newPotion.ItemName = "Health Potion";
  41. newPotion.PotionType = BasePotion.PotionTypes.HEALTH;
  42. newPotion.ItemID = 11;
  43. break;
  44. case 1:
  45. newPotion.ItemName = "Mana Potion";
  46. newPotion.PotionType = BasePotion.PotionTypes.MANA;
  47. newPotion.ItemID = 12;
  48. break;
  49. case 2:
  50. newPotion.ItemName = "Potion of Strength";
  51. newPotion.PotionType = BasePotion.PotionTypes.STRENGTH;
  52. newPotion.ItemID = 13;
  53. break;
  54. case 3:
  55. newPotion.ItemName = "Potion of Intellect";
  56. newPotion.PotionType = BasePotion.PotionTypes.INTELLECT;
  57. newPotion.ItemID = 14;
  58. break;
  59. case 4:
  60. newPotion.ItemName = "Potion of Speed";
  61. newPotion.PotionType = BasePotion.PotionTypes.SPEED;
  62. newPotion.ItemID = 15;
  63. break;
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement