示例#1
0
文件: WorldLogic.cs 项目: 9volt/ld29
 // Update is called once per frame
 void Update()
 {
     // Check for mute
     ass.mute  = (PlayerPrefs.GetInt("Mute", 0) == 1);
     ass2.mute = (PlayerPrefs.GetInt("Mute", 0) == 1);
     // Update the season
     if (Time.time > season_length + last_season)
     {
         season   = (season + 1) % seasons.Length;
         ass.clip = seasons[season];
         ass.Play();
         if (season == FALL)
         {
             SpawnFoxes();
         }
         if (season == SUMMER)
         {
             SpawnHawks();
         }
         if (season == SPRING)
         {
             year++;
             DespawnFerrets();
             DespawnFarmer();
             PlantCrops();
         }
         if (season == WINTER)
         {
             DespawnFox();
             DespawnHawk();
             SpawnFarmer();
             KillCrops();
         }
         last_season = Time.time;
     }
     if (Input.GetButtonDown("Fire1") && GUIUtility.hotControl == 0)
     {
         // Attempt to set new target
         int    type   = wg.ClickToType();
         Vertex target = wg.ClickToVertex();
         if (type == WorldGen.CARROT)
         {
             if (!food_targets.Contains(target) && target.InBounds(new Vertex(wg.width, wg.height)))
             {
                 food_targets.Add(target);
             }
         }
         else if (type == WorldGen.DIRT || type == WorldGen.GRASS)
         {
             if (!dig_targets.Contains(target) && target.InBounds(new Vertex(wg.width, wg.height)))
             {
                 dig_targets.Add(target);
             }
         }
     }
     if (Input.GetButtonDown("Fire2") && GUIUtility.hotControl == 0)
     {
         // Attempt to remove target
         int    type   = wg.ClickToType();
         Vertex target = wg.ClickToVertex();
         if (type == WorldGen.CARROT)
         {
             if (food_targets.Contains(target))
             {
                 food_targets.Remove(target);
             }
         }
         else if (type == WorldGen.DIRT || type == WorldGen.GRASS)
         {
             if (dig_targets.Contains(target))
             {
                 dig_targets.Remove(target);
             }
         }
         else if (type == WorldGen.TUNNEL)
         {
             if (!fill_targets.Contains(target))
             {
                 fill_targets.Add(target);
             }
             else
             {
                 fill_targets.Remove(target);
             }
         }
     }
 }