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

重庆建站模板大全谷歌应用商店app下载

重庆建站模板大全,谷歌应用商店app下载,网站建设方案范文,销售型网站如何做推广本身也具有一些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.tj-hxxt.cn/news/96843.html

相关文章:

  • 做视频网站违法吗seo排名赚app下载
  • 做网站数据对电脑要求b2b网站平台有哪些
  • 英文网站建设模板网级移动营销app下载
  • 网站搭建找谁单页网站怎么优化
  • 苏州专业做网站公司有哪些百度学术官网
  • 电商网站前台功能模块seo教程搜索引擎优化
  • 软件介绍下载网站建设一键优化表格
  • wordpress get header企业seo排名
  • 网站建设公司前景如何域名注册优惠
  • 防做电脑租赁网站如何建立自己的网站平台
  • 怎样把自己做的网站发布产品推广方法有哪些
  • 网页站点的建立流程北京关键词排名推广
  • wordpress加载不同模板北京网站seo设计
  • 政府网站集约化建设 创新性军事新闻最新消息
  • 特产网站开发的目的今日小说百度搜索风云榜
  • 建设信用卡登录中心网站建什么网站可以长期盈利
  • 一元购网站建设方案书企业网站首页
  • 棋牌游戏在哪做网站上海哪家seo好
  • 电商网站建设与课程设计湛江seo推广公司
  • phython 做的网站建站seo推广
  • 专业网站的建设域名注册网站有哪些
  • 乌克兰vps国外服务器中国seo高手排行榜
  • 医院网站建设步骤查网站流量的网址
  • 国内最好的旅游网站新冠疫苗接种最新消息
  • 中企动力是国企性质吗网站推广优化之八大方法
  • 网站建设技术主管相关搜索优化软件
  • 全球网站建设太原seo关键词优化
  • 晋城建设局官方网站搜索引擎付费推广
  • 网站编辑怎么赚钱夜狼seo
  • 网站建设淄博佳铉网络网站统计系统