diff --git a/Assets/Prefabs/Environment.prefab b/Assets/Prefabs/Environment.prefab new file mode 100644 index 0000000..c3a8b7a Binary files /dev/null and b/Assets/Prefabs/Environment.prefab differ diff --git a/Assets/Prefabs/Environment.prefab.meta b/Assets/Prefabs/Environment.prefab.meta new file mode 100644 index 0000000..b85e331 --- /dev/null +++ b/Assets/Prefabs/Environment.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: da994aa3e08f3074f851b3fa1f1c47c8 +timeCreated: 1504776219 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/GameController.prefab b/Assets/Prefabs/GameController.prefab new file mode 100644 index 0000000..98bc613 Binary files /dev/null and b/Assets/Prefabs/GameController.prefab differ diff --git a/Assets/Prefabs/GameController.prefab.meta b/Assets/Prefabs/GameController.prefab.meta new file mode 100644 index 0000000..eda6267 --- /dev/null +++ b/Assets/Prefabs/GameController.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b6b811325c22d204f99c68e43d20ab26 +timeCreated: 1504776277 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab new file mode 100644 index 0000000..a519592 Binary files /dev/null and b/Assets/Prefabs/Player.prefab differ diff --git a/Assets/Prefabs/Player.prefab.meta b/Assets/Prefabs/Player.prefab.meta new file mode 100644 index 0000000..effdfea --- /dev/null +++ b/Assets/Prefabs/Player.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 452a27e6d13c710469c6724f0c0ef8cf +timeCreated: 1504775911 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/RegularCamera.prefab b/Assets/Prefabs/RegularCamera.prefab new file mode 100644 index 0000000..6badd58 Binary files /dev/null and b/Assets/Prefabs/RegularCamera.prefab differ diff --git a/Assets/Prefabs/RegularCamera.prefab.meta b/Assets/Prefabs/RegularCamera.prefab.meta new file mode 100644 index 0000000..80e1f9f --- /dev/null +++ b/Assets/Prefabs/RegularCamera.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 53c74ac38e8859541a460d548c3e03dd +timeCreated: 1504776264 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/UICamera.prefab b/Assets/Prefabs/UICamera.prefab new file mode 100644 index 0000000..efe4d00 Binary files /dev/null and b/Assets/Prefabs/UICamera.prefab differ diff --git a/Assets/Prefabs/UICamera.prefab.meta b/Assets/Prefabs/UICamera.prefab.meta new file mode 100644 index 0000000..44478f7 --- /dev/null +++ b/Assets/Prefabs/UICamera.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9caf8dcb201d5d242aca912ebd7beb7d +timeCreated: 1504776215 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/LoginPanel.prefab b/Assets/Resources/LoginPanel.prefab index b49c492..aa082b8 100644 Binary files a/Assets/Resources/LoginPanel.prefab and b/Assets/Resources/LoginPanel.prefab differ diff --git a/Assets/Scripts/core/Root.cs b/Assets/Scripts/core/Root.cs index 2162da2..caf7261 100644 --- a/Assets/Scripts/core/Root.cs +++ b/Assets/Scripts/core/Root.cs @@ -7,12 +7,18 @@ public class Root : MonoBehaviour { void Start() { + DontDestroyOnLoad(this); Application.runInBackground = true; + + // 打开登录面板 PanelMgr.instance.OpenPanel(""); + + Debug.Log("Application has been started up!"); } - void Update() + void FixedUpdate() { + // 固定时间间隔更新,处理消息队列中的消息 NetMgr.Update(); } } \ No newline at end of file diff --git a/Assets/Scripts/core/net/Connection.cs b/Assets/Scripts/core/net/Connection.cs index 68eb6e1..de371fb 100644 --- a/Assets/Scripts/core/net/Connection.cs +++ b/Assets/Scripts/core/net/Connection.cs @@ -171,12 +171,15 @@ public bool Send(ProtocolBase protocol, MsgDistribution.Delegate cb) return Send(protocol, cbName, cb); } - + /// + /// 每个逻辑帧处理消息分发和向服务端发送心跳消息 + /// public void Update() { - //消息 + // 消息分发 msgDist.Update(); - //心跳 + + // 心跳 if (status == Status.Connected) { if (Time.time - lastTickTime > heartBeatTime) diff --git a/Assets/Scripts/core/net/MsgDistribution.cs b/Assets/Scripts/core/net/MsgDistribution.cs index f6c11df..25a3404 100644 --- a/Assets/Scripts/core/net/MsgDistribution.cs +++ b/Assets/Scripts/core/net/MsgDistribution.cs @@ -22,7 +22,9 @@ public class MsgDistribution private Dictionary onceDict = new Dictionary(); - //Update + /// + /// 每一逻辑帧处理消息分发 + /// public void Update() { for (int i = 0; i < num; i++) @@ -43,7 +45,10 @@ public void Update() } } - // 消息分发 + /// + /// 向各监听者分发消息 + /// + /// public void DispatchMsgEvent(ProtocolBase protocol) { string name = protocol.GetName(); diff --git a/Assets/Scripts/gameplay/GameController.cs b/Assets/Scripts/gameplay/GameController.cs index 813bc44..6e6c825 100644 --- a/Assets/Scripts/gameplay/GameController.cs +++ b/Assets/Scripts/gameplay/GameController.cs @@ -25,6 +25,8 @@ public class GameController : MonoBehaviour void Start() { + DontDestroyOnLoad(this); + _isGameOver = false; _isRestart = false; gameOverText.enabled = false; @@ -41,16 +43,17 @@ void Update() { if (_isRestart) { -#if UNITY_EDITOR + // TODO: 这里可不能重新加载场景,要改为还原现场,或者说重置所有对象的状态 + if (Input.GetKeyDown(KeyCode.R)) { - SceneManager.LoadScene("Main"); + SceneManager.LoadScene("Online"); } -#endif + #if UNITY_ANDROID || UNITY_IOS if (Input.touchCount != 0) { - SceneManager.LoadScene("Main"); + SceneManager.LoadScene("Online"); } #endif } diff --git a/Assets/Scripts/gameplay/PlayerController.cs b/Assets/Scripts/gameplay/PlayerController.cs index 5dd7ae6..84cc46a 100644 --- a/Assets/Scripts/gameplay/PlayerController.cs +++ b/Assets/Scripts/gameplay/PlayerController.cs @@ -1,23 +1,32 @@ using UnityEngine; +/// +/// 地图边界 +/// [System.SerializableAttribute] public class Boundary { public float xMin, xMax, zMin, zMax; } +/// +/// 角色控制器 +/// public class PlayerController : MonoBehaviour { + // 移动速度 [SerializeField] private float speed; + // 转向速度 [SerializeField] private float rotateSpeed; [SerializeField] private Boundary boundary; + // 机身倾斜系数 [SerializeField] private float tilt; [SerializeField] private GameObject shot; [SerializeField] private Transform shotSpawn; [SerializeField] private float fireDelta = 0.25f; - [SerializeField] private ParticleSystem particleSystem1; + [SerializeField] private ParticleSystem particleSystem1; [SerializeField] private ParticleSystem particleSystem2; private Rigidbody _rigidbody; @@ -26,7 +35,9 @@ public class PlayerController : MonoBehaviour private float _myTime = 0.0f; private float _nextFire = 0.25f; + // 移动增量 [HideInInspector] public Vector2 deltaMovement; + // 转向增量 [HideInInspector] public Vector2 deltaRotation; public enum InputForcedMode @@ -69,12 +80,14 @@ void FixedUpdate() Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); _rigidbody.velocity = movement * speed; + // 限制角色移动范围 _rigidbody.position = new Vector3( Mathf.Clamp(_rigidbody.position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp(_rigidbody.position.z, boundary.zMin, boundary.zMax) ); + // 左右平移时稍微倾斜一下机身(绕 z 轴) _rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, _rigidbody.velocity.x * -tilt); // 旋转方向 diff --git a/Assets/Scripts/panel/RoomPanel.cs b/Assets/Scripts/panel/RoomPanel.cs index 0eb646c..79e2841 100644 --- a/Assets/Scripts/panel/RoomPanel.cs +++ b/Assets/Scripts/panel/RoomPanel.cs @@ -149,11 +149,11 @@ public void OnStartBack(ProtocolBase protocol) } } - + // TODO: 这里开始战斗 public void RecvFight(ProtocolBase protocol) { ProtocolBytes proto = (ProtocolBytes)protocol; - MultiBattle.instance.StartBattle(proto); +// MultiBattle.instance.StartBattle(proto); Close(); } diff --git a/Assets/Textures/title-space.jpg b/Assets/Textures/title-space.jpg new file mode 100644 index 0000000..fb4084d Binary files /dev/null and b/Assets/Textures/title-space.jpg differ diff --git a/Assets/Textures/title-space.jpg.meta b/Assets/Textures/title-space.jpg.meta new file mode 100644 index 0000000..9c12b0c --- /dev/null +++ b/Assets/Textures/title-space.jpg.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: 6bd4f6c4f6b9fee40805a2b3d983959f +timeCreated: 1504780468 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Android + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: WebGL + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scenes/Online.unity b/Assets/_Scenes/Online.unity index 8e0cc95..ce8e406 100644 Binary files a/Assets/_Scenes/Online.unity and b/Assets/_Scenes/Online.unity differ diff --git a/Assets/_Scenes/Standalone.unity b/Assets/_Scenes/Standalone.unity index d1d2399..07cb9b8 100644 Binary files a/Assets/_Scenes/Standalone.unity and b/Assets/_Scenes/Standalone.unity differ diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 45e17f0..a6d06d6 100644 Binary files a/ProjectSettings/EditorBuildSettings.asset and b/ProjectSettings/EditorBuildSettings.asset differ