//System.Windows.Media.DrawingVisual /* * public static System.Windows.Media.DrawingVisual Render() * { * System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); * * // Retrieve the DrawingContext in order to create new drawing content. * System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen(); * * System.Windows.Media.Pen MyPen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1); * * // Create a rectangle and draw it in the DrawingContext. * foreach (Projectile P in Projectiles) * { * Rect rect = new Rect(new System.Windows.Point(P.XPos - 1, P.YPos - 1), new System.Windows.Size(2, 2)); * drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, (System.Windows.Media.Pen)null, rect); * //drawingContext.DrawLine(MyPen, new Point(P.XPos, P.YPos), new Point(P.XPos + P.XVel, P.YPos + P.YVel)); * * } * // Persist the drawing content. * drawingContext.Close(); * * return drawingVisual; * } * */ //System.Windows.Media.Pen MyPen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1); //static Rect rect = new Rect(new Point(0, 0), new Size(2, 2)); //public static void OnRender(System.Windows.Media.DrawingContext drawingContext) //{ //foreach (Projectile P in Projectiles) //{ // rect.Location = new Point(P.XPos - 1, P.YPos - 1); // drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, null, rect);//(System.Windows.Media.Pen) // int T = Arena.instance.Frame - P.AquiredFrame; // Point O = new Point((P.XPos + (P.XVel * T)) - 1, (P.YPos+(P.YVel*T) - 1)); // rect = new Rect(O, new System.Windows.Size(2, 2)); // drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows.Point((P.XPos - P.XVel / 10) - 1, (P.YPos - P.YVel / 10) - 1), new System.Windows.Size(2, 2)); //drawingContext.DrawRectangle(System.Windows.Media.Brushes.Gray, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows.Point((P.XPos - P.XVel / 5) - 1, (P.YPos - P.YVel / 5) - 1), new System.Windows.Size(2, 2)); //drawingContext.DrawRectangle(System.Windows.Media.Brushes.Gray, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows., new System.Windows.Size(2, 2)); //drawingContext.DrawLine(MyPen, new Point(P.XPos, P.YPos), new Point(P.XPos + P.XVel, P.YPos + P.YVel)); //} //} static public void GenericHitCreep(Creep C) { C.TakeDamage(10); }
//System.Windows.Media.DrawingVisual /* public static System.Windows.Media.DrawingVisual Render() { System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); // Retrieve the DrawingContext in order to create new drawing content. System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen(); System.Windows.Media.Pen MyPen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1); // Create a rectangle and draw it in the DrawingContext. foreach (Projectile P in Projectiles) { Rect rect = new Rect(new System.Windows.Point(P.XPos - 1, P.YPos - 1), new System.Windows.Size(2, 2)); drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, (System.Windows.Media.Pen)null, rect); //drawingContext.DrawLine(MyPen, new Point(P.XPos, P.YPos), new Point(P.XPos + P.XVel, P.YPos + P.YVel)); } // Persist the drawing content. drawingContext.Close(); return drawingVisual; } * */ //System.Windows.Media.Pen MyPen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1); //static Rect rect = new Rect(new Point(0, 0), new Size(2, 2)); //public static void OnRender(System.Windows.Media.DrawingContext drawingContext) //{ //foreach (Projectile P in Projectiles) //{ // rect.Location = new Point(P.XPos - 1, P.YPos - 1); // drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, null, rect);//(System.Windows.Media.Pen) // int T = Arena.instance.Frame - P.AquiredFrame; // Point O = new Point((P.XPos + (P.XVel * T)) - 1, (P.YPos+(P.YVel*T) - 1)); // rect = new Rect(O, new System.Windows.Size(2, 2)); // drawingContext.DrawRectangle(System.Windows.Media.Brushes.Black, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows.Point((P.XPos - P.XVel / 10) - 1, (P.YPos - P.YVel / 10) - 1), new System.Windows.Size(2, 2)); //drawingContext.DrawRectangle(System.Windows.Media.Brushes.Gray, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows.Point((P.XPos - P.XVel / 5) - 1, (P.YPos - P.YVel / 5) - 1), new System.Windows.Size(2, 2)); //drawingContext.DrawRectangle(System.Windows.Media.Brushes.Gray, (System.Windows.Media.Pen)null, rect); //rect = new Rect(new System.Windows., new System.Windows.Size(2, 2)); //drawingContext.DrawLine(MyPen, new Point(P.XPos, P.YPos), new Point(P.XPos + P.XVel, P.YPos + P.YVel)); //} //} static public void GenericHitCreep(Creep C) { C.TakeDamage(10); }
public new void Tick(int FrameCount) { base.Tick(FrameCount); if (this.SubClassData == null) { if (this.Data == null) { return; } SubClassData = Data as BeamTowerData; } //if (ProjectileColor == Colors.Transparent) { // ProjectileColor = System.Windows.Media.Color.FromRgb((byte)R.Next(255), (byte)R.Next(255), (byte)R.Next(255)); // Arena.instance.AddToArena(TargetLaserD); //Arena.instance.AddToArena(TargetLaserB); } CurrentTarget = null; double TXV; double TYV; double V; //System.Windows.Media.Color bc = Color.FromScRgb(1f, (float)(Heat / Data.ShutdownHeat), 0f, 0f);//(float)(Target.LockDuration / 255) //Body.Fill = new System.Windows.Media.SolidColorBrush(HeatColor(Heat, Data.ShutdownHeat)); Body.Fill = StaticHelpers.HeatBrush(Heat, Data.ShutdownHeat); // Are we already locked on? if (Target.LockedTarget != null && Target.LockedTarget.IsAlive == true) { // is the locked target still in range? TXV = (Target.LockedTarget.XPos - PivotPoint.X); TYV = (Target.LockedTarget.YPos - PivotPoint.Y); V = (TXV)*(TXV) + (TYV)*(TYV); if (V < (SubClassData.Range * SubClassData.Range)) { CurrentTarget = Target.LockedTarget; Target.LockDuration++; } } else { Arena.instance.Children.Remove(Beam); Beam.Stroke = Brushes.Transparent; Arena.instance.AddToArena(Beam); } // Find a new target if (CurrentTarget == null) { CurrentTarget = NearestCreep(SubClassData.Range); Target.LockedTarget = CurrentTarget; Target.LockDuration = 0; return; } // No valid targets if (CurrentTarget == null) { return; } if (RefireCount > 0) { RefireCount--; } Point TargetPoint = new Point(CurrentTarget.XPos, CurrentTarget.YPos); //lastsetrotation = new CoercedAngle(StaticHelpers.Angle(PivotPoint, TargetPoint)); if (Target.LockDuration > 0) { // float MuzzleVelocity = 25; Beam.X1 = this.PivotPoint.X; Beam.Y1 = this.PivotPoint.Y; Beam.X2 = CurrentTarget.XPos; Beam.Y2 = CurrentTarget.YPos; // Beam.Stroke = Brushes.Green; Beam.StrokeThickness = 3; //calculate the distance to the target TXV = (CurrentTarget.XPos - PivotPoint.X); TYV = (CurrentTarget.YPos - PivotPoint.Y); V = Math.Sqrt((TXV)*(TXV) + (TYV)*(TYV)); // Rotate barrel if not aligned with leading point. if (!IsAlignedTo(TargetPoint, SubClassData.TrackingSpeed)) { CoercedAngle diff = new CoercedAngle(StaticHelpers.Angle(PivotPoint, TargetPoint) - currentrotation.Angle); if (diff.Angle > 180) { currentrotation.Angle -= SubClassData.TrackingSpeed; } else { currentrotation.Angle += SubClassData.TrackingSpeed; } // Body.Fill = Brushes.Yellow; Barrel.RenderTransform = new RotateTransform(currentrotation.Angle); //return; } else { // We are aligned (within tracking speed margin of error) with the targets predicted position. currentrotation.Angle = StaticHelpers.Angle(PivotPoint, TargetPoint); this.Barrel.RenderTransform = new RotateTransform(StaticHelpers.Angle(PivotPoint, TargetPoint)); //Are we ready to fire? if (this.Heat > this.Data.ShutdownHeat) { RefireCount += 5; } if (RefireCount <= 0 && Target.LockDuration > 1 && this.Heat <= this.Data.ShutdownHeat) { //FIRE!!! /* * Projectile P = Projectile.Create( * FrameCount, * (float)PivotPoint.X, * (float)PivotPoint.Y, * (float)(TXV / V) * (float)MuzzleVelocity, * (float)(TYV / V) * (float)MuzzleVelocity, * Projectile.GenericHitCreep * ); * RefireCount = SubClassData.RefireDelay; */ Beam.Stroke = StaticHelpers.HeatBrush((float)Target.LockDuration + 50, 100f); CurrentTarget.TakeDamage(Target.LockDuration / 20); this.Heat += this.SubClassData.FiringHeat; } else { Beam.Stroke = Brushes.Transparent; } } } else { Beam.Stroke = Brushes.Transparent; } }