Exemplo n.º 1
0
        private static StateInRuntime ConvertState(State originalState)
        {
            StateInRuntime State = new StateInRuntime();

            State.SetState(originalState);
            State.SetWeaponStats(FileMgr.GetInstance().LoadWeaponStats(originalState.SelectedWeaponStats));
            return(State);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 4
0
 private FileMgr()
 {
     Instance = this;
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Saves the current state.
 /// </summary>
 public void Save()
 {
     OriginatingState.SelectedWeaponStats = SelectedWeapon.WeaponGUID;
     FileMgr.GetInstance().SaveState(OriginatingState);
 }
Exemplo n.º 7
0
 public static StateInRuntime LoadState()
 {
     FileMgr.GetInstance().LoadState(out State LoadedState);
     Instance = ConvertState(LoadedState);
     return(Instance);
 }