shopController.AddSelectableItem(item);// Inform controller that a new item is selectable
//print("Attempt to add item " + item.name + " to view");
//print("Attempt to add item " + item.name + " to view");
}
}
@ -62,6 +65,7 @@ public class ShopViewGrid : ShopView
if(itemView.Item==item)
if(itemView.Item==item)
{
{
model.RemoveObserver(itemView);
model.RemoveObserver(itemView);
shopController.RemoveSelectableItem(itemView.Item);// Notify the controller that this item is no longer selectable
Destroy(itemView.gameObject);
Destroy(itemView.gameObject);
return;
return;
}
}
@ -70,18 +74,22 @@ public class ShopViewGrid : ShopView
protectedoverridevoidSwitchToKeyboardControl()
protectedoverridevoidSwitchToKeyboardControl()
{
{
varavailableItems=shopController.Items;
Destroy(shopController);//Remove the current controller component
Destroy(shopController);//Remove the current controller component
shopController=gameObject.AddComponent<GridViewKeyboardController>().Initialize(model);//Create and add a keyboard controller
shopController=gameObject.AddComponent<GridViewKeyboardController>().Initialize(model);//Create and add a keyboard controller
instructionText.text="The current control mode is: Keyboard Control, WASD to select item, press K to buy. Press left mouse button to switch to Mouse Control.";
instructionText.text="The current control mode is: Keyboard Control, WASD to select item, press K to buy. Press left mouse button to switch to Mouse Control.";
buyButton.gameObject.SetActive(false);//Hide the buy button because we only use keyboard
buyButton.gameObject.SetActive(false);//Hide the buy button because we only use keyboard
shopController.Items=availableItems;
}
}
protectedoverridevoidSwitchToMouseControl()
protectedoverridevoidSwitchToMouseControl()
{
{
varavailableItems=shopController.Items;
Destroy(shopController);//Remove the current controller component
Destroy(shopController);//Remove the current controller component
shopController=gameObject.AddComponent<MouseController>().Initialize(model);//Create and add a mouse controller
shopController=gameObject.AddComponent<MouseController>().Initialize(model);//Create and add a mouse controller
instructionText.text="The current control mode is: Mouse Control, press 'K' to switch to Keyboard Control.";
instructionText.text="The current control mode is: Mouse Control, press 'K' to switch to Keyboard Control.";
buyButton.gameObject.SetActive(true);//Show the buy button for the mouse controler
buyButton.gameObject.SetActive(true);//Show the buy button for the mouse controler