/// <summary> /// Briefs the invader on it's mission. It should go from the start cell and try to /// reach the goal cell. /// </summary> /// <param name="start">The cell to start on.</param> /// <param name="goal">The goal to get to.</param> /// <param name="key">The key to assign to this invader to aid in path finding.</param> public void BriefOnMission(GridCell start, GridCell goal, DijkstraType key) { TargetCell = start; GoalCell = goal; DijkstraKey = key; float dx = (DijkstraKey == DijkstraType.LeftToRight ? TargetCell.Width * 2f : 0); float dy = (DijkstraKey == DijkstraType.TopToBottom ? TargetCell.Height * 2f : 0); float mux = RandomGenerator.NextSingle(); float muy = RandomGenerator.NextSingle(); X = TargetCell.X - (dx * GsMath.SmoothStep(1, 5, mux)); Y = TargetCell.Y - (dy * GsMath.SmoothStep(1, 5, muy)); Width = TargetCell.Width * (Flying ? 1.5f : 1f); Height = TargetCell.Height * (Flying ? 1.5f : 1f); Velocity = new GsVector(mAttributes[InvaderAttributes.Speed]); AdjustOrientation(); var texture = GetImage(); var size = ImageProvider.GetSize(texture); Origin = new GsVector(size.Width / 2f, size.Height / 2f); CurrentLife = MaximumLife; TargetCell = Flying ? goal : start; }
protected override ImageParams GetTextureDrawData(GsVector offset) { var image = GetImage(); var imgSize = ImageProvider.GetSize(image); var scale = Calculator.ComputeScale(imgSize, Size); return(new ImageParams(image, imgSize, Position + offset, Origin, scale)); }
public FlameProjectile(Piece parent, double timeToLiveInSeconds) : base(parent, timeToLiveInSeconds) { Size = new GsSize(20f, 80f); ImageKey = "flame"; var size = ImageProvider.GetSize(GetImage()); Origin = new GsVector(0, size.Height / 2); }
protected virtual void DrawWeaponBase(DrawParams dparams, GsRectangle bounds, GsRectangle inside) { var wbase = ImageProvider.GetFramedImage("towerBase").Image; var wbaseSize = ImageProvider.GetSize(wbase); var scale = Calculator.ComputeScale(wbaseSize, bounds.Size); var color = new GsColor(GsColor.Gray, 128); var graphics = dparams.Graphics; graphics.DrawImage(wbase, color, bounds.Location, scale); }
protected override void DrawWeaponBase(DrawParams dparams, GsRectangle bounds, GsRectangle inside) { // draw a speed bump! var speedbump = GetImage(); var speedbumpSize = ImageProvider.GetSize(speedbump); var scale = Calculator.ComputeScale(speedbumpSize, bounds.Size); GsColor color = GsColor.White; var graphics = dparams.Graphics; graphics.DrawImage(speedbump, color, bounds.Location, scale); }
public Projectile(Piece parent, double timeToLiveInSeconds) { IsAlive = true; mTimeToLive = timeToLiveInSeconds; ImageKey = "bullet"; var sz = ImageProvider.GetSize(GetImage()); Origin = new GsVector(0, sz.Height / 2f); Color = GsColor.White; Size = new GsSize(20f, 6.5f); StayAlive = false; Parent = parent; }
protected override ImageParams GetTextureDrawData(GsVector offset) { var outin = GetOutsideInsideBounds(offset); var bounds = outin.Outside; var wtower = GetImage(); var imgSize = ImageProvider.GetSize(wtower); var actSize = new GsSize(bounds.Width, bounds.Height); GsVector scale = Calculator.ComputeScale(imgSize, actSize); GsVector origin = imgSize.ToVector() * .5f; GsVector center = actSize.ToVector() * .5f; return(new ImageParams(wtower, imgSize, bounds.Location + center, origin, scale)); }
protected override ImageParams GetTextureDrawData(GsVector offset) { var projectile = GetImage(); var projectileSize = ImageProvider.GetSize(projectile); var origin = projectileSize.ToVector() * .5f; var scale = Calculator.ComputeScale(projectileSize, Size); var position = mOwnerBounds.Location; position += ((mOwnerBounds.Size.ToVector() * .5f)); // return the data return(new ImageParams(projectile, projectileSize, position + offset, origin, scale)); }
public TeslaCoilPiece() { // setup the description StringBuilder sb = new StringBuilder(); sb.AppendLine("Fires a charged burst of electricity. The burst is very effective against ground units."); // set the properties needed Attack = 9000; Price = 2500; Radius = 250; UpgradePercent = 45; LevelVisibility = 75; Description = sb.ToString(); ProjectileLifeInSeconds = 6.7f; CanFireProjectiles = false; Name = TeslaCoilName; UltimateName = UltimateTeslaCoilName; Grouping = PieceGrouping.Three; ImageKey = "teslaCoil"; Element = Element.Electricity; Specialty = PieceSpecialty.Both; // set the properties of the piece mIndex = 0; mAggregateTimeSinceUpdate = 0; mTeslaState = TeslaState.Idle; Color = GsColor.White; // get the image var image = GetImage(); var imageSize = ImageProvider.GetSize(image); FrameSize = new GsSize(imageSize.Width / (NumberIndexFrames + 1), imageSize.Height); LightningColor = GsMath.Lerp(GsColor.Purple, GsColor.DarkBlue, .5f); LightningColor = GsMath.Lerp(LightningColor, GsColor.Red, .75f); }
public static void DrawImage(this IGsGraphics graphics, GsImage image, GsColor color, GsVector location, GsVector scale) { var size = ImageProvider.GetSize(image).ToVector() * scale; graphics.DrawImage(image, location.X, location.Y, size.X, size.Y, color); }