Advertisement
Guest User

Untitled

a guest
Oct 6th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. public void Begin(RaceParameters param)
  2.     {
  3.       this.Parameters = param;
  4.       this.Cars = new Car[8];
  5.       this.game.track.Load(param.Name);
  6.       foreach (PhysicsEntity entity in this.game.track.FindEntities("waypoint", true))
  7.       {
  8.         Prop prop = (Prop) entity;
  9.         this.Waypoints.Add(new Waypoint()
  10.         {
  11.           Position = entity.Rigidbody.Position,
  12.           Flags = (WaypointFlags) prop.Flags
  13.         });
  14.       }
  15.       PhysicsEntity playerStart = this.FindPlayerStart();
  16.       if (playerStart == null)
  17.         Game.Current.Log.Print("Warning: No player start!");
  18.       this.Cars[0] = new Car(this.game, this.game.PlayerProfile.Car.Name, false);
  19.       this.Cars[0].Rigidbody.Position = playerStart.Rigidbody.Position;
  20.       this.Cars[0].Rigidbody.Rotation = playerStart.Rigidbody.Rotation;
  21.       PhysicsEntity[] entities = this.game.track.FindEntities("startMark");
  22.       string[] carList = Car.GetCarList();
  23.       this.carPositions = new int[entities.Length + 1];
  24.       for (int index = 0; index < entities.Length; ++index)
  25.       {
  26.         this.carPositions[index] = index + 1;
  27.         this.Cars[index + 1] = (Car) new AICar(this.game, this, carList[new Random(DateTime.Now.Millisecond).Next(0, carList.Length - 1)], false);
  28.         this.Cars[index + 1].SetColor(Car.Colors[new Random(DateTime.Now.Millisecond + index).Next(0, Car.Colors.Length - 2)]);
  29.         this.Cars[index + 1].Rigidbody.Position = entities[index].Rigidbody.Position;
  30.         this.Cars[index + 1].Rigidbody.Rotation = entities[index].Rigidbody.Rotation;
  31.         this.Cars[index + 1].PlayerName = RaceManager.Names[index];
  32.       }
  33.       this.isPlayerCarControllable = true;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement