public void Update(float delta) { for (int i = 0; i < m_MoveList.Count;) { LightingMoveData lmd = m_MoveList[i]; lmd.Delta += delta; float t = Mathf.Min(lmd.Delta / 0.3f, 1.0f); lmd.Trans.localPosition = Vector3.Lerp(lmd.StartPos, lmd.EndPos, t); if (t >= 1.0f) { Utility.ListRemoveAt(m_MoveList, i); continue; } else { ++i; } } for (int i = 0; i < m_LightinData.Count;) { CatchLithingList cll = m_LightinData[i]; cll.DelayTime -= delta; if (cll.DelayTime <= 0) { ProcessLightingData(cll); Utility.ListRemoveAt(m_LightinData, i); } else { ++i; } } }
public void ProcessLightingFish(List <Fish> fishList, Fish fishLighting) { GlobalEffectData efc = null; Vector3 p1 = fishLighting.ScreenPos; Vector3 pv1 = ScreenToCenterPoint(p1); foreach (Fish f in fishList) { Vector3 p2 = f.ScreenPos; Vector3 pv2 = ScreenToCenterPoint(p2); Vector3 dir = (pv2 - pv1); float dist = dir.magnitude; dir /= dist; float dot = Vector3.Dot(Vector3.right, dir); float angle = Mathf.Acos(Mathf.Clamp(dot, -1.0f, 1.0f)) * Mathf.Rad2Deg; if (dir.y < 0) { angle = -angle; } GameObject gov2 = SceneRuntime.EffectMgr.GetLightingFishEffect(true); GameObject gov3 = SceneRuntime.EffectMgr.GetLightingFishEffect(false); efc = new GlobalEffectData(gov2, 0, 2.0f); GlobalEffectMgr.Instance.AddEffect(efc); efc = new GlobalEffectData(gov3, 0, 2.0f); GlobalEffectMgr.Instance.AddEffect(efc); gov2.transform.SetParent(SceneBoot.Instance.UIPanelTransform, false); gov3.transform.SetParent(SceneBoot.Instance.UIPanelTransform, false); LightingMoveData lmd = new LightingMoveData(); lmd.Delta = 0; lmd.Trans = gov3.transform; lmd.StartPos = pv1; lmd.EndPos = pv2; m_MoveList.Add(lmd); Vector3 ss = gov2.transform.localScale; ss.x = dist; gov2.transform.localPosition = pv1; gov3.transform.localPosition = pv1; gov2.transform.localScale = ss; gov2.transform.localRotation = Quaternion.AngleAxis(angle, Vector3.forward); } }