示例#1
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/slot1.dat"))
        {
            thePlayer.isTalking = false;
            thePlayer.canMove   = true;
            PlayerPrefs.DeleteAll();
            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_START_MENU_SELECT);

            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/slot1.dat", FileMode.Open);

            PlayerData data = (PlayerData)bf.Deserialize(file);
            file.Close();

            thePlayer.nextUuid = data.savePointId;
            stats.level        = data.level;
            moneyManager.AddMoney(data.gold);
            healthManager.UpdateMaxHealth(stats.hpLevels[data.level]);
            mpManager.UpdateMaxMP(stats.mpLevels[data.level]);
            uiManager.LevelChanged(stats.level, stats.expToLevelUp.Length,
                                   stats.expToLevelUp[stats.level],
                                   stats.expToLevelUp[stats.level - 1]);
            stats.exp = data.exp;
            uiManager.ExpChanged(data.exp);

            stats.newstrengthLevels = data.str;
            stats.newdefenseLevels  = data.def;
            stats.newmagicAttLevels = data.mat;
            stats.newmagicDefLevels = data.mdf;
            stats.newspeedLevels    = data.spd;
            stats.newluckLevels     = data.lck;
            stats.newaccuracyLevels = data.acc;


            //stats.AddStatsAtLevelUP(0);
            mpManager.ChangeMP(data.mp);
            healthManager.ChangeHealth(data.health);
            itemsManager.currentPotions     = data.potions;
            itemsManager.currentEthers      = data.ethers;
            itemsManager.currentPhoenixDown = data.pd;

            //Recupera weapons
            for (int i = 0; i < data.weaponsInInventory.Count; i++)
            {
                weaponManager.SearchWeaponByName(data.weaponsInInventory[i]);
            }
            //Activa el arma que tenia activa
            //weaponManager.ChangeWeapon(data.activeWeapon);
            weaponManager.activeWeapon = data.activeWeapon;
            weaponManager.DeactivateWeapon(true);
            uiManager.WeaponEq();
            //Recupera Armors
            for (int i = 0; i < data.armorsInInventory.Count; i++)
            {
                armorManager.SearchArmorByName(data.armorsInInventory[i]);
            }
            //armorManager.ChangeArmor(data.activeArmor);
            armorManager.activeArmor = data.activeArmor;
            armorManager.ActivateArmor(true);
            uiManager.ArmorEq();
            //Recupera Accesorios
            for (int i = 0; i < data.accesoriesInInventory.Count; i++)
            {
                accesoryManager.SearchAccByName(data.accesoriesInInventory[i]);
            }
            //accesoryManager.ChangeAccesory(data.activeAccesory);
            accesoryManager.activeAccesory = data.activeAccesory;
            accesoryManager.ActivateAcc(true);
            uiManager.AccesoryEq();

            //Recupera quests terminadas
            for (int i = 0; i < data.questsCompleted.Count; i++)
            {
                questManager.SearchQuestByIDSetCompleted(data.questsCompleted[i]);
            }

            //Recupera quests arrancadas
            for (int i = 0; i < data.questsStarted.Count; i++)
            {
                questManager.SearchQuestByIDSetStarted(data.questsStarted[i]);
            }

            //Recupera Items Quest

            for (int i = 0; i < data.questItems.Count; i++)
            {
                //Debug.Log(data.questItems[i]);
                itemsManager.AddQuestItemByName(data.questItems[i]);
            }

            //Recupera skills activas
            for (int i = 0; i < data.activeSkills.Count; i++)
            {
                uiManager.ActivateSkill(data.activeSkills[i]);
            }

            itemsManager.chestsDict = data.chests;
            // Recupera los chests
            foreach (KeyValuePair <string, string> entry in data.chests)
            {
                PlayerPrefs.SetString(entry.Key, entry.Value);
            }

            sceneTransition.Transition(data.sceneName);
            //SceneManager.LoadScene(data.sceneName)
        }
        else
        {
            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_MENU_ERROR);
        }
    }
示例#2
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    public void Sell()
    {
        MoneyManager moneyManager = GameObject.Find("MoneyManager").GetComponent <MoneyManager>();

        moneyManager.AddMoney(MoneyOnSelling());
    }
 // Start is called before the first frame update
 void Start()
 {
     //Set money to the starting money amount
     money.AddMoney(startingMoney);
 }
 private void Start()
 {
     moneyManager.AddMoney(initialWealth);
     StartCoroutine(GameLoop());
 }
