/// <summary> /// 创建Besize曲线的Action /// </summary> /// <param name="targetTF">Target T.</param> /// <param name="startPos">Start position.</param> /// <param name="endPos">End position.</param> /// <param name="showTime">Show time.</param> /// <param name="config">Config.</param> public static MTBezierTo CreateBesizeAction(Transform targetTF, Vector3 startPos, Vector3 endPos, float showTime, BesizeControlConfig config, BesizeControlConfig config2) { bool left = MTRandom.GetRandomInt(1, 2) > 1; Vector3 controller1; EffectUtil.BesizeControlPos(startPos, endPos, config, out controller1, out controller1, left); controller1.z = 0; Vector3 controller2; EffectUtil.BesizeControlPos(startPos, endPos, config2, out controller2, out controller2, left); controller2.z = 0; startPos = targetTF.InverseTransformPoint(startPos); startPos.z = 0; endPos = targetTF.InverseTransformPoint(endPos); endPos.z = 0; controller1 = targetTF.InverseTransformPoint(controller1); controller1.z = 0; controller2 = targetTF.InverseTransformPoint(controller2); controller2.z = 0; MTBezierConfig bconfig = new MTBezierConfig(); bconfig.ControlPoint1 = controller1; bconfig.ControlPoint2 = controller2; bconfig.EndPosition = endPos; return(new MTBezierTo(showTime, bconfig)); }
void RunTo(Vector3 startPos, Vector3 endPos, float delayTime, float showTime, TrailConfig config) { StartCoroutine(CurveAction(startPos, endPos, Vector3.up, delayTime, showTime)); Destroy(gameObject, delayTime + showTime); return; //----------------------curve--------------- int minAngle = config.MinAngle; int maxAngle = config.MaxAngle; float minDist = config.MinDistRatio; float maxDist = config.MaxDistRatio; int angle = UnityEngine.Random.Range(minAngle, maxAngle); if (MTRandom.GetRandomInt(1, 2) > 1) { angle = -angle; } Vector3 dis = new Vector3(endPos.x - startPos.x, endPos.y - startPos.y, 0); float r = Mathf.Atan2(dis.y, dis.x) * 180 / Mathf.PI; angle += (int)r; //计算两点之间随机值 float dist = UnityEngine.Random.Range(minDist, maxDist); Vector3 middlePos = Vector3.Lerp(startPos, endPos, dist); dist = Vector3.Distance(startPos, middlePos); // middlePos = Vector3.RotateTowards float distx = Mathf.Cos(angle) * dist; float disty = Mathf.Sin(angle) * dist; Vector3 c1 = new Vector3(distx + startPos.x, disty + startPos.y, 0); // c1 = new Vector3 (c1.x / 100, c1.y / 100, 0); // endPos = new Vector3 (endPos.x / 100, endPos.y / 100, 0); MTBezierConfig bconfig = new MTBezierConfig(); bconfig.ControlPoint1 = c1; bconfig.ControlPoint2 = c1; bconfig.EndPosition = endPos; MTBezierTo action = new MTBezierTo(showTime, bconfig); // trail.gameObject.RunAction (action); trail.gameObject.RunActions(new MTDelayTime(delayTime), action, new MTDestroy()); // MTMoveTo action = new MTMoveTo (showTime, endPos); // trail.gameObject.RunAction (action); }
public void DestoryAndGenCoin() { int m = MTRandom.GetRandomInt(0, 2); if (m == 0) { var coin = Instantiate <GameObject>(ResMgr.Current.CoinPrefab); coin.transform.position = transform.position; SoundMgr.Current.PlayCoinCameOut(); } DestroyCell(); }
public void SetPow(int n) { pow = n; var bgColor = ResMgr.Current.cbg[n]; var cellColor = ResMgr.Current.Colors[n]; SetCenterColor(cellColor); SetBgColor(bgColor); if (pow < BOMBINDEX) { number = (int)System.Math.Pow(2, n); Number.sprite = ResMgr.Current.Numbers[n]; } else { LevelMgr.Current.OnGenBomb(); _cellType = CellType.Bomb; int index = MTRandom.GetRandomInt(0, 4); _bombType = (BombType)index; Number.sprite = ResMgr.Current.Bombs[index]; } }