/// <summary> /// 显示path /// </summary> private void UpdateReference() { if (m_Power > 0.01f) { m_TrajectoryDir = m_TrajectoryDir.normalized; m_VerticalInitialVelocity = m_Power * Time.fixedDeltaTime * m_Rigi.mass; m_Hypotenuse = Mathf.Sqrt(m_TrajectoryDir.x * m_TrajectoryDir.x + m_TrajectoryDir.y * m_TrajectoryDir.y); //水平初速度 m_VerticalVelocity = m_TrajectoryDir.x / m_Hypotenuse * m_VerticalInitialVelocity; //处置初速度 m_VerticalEndVelocity = m_TrajectoryDir.y / m_Hypotenuse * m_VerticalInitialVelocity; float time = 0; for (int i = 0; i < MissilePath.ReferencePointCount; i++) { time += m_ReferenceTime; Vector2 pos = CalPos(time); GameObject go = MissilePath.GetReference(i); go.SetActive(true); go.transform.position = new Vector3(pos.x, pos.y, 0) + transform.position; go.transform.localScale = Vector3.one * ((1 - m_ReferencePointMinSize) * (1 - i / ((float)MissilePath.ReferencePointCount - 1)) + m_ReferencePointMinSize); } } else { MissilePath.ShowOrHideReference(false); } }
protected override void ReadyEnter() { base.ReadyEnter(); m_Power = 0; m_PrePos = Vector2.zero; transform.localPosition = Vector3.zero; transform.SetParent(null); MissilePath.ShowOrHidePath(false); }
private void UpdatePath() { if (m_Status == Status.Shoot) { m_PathTimer += Time.deltaTime; if (m_PathTimer > m_PathTime) { m_PathTimer = 0; GameObject go = null; go = MissilePath.GetOrCreatePath(); go.transform.position = transform.position; } } }
protected override void ShootEnter() { base.ShootEnter(); m_TrailRenderer.enabled = true; MissilePath.ShowOrHideReference(false); MissilePath.ShowOrHidePath(false); m_TrajectoryTimer = 0; m_PathTimer = 0; m_Rigi.constraints = RigidbodyConstraints2D.FreezeRotation; m_Rigi.velocity = new Vector2(m_VerticalVelocity, m_VerticalEndVelocity); IsTrajectory = true; if (OnShoot != null) { OnShoot(); } }
// Use this for initialization void Start() { MissilePath.Init(); m_GameStae = GameStae.Play; m_View = UISceneCtrl.Instance.Load(UISceneType.Game).GetComponent <UIGameSceneView>(); ChangeSceneCtrl.Instance.Show(ChangeSceneType.Open); UIRockerView.Instance.AddEventOnRocker("rocker", OnRockerEvent); CreateKnife(); RefreshEmitter(m_CurEmitter); m_CurEmitter.Fixed(m_CurKnife); StarCount = -1; m_View.SetUI(m_KnifeCount, Global.CurLevel); m_Star.CollectEvent += OnStarHit; for (int i = 0; i < m_MonsterList.Count; i++) { m_MonsterList[i].DeadEvent += OnMonsterDead; } }