public void ForwardOver() { //检查所有动画是否播放完 bool isEnd = true; foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); if (!fa.IsEnd()) { isEnd = false; break; } } Debug.Log("ForwardOver isEnd=" + isEnd + ",_gunDisappear=" + _gunDisappear); if (isEnd && _gunDisappear) { _status = 2; //设置动画组件隐藏 foreach (var obj in AniObjs) { obj.SetActive(false); } ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.Victory), null); } }
//设置方向播放方向 public void ChangeBackwardDir() { _status = 2; foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); fa.PlayFallback(gameObject); } }
//设置正向播放方向 public void ChangeForwardDir() { _status = 1; foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); fa.PlayForward(gameObject); } }
public void FallbackOver() { //检查所有动画是否回滚完 bool isEnd = true; foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); if (!fa.IsRollBack()) { isEnd = false; break; } } if (isEnd) { _status = 0; //设置隐藏的物体显示 for (int i = 0; i < HideObjs.Length; i++) { if (HideWithUnactive) { HideObjs[i].SetActive(true); } else { SpriteRenderer sr = HideObjs[i].GetComponent <SpriteRenderer>(); sr.material.color = _hideColors[i]; } } //设置动画组件隐藏 foreach (var obj in AniObjs) { if (HideWithUnactive) { obj.GetComponent <FrameAni>().SwitchLightControl(false); } obj.SetActive(false); } //设置目标组件隐藏 foreach (var obj in TargetObjs) { obj.SetActive(false); } } }
private void PlayAni() { if (_status == 0) { _status = 1; //自身设置为隐藏 gameObject.SetActive(false); foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); fa.PlayForward(gameObject); obj.SetActive(true); } } }
public void ForwardOver() { //检查所有动画是否播放完 bool isEnd = true; foreach (var obj in AniObjs) { FrameAni fa = obj.GetComponent <FrameAni>(); if (!fa.IsEnd()) { isEnd = false; break; } } if (isEnd) { _status = 3; //设置隐藏的物体真正隐藏 foreach (var obj in HideObjs) { obj.SetActive(false); } //设置动画组件隐藏 foreach (var obj in AniObjs) { obj.SetActive(false); } //设置目标组件展示 foreach (var obj in TargetObjs) { obj.SetActive(true); } } }
void CastLight() { // Debug.LogWarning("CastLight 1"); int spIdx = 0; int gunIdx = 0; linePoints.Clear(); //光线起始点 Vector2 startPoint = transform.position; //光线射出方向 Vector2 direction = (Vector2)transform.up; if (_shotDir != Vector2.zero) { direction = _shotDir; } linePoints.Add(startPoint); RaycastHit2D hit = new RaycastHit2D(); // do // { // Debug.LogWarning("CastLight 2"); hit = Physics2D.Raycast(startPoint, direction); if (hit.collider != null) { linePoints.Add(hit.point); //添加击中点闪光 if (spIdx >= _shiningPoints.Count) { var ogg = ObjectPool.GetInstance().GetShiningPoint(); _shiningPoints.Add(ogg); } GameObject gObj = _shiningPoints[spIdx]; // gObj.transform.parent = transform; gObj.transform.position = hit.point; spIdx++; // Debug.LogWarning("CastLight 3 var obj = hit.collider.gameObject; LightCondition lc = obj.GetComponent <LightCondition>(); bool isMatch = true; if (lc != null) { lc.LightShining(color, LineStrenth); isMatch = lc.isMatch(); } if (!isMatch) { ClearDirty(spIdx, gunIdx); return; } // Debug.LogWarning("CastLight 4"); Reflect re = obj.GetComponent <Reflect>(); if (re != null) { //利用Vector2的反射函数来计算反射方向 var inDirection = hit.point - (Vector2)startPoint; direction = re.GetOutDirection(inDirection, hit.normal); if (gunIdx >= _guns.Count) { var gg = ObjectPool.GetInstance().GetGun(); _guns.Add(gg); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); g.SetShotDir(direction); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hit.point + direction * 0.01f; // Debug.LogWarning("Reflect hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; } // Debug.LogWarning("CastLight 5"); ThroughPass th = obj.GetComponent <ThroughPass>(); if (th != null) { // Debug.Log("Exec ThroughPass LightShining"); var inDirection = hit.point - (Vector2)startPoint; Vector2 hitP = th.GetOutPosition(hit.point, inDirection); if (gunIdx >= _guns.Count) { _guns.Add(ObjectPool.GetInstance().GetGun()); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); if (th.UseOriginLight) { g.color = color; g.LineStrenth = LineStrenth; // g.ResetLight(); } else { var c = th.OutColor; if (th.OutColor == 0) { c = color; } var l = th.OutLineStrength; if (th.OutLineStrength == 0) { l = LineStrenth; } g.color = c; g.LineStrenth = l; // g.ResetLight(); } g.SetShotDir(inDirection); g.SetLightInfo(g.color, g.LineStrenth); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hitP; // Debug.LogWarning("Through[" + th.gameObject.name + "] hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; // th.LightShining(lineRenderer,hit.point,linePoints[linePoints.Count-1]-linePoints[linePoints.Count-2],color,LineStrenth); } // Debug.LogWarning("CastLight 6"); Refraction refr = obj.GetComponent <Refraction>(); if (refr != null) { var inDirection = hit.point - (Vector2)startPoint; Vector2 outDir = refr.GetOutDir(inDirection); Vector2 hitP = refr.GetOutPosition(outDir); if (gunIdx >= _guns.Count) { _guns.Add(ObjectPool.GetInstance().GetGun()); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); if (refr.UseOriginLight) { g.color = color; g.LineStrenth = LineStrenth; } else { var c = refr.OutColor; if (refr.OutColor == 0) { c = color; } var l = refr.OutLineStrength; if (refr.OutLineStrength == 0) { l = LineStrenth; } g.color = c; g.LineStrenth = l; // g.ResetLight(); } g.SetShotDir(outDir); g.SetLightInfo(g.color, g.LineStrenth); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hitP; // Debug.LogWarning("Refraction[" + refr.gameObject.name + "] hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; } ActiveObject ao = obj.GetComponent <ActiveObject>(); if (ao != null) { // Debug.Log("Exec LightShining"); ao.LightShining(lineRenderer); } Diliver di = obj.GetComponent <Diliver>(); if (di != null) { // Debug.Log("Exec Diliver LightShining"); di.LightShining(lineRenderer); } Collections co = obj.GetComponent <Collections>(); if (co != null) { // Debug.Log("Exec Collections LightShining"); co.LightShining(); } FrameAni fa = obj.GetComponent <FrameAni>(); if (fa != null) { // Debug.LogWarning("Exec FrameAni LightShining"); fa.LightShining(); } } else { var p = startPoint + (direction * 1920 / 100f); linePoints.Add(p); } ClearDirty(spIdx, gunIdx); // } while (needReflect); }