当前位置: 首页 > news >正文

重庆建站模板大全成全视频免费观看在线看

重庆建站模板大全,成全视频免费观看在线看,西安做网站公司xamokj,北京中国建设工程造价管理协会网站本身也具有一些unity知识,包括Eidtor界面使用、Shader效果实现、性能分析,但对C#、游戏逻辑不太清楚,这次想从开发者角度理解游戏,提高C#编程,从简单的unity游戏理解游戏逻辑,更好的为工作服务。 unity201…

本身也具有一些unity知识,包括Eidtor界面使用、Shader效果实现、性能分析,但对C#、游戏逻辑不太清楚,这次想从开发者角度理解游戏,提高C#编程,从简单的unity游戏理解游戏逻辑,更好的为工作服务。

unity2019.4.40f1c1,使用Unity官网FPS Microgame(如下图)。原本想从游戏源码启动流程开始学习,但Unity核心代码没有开源,就还是先理解游戏逻辑。

游戏分成 5个Scene,我们关注MainScene,其中有个GameManager,从Inspector看挂有许多Scripts,我们先一个个分析。

 GameFlowManager,引用using UnityEngine.SceneManagement,定义类GameFlowManager前半部分是在自定义Eidtor界面,这里float timeRatio = 1 - (m_TimeLoadEndGameScene - Time.time) / endSceneLoadDelay;不是很理解,待续

using UnityEngine;
using UnityEngine.SceneManagement;public class GameFlowManager : MonoBehaviour
{[Header("Parameters")][Tooltip("Duration of the fade-to-black at the end of the game")]public float endSceneLoadDelay = 3f;[Tooltip("The canvas group of the fade-to-black screen")]public CanvasGroup endGameFadeCanvasGroup;[Header("Win")][Tooltip("This string has to be the name of the scene you want to load when winning")]public string winSceneName = "WinScene";[Tooltip("Duration of delay before the fade-to-black, if winning")]public float delayBeforeFadeToBlack = 4f;[Tooltip("Duration of delay before the win message")]public float delayBeforeWinMessage = 2f;[Tooltip("Sound played on win")]public AudioClip victorySound;[Tooltip("Prefab for the win game message")]public GameObject WinGameMessagePrefab;[Header("Lose")][Tooltip("This string has to be the name of the scene you want to load when losing")]public string loseSceneName = "LoseScene";public bool gameIsEnding { get; private set; }PlayerCharacterController m_Player;NotificationHUDManager m_NotificationHUDManager;ObjectiveManager m_ObjectiveManager;float m_TimeLoadEndGameScene;string m_SceneToLoad;void Start(){   Debug.Log("Start Game: " + m_Player);//返回场景中的所填类型的随机个体m_Player = FindObjectOfType<PlayerCharacterController>();//DebugUtility.cs不是Unity中的内置脚本,存在Assets/FPS/Scripts/DebugUtility.csDebugUtility.HandleErrorIfNullFindObject<PlayerCharacterController, GameFlowManager>(m_Player, this);m_ObjectiveManager = FindObjectOfType<ObjectiveManager>();DebugUtility.HandleErrorIfNullFindObject<ObjectiveManager, GameFlowManager>(m_ObjectiveManager, this);AudioUtility.SetMasterVolume(1);}void Update(){if (gameIsEnding){   Debug.Log("m_TimeLoadEndGameScene: " + m_TimeLoadEndGameScene);Debug.Log("Time.time: " + Time.time);Debug.Log("endSceneLoadDelay: " + endSceneLoadDelay);float timeRatio = 1 - (m_TimeLoadEndGameScene - Time.time) / endSceneLoadDelay;Debug.Log("timeRatio: " + timeRatio);endGameFadeCanvasGroup.alpha = timeRatio;AudioUtility.SetMasterVolume(1 - timeRatio);// See if it's time to load the  (after the delay)if (Time.time >= m_TimeLoadEndGameScene){Debug.Log("Scene loading: " + m_SceneToLoad);SceneManager.LoadScene(m_SceneToLoad);gameIsEnding = false;}}else{if (m_ObjectiveManager.AreAllObjectivesCompleted())EndGame(true);// Test if player diedif (m_Player.isDead)EndGame(false);}}void EndGame(bool win){// unlocks the cursor before leaving the scene, to be able to click buttonsCursor.lockState = CursorLockMode.None;Cursor.visible = true;// Remember that we need to load the appropriate end scene after a delaygameIsEnding = true;endGameFadeCanvasGroup.gameObject.SetActive(true);if (win){m_SceneToLoad = winSceneName;m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;// play a sound on winvar audioSource = gameObject.AddComponent<AudioSource>();audioSource.clip = victorySound;audioSource.playOnAwake = false;audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);// create a game messagevar message = Instantiate(WinGameMessagePrefab).GetComponent<DisplayMessage>();if (message){message.delayBeforeShowing = delayBeforeWinMessage;message.GetComponent<Transform>().SetAsLastSibling();}}else{m_SceneToLoad = loseSceneName;m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay;}}
}

http://www.15wanjia.com/news/42053.html

相关文章:

  • seo自带 网站建设上海抖音seo公司
  • 专门做流程图的网站搜索引擎排名2022
  • 站长工具韩国日本站长工具seo优化建议
  • 设计公司vi长沙网站包年优化
  • 进行目的地网站建设郑州网站seo服务
  • 常州建设网站公司哪家好最新新闻热点素材
  • unas做网站服务器软文素材
  • 上海网站建设的qq排名优化网站
  • 哪些做调查问卷挣钱的网站免费大数据网站
  • 重庆做蔬菜配送的网站有哪些seo网络推广是什么意思
  • 江西省工程建设信息官方网站百度官网app
  • 模板网站什么意思企业网络推广计划书
  • 南山做棋牌网站建设免费的个人网页
  • 网站建设定制b2b电子商务平台
  • 苏州网站制作设计百度指数的搜索指数
  • wordpress主题网址导航葬爱搜狗seo培训
  • 设计高端网站建设seo内部优化方案
  • 什么外贸网站开发客户网络营销期末总结
  • 网站类产品怎么做竞品分析2023新一轮病毒叫什么名字
  • 网站建设部门宣言外贸如何做网站推广
  • 建设网站开发做关键词优化的公司
  • 成免费crm软件下载遵义网站seo
  • 双语网站建设定制开发百度企业推广怎么收费
  • 微信漫画网站模板轻松seo优化排名 快排
  • 代写网站h5下一页
  • 如何免费制作企业网站网络营销的概念是什么
  • 不用服务器做网站seo自学网app
  • 网站建设怎么样工作目前搜索引擎排名
  • 深圳专业做网站建设哈尔滨网站优化
  • 专业做网站价格韩国日本比分