コード例 #1
0
        public void StartSinglePlayer(int playerNumber)
        {
            bool result;
            int  price;

            switch (playerNumber)
            {
            case 1: price = 0; result = (profileController.GetActivePlayer().GetCoinBalance() >= price); break;

            case 2: price = 100; result = (profileController.GetActivePlayer().GetCoinBalance() >= price); break;

            case 3: price = 200; result = (profileController.GetActivePlayer().GetCoinBalance() >= price); break;

            default: result = false; price = 0; break;
            }

            if (result)
            {
                profileController.GetActivePlayer().SpendCoins(price);
                Profile_Controller.settingsState = ProfileSettings.Silent;
                profileController.SaveProfile();

                dataController.SetOpponents(playerNumber);
                SceneManager.LoadScene("SinglePlayer_Battle");
            }

            else
            {
                Notification_Controller.DisplayNotification("Nem rendelkezel elég érmével!");
            }
        }
コード例 #2
0
        public override void Init()
        {
            modules.GetDataModule().CreateRandomOrder();

            //A legelső körnél nincs szükség különleges sorrendre
            if (controller.GetFirstRoundStatus())
            {
                controller.SetFirstRoundStatus(false);
                firstRound = true;

                ChangeState();
            }

            //A többi esetben az előző meccs nyertese lesz az új támadó, azaz az első a listában
            else
            {
                firstRound = false;
                //Valós érték vizsgálat
                if (controller.GetCurrentWinnerKey() != -1)
                {
                    modules.GetDataModule().PutWinnerInFirstPlace(controller.GetCurrentWinnerKey());
                }

                else
                {
                    Notification_Controller.DisplayNotification("Hiba történt! Visszatérés a Főmenübe!", controller.ExitGame);
                }
            }

            ChangeState();
        }
コード例 #3
0
        public void BuyItem()
        {
            if (profile.GetActivePlayer().GetCoinBalance() >= chipsData[index].GetPrice())
            {
                cardList.Clear();

                profile.GetActivePlayer().SpendCoins(chipsData[index].GetPrice());

                int cardNumber = chipsData[index].GetValue() + GetBonus();
                for (var i = 0; i < cardNumber; i++)
                {
                    Card temp = cardData.GetRandomCard();
                    cardList.Add(temp);
                    profile.GetActivePlayer().GetSecondaryDeck().AddCard(temp);
                }

                Profile_Controller.settingsState = ProfileSettings.Silent;
                profile.SaveProfile();
                balance.text = profile.GetActivePlayer().GetCoinBalance().ToString();
                RefreshMenu();

                boughtCardWindow = Instantiate(boughtCardWindowPrefab);
                boughtCardWindow.GetComponent <BoughtCard_Panel>().SetupPanel(cardList);
            }

            else
            {
                Notification_Controller.DisplayNotification("Nem rendelkezel elég érmével!");
            }
        }
コード例 #4
0
        //Karakter és játék adatok elmentése
        public void SaveProfile()
        {
            FileStream   stream = OpenFile(FileMode.Create);
            Profile_Data data   = playerProfile.GetData();

            try
            {
                formatter.Serialize(stream, data);
            }

            catch (SerializationException e)
            {
                Debug.Log(e);
                throw;
            }

            stream.Close();

            if (settingsState == ProfileSettings.NewProfile)
            {
                Notification_Controller.DisplayNotification("Az új profil létrehozva!");
            }

            else if (settingsState == ProfileSettings.Default)
            {
                Notification_Controller.DisplayNotification("A változtatások sikeresen elmentve!");
            }

            else if (settingsState == ProfileSettings.Silent)
            {
                settingsState = ProfileSettings.Default;
            }
        }
