Example #1
0
 public void OnGameModeInit(IWorldService worldService)
 {
     _menu = worldService.CreateMenu("Test menu", new Vector2(200, 300), 100);
     _menu.AddItem("Hello!!!");
     _menu.AddItem("Hello!!");
     _menu.AddItem("Hello!");
 }
Example #2
0
        public void OnGameModeInit(IVehicleRepository vehiclesRepository, IWorldService worldService,
                                   IServerService serverService, IVehicleInfoService vehicleInfoService)
        {
            // Event methods have dependency injection alongside the arguments

            Console.WriteLine("Do game mode loading goodies...");

            vehiclesRepository.Foo();

            worldService.CreateActor(101, new Vector3(0, 0, 20), 0);

            var blue = Color.Blue;

            blue.A      = 128;
            _zone       = worldService.CreateGangZone(0, 0, 100, 100);
            _zone.Color = blue;
            _zone.Show();

            var obj = worldService.CreateObject(16638, new Vector3(10, 10, 40), Vector3.Zero, 1000);

            obj.DisableCameraCollisions();

            worldService.CreateVehicle(VehicleModelType.Alpha, new Vector3(40, 40, 10), 0, 0, 0);

            var green = Color.Green;

            green.A = 128;
            worldService.CreateTextLabel("text", green, new Vector3(10, 10, 10), 1000);

            _welcome              = worldService.CreateTextDraw(new Vector2(20, 40), "Hello, world");
            _welcome.Alignment    = TextDrawAlignment.Left;
            _welcome.Font         = TextDrawFont.Diploma;
            _welcome.Proportional = true;
            Console.WriteLine("TD pos: " + _welcome.Position);
            Console.WriteLine(_welcome.Entity.ToString());

            _menu = worldService.CreateMenu("Test menu", new Vector2(200, 300), 100);
            _menu.AddItem("Hello!!!");
            _menu.AddItem("Hello!!");
            _menu.AddItem("Hello!");

            var ctx = SynchronizationContext.Current;

            Task.Run(() =>
            {
                // ... Run things on a worker thread.

                ctx.Send(_ =>
                {
                    // ... Run things on the main thead.
                }, null);
            });

            serverService.SetGameModeText("SampSharp.Entities");

            var size = vehicleInfoService.GetModelInfo(VehicleModelType.AT400, VehicleModelInfoType.Size);

            Console.WriteLine($"AT400 size {size}");
        }