public void Update(View view) { DoToAll((int x, int y) => { TechGrid[x, y].Update(); }); if (Parent.Accelerate) AccelerateForward(); Parent.Update(External, view); }
public void Update(Cluster cluster,View view) { if (AutoPilot) { Console.WriteLine("Coords = " + cluster.PositionTopLeft); if (SetHeadingTo(FixTheta(Math.Abs(Resources.Helper.GetPolarCoords(cluster.Velocity).Y)), cluster)) Accelerate = true; else Accelerate = false; if (cluster.Velocity.LengthSquared < 0.01) AutoPilot = false; } switch(Master) { case ControlType.Human: { if(Input.KeyRelease(OpenTK.Input.Key.O)) { if(AutoPilot) { AutoPilot = false; Console.WriteLine("AutoPilot:Off"); } else { AutoPilot = true; Console.WriteLine("AutoPilot:On"); } } sbyte[] input = Input.GetKeyInputVector2(); if (-input[1] > 0) Accelerate = true; else if(!AutoPilot) Accelerate = false; cluster.AccelerateTorque(input[0]); view.SetPosition( cluster.PositionTopLeft + new OpenTK.Vector2(cluster.Width / 2, cluster.Height / 2) + cluster.Velocity); if (Input.KeysDown.Contains(OpenTK.Input.Key.KeypadPlus)) { view.Zoom *= 1.0625f; } if (Input.KeysDown.Contains(OpenTK.Input.Key.KeypadMinus)) { view.Zoom /= 1.0625f; } OpenTK.Vector2 velocity = new OpenTK.Vector2((float)Math.Round(cluster.Velocity.X,2), (float)Math.Round(cluster.Velocity.Y, 2)); if (velocity != velocityLast) { //Console.WriteLine("Velocity = " + velocity); Console.WriteLine("Kilometers Per Second = " + velocity.Length*60*60/1000); velocityLast = velocity; } break; } case ControlType.Runner: { break; } case ControlType.Charger: { break; } default: { break; } } }