예제 #1
0
        private static StateInRuntime ConvertState(State originalState)
        {
            StateInRuntime State = new StateInRuntime();

            State.SetState(originalState);
            State.SetWeaponStats(FileMgr.GetInstance().LoadWeaponStats(originalState.SelectedWeaponStats));
            return(State);
        }
예제 #2
0
        /// <summary>
        /// Resets the State, both in Run time and both in persistant storage.
        /// </summary>
        public StateInRuntime Reset()
        {
            FileMgr.GetInstance().DeleteState();
            OriginatingState = null;
            State NewState = State.NewState();

            FileMgr.GetInstance().SaveState(NewState);
            Instance = ConvertState(NewState);
            return(Instance);
        }
예제 #3
0
        /// <summary>
        /// Verifies that all buttons display the correct values.
        /// </summary>
        private void RevalidateShop()
        {
            GameObject ItemTemplate = Resources.Load(GameConstants.PREFAB_PATH_STORE_ITEM_TEMPLATE, typeof(GameObject)) as GameObject;
            GameObject ItemDisplay  = GameObject.Find(GameConstants.UI_STORE_NAME_ITEM_DISPLAY);

            FileMgr FileManager = FileMgr.GetInstance();

            foreach (Button PurchaseButton in ItemDisplay.GetComponentsInChildren <Button>())
            {
                ItemDataHolder DataHolder = PurchaseButton.GetComponent <ItemDataHolder>();
                WeaponStats    Stats      = FileManager.LoadWeaponStats(DataHolder.GUID);
                PurchaseButton.GetComponent <Button>().onClick.RemoveAllListeners();
                if ((Stats.DefaultWeapon || CurrentLevel.IsPurchased(DataHolder.GUID)))
                {
                    if (CurrentLevel.PlayerState.SelectedWeapon.WeaponGUID.Equals(Stats.WeaponGUID))
                    {
                        PurchaseButton.GetComponentInChildren <Text>().text = "Selected";
                        PurchaseButton.GetComponent <Button>().interactable = false;
                        DataHolder.Selected = true;
                    }
                    else
                    {
                        PurchaseButton.GetComponentInChildren <Text>().text = "Select Item";
                        PurchaseButton.GetComponent <Button>().interactable = true;
                        DataHolder.Selected = false;
                        PurchaseButton.GetComponent <Button>().onClick.AddListener(SelectItem);
                    }
                }
                else if (!Stats.Purchased && (CurrentLevel.CanPurchase(Stats.Price)))
                {
                    PurchaseButton.GetComponent <Button>().onClick.AddListener(Purchase);
                }
                else
                {
                    PurchaseButton.GetComponentInChildren <Text>().text = "Too Expensive";
                    PurchaseButton.GetComponent <Button>().interactable = false;
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Marks a specific GUID as the selected weapon.
 /// </summary>
 /// <param name="GUID"></param>
 public void SelectWeapon(string GUID)
 {
     OriginatingState.SelectedWeaponStats = GUID;
     SelectedWeaponStats = FileMgr.GetInstance().LoadWeaponStats(GUID);
 }
예제 #5
0
 /// <summary>
 /// Saves the current state.
 /// </summary>
 public void Save()
 {
     OriginatingState.SelectedWeaponStats = SelectedWeapon.WeaponGUID;
     FileMgr.GetInstance().SaveState(OriginatingState);
 }
예제 #6
0
 public static StateInRuntime LoadState()
 {
     FileMgr.GetInstance().LoadState(out State LoadedState);
     Instance = ConvertState(LoadedState);
     return(Instance);
 }