示例#5
0
    void Update()
    {
        if (!bTutorial)
        {
            timeElapsed += Time.deltaTime;

            if (timeElapsed >= 2.0f)
            {
                timeElapsed    = 0.0f;
                time           = time.AddMinutes(MinutesToAdd * 15);
                TimerText.text = time.ToShortTimeString();

                if (time.ToShortTimeString().Equals("6:00 a.m."))
                {
                    DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x,
                               new Color(0.8014706f, 0.5852523f, 0.5181363f, 1.0f), 1);
                }
                else if (time.ToShortTimeString().Equals("8:00 a.m."))
                {
                    DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x,
                               new Color(1.0f, 1.0f, 1.0f, 1.0f), 1);

                    foreach (MeshRenderer rend in tileManager.m_EmissiveTiles)
                    {
                        rend.enabled = false;
                    }
                }
                else if (time.ToShortTimeString().Equals("6:00 p.m."))
                {
                    DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x,
                               new Color(0.7352941f, 0.4541522f, 0.5181363f, 1.0f), 1);
                }
                else if (time.ToShortTimeString().Equals("8:00 p.m."))
                {
                    DOTween.To(() => RenderSettings.ambientLight, x => RenderSettings.ambientLight = x,
                               new Color(0.075f, 0.11f, 0.242f, 1.0f), 1);
                    foreach (MeshRenderer rend in tileManager.m_EmissiveTiles)
                    {
                        rend.enabled = true;
                    }
                }

                if (time.ToShortTimeString().Equals("7:00 p.m."))
                {
                    // NIGHTTIME
                    MinutesToAdd = 2;
                    Camera.main.GetComponents <AudioSource>()[0].DOFade(0.0f, 1.0f);
                    Camera.main.GetComponents <AudioSource>()[1].Play();
                    Camera.main.GetComponents <AudioSource>()[1].DOFade(0.7f, 1.0f);

                    GetComponent <AudioSource>().Play();
                }
                else if (time.ToShortTimeString().Equals("7:00 a.m."))
                {
                    // DAYTIME
                    MinutesToAdd = 1;
                    Camera.main.GetComponents <AudioSource>()[0].DOFade(1.0f, 1.0f);
                    Camera.main.GetComponents <AudioSource>()[1].DOFade(0.0f, 1.0f);
                }
            }

            if (time.ToShortTimeString().Equals("7:00 p.m."))
            {
                DayTime = false;
                t       = 0;
            }
            else if (time.ToShortTimeString().Equals("8:00 a.m."))
            {
                DayTime = true;
                t       = 0;
            }

            if (!DayTime)
            {
                IssuesManager.Daytime = false;
                foreach (SpriteRenderer OneCloud in Allclouds)
                {
                    OneCloud.DOFade(0.0f, 0.2f);
                }

                foreach (SpriteRenderer OneStar in Allstars)
                {
                    OneStar.DOFade(1.0f, 2.0f);
                }


                if (t < 1)
                { // while t below the end limit...
                  // increment it at the desired rate every update:
                    t += Time.deltaTime / duration;
                }

                lerpColor = Color.Lerp(DayTimeColor, NightTimeColor, t);

                RenderSettings.skybox.SetColor("_Tint", lerpColor);
            }
            else
            {
                IssuesManager.Daytime = true;
                foreach (SpriteRenderer OneCloud in Allclouds)
                {
                    OneCloud.DOFade(1.0f, 2.0f);
                }

                foreach (SpriteRenderer OneStar in Allstars)
                {
                    OneStar.DOFade(0.0f, 0.2f);
                }

                if (t < 1)
                { // while t below the end limit...
                  // increment it at the desired rate every update:
                    t += Time.deltaTime / duration;
                }

                lerpColor = Color.Lerp(NightTimeColor, DayTimeColor, t);

                RenderSettings.skybox.SetColor("_Tint", lerpColor);
            }

            if (!bHasDayFinished && time.ToShortTimeString().Equals("12:00 a.m.") || time.ToShortTimeString().Equals("12:15 a.m."))
            {
                bHasDayFinished = true;

                // Add population
                iPopulation        *= 1.02f;
                PopulationText.text = iPopulation.ToString();

                // Add currency
                Money.AddMoney(200.0f);

                // close all issues
                IssuesManager.ResetIssues();
                tileManager.ResetRubbish();

                RubbishTruckController rubbishTruck = FindObjectOfType <RubbishTruckController>();
                if (rubbishTruck)
                {
                    Destroy(rubbishTruck.gameObject);
                }

                // reset contractors
                for (int i = 0; i < AllHQs.Length; ++i)
                {
                    AllHQs[i].RemoveContractors();
                }

                Time.timeScale = 0;
                Transform[] gos = EffectsObject.GetComponentsInChildren <Transform>();
                for (int i = 1; i < gos.Length; ++i)
                {
                    Destroy(gos[i].gameObject);
                }
                DayCompletedCanvas.SetActive(true);

                int iJobsCompletedDay = 0;
                for (int i = 0; i < 4; ++i)
                {
                    iJobsCompletedDay            += AllHQs[i].JobsCompletedForDay;
                    AllHQs[i].JobsCompletedForDay = 0;
                }
                AucklandersHelpedText.text = iJobsCompletedDay.ToString();
                MostLiveableText.text      = CitySatisfaction.GetCitySatisfaction().ToString() + "%";
                DayHeaderText.text         = "Congratulations! You Finished Day " + CurrentDay.ToString();

                float citySatisfaction = CitySatisfaction.GetCitySatisfaction();
                SaveLoadHighScore.Save(citySatisfaction);
                FeedbackText.text = "";
                if (CurrentDay == 1)
                {
                    if (citySatisfaction < 10.0f)
                    {
                        FeedbackText.text = "Rough first day huh? Better luck tomorrow, you can do this!";
                    }
                    else if (citySatisfaction < 25.0f)
                    {
                        FeedbackText.text = "Not bad for a first day!";
                    }
                    else if (citySatisfaction < 50.0f)
                    {
                        FeedbackText.text = "Good job on increasing Auckland's Liveability so quickly!";
                    }
                    else if (citySatisfaction < 75.0f)
                    {
                        FeedbackText.text = "Well on the way to being the most Liveable City! First day on the job, too!";
                    }
                }
                else if (CurrentDay < 5)
                {
                    if (citySatisfaction < 10.0f)
                    {
                        FeedbackText.text = "Hm, Auckland doesn't seem very happy with how you're managing this.";
                    }
                    else if (citySatisfaction < 25.0f)
                    {
                        FeedbackText.text = "Not too bad, but definitely not the most liveable city in the world...";
                    }
                    else if (citySatisfaction < 50.0f)
                    {
                        FeedbackText.text = "Aucklanders are happy - but they could be happier! Can you increase the rating tomorrow?";
                    }
                    else if (citySatisfaction < 75.0f)
                    {
                        FeedbackText.text = "Well on the way to being the most Liveable City!";
                    }
                    else if (citySatisfaction < 100.0f)
                    {
                        FeedbackText.text = "Aucklanders are happier than ever - nearly the most Liveable City in the World!";
                    }
                    else
                    {
                        FeedbackText.text = "Wow! You've helped make Auckland the World's Most Liveable City! ";
                    }
                }
                else
                {
                    if (citySatisfaction < 10.0f)
                    {
                        FeedbackText.text = "You survived 5 days - just!";
                    }
                    else if (citySatisfaction < 25.0f)
                    {
                        FeedbackText.text = "You survived 5 days, but Aucklanders are pretty disgruntled...";
                    }
                    else if (citySatisfaction < 50.0f)
                    {
                        FeedbackText.text = "Aucklanders are happy - but they could be happier!";
                    }
                    else if (citySatisfaction < 75.0f)
                    {
                        FeedbackText.text = "Well on the way to being the most Liveable City!";
                    }
                    else if (citySatisfaction < 100.0f)
                    {
                        FeedbackText.text = "Aucklanders are happier than ever - nearly the most Liveable City in the World!";
                    }
                    else
                    {
                        FeedbackText.text = "Wow! You've helped make Auckland the World's Most Liveable City! ";
                    }
                }

                CurrentDay++;
                DayText.text = "Day " + CurrentDay.ToString();

                int newNumProblems = (int)(iPopulation / ProblemsPerPop + 0.95f * OldNumProblems);
                OldNumProblems = newNumProblems;
                IssuesManager.StartNewDay(newNumProblems, 23);
            }
        }
    }
示例#6
0
 public void KillEnemy()
 {
     killCounterManager.AddOneKill();
     moneyManager.AddMoney(dropMoney);
     Destroy(gameObject);
 }