public static void WriteChat(D2D.WindowRenderTarget renderTarget, Starbase starbase, SharpDX.DirectWrite.Factory textFactory, TextFormat textFormat, float height, D2D.Brush brush) { renderTarget.Clear(new SharpDX.Mathematics.Interop.RawColor4(0f, 0f, 0f, 0f)); lock (starbase.SyncMessages) { int number = starbase.Messages.Count; int offset = 0; int showNumber = number - 10 < 0 ? 0 : number - 10; int maxNumber = number - showNumber < 10 ? number - showNumber : 10; if (number > 0) { foreach (string message in starbase.Messages.GetRange(showNumber, maxNumber)) { using (SharpDX.DirectWrite.TextLayout layout = new SharpDX.DirectWrite.TextLayout(textFactory, message, textFormat, 500, 500)) renderTarget.DrawTextLayout(new SharpDX.Mathematics.Interop.RawVector2() { X = 10, Y = height - 110 + offset }, layout, brush, D2D.DrawTextOptions.Clip); offset += 10; } } } }
static void Main() { Starbase starBase = new Starbase(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainWindow(starBase)); }
public MainWindow(Starbase starbase) { this.starbase = starbase; SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.ResizeRedraw, false); SetStyle(ControlStyles.AllPaintingInWmPaint, true); Shown += MainWindow_Shown; starbase.ReadyEvent += ReadyMethod; InitializeComponent(); }
public Starship(Starbase starBase, UniverseGroup universeGroup) { this.universeGroup = universeGroup; this.starBase = starBase; Random r = new Random(); Name = "Scharle" + r.Next(1000, 2000).ToString(); ship = universeGroup.RegisterShip("ScharleRover", Name); Thread thread = new Thread(shipRotation); thread.Name = "StarShip"; thread.Start(); scanRange = ship.ScannerArea.Limit; scanAngle = ship.ScannerDegreePerScan; shotStartDistance = ship.WeaponSize + ship.Radius - 10; shotSpeed = ship.WeaponShot.Speed.Limit; shotTime = ship.WeaponShot.Time.Limit; }