![using UnityEngine;
using System.Collections;
public class MainInv_Lab3 : MonoBehaviour {
PF1_IO myIO;
LAA_Inventory inv;
LAA_Items tempItems;
LAA_Weapons tempWeapons;
LAA_Defense tempDefense;
enum STATE { none, name, value, att_def, inputItem };
STATE curState = STATE.none;
string iName = "";
int value = 0;
int att_def = 0;
string userInput;
void Start () {
myIO = PF1_IO.pf;
printInventory();
}
void Update () {
string sInput = "";
int itemp = 0;
if(myIO.IsThereInput()){
sInput = myIO.getString();
itemp = myIO.getInteger();
myIO.ClearPreviousInput();
}
switch(curState){
case STATE.name:
myIO.replaceText("Please enter a name for the item.");
if(sInput != ""){
print(sInput);
iName = sInput;
curState = STATE.value;
}
break;
case STATE.value:
myIO.replaceText("Item Name: " + iName + "\nPlease enter a value for the item.");
if(itemp > 0){
value = itemp;
itemp = 0;
curState = STATE.att_def;
}
break;
case STATE.att_def:
myIO.replaceText("Item Name: " + iName + "\nItem Value: " + value + "\n");
if(userInput ==){
myIO.appendText("Please enter a stat for the item.");
}
else if(userInput ==){
myIO.appendText("Please enter a stat for the item.");
if(itemp > 0){
att_def = itemp;
itemp = 0;
curState = STATE.inputItem;
}
break;
case STATE.inputItem:
if(userInput == ){
myIO.replaceText("Your item has been added to your inventory!");
WouldYouLikeTo();
}
if(userInput == ){
myIO.replaceText("Your item has been added to your inventory!");
WouldYouLikeTo();
}
break;
case STATE.none:
string temp = sInput.ToLower();
if(temp == || temp == ){
print(sInput);
userInput = temp;
sInput = "";
curState = STATE.name;
}
else if(temp == "inventory"){
printInventory();
sInput = "";
}
break;
}
}
void printInventory(){
myIO.replaceText("You currently have " + +
" items in your inventory. Consisting of:\n");
WouldYouLikeTo();
}
void WouldYouLikeTo(){
myIO.appendText("\n\nWould you like to add another type of \"\" or \"\" item to your inventory?" +
"\n\tOr would you like to see your \"inventory\" again?");
curState = STATE.none;
iName = "";
value = 0;
att_def = 0;
userInput = "";
}
}][1]
[1]: /storage/temp/70554-screen-shot-2016-05-22-at-52033-pm.png
↧