合并后错误修改
This commit is contained in:
1 parent
e513eeac5c
commit
c6d0f7ac13
22 files changed
+20977
-24867
No files matched your search
@@ -69,6 +69,9 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
camera = Camera.main;
|
||||
//bone_bottle_2
|
||||
bone_bottle_2 = transform.Find("bone_cable_20");
|
||||
var config = manager.mockDirection;
|
||||
pre = config[0];
|
||||
next = config[0];
|
||||
}
|
||||
|
||||
//人物状态
|
||||
@@ -109,12 +112,8 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
protected virtual void Update()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#endif
|
||||
timer -= Time.deltaTime;
|
||||
CreateHeadImage();
|
||||
CharacterControl();
|
||||
Turn();
|
||||
while (timer <= 0)
|
||||
{
|
||||
@@ -142,52 +141,6 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
|
||||
}
|
||||
private Vector3 rotation = Vector3.zero;
|
||||
private void CharacterControl()
|
||||
{
|
||||
float KeyVertical = Input.GetAxis("Vertical");
|
||||
float KeyHorizontal = Input.GetAxis("Horizontal");
|
||||
|
||||
var delta = 0.2f;
|
||||
var zdelta = 0.1f;
|
||||
|
||||
//控制人物左右倾斜
|
||||
if (Input.GetKey(KeyCode.Q))
|
||||
{
|
||||
rotation.y -= delta;
|
||||
rotation.z += zdelta;
|
||||
transform.DORotate(rotation, 0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.E))
|
||||
{
|
||||
rotation.y += delta;
|
||||
rotation.z -= zdelta;
|
||||
transform.DORotate(rotation, 0);
|
||||
}
|
||||
//空格键记录当前人物数据
|
||||
if (Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
Debug.Log($"{manager.GetCurrentFrame()}:{transform.rotation.y},{transform.rotation.z},{transform.position.x}");
|
||||
}
|
||||
|
||||
//人物前后左右
|
||||
if (KeyVertical == -1)
|
||||
{
|
||||
setHeroState(HERO_DOWN); //下
|
||||
}
|
||||
else if (KeyVertical == 1)
|
||||
{
|
||||
setHeroState(HERO_UP); //上
|
||||
}
|
||||
if (KeyHorizontal == 1)
|
||||
{
|
||||
setHeroState(HERO_RIGHT); //右
|
||||
}
|
||||
else if (KeyHorizontal == -1)
|
||||
{
|
||||
setHeroState(HERO_LEFT); //左
|
||||
}
|
||||
}
|
||||
|
||||
//人物碰撞
|
||||
void OnCollisionEnter(Collision collision)
|
||||
@@ -228,16 +181,17 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
return manager.GetCurrentFrame();
|
||||
}
|
||||
|
||||
private CustomRange pre;
|
||||
private CustomRange next;
|
||||
protected CustomRange pre { get; set; }
|
||||
protected CustomRange next { get; set; }
|
||||
|
||||
protected float t { get; set; }
|
||||
protected virtual void Turn()
|
||||
{
|
||||
//控制人物的转向
|
||||
var currentFrame = GetCurrentFrame();
|
||||
var config = manager.mockDirection;
|
||||
|
||||
pre = config[0];
|
||||
next = config[0];
|
||||
if (config.Count == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < config.Count; i++)
|
||||
{
|
||||
@@ -251,19 +205,9 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
|
||||
var p = new Vector3(0, pre.RotationY, pre.RotationZ);
|
||||
var q = new Vector3(0, next.RotationY, next.RotationZ);
|
||||
var t = (float)(currentFrame - pre.KeyFrame) / (float)(next.KeyFrame - pre.KeyFrame);
|
||||
var rt = Vector3.Slerp(p, q, t);
|
||||
|
||||
t = next.KeyFrame - pre.KeyFrame == 0 ? 1 : (float)(currentFrame - pre.KeyFrame) / (float)(next.KeyFrame - pre.KeyFrame);
|
||||
var rt = Vector3.Lerp(p, q, t);
|
||||
transform.DORotate(rt, 0, RotateMode.Fast);
|
||||
|
||||
//控制人物的前后左右
|
||||
|
||||
var l = new Vector3(pre.PositionX, pre.PositionY, pre.PositionZ);
|
||||
var s = new Vector3(next.PositionX, next.PositionY, next.PositionZ);
|
||||
var pos = Vector3.Slerp(l,s, t);
|
||||
transform.DOMove(pos,0);
|
||||
|
||||
//TODO:控制光线
|
||||
}
|
||||
|
||||
//计算人物当前属性
|
||||
|
||||
@@ -30,12 +30,15 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const int rate = 20;// z轴与帧数的比例 1 :20
|
||||
//人物向前超车 右边超车
|
||||
protected override void Turn()
|
||||
{
|
||||
base.Turn();
|
||||
var current = manager.CurrentPlayer;
|
||||
var z = current.transform.position.z + diff*1000 * 0.5f;
|
||||
var interval = this.currentFrame - manager.GetCurrentFrame();
|
||||
var z = current.transform.position.z + interval / rate;
|
||||
transform.DOMoveZ((float)z, 1f);
|
||||
//x轴位移
|
||||
//var x = bearing + current.bearing;
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public RouteResult routeResult;
|
||||
public string recordId { get; set; }
|
||||
public DateTime startTime { get; set; }
|
||||
public int FrameKM { get; private set; }//一米对应的帧数
|
||||
public CyclingModel cyclingModel;
|
||||
public BaseCycling cyclingController;
|
||||
public List<CustomRange> mockDirection = new List<CustomRange>();
|
||||
@@ -132,12 +133,20 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
endDistance = 0;
|
||||
videoLoading = FindObjectOfType<VideoLoading>();
|
||||
|
||||
}
|
||||
private IEnumerator Init()
|
||||
{
|
||||
yield return null;
|
||||
videoLoading.Init();//初始化loading页面
|
||||
}
|
||||
|
||||
public int GetFrameKm()
|
||||
{
|
||||
var s = mediaPlayer.Info.GetDurationFrames();
|
||||
FrameKM = (int)Math.Floor(s / (mapData.TotalDistance * 1000));
|
||||
return FrameKM;
|
||||
}
|
||||
VideoLoading videoLoading { get; set; }
|
||||
// Update is called once per frame
|
||||
float timer = 0f;
|
||||
@@ -234,7 +243,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
if (currentPlayerInfo != null)
|
||||
{
|
||||
var diff = item.EndDistance % mapData.TotalDistance - currentPlayerInfo.EndDistance % mapData.TotalDistance;
|
||||
if (Math.Abs(diff * 1000) <= 50)
|
||||
if (Math.Abs(diff * 1000) <= 100)
|
||||
{
|
||||
GameObject obj;
|
||||
if (currentPlayerInfo.Sex == 1)
|
||||
|
||||
@@ -11,12 +11,15 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
public class VideoPlayer : AbstractVideoPlayer
|
||||
{
|
||||
public double EndDistance => totalDistance;
|
||||
protected Transform LightTrans { get; set; }
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
animator.Play("idle");
|
||||
UserId = App.CurrentUser.Id;
|
||||
UserName = App.CurrentUser.Nickname;
|
||||
var light = FindObjectOfType<Light>();
|
||||
LightTrans = light.transform;
|
||||
}
|
||||
|
||||
protected override bool GetStart()
|
||||
@@ -48,6 +51,16 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
protected override void Turn()
|
||||
{
|
||||
base.Turn();
|
||||
//控制人物的前后左右
|
||||
var l = new Vector3(pre.PositionX, pre.PositionY, pre.PositionZ);
|
||||
var s = new Vector3(next.PositionX, next.PositionY, next.PositionZ);
|
||||
var pos = Vector3.Lerp(l, s, t);
|
||||
transform.DOMove(pos, 0);
|
||||
//控制光线
|
||||
var z = new Vector3(50, pre.LightY, 0);
|
||||
var c = new Vector3(50, next.LightY, 0);
|
||||
var zc = Vector3.Lerp(z, c, t);
|
||||
LightTrans.DORotate(zc, 0);
|
||||
}
|
||||
protected override void ComputePlayer()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user