コード例 #5
0
        public void LoadProfile()
        {
            string path = Path.Combine(Application.persistentDataPath, fileName);

            mainMenuController = GameObject.Find("Menu_Controller").GetComponent <Main_Menu_Controller>();

            //Ellenőrzi, hogy van-e már mentésünk
            if (File.Exists(path))
            {
                FileStream   stream = OpenFile(FileMode.Open);
                Profile_Data data   = null;
                try
                {
                    data = formatter.Deserialize(stream) as Profile_Data;
                }

                catch (SerializationException e)
                {
                    Debug.Log(e);
                    throw;
                }

                stream.Close();

                //Megnézzük, hogy a betöltött adatok érvényesek-e
                if (data != default(Profile_Data))
                {
                    //Amennyiben igen, úgy betöltjük őket a profilba
                    Deck active    = factory.GetDeckFromList(data.activeDeck);
                    Deck secondary = factory.GetDeckFromList(data.secondaryDeck);
                    playerProfile = new Player(data, active, secondary);

                    //Jelezzük, hogy megtörtént a belépés.
                    mainMenuController.PlayerLoginStatus(true);
                }

                else
                {
                    Notification_Controller.DisplayNotification("A betöltés sikertelen!");
                    settingsState = ProfileSettings.NewProfile;
                    AskForName();
                    NewProfile();
                }
            }

            //Ha nincs még mentés file
            else
            {
                Notification_Controller.DisplayNotification("A mentést tároló fájl nincs létrehozva!");
                settingsState = ProfileSettings.NewProfile;
                AskForName();
            }
        }
コード例 #6
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else
        {
            Destroy(gameObject);
        }
    }
コード例 #7
0
        private bool VerifyName()
        {
            if (nameField.text.Length > 15 || nameField.text.Length < 1)
            {
                string msg = "A név hossza nem megfelelő!\nMinimum 1 és maximum 15 karakter lehet!";
                Notification_Controller.DisplayNotification(msg);
                return(false);
            }
            Regex rgx = new Regex(@"^[A-Za-z0-9áÁöÖüÜőŐúÚűŰéÉíÍ]+$");

            if (rgx.IsMatch(nameField.text))
            {
                return(true);
            }

            else
            {
                string msg = "Szabálytalan név formátum!\nKérem csak betűket és számokat használjon!";
                Notification_Controller.DisplayNotification(msg);
                return(false);
            }
        }
コード例 #8
0
        public override void ChangeState()
        {
            //Ha holtverseny van
            if (winnerCardCount.Count(p => p >= GameSettings_Controller.winsNeeded) > 1)
            {
                foreach (int key in maxKeys)
                {
                    //Ha a játékos is a győztesek között van.
                    if (modules.GetDataModule().GetPlayerWithKey(key).GetPlayerStatus())
                    {
                        reward = (reward / maxKeys.Count);
                        GameObject.Find("Profile_Controller").GetComponent <Profile_Controller>().GetActivePlayer().AddCoins(reward);
                        Profile_Controller.settingsState = ProfileSettings.Silent;
                        GameObject.Find("Profile_Controller").GetComponent <Profile_Controller>().SaveProfile();
                    }
                }
                Notification_Controller.DisplayNotification($"Játék Vége!\nAz eredmény döntetlen!\nJutalmad:{reward} Érme", controller.ExitGame);
            }

            //Ha egyértelmű a győzelem
            else
            {
                //Ha a játékos a győztes
                if (modules.GetDataModule().GetPlayerWithKey(maxKeys[0]).GetPlayerStatus())
                {
                    GameObject.Find("Profile_Controller").GetComponent <Profile_Controller>().GetActivePlayer().AddCoins(reward);
                    Profile_Controller.settingsState = ProfileSettings.Silent;
                    GameObject.Find("Profile_Controller").GetComponent <Profile_Controller>().SaveProfile();
                }

                else
                {
                    reward = 0;
                }

                Notification_Controller.DisplayNotification($"Játék Vége!\nA győztes: {modules.GetDataModule().GetPlayerWithKey(maxKeys[0]).GetUsername()}\nJutalmad:{reward} Érme", controller.ExitGame);
            }
        }
コード例 #9
0
 public void Multiplayer()
 {
     //SceneManager.LoadScene("Multiplayer");
     Notification_Controller.DisplayNotification("Dolgozok rajta, eskü!");
 }
コード例 #10
0
 public void RulesButton()
 {
     Notification_Controller.DisplayNotification("A pakli minimális mérte: 10 kártya.\n10 kártyánként 1 példány lehet csak minden lapból.\n(Példa: 20 lapnál 2 lehet maximum minden lapból)");
 }
コード例 #11
0
 public void GetHelp()
 {
     Notification_Controller.DisplayNotification("A sajtos Chips 1, a pizzás 3 garantált kártyát ad.\nVan rá esély, hogy ezek mellett egy bónusz lapot is találsz a zacskóban!");
 }