Commit 6b5e9d6d authored by wanqing's avatar wanqing

旋转镜头

parent 201de911
......@@ -5,6 +5,7 @@ using RayFire;
public class BombView : MonoBehaviour
{
public Transform m_cameraTrans;//相机
public Transform m_rootTrans;//root节点
//public GameObject m_bombParticleObj;//炸弹粒子
......@@ -15,10 +16,37 @@ public class BombView : MonoBehaviour
private bool m_bControlWin = true;//控制成功
private bool m_bControlFail = true;//控制失败
private float m_rate = 0.2f;//百分比
private float m_rotateSpeed = 1000.0f;//旋转速度
private float m_curRotateAngle = 0.0f;//当前旋转角度
private float m_lastRotateAngle = 0.0f;//之前的旋转角度
private void Awake()
{
m_totalChildNum = m_rootTrans.childCount;
}
private void Start()
{
GameServices.inputService.pad.onMoveVec3 += OnMove;
}
//移动
void OnMove(Vector3 dir)
{
if (!BattleCtrl.instance.isStartBattle)
{
return;
}
m_curRotateAngle = m_cameraTrans.localEulerAngles.y;
//向左滑
if (dir.x > 0)
{
m_curRotateAngle -= Time.deltaTime* m_rotateSpeed;
}
//向右滑
if (dir.x < 0)
{
m_curRotateAngle += Time.deltaTime* m_rotateSpeed;
}
m_cameraTrans.localRotation = Quaternion.Euler(0, m_curRotateAngle, 0);
}
//设置炸弹
void SetBomb(RayfireBomb rayfireBomb)
{
......@@ -67,6 +95,10 @@ public class BombView : MonoBehaviour
{
PoolManager.Instance.ReturnObjectToPool(m_curBombEffect);
}
if (GameServices.inputService != null)
{
GameServices.inputService.pad.onMoveVec3 -= OnMove;
}
}
private void Update()
{
......@@ -74,11 +106,15 @@ public class BombView : MonoBehaviour
{
return;
}
if (Input.GetMouseButtonDown(0))
if (Input.GetMouseButtonUp(0))
{
Clicked();
if (m_lastRotateAngle == m_curRotateAngle)
{
Clicked();
}
m_lastRotateAngle = m_curRotateAngle;
}
Debug.LogError(m_rootTrans.childCount + "................." + m_totalChildNum);
//Debug.LogError(m_rootTrans.childCount + "................." + m_totalChildNum);
if(m_rootTrans.childCount <= m_totalChildNum* m_rate && m_bControlWin)
{
m_bControlWin = false;
......
......@@ -1487,6 +1487,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d4d7af6aafe645428f83f43b3648850, type: 3}
m_Name:
m_EditorClassIdentifier:
m_cameraTrans: {fileID: 872006676200567831}
m_rootTrans: {fileID: 872006677352889631}
--- !u!1 &872006675506863648
GameObject:
......
......@@ -203,6 +203,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d4d7af6aafe645428f83f43b3648850, type: 3}
m_Name:
m_EditorClassIdentifier:
m_cameraTrans: {fileID: 336782563541157815}
m_rootTrans: {fileID: 627549039706593791}
--- !u!114 &7511686585617871288
MonoBehaviour:
......
......@@ -16785,6 +16785,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d4d7af6aafe645428f83f43b3648850, type: 3}
m_Name:
m_EditorClassIdentifier:
m_cameraTrans: {fileID: 4902499387553085372}
m_rootTrans: {fileID: 4902499387505464632}
--- !u!1 &4902499387535544796
GameObject:
......
......@@ -4802,6 +4802,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d4d7af6aafe645428f83f43b3648850, type: 3}
m_Name:
m_EditorClassIdentifier:
m_cameraTrans: {fileID: 4208059260402148735}
m_rootTrans: {fileID: 4208059260721783105}
--- !u!114 &945570835972455969
MonoBehaviour:
......
......@@ -15150,6 +15150,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1d4d7af6aafe645428f83f43b3648850, type: 3}
m_Name:
m_EditorClassIdentifier:
m_cameraTrans: {fileID: 2361839227552686773}
m_rootTrans: {fileID: 2361839228292075822}
--- !u!1 &2361839228918312804
GameObject:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment