Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!Menu.running)
        {
            return;
        }

        timer += rate * Time.deltaTime;

        //Regular updates
        lunaSol.update(pm);

        if (timer > 2.5f)
        {
            hours++;
            timer = 0f;

            pm.cycle(sm.getSeason(), wm.getWeather(), lunaSol.isDaytime());
            wm.spawnCloud();

            if (timer == 24)
            {
                hours = 0;
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            menu.toggleMenu();
        }

        pm.checkDeath();

        display.text = sm.getSeason() + ", " + wm.getWeather();
    }
Пример #2
0
    public void update(PlantManager pm)
    {
        if (!Menu.running)
        {
            return;
        }

        timer += 6 * Time.deltaTime;

        Vector3 newPos = new Vector3(0f, 0f);

        newPos.x = Mathf.Cos((timer * Mathf.PI) / 180f) * 1.5f;
        newPos.y = Mathf.Sin((timer * Mathf.PI) / 180f) * 1.5f;

        transform.position = newPos;
        skyColor(); triggers();

        if (timer > 270)
        {
            timer     = -90f;
            day       = !day;
            dayNum   += 0.5f;
            days.text = "Day: " + dayNum;

            sm.update(dayNum);
            wm.cycle(sm.getSeason());

            if (day)
            {
                bm.newDawn(sm.getSeason(), wm.getWeather(), pm.getPlants());
                saveManager.save();
            }
            else
            {
                bm.newDusk(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }

            beastTrigger = true;
        }

        else if (timer > 90 && beastTrigger)
        {
            beastTrigger = false;
            if (day)
            {
                bm.newDay(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }
            else
            {
                bm.newNight(sm.getSeason(), wm.getWeather(), pm.getPlants());
            }
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        changeSeason(sm.getSeason());

        if (!mp.isPlaying)
        {
            changeSongs();
        }
    }
Пример #4
0
    public void save()
    {
        //Save score
        switch (stageName)
        {
        case "Small":
            if (ScoreManager.smallDays < dm.getDays())
            {
                ScoreManager.smallDays = dm.getDays();
            }
            if (ScoreManager.smallScore < pm.getScore())
            {
                ScoreManager.smallScore = pm.getScore();
            }
            break;

        case "Medium":
            if (ScoreManager.medDays < dm.getDays())
            {
                ScoreManager.medDays = dm.getDays();
            }
            if (ScoreManager.medScore < pm.getScore())
            {
                ScoreManager.medScore = pm.getScore();
            }
            break;

        case "Large":
            if (ScoreManager.largeDays < dm.getDays())
            {
                ScoreManager.largeDays = dm.getDays();
            }
            if (ScoreManager.largeScore < pm.getScore())
            {
                ScoreManager.largeScore = pm.getScore();
            }
            break;

        case "Mountain":
            if (ScoreManager.mountainDays < dm.getDays())
            {
                ScoreManager.mountainDays = dm.getDays();
            }
            if (ScoreManager.mountainScore < pm.getScore())
            {
                ScoreManager.mountainScore = pm.getScore();
            }
            break;

        case "Zen":
            if (ScoreManager.zenDays < dm.getDays())
            {
                ScoreManager.zenDays = dm.getDays();
            }
            if (ScoreManager.zenScore < pm.getScore())
            {
                ScoreManager.zenScore = pm.getScore();
            }
            break;
        }

        ScoreManager.save();

        //Save plant data
        pm.save(stageName);

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/" + stageName + name + ".dat");

        SaveData data = new SaveData();

        data.weather = wm.getWeather();
        data.season  = sm.getSeason();
        data.dayNum  = dm.getDays();
        data.money   = ItemManager.money;

        //Items
        data.water      = ItemManager.waters;
        data.fertilizer = ItemManager.fertilizer;
        data.synth      = ItemManager.synth;
        data.heater     = ItemManager.heaters;
        data.spray      = ItemManager.sprays;
        data.cover      = ItemManager.cover;
        data.music      = ItemManager.music;

        bf.Serialize(file, data);
        file.Close();
    }