public override void Update() { if (!m_active) { return; } m_pastPositions.Add(Position); m_mesh.Reset(); float width = 3; int nbrPoint = 24; int iStart = m_pastPositions.Count > nbrPoint ? m_pastPositions.Count - nbrPoint : 0; for (int i = iStart; i < m_pastPositions.Count - 1; i++) { float alphaCoef = (m_fadeOutTimer.TargetTime - m_fadeOutTimer.TimeMS) / m_fadeOutTimer.TargetTime; float alpha = 1.0f / (float)nbrPoint * (i - iStart) * alphaCoef; Color colCenter = new Color(m_color, alpha); Color colSide = new Color(m_color, alpha * 0.25f); Vector2 dir = m_pastPositions[i + 1] - m_pastPositions[i]; dir.Normalize(); Vector2 orthoDir = dir.Rotate((float)Math.PI * 0.5f); orthoDir.Normalize(); int i1 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] + orthoDir * width * 2, 0), colSide)); int i2 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] + orthoDir * width, 0), colCenter)); int i3 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] - orthoDir * width, 0), colCenter)); int i4 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] - orthoDir * width * 2, 0), colSide)); int i5 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] + orthoDir * width * 2, 0), colSide)); int i6 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] + orthoDir * width, 0), colCenter)); int i7 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] - orthoDir * width, 0), colCenter)); int i8 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] - orthoDir * width * 2, 0), colSide)); m_mesh.Index(i1); m_mesh.Index(i2); m_mesh.Index(i5); m_mesh.Index(i2); m_mesh.Index(i5); m_mesh.Index(i6); m_mesh.Index(i2); m_mesh.Index(i3); m_mesh.Index(i6); m_mesh.Index(i3); m_mesh.Index(i6); m_mesh.Index(i7); m_mesh.Index(i3); m_mesh.Index(i4); m_mesh.Index(i7); m_mesh.Index(i4); m_mesh.Index(i7); m_mesh.Index(i8); } }
public override void Update() { if (!(m_chargeTimerMS.Active || m_maxChargeTimerMS.Active)) { return; } base.Update(); // Update angle float chargeCompletion = LBE.MathHelper.LinearStep(0, m_chargeTimerMS.TargetTime, m_chargeTimerMS.TimeMS); if (m_chargedMax) { chargeCompletion = 1; } m_angle = (float)Math.PI * chargeCompletion; // Create gfx feedback m_lineMesh.Reset(); m_triangleMesh.Reset(); int nbrSide = 32; float radius = 30 * m_scale; for (int i = 0; i < nbrSide; i++) { float angleStep = m_angle / nbrSide; Vector2 circlePoint1 = new Vector2((float)Math.Cos(angleStep * i), (float)Math.Sin(angleStep * i)); circlePoint1 = circlePoint1.Rotate(GetWorldTransform().Orientation - 0.5f * m_angle); Vector2 p1 = Owner.Position + radius * circlePoint1; Vector2 circlePoint2 = new Vector2((float)Math.Cos(angleStep * (i + 1)), (float)Math.Sin(angleStep * (i + 1))); circlePoint2 = circlePoint2.Rotate(GetWorldTransform().Orientation - 0.5f * m_angle); Vector2 p2 = Owner.Position + radius * circlePoint2; // Circle var vertex = new VertexPositionColor(); vertex.Color = m_team.ColorScheme.Color1; vertex.Position = new Vector3(p1, 0); int idx1 = m_lineMesh.Vertex(vertex); vertex.Position = new Vector3(p2, 0); int idx2 = m_lineMesh.Vertex(vertex); m_lineMesh.Index(idx1); m_lineMesh.Index(idx2); // Disk var vertexT = new VertexPositionColor(); vertexT.Color = new Color(m_team.ColorScheme.Color1, 0.2f); vertexT.Position = new Vector3(Owner.Position, 0); int idxT1 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p1, 0); int idxT2 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p2, 0); int idxT3 = m_triangleMesh.Vertex(vertexT); m_triangleMesh.Index(idxT1); m_triangleMesh.Index(idxT2); m_triangleMesh.Index(idxT3); } // UpdateScan(); if (m_playerToAim != null) { PassBallToTeam(); StopCharge(); } }
public void Reset() { m_lineMesh.Reset(); m_triangleMesh.Reset(); m_texts.Clear(); }
public override void Update() { base.Update(); m_lineMesh.Reset(); m_triangleMesh.Reset(); int nbrSide = 32; int radius = 50; float chargeCompletion = LBE.MathHelper.LinearStep(0, m_chargeTimerMS.TargetTime, m_chargeTimerMS.TimeMS); if (m_chargedMax) { chargeCompletion = 1; } m_angle = 2 * (float)Math.PI * Math.Max(chargeCompletion, 0.05f * (float)Math.PI); for (int i = 0; i < nbrSide; i++) { float angleStep = m_angle / nbrSide; Vector2 circlePoint1 = new Vector2((float)Math.Cos(angleStep * i), (float)Math.Sin(angleStep * i)); circlePoint1 = circlePoint1.Rotate(m_player.BallAngle - 0.5f * m_angle); Vector2 p1 = Owner.Position + radius * circlePoint1; Vector2 circlePoint2 = new Vector2((float)Math.Cos(angleStep * (i + 1)), (float)Math.Sin(angleStep * (i + 1))); circlePoint2 = circlePoint2.Rotate(m_player.BallAngle - 0.5f * m_angle); Vector2 p2 = Owner.Position + radius * circlePoint2; // Circle var vertex = new VertexPositionColor(); vertex.Color = m_player.Team.ColorScheme.Color1; vertex.Position = new Vector3(p1, 0); int idx1 = m_lineMesh.Vertex(vertex); vertex.Position = new Vector3(p2, 0); int idx2 = m_lineMesh.Vertex(vertex); m_lineMesh.Index(idx1); m_lineMesh.Index(idx2); // Disk var vertexT = new VertexPositionColor(); vertexT.Color = new Color(m_player.Team.ColorScheme.Color1, 0.2f); vertexT.Position = new Vector3(Owner.Position, 0); int idxT1 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p1, 0); int idxT2 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p2, 0); int idxT3 = m_triangleMesh.Vertex(vertexT); m_triangleMesh.Index(idxT1); m_triangleMesh.Index(idxT2); m_triangleMesh.Index(idxT3); } }