// Start is called before the first frame update
 void Start()
 {
     if (ContinueButton != null)
     {
         ContinueButton.GetComponent <Button>().interactable = VSAllCountriesModel.HasCurrentGame();
     }
 }
    public static void SaveInstance(VSAllCountriesModel toSave)
    {
        string json = JsonConvert.SerializeObject(toSave);

        PlayerPrefs.SetString(PREF_KEY, json);

        PlayerPrefs.Save();
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        vsacm = VSAllCountriesModel.GetCurrentGame();
        cm    = CountryModel.GetCountries();

        SetPointsText(vsacm.RemainingPoints);
        SetIntText(vsacm.AllocatedInt);
        SetPowText(vsacm.AllocatedPower);
        SetSpdText(vsacm.AllocatedSpeed);

        Initialize();
    }
Beispiel #4
0
    public void SaveAllocation()
    {
        AllocationInt.color = Color.white;
        AllocationSpd.color = Color.white;
        AllocationPow.color = Color.white;

        vsacm.AllocatedInt    = _int;
        vsacm.AllocatedPower  = _pow;
        vsacm.AllocatedSpeed  = _spd;
        vsacm.RemainingPoints = _points;

        VSAllCountriesModel.SaveInstance(vsacm);
    }
    public static void StartNew()
    {
        VSAllCountriesModel vsm = new VSAllCountriesModel()
        {
            AllocatedInt = 75, AllocatedPower = 75, AllocatedSpeed = 75, CurrentLevel = 0, RemainingPoints = 5
        };

        var countries = CountryModel.GetCountries();

        List <string> orderCountries = new List <string>();

        foreach (var i in countries)
        {
            orderCountries.Add(i.ShortName);
        }

        RandomUtil.Shuffle <string>(orderCountries);

        vsm.OrderOfCountries = orderCountries;

        SaveInstance(vsm);
    }
Beispiel #6
0
    public void AddScore(int teamIndex)
    {
        var sd = GameObject.FindObjectsOfType <SuperKickDestination>();

        foreach (var i in sd)
        {
            Destroy(i.gameObject);
        }

        if (SelectionSingleton.instance.IsPractice)
        {
            return;
        }

        TeamProps t  = teams[teamIndex];
        TeamProps to = teams[(teamIndex == 0) ? 1 : 0];
        string    sr = "ROUND";

        t.Score       += 1;
        t.UIScore.text = t.Score.ToString();
        string c = (teamIndex == 0) ? "red" : "blue";

        if ((t.Score + to.Score) % 3 == 0)
        {
            isTopServe = !isTopServe;
        }

        if (t.Score >= currentScoreToWin && t.Score - to.Score > 1)
        {
            currentSet++;

            sr                = "SET";
            t.SetCore        += 1;
            t.UISetScore.text = t.SetCore.ToString();
            t.Score           = 0;
            t.UIScore.text    = t.Score.ToString();
            to.Score          = 0;
            to.UIScore.text   = t.Score.ToString();


            if (currentSet == FINAL_SET)
            {
                Debug.Log("FINAL SET");
                currentScoreToWin = SCORE_TO_WIN_LAST_SET;
            }
        }

        if (t.SetCore == SETS_TO_WIN)
        {
            MatchFinishedPanel.SetActive(true);
            hasWinner = true;
            sr        = "MATCH";

            if (teamIndex == 1)
            {
                if (!SelectionSingleton.instance.IsMinigame)
                {
                    TextEndGame.text = "You've earned <color=\"yellow\">100</color> points";
                    EarnedPointsUI.SetActive(true);
                    PointsUtil.AddPoints(100);
                }
                else
                {
                    TextEndGame.text = "You've earned <color=\"yellow\">5</color> allocation points";
                    EarnedPointsUI.SetActive(true);
                    var vsac = VSAllCountriesModel.GetCurrentGame();
                    vsac.RemainingPoints += 5;
                    vsac.CurrentLevel     = vsac.CurrentLevel < 4 ? vsac.CurrentLevel + 1 : 0;
                    VSAllCountriesModel.SaveInstance(vsac);
                    //PointsUtil.AddPoints(100);
                }
            }
        }

        ScoredTeamText.text = $"<color={c}>{t.TeamName}</color> WIN {sr}";
    }
    public void StartNewGame()
    {
        VSAllCountriesModel.StartNew();

        GoToAllCountriesGame();
    }