当前位置:   article > 正文

Unity游戏源码分享-Unity2D横版游戏(深海潜水艇)_unity 游戏源码

unity 游戏源码

找到个挺有意思的小游戏Unity2D横版游戏(深海潜水艇)

这个也是曾经有段时间抖、音很火的一个小游戏。

鼠标左键点击让小艇上升

因为是unity开发的小游戏,可发布多个平台,有兴趣的拿去玩吧。

代码也是挺简单的

  1. using UnityEngine;
  2. using System.Collections;
  3. public class LevelManager : MonoBehaviour
  4. {
  5. int coins = 0; //Collected coins
  6. static LevelManager myInstance;
  7. static int instances = 0;
  8. //Retursn the instance
  9. public static LevelManager Instance
  10. {
  11. get
  12. {
  13. if (myInstance == null)
  14. myInstance = FindObjectOfType(typeof(LevelManager)) as LevelManager;
  15. return myInstance;
  16. }
  17. }
  18. //Called at the start of the game
  19. void Start()
  20. {
  21. //Calibrates the myInstance static variable
  22. instances++;
  23. if (instances > 1)
  24. Debug.Log("Warning: There are more than one Level Manager at the level");
  25. else
  26. myInstance = this;
  27. SaveManager.CreateAndLoadData(); //Create or load the saved stats
  28. GUIManager.Instance.UpdateBestDistance(); //Update best distance at the hangar
  29. GUIManager.Instance.SetLevelResolution(); //Set the level for the current resolution
  30. MissionManager.Instance.LoadStatus(); //Load mission status
  31. }
  32. //Called when the level is started
  33. public void StartLevel()
  34. {
  35. StartCoroutine(LevelGenerator.Instance.StartToGenerate(1.25f, 3)); //Start the level generator
  36. PlayerManager.Instance.ResetStatus(true); //Reset player status, and move the submarine to the starting position
  37. GUIManager.Instance.ShowStartPowerUps(); //Show the power up activation GUI
  38. GUIManager.Instance.ActivateMainGUI(); //Activate main GUI
  39. }
  40. //Called when the game is paused
  41. public void PauseGame()
  42. {
  43. PlayerManager.Instance.DisableControls(); //Disable sub controls
  44. LevelGenerator.Instance.Pause(); //Pause the level generator
  45. }
  46. //Called then the game is resumed
  47. public void ResumeGame()
  48. {
  49. PlayerManager.Instance.EnableControls(); //Enable the sub controls
  50. LevelGenerator.Instance.Resume(); //Resume level generation
  51. }
  52. //Called when the player is reviving
  53. public void Revive()
  54. {
  55. StartCoroutine(PlayerManager.Instance.Revive()); //Revive the player
  56. }
  57. //Called when a coin has been collected
  58. public void CoinGathered()
  59. {
  60. coins++; //Increase coin number
  61. MissionManager.Instance.CoinEvent(coins); //Notify the mission manager
  62. }
  63. //Returns the number of collected coins
  64. public int Coins()
  65. {
  66. return coins;
  67. }
  68. //Called when the level is restarting
  69. public void Restart()
  70. {
  71. coins = 0; //Reset coin numbers
  72. LevelGenerator.Instance.Restart(true); //Restart level generator
  73. PlayerManager.Instance.ResetStatus(true); //Reset player status
  74. MissionManager.Instance.Save(); //Save mission status
  75. GUIManager.Instance.ShowStartPowerUps(); //Show the power up activation GUI
  76. GUIManager.Instance.ActivateMainGUI(); //Activate main GUI
  77. GUIManager.Instance.UpdateBestDistance(); //Update best distance at the hangar
  78. }
  79. //Called when quiting to the main menu from the level
  80. public void QuitToMain()
  81. {
  82. LevelGenerator.Instance.Restart(false); //Disable level generator
  83. PlayerManager.Instance.ResetStatus(false); //Reset player status
  84. MissionManager.Instance.Save(); //Save progress
  85. GUIManager.Instance.DeactivateMainGUI(); //Deactivate the main GUI
  86. GUIManager.Instance.ActivateMainMenu(); //Activate main menu
  87. GUIManager.Instance.UpdateBestDistance(); //Update best distance at the hangar
  88. }
  89. }

项目地址:
https://download.csdn.net/download/Highning0007/87998810

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/587919
推荐阅读
相关标签
  

闽ICP备14008679号