Example #1
0
        private void Delete()
        {
            Console.Clear();

            ConsoleUI.AddHeader("Delete Save", ConsoleColor.Yellow);

            for (int i = 0; i < SaveManager.Instance.GetValidIndex().Length; i++)
            {
                int    index  = SaveManager.Instance.GetValidIndex()[i];
                string option = $"{SaveManager.Instance.GetSaveName(index)}";
                ConsoleUI.AddOption(option, $"{index}", ConsoleColor.Red);
            }


            SaveManager.Instance.DeleteAt(InputNumber());
            OnUpdateUI.Invoke();
        }
Example #2
0
    void Start()
    {
        inventory       = Inventory.instance;
        chestController = ChestController.instance;
        chest           = FindObjectOfType <Chest>();

        inventoryUI.SetActive(false);
        equipmentUI.SetActive(false);
        chestUI.SetActive(false);

        // Важно е този скрипт(UIController) да се извърши след Inventory, EquipmentController и ChestController,
        // защото иначе при отваряне на инвентара или chest-a, ще дава Index out of range,
        // понеже масивите items[], currentEquipment[] и chestItems[] няма да са инициализирани.
        // Приоритетът на изпълнение на скриптовете може да се настройва ръчно от меню Script Execution Order.

        onUpdateUICallback += UpdateChestUI;
    }
        void SetClass()
        {
            Console.Clear();
            ConsoleUI.AddHeader("Select Class", ConsoleColor.Yellow);

            string[] classList =
            {
                "Warrior",
                "Mage",
                "Ranger",
                "Thief",
                "Priest",
                "Archer",
                "Orc",
                "Demon"
            };

            ConsoleUI.AddList(classList, 1, ConsoleColor.Cyan);

            CharacterClass characterClass = new Warrior();

            string classInput = Console.ReadLine();

            if (GetKeyInput(classInput, "1", "warrior"))
            {
                characterClass = new Warrior(250, 100, 100, 0);
            }
            else if (GetKeyInput(classInput, "2", "mage"))
            {
                characterClass = new Mage(200, 75, 75, 100);
            }
            else if (GetKeyInput(classInput, "3", "ranger"))
            {
                characterClass = new Ranger(200, 50, 100, 50);;
            }
            else if (GetKeyInput(classInput, "4", "thief"))
            {
                characterClass = new Thief(150, 50, 125, 75);
            }

            GameManager.Instance.PlayerCharacter.CharacterClass = characterClass;

            OnUpdateUI?.Invoke();
            ConsoleUI.Warning("You have selected : " + characterClass.GetType().Name);
            Console.WriteLine();
        }
        void SetName()
        {
InputName:
            Console.Write("Character Name : ");
            string name = Console.ReadLine();

            if (name == string.Empty)
            {
                OnUpdateUI?.Invoke();
                ConsoleUI.Error("\nPlease select a valid option...\n");
                goto InputName;
            }

            GameManager.Instance.PlayerCharacter.Name = name;
            OnUpdateUI?.Invoke();
            ConsoleUI.Warning("Character name has been set to : " + GameManager.Instance.PlayerCharacter.Name);
            Console.WriteLine();
        }
Example #5
0
 public MainMenuState(Stack <State> states) : base(states)
 {
     OnUpdateUI?.Invoke();
 }
Example #6
0
        public override void Update()
        {
            ConsoleUI.ColorText("Choice : ", ConsoleColor.Green);
            string keyInput = Console.ReadLine();

            if (GetKeyInput(keyInput, "0"))
            {
                PopState();
            }
            else if (GetKeyInput(keyInput, "1"))
            {
                OnUpdateUI?.Invoke();
                Console.WriteLine("IMPLEMENT GAME STATE...");
                Console.ReadKey();
            }
            else if (GetKeyInput(keyInput, "2"))
            {
                PushState(new CreateCharacterState(States));
            }
            else if (GetKeyInput(keyInput, "3"))
            {
                if (SaveManager.Instance.SaveCount() > 0)
                {
                    PushState(new SelectCharacterState(States));
                }
                else
                {
                    OnUpdateUI?.Invoke();
                    ConsoleUI.Error("Unable to find any save, please create one...");
                }
            }
            else if (GetKeyInput(keyInput, "4"))
            {
                OnUpdateUI?.Invoke();
                Save();
            }
            else if (GetKeyInput(keyInput, "5"))
            {
                OnUpdateUI?.Invoke();
                Load();
            }
            else if (GetKeyInput(keyInput, "6"))
            {
                if (SaveManager.Instance.SaveCount() >= 1)
                {
                    Delete();
                }
                else
                {
                    ConsoleUI.Error("There is no save to delete...");
                }
            }
            else if (GetKeyInput(keyInput, "7"))
            {
                GameManager.Instance.PlayerCharacter.DisplayInfo();
                Console.WriteLine("Press Any Key...");
                Console.ReadKey();
                OnUpdateUI?.Invoke();
            }
            else
            {
                OnUpdateUI?.Invoke();
                ConsoleUI.Error("Please select a valid option...");
            }
        }
 public CreateCharacterState(Stack <State> states) : base(states)
 {
     OnUpdateUI.Invoke();
     GameManager.Instance.PlayerCharacter = new Character();
 }
Example #8
0
 public SelectCharacterState(Stack <State> states) : base(states)
 {
     OnUpdateUI?.Invoke();
 }
Example #9
0
 public void RaiseUpdateUI(object sender, EventArgs args)
 {
     OnUpdateUI.Raise(sender, args);
 }
Example #10
0
 public void UpdateUI()
 {
     OnUpdateUI?.Invoke();
 }