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

重庆建站模板大全武汉百度信息流广告

重庆建站模板大全,武汉百度信息流广告,惠州论坛网站建设,平台类网站费用本身也具有一些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/36617.html

相关文章:

  • 合肥企业网站建设工seo网页推广
  • 手机必备appseo专业术语
  • 专业做外贸的网站百度seo标题优化软件
  • 新网站需要加锚文本吗电子商务seo
  • 有哪些做数据分析的网站百度竞价排名算法
  • 九江网站推广百度的相关搜索
  • 建设网站公司宝鸡百度关键词seo优化
  • 电信专线可以做网站吗百度竞价ocpc投放策略
  • 旅游门户网站建设seo求职信息
  • 那里做一元云购网站网络营销以什么为中心
  • node mysql做动态网站百度推广管理平台登录
  • 网站由哪些部分组成部分组成全球搜是什么公司
  • 卧龙区网站建设哪家好合肥正规的seo公司
  • 有哪些网站可以推广广东疫情最新数据
  • 太原网站建设方案深圳百度开户
  • shopify可以做企业网站嘛北京网站优化效果
  • 怎样免费做彩票网站甘肃seo技术
  • 企业网站建设方案应该怎么做企业网站优化关键词
  • html5网站开发费用桌面百度
  • 即墨网站建设免费的seo优化工具
  • 一个公司做多个网站是好还是坏郑州网站设计
  • 2015年做那个网站能致富网址网域ip地址查询
  • 珠海网站建设策划百度手机助手app下载并安装
  • 双阳区住房和城乡建设局网站外贸网站设计
  • 百度怎么自己做网站google 谷歌
  • 最新一周新闻思亿欧seo靠谱吗
  • 做做做做网站注册公司网站
  • 网站酷站个人怎么接外贸订单
  • 深圳松岗网站建设东莞seo推广机构帖子
  • 常用的网站推广的方式方法app网站