void Start() { m_collider = GetComponent<BoxCollider>(); m_parabola = new Parabola(gameObject, Random.Range(5f, 8f), Random.Range(-3.14f, 3.14f), Random.Range(1.3f, 1.57f), 2); m_parabola.GroundY = 0.5f; m_parabola.TimeScale = 1.5f; LifeTime = m_lifeTime; }
public override void Init(Creature ownerCreature, Weapon weapon, Weapon.FiringDesc targetAngle) { base.Init(ownerCreature, weapon, targetAngle); m_status = Status.Dropping; //m_parabola = new Parabola(gameObject, m_speed, -targetAngle.angle * Mathf.Deg2Rad, Random.Range(45f, 85f) * Mathf.Deg2Rad, m_bouncing); m_parabola = new Parabola(gameObject, m_speed, -ownerCreature.transform.rotation.eulerAngles.y * Mathf.Deg2Rad, Random.Range(45f, 85f) * Mathf.Deg2Rad, m_bouncing); }
void Update() { if (m_parabola != null && false == m_parabola.Update()) { m_creature.CrowdControl(Creature.CrowdControlType.LeapStrike, false); CreateBullet(m_firingDescs[0], transform.position); m_parabola = null; m_effectTargetingPoint.Death(); } }
public override void Init(Creature mob) { base.Init(mob); m_parabola = new Parabola(mob.gameObject, Random.Range(m_hSpeed[0], m_hSpeed[1]), Random.Range(m_vRadian[0], m_vRadian[1]), Random.Range(m_hRadian[0], m_hRadian[1]), 1); }
public void CalculateParabolaMinimum() { int _dim=5; double []_data = {5,34,-12,55,6}; double []_reference = {0,0,0,0,0}; double _epsilon=1e-7; double _realEpsilon = System.Math.Sqrt(_epsilon); double _step=1000; int _itmax=1000; double diff; Parabola func = new Parabola(_dim); Nelder objNelder = new Nelder(_dim,_data,func,_step,_epsilon,_itmax); objNelder.FindMinimum(); diff = NumericNet.CalcDiff(_dim,_reference,objNelder.Result); Assert.IsTrue(diff<_realEpsilon); }
public override void StartFiring(float targetAngle) { if ( isCoolTime() == true && m_creature.Targetting != null) { float d = Vector3.Distance(m_creature.transform.position, m_creature.Targetting.transform.position); m_parabola = new Parabola(m_creature.gameObject, d*1.7f, targetAngle*Mathf.Deg2Rad, 80*Mathf.Deg2Rad, 1); m_parabola.TimeScale = 0.80f; m_effectTargetingPoint = new EffectTargetingCircle(); m_effectTargetingPoint.Init(m_parabola.DestPosition); m_creature.CrowdControl(Creature.CrowdControlType.LeapStrike, true); DidStartFiring(0f); } m_firing = true; }
public void Init(Creature obj, string damage, Color color, MovementType movementType) { m_movementType = movementType; m_target = obj; m_targetPos = obj.transform.position+m_target.HPPointTransform.localPosition; m_targetPos.y += 1; transform.position = m_targetPos; m_startTime = Time.time; m_posY = 0f; m_text = GetComponent<TypogenicText>(); m_text.Text = damage; m_text.ColorTopLeft = color; //transform.localScale = Vector3.one/2f; if (movementType == MovementType.Parabola || movementType == MovementType.ParabolaAlpha) { float[] angs = {80,100}; m_parabola = new Parabola(gameObject, 6f, 0f,angs[Random.Range(0, angs.Length)]*Mathf.Deg2Rad, 1); } }
void OnTriggerEnter(Collider other) { rock = other.GetComponent<Rock>(); para = other.GetComponent<Parabola>(); if(other.tag == "weapon") { //Debug.Log (relativePos); //Quaternion q; //q.SetFromToRotation; tempObj = other.gameObject; //Debug.Log("else"); isMeet = true; rock.enWeapon = 0; //other.transform.rotation= transform.rotation; } //Debug.Log(other.tag); }
public void OnPointerDown(PointerEventData data) { /* * Vector2 mousePosition = data.position - new Vector2(780f, 310f); * mousePosition /= 260f; */ Vector3[] corners = new Vector3[4]; rectTransform.GetWorldCorners(corners); Vector2 mousePosition = data.position - new Vector2(corners[0].x, corners[0].y); Vector2 size = corners[2] - corners[0]; mousePosition.x /= size.x; mousePosition.y /= size.y; mousePosition.x = mousePosition.x * 2f - 1f; mousePosition.y = mousePosition.y * 2f - 1f; //Debug.Log(mousePosition); LinePanel[] linePanels = panelContainer.GetComponentsInChildren <LinePanel>(); foreach (LinePanel linePanel in linePanels) { Line line = linePanel.Line; if (line.Locked) { continue; } Vector2 v = (line.PointAHandle /*- cameraPosition*/ / (mathViewRenderer.cameraZoom / 2f)) - mousePosition; if (v.magnitude < 0.1f) { line.PointAHandle += data.delta * mathViewRenderer.cameraZoom * (cameraDragSpeed / 1000f); draggedLine = line; draggedParabola = null; if (doubleClickCooldown > 0f) { draggedLinePiece = 2; } else { draggedLinePiece = 0; } return; } v = (line.PointBHandle /*- cameraPosition*/ / (mathViewRenderer.cameraZoom / 2f)) - mousePosition; if (v.magnitude < 0.1f) { line.PointBHandle += data.delta * mathViewRenderer.cameraZoom * (cameraDragSpeed / 1000f); draggedLine = line; draggedParabola = null; if (doubleClickCooldown > 0f) { draggedLinePiece = 2; } else { draggedLinePiece = 1; } return; } } ParabolaPanel[] parabolaPanels = panelContainer.GetComponentsInChildren <ParabolaPanel>(); foreach (ParabolaPanel parabolaPanel in parabolaPanels) { Parabola parabola = parabolaPanel.Parabola; if (parabola.Locked) { continue; } Vector2 v = (parabola.OriginHandle /*- cameraPosition*/ / (mathViewRenderer.cameraZoom / 2f)) - mousePosition; //Debug.Log("Handle = " + (parabola.CurveHandle /*- cameraPosition*/ / (cameraZoom / 2f)) + " Mouse Click = " + mouseClick); if (v.magnitude < 0.1f) { parabola.OriginHandle += data.delta * mathViewRenderer.cameraZoom * (cameraDragSpeed / 1000f); draggedParabola = parabola; draggedLine = null; if (doubleClickCooldown > 0f) { draggedParabolaPiece = 2; } else { draggedParabolaPiece = 0; } return; } v = (parabola.CurveHandle /*- cameraPosition*/ / (mathViewRenderer.cameraZoom / 2f)) - mousePosition; if (v.magnitude < 0.1f) { parabola.CurveHandle += data.delta * mathViewRenderer.cameraZoom * (cameraDragSpeed / 1000f); draggedParabola = parabola; draggedLine = null; if (doubleClickCooldown > 0f) { draggedParabolaPiece = 2; } else { draggedParabolaPiece = 1; } return; } /* * v = (parabola.CurveHandleCopy / (cameraZoom / 2f)) - mousePosition; * if (v.magnitude < 0.1f) * { * parabola.CurveHandleCopy += data.delta * cameraZoom * (cameraDragSpeed / 1000f); * draggedParabola = parabola; * draggedParabolaPiece = 2; * return; * } */ } }
protected virtual void createParabola(float targetAngle) { m_parabola = new Parabola(gameObject, m_speed, -(transform.rotation.eulerAngles.y + targetAngle) * Mathf.Deg2Rad, Random.Range(m_yangles[0],m_yangles[1]) * Mathf.Deg2Rad, m_bouncing); }
// Update is called once per frame void Update () { #if UNITY_IPHONE int i = 0; if ( Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { this.mousepos = Camera.main.ScreenToWorldPoint(Input.GetTouch(i).position); //this.mousepos = Input.GetTouch(i).position; mousepos = new Vector3(mousepos.x, mousepos.y, 0); if (!isClike) { obj = Instantiate(this.pointer, mousepos, Quaternion.identity) as GameObject; text.text = i.ToString() +"@" + this.mousepos.ToString(); isClike = true; } } //if (Input.GetMouseButtonUp(0)) if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) { isClike = false; } #endif #if UNITY_STANDALONE_WIN ////////////////////////////////////////////////mouse////////////////////////////////////// // if(Input.GetMouseButtonDown(0)) // { // rock.collider.bounds. // Debug.Log("down"); // } if (Input.GetMouseButtonDown(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { GameObject obj; // obj = hit.collider.gameObject.transform.parent.gameObject; // if(obj == null) // { obj = hit.collider.gameObject; Debug.Log(tileMap.data.tileSize); //} rockObj = obj.GetComponent<Rock>(); //取不到值????? para = obj.GetComponent<Parabola>(); Debug.Log(obj.name); Debug.Log(hit.collider.gameObject.name); Debug.Log(rockObj); //if(rockObj != null) if(obj.tag == "ground") { tSprite = obj.GetComponent<tk2dTiledSprite>(); tSprite.color = Color.yellow; } //obj.gameObject. if(rockObj != null ) { rockObj.State = Rock.RockStateEnum.act4; //para.active = false; Debug.Log(hit.collider.gameObject.name); } } // Ray ray; // RaycastHit hit; // // if (Input.GetMouseButton(0)) // { // ray = Camera.main.ScreenPointToRay(Input.mousePosition); // if (Physics.Raycast(ray, out hit)) // Debug.Log(hit.collider.gameObject.name); // } } if (Input.GetMouseButton(0)) { this.mousepos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z)); mousepos = new Vector3(mousepos.x, mousepos.y, 0); if (!isClike) { obj = Instantiate(this.pointer, mousepos, Quaternion.identity) as GameObject; isClike = true; } } if (Input.GetMouseButtonUp(0)) { isClike = false; } ////////////////////////////////////////////////mouse////////////////////////////////////// #endif }
void RenderParabola(Parabola parabola, int resolution) { if (resolution <= 0) { return; } float x1 = Mathf.Min(parabola.OriginHandle.x, parabola.CurveHandle.x), x2 = Mathf.Max(parabola.OriginHandle.x, parabola.CurveHandle.x); if (Mathf.Abs(x1 - x2) <= 0.01f) { x1 -= 0.01f; x2 += 0.01f; } if (parabola.Infinite) { if (parabola.OriginHandle.y < parabola.CurveHandle.y) // if the origin handle is below the curve handle the parabole opens up towards the top { List <float> intersects = parabola.Intersect(cameraZoom / 2f - cameraPosition.y); if (intersects == null) { return; } if (intersects.Count != 2) { return; } x1 = intersects[0]; x2 = intersects[1]; } else if (parabola.OriginHandle.y > parabola.CurveHandle.y) { List <float> intersects = parabola.Intersect(-cameraZoom / 2f - cameraPosition.y); if (intersects == null) { return; } if (intersects.Count != 2) { return; } x1 = intersects[1]; x2 = intersects[0]; } } float spanWidth = x2 - x1; float stepWidth = spanWidth / resolution; for (float x = x1; x < x1 + spanWidth; x += stepWidth) { Vector2 from, to; from = new Vector2(x, parabola.Solve(x)); to = new Vector2(x + stepWidth, parabola.Solve(x + stepWidth)); RenderThickLine(from, to, 0.5f, parabola.Color); } RenderPoint(parabola.OriginHandle, Color.black, Color.white, 0.02f); RenderPoint(parabola.OriginHandle, Color.black, parabola.Color, 0.01f); RenderPoint(parabola.CurveHandle, Color.black, Color.white, 0.02f); RenderPoint(parabola.CurveHandle, Color.black, parabola.Color, 0.01f); //RenderPoint(parabola.CurveHandleCopy, Color.black, Color.white, 0.02f); //RenderPoint(parabola.CurveHandleCopy, Color.black, parabola.Color, 0.01f); }
public Parabola parabola; // The parabola who hold the event public Event(Vector2 p, Vector2 bp, Parabola para) { point = p; breakPoint = bp; parabola = para; }
public Parabola(Parabola para) { point = para.point; previous = para.previous; next = para.next; }
private void CreateSegment(Parabola p, Vector2 circleCenter) { }
//Every Update position from parabola will be counted void Update() { Animation += Time.deltaTime; transform.position = Parabola.Parabola1(beginP, targetP, 5f, Animation / 5f); }
public EdgeEvent(Parabola parabola) { _parabola = parabola; }
private void pictureBox_MouseUp(object sender, MouseEventArgs e) { if (controller.mode == DrawMode.MODE_DRAW_BY_MOUSE && controller.isDrawing == true) { int x = e.Location.X; int y = e.Location.Y; lbMousePos.Text = x.ToString() + ", " + y.ToString(); if (controller.mShape is Line) { Line l = (Line)controller.mShape; l.p2.x = x; l.p2.y = y; if (l.p1 != l.p2) { this.DrawShape(); } controller.isDrawing = false; } else if (controller.mShape is Circle) { Circle c = (Circle)controller.mShape; Point p = new Point(x, y); int r = (int)p.getDistance(c.I); if (r > 0) { c.R = r; this.DrawShape(); controller.isDrawing = false; } } else if (controller.mShape is Ellipse) { Ellipse el = (Ellipse)controller.mShape; int ra = Math.Abs(el.I.x - x); int rb = Math.Abs(el.I.y - y); if (ra > 0 && rb > 0) { el.a = ra; el.b = rb; this.DrawShape(); controller.isDrawing = false; } } else if (controller.mShape is Ellipse) { Ellipse el = (Ellipse)controller.mShape; int ra = Math.Abs(el.I.x - x); int rb = Math.Abs(el.I.y - y); if (ra > 0 && rb > 0) { el.a = ra; el.b = rb; this.DrawShape(); controller.isDrawing = false; } } else if (controller.mShape is Parabola) { Parabola pa = (Parabola)controller.mShape; pa.Bound = new Point(x, y); this.DrawShape(); controller.isDrawing = false; } else if (controller.mShape is Hyperbole) { Hyperbole hy = (Hyperbole)controller.mShape; hy.Bound = new Point(x, y); this.DrawShape(); controller.isDrawing = false; } } }
public static void spline_overhauser_val(int ndim, int ndata, double[] tdata, double[] ydata, double tval, double[] yval) //****************************************************************************80 // // Purpose: // // SPLINE_OVERHAUSER_VAL evaluates an Overhauser spline. // // Discussion: // // Over the first and last intervals, the Overhauser spline is a // quadratic. In the intermediate intervals, it is a piecewise cubic. // The Overhauser spline is also known as the Catmull-Rom spline. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 December 2004 // // Author: // // John Burkardt // // Reference: // // JA Brewer, DC Anderson, // Visual Interaction with Overhauser Curves and Surfaces, // SIGGRAPH 77, // in Proceedings of the 4th Annual Conference on Computer Graphics // and Interactive Techniques, // ASME, July 1977, pages 132-137. // // Edwin Catmull, Raphael Rom, // A Class of Local Interpolating Splines, // in Computer Aided Geometric Design, // edited by Robert Barnhill, Richard Reisenfeld, // Academic Press, 1974, // ISBN: 0120790505. // // David Rogers, Alan Adams, // Mathematical Elements of Computer Graphics, // Second Edition, // McGraw Hill, 1989, // ISBN: 0070535299. // // Parameters: // // Input, int NDIM, the dimension of a single data point. // NDIM must be at least 1. // // Input, int NDATA, the number of data points. // NDATA must be at least 3. // // Input, double TDATA[NDATA], the abscissas of the data points. The // values in TDATA must be in strictly ascending order. // // Input, double YDATA[NDIM*NDATA], the data points corresponding to // the abscissas. // // Input, double TVAL, the abscissa value at which the spline // is to be evaluated. Normally, TDATA[0] <= TVAL <= T[NDATA-1], and // the data will be interpolated. For TVAL outside this range, // extrapolation will be used. // // Output, double YVAL[NDIM], the value of the spline at TVAL. // { int i; int left = 0; int right = 0; // // Check. // int order = typeMethods.r8vec_order_type(ndata, tdata); if (order != 2) { Console.WriteLine(""); Console.WriteLine("SPLINE_OVERHAUSER_VAL - Fatal error!"); Console.WriteLine(" The data abscissas are not strictly ascending."); return; } switch (ndata) { case < 3: Console.WriteLine(""); Console.WriteLine("SPLINE_OVERHAUSER_VAL - Fatal error!"); Console.WriteLine(" NDATA < 3."); return; } // // Locate the abscissa interval T[LEFT], T[LEFT+1] nearest to or // containing TVAL. // typeMethods.r8vec_bracket(ndata, tdata, tval, ref left, ref right); // // Evaluate the "left hand" quadratic defined at // T[LEFT-1], T[LEFT], T[RIGHT]. // double[] yl = new double[ndim]; double[] yr = new double[ndim]; switch (left - 1) { case > 0: Parabola.parabola_val2(ndim, ndata, tdata, ydata, left - 1, tval, ref yl); break; } // // Evaluate the "right hand" quadratic defined at // T[LEFT], T[RIGHT], T[RIGHT+1]. // if (right + 1 <= ndata) { Parabola.parabola_val2(ndim, ndata, tdata, ydata, left, tval, ref yr); } switch (left) { // // Blend the quadratics. // case 1: { for (i = 0; i < ndim; i++) { yval[i] = yr[i]; } break; } default: { if (right < ndata) { for (i = 0; i < ndim; i++) { yval[i] = ( (tdata[right - 1] - tval) * yl[i] + (tval - tdata[left - 1]) * yr[i]) / (tdata[right - 1] - tdata[left - 1]); } } else { for (i = 0; i < ndim; i++) { yval[i] = yl[i]; } } break; } } }
IEnumerator EffectAirborne() { if (gameObject != null) { DamageText(CrowdControlType.Airborne.ToString(), Vector3.one, Color.white, DamageNumberSprite.MovementType.FloatingUp); CrowdControl(CrowdControlType.Airborne, true); Parabola parabola = new Parabola(gameObject, 8, 0f, 90*Mathf.Deg2Rad, 1); while(parabola.Update()) { yield return null; } m_buffEffects[(int)DamageDesc.BuffType.Airborne].m_run = false; CrowdControl(CrowdControlType.Airborne, false); } }
protected override void createParabola(float targetAngle) { m_parabola = new Parabola(gameObject, m_speed, -(transform.rotation.eulerAngles.y+targetAngle) * Mathf.Deg2Rad, Random.Range(1f, 1.4f), m_bouncing); m_effectTargetingPoint.Init(m_parabola.DestPosition); }
public Matrix4x4 Cast(Transform sourceTransform, Vector2 inputDirection) { if (this.castingObjectTransform == null) { this.castingObjectTransform = sourceTransform; } else if (this.castingObjectTransform != sourceTransform) { return(Matrix4x4.zero); } visualizerAssembly.SetActive(true); transform.position = sourceTransform.position; Parabola parabola = Parabola.Cast(sourceTransform.position, sourceTransform.forward * strength, stepSize, maxSteps); for (int i = 0; i < bones.Count; i++) { TennisSim.Utility.ApplyMatrixToTransform(bones[i], parabola.GetNormalizedPathMatrix((float)i / (bones.Count - 1))); //bones[i].rotation = Quaternion.AngleAxis(90, bones[i].right) * Quaternion.AngleAxis(90, bones[i].up) * bones[i].rotation; bones[i].rotation = Quaternion.AngleAxis(90, bones[i].up) * Quaternion.AngleAxis(-90, bones[i].right) * bones[i].rotation; } if (parabola.hasDestination) { SnappingTeleportingPoint teleportPoint = parabola.hitObject.GetComponent <SnappingTeleportingPoint>(); if (teleportPoint) { if (prevTeleportPoint != teleportPoint) { UnhighlightTeleportPoint(); prevTeleportPoint = teleportPoint; teleportPoint.Highlight(); } destinationArrow.gameObject.SetActive(false); return(teleportPoint.snappingPoint.localToWorldMatrix); } else { UnhighlightTeleportPoint(); if (Vector3.Angle(parabola.normal, Vector3.up) <= acceptableUpAngle) { destinationArrow.gameObject.SetActive(true); destinationArrow.position = parabola.destination; } else { // Cast a ray straight down to find ground. RaycastHit hit; if (Physics.Raycast(parabola.destination + Vector3.up * .001f, -Vector3.up, out hit)) { if (Vector3.Angle(hit.normal, Vector3.up) <= acceptableUpAngle) { destinationArrow.gameObject.SetActive(true); Vector3 backOffWallVector = parabola.normal; backOffWallVector.y = 0; backOffWallVector = backOffWallVector.normalized * backOffWallDistance; destinationArrow.position = hit.point + backOffWallVector; } } } if (destinationArrow.gameObject.activeSelf) { Vector3 right = Vector3.Cross(Vector3.up, sourceTransform.forward).normalized; Vector3 forward = Vector3.Cross(right, Vector3.up); Vector3 direction = right * inputDirection.x + forward * inputDirection.y; destinationArrow.rotation = Quaternion.LookRotation(direction); return(destinationArrow.localToWorldMatrix); } } } destinationArrow.gameObject.SetActive(false); return(Matrix4x4.zero); }
void Start() { m_parabola = new Parabola(gameObject, Random.Range(5f, 8f), Random.Range(-3.14f, 3.14f), Random.Range(1.0f, 1.57f), 3); rigidbody.AddTorque(Random.Range(0f, 2f), Random.Range(0f, 2f), Random.Range(0f, 2f), ForceMode.Impulse); }