Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class CreateNewPotion : MonoBehaviour {
- // Call the class BasePotion and assign it the name newPotion
- private BasePotion newPotion;
- // Use this for initialization
- void Start () {
- // Call the function CreatePotion
- CreatePotion();
- // This is for testing it out
- Debug.Log(newPotion.ItemName);
- Debug.Log(newPotion.PotionType.ToString());
- Debug.Log(newPotion.ItemID.ToString());
- Debug.Log(newPotion.ItemDescription);
- }
- private void CreatePotion()
- {
- // Initialize the newPotion variable
- newPotion = new BasePotion();
- // Description can be given more work.
- // What the potion does obviously.
- newPotion.ItemDescription = "This is a potion";
- // Call the function ChoosePotion
- ChoosePotion();
- }
- private void ChoosePotion()
- {
- // Create a temporary random variable that rolls the dice between 0 and 5
- // Actual numbers are 0, 1, 2, 3, and 4 - One for each Potion Type
- int randomTemp = Random.Range(0,5);
- // Attach the variable to a switch to determine what will happen
- switch (randomTemp)
- {
- case 0:
- newPotion.ItemName = "Health Potion";
- newPotion.PotionType = BasePotion.PotionTypes.HEALTH;
- newPotion.ItemID = 11;
- break;
- case 1:
- newPotion.ItemName = "Mana Potion";
- newPotion.PotionType = BasePotion.PotionTypes.MANA;
- newPotion.ItemID = 12;
- break;
- case 2:
- newPotion.ItemName = "Potion of Strength";
- newPotion.PotionType = BasePotion.PotionTypes.STRENGTH;
- newPotion.ItemID = 13;
- break;
- case 3:
- newPotion.ItemName = "Potion of Intellect";
- newPotion.PotionType = BasePotion.PotionTypes.INTELLECT;
- newPotion.ItemID = 14;
- break;
- case 4:
- newPotion.ItemName = "Potion of Speed";
- newPotion.PotionType = BasePotion.PotionTypes.SPEED;
- newPotion.ItemID = 15;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement