parent
1bd7da7824
commit
91c84e5df8
|
@ -0,0 +1,25 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class ChangeScene : MonoBehaviour
|
||||||
|
{
|
||||||
|
public string sceneName;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
GetComponent<Button>().onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene(sceneName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3e68e711d3b0914ea809b9a27fbe9be
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 48866e7cff064f6194616ba5cf992b7b
|
|
||||||
timeCreated: 1721367868
|
|
|
@ -14,6 +14,9 @@ namespace Unity.Loader
|
||||||
[SerializeField] private string packageName = "DefaultPackage";
|
[SerializeField] private string packageName = "DefaultPackage";
|
||||||
|
|
||||||
ZCGame zcGame;
|
ZCGame zcGame;
|
||||||
|
|
||||||
|
private float time;
|
||||||
|
DateTime startTime;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
@ -23,6 +26,14 @@ namespace Unity.Loader
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback);
|
this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback);
|
||||||
|
startTime = System.DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
time += Time.fixedTime;
|
||||||
|
var timeSpan = System.DateTime.Now - startTime;
|
||||||
|
Debug.Log($"{timeSpan:c}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FinishCallback()
|
private void FinishCallback()
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Unity.Loader
|
||||||
|
{
|
||||||
|
public class GlobalData
|
||||||
|
{
|
||||||
|
private DateTime _startTime;
|
||||||
|
private DateTime _endTime;
|
||||||
|
|
||||||
|
private TimeSpan _runTime => System.DateTime.Now - _startTime;
|
||||||
|
public string runTimeStr => $"{_runTime:c}";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int _score;
|
||||||
|
public int score => _score;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bf718765f6e4d30b3283ad77fed165b
|
||||||
|
timeCreated: 1729868704
|
|
@ -0,0 +1,52 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(CharacterController))]
|
||||||
|
public class PlayerMove : MonoBehaviour
|
||||||
|
{
|
||||||
|
private CharacterController _controller;
|
||||||
|
[SerializeField] private float moveSpeed = 6.0f;
|
||||||
|
|
||||||
|
private Camera mainCamera;
|
||||||
|
[SerializeField] private float rotateSpeed = 50;
|
||||||
|
private float x, y;
|
||||||
|
|
||||||
|
//重力
|
||||||
|
[SerializeField] private float gravity = 110f;
|
||||||
|
[SerializeField] private float jumpSpeed = 8.0f;
|
||||||
|
private Vector3 moveDirection = Vector3.zero;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_controller = GetComponent<CharacterController>();
|
||||||
|
mainCamera = Camera.main;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
// Move
|
||||||
|
if (_controller.isGrounded)
|
||||||
|
{
|
||||||
|
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
|
||||||
|
moveDirection = transform.TransformDirection(moveDirection);
|
||||||
|
moveDirection *= moveSpeed;
|
||||||
|
if (Input.GetButton("Jump"))
|
||||||
|
moveDirection.y = jumpSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
moveDirection.y -= gravity * Time.deltaTime;
|
||||||
|
_controller.Move(moveDirection * Time.deltaTime);
|
||||||
|
|
||||||
|
// Rotate
|
||||||
|
if (Input.GetMouseButton(1))
|
||||||
|
{
|
||||||
|
y = Input.GetAxis("Mouse X");
|
||||||
|
x = Input.GetAxis("Mouse Y");
|
||||||
|
mainCamera.transform.eulerAngles +=
|
||||||
|
new Vector3(-x * Time.deltaTime * rotateSpeed, 0, 0);
|
||||||
|
transform.eulerAngles +=
|
||||||
|
new Vector3(0, y * Time.deltaTime * rotateSpeed, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e233961dc73a12f46b8d80c86a47d147
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue