public Asteroid(Game1 Game, Sprite spriteSheet, Vector2 coordinates) : base(Game, spriteSheet) { this.coordinates = coordinates; position = MathFunctions.CoordinateToPosition(coordinates); this.angle = (float)(MathFunctions.GetExternalRandomDouble() * 2 * Math.PI); }
public override void Initialize() { base.Initialize(); text = new List <string>(); options = new List <string>(); scale = 1f; layerDepth = 0.3f + (float)(MathFunctions.GetExternalRandomDouble() * 0.01); color = Color.White; }
private VerticalShooterShip StandardCreatureSetup(VerticalShooterShip creature) { creature.Initialize(); creature.Direction = new Vector2(0, 1.0f); if (setupCreature != null) { creature.HP *= setupCreature.HPFactor; creature.Speed *= setupCreature.speedFactor; if (setupCreature.newMovement != Movement.None) { if (setupCreature.newMovement != Movement.BossStop_X) { creature.SetMovement(setupCreature.newMovement); } else { creature.SetBossMovement(setupCreature.YStopPosition); } } } //Extra logic for allys if (creature is AlliedShip) { ((AlliedShip)creature).SetFormationArea(new Rectangle((int)(creature.PositionX), 500, 1, 7)); if (creature is AllianceFighterAlly || creature is RebelFighterAlly) { ((AlliedShip)creature).CreateAI(AIBehaviour.Standard); } else if (creature is FreighterAlly) { ((AlliedShip)creature).CreateAI(AIBehaviour.NoWeapon); } else { throw new ArgumentException("Unknown ally type!"); } } // Slightly alters the draw layer to give all gameobjects individual layers creature.DrawLayer += (float)(MathFunctions.GetExternalRandomDouble() * 0.01); return(creature); }
private ItemVariety GetRandomVariety() { double randNbr = MathFunctions.GetExternalRandomDouble(); if (randNbr < goodQualThres) { return(ItemVariety.High); } else if (randNbr < regQualThres) { return(ItemVariety.Regular); } else //if (randNbr < regQualThres) { return(ItemVariety.Low); } }
private List <Vector2> GetRandomCoordinateFields(int count, double radius, double emptyInnerRadius = 0) { List <Vector2> coordList = new List <Vector2>(); for (int n = 0; n < count; n++) { double r = MathFunctions.GetExternalRandomDouble() * (radius - emptyInnerRadius) + emptyInnerRadius; double rad = MathFunctions.GetExternalRandomDouble() * Math.PI * 2; Vector2 coord = new Vector2((float)(MathFunctions.DirFromRadians(rad).X *r), (float)(MathFunctions.DirFromRadians(rad).Y *r)); coordList.Add(coord); } return(coordList); }
private double GetQualityNumber() { double randNbr = MathFunctions.GetExternalRandomDouble(); if (randNbr < greatQualThres) { return(greatQuality); } else if (randNbr < goodQualThres) { return(goodQuality); } else if (randNbr < regQualThres) { return(regularQuality); } else { return(lowQuality); } }