Beispiel #1
0
 public GasStation(Vector3 position)
 {
     Position   = position;
     _pickup    = Pickup.Create(ObjectModel.Petrolpump, PickupType.ScriptedActionsOnlyEveryFewSeconds, position);
     _textLabel = new TextLabel("Honk the horn\nto refuel your vehicle", Color.Teal, position, 30.0f);
     _mapIcon   = new DynamicMapIcon(position, 56);
 }
Beispiel #2
0
    public Team(
        int skin,
        string otherColor,
        string colorGameText,
        TextDraw tdscore,
        TeamID teamid,
        string name,
        string namecolor,
        string colorEnglish,
        Flag flag,
        int interior
        )
    {
        Skin          = skin;
        OtherColor    = otherColor;
        ColorGameText = colorGameText;
        TdScore       = tdscore;
        Id            = teamid;
        NameTeam      = name;
        NameColor     = namecolor;
        ColorEnglish  = colorEnglish;
        Flag          = flag;
        Icon          = new DynamicMapIcon(Flag.PositionBase, 0)
        {
            StreamDistance = 5000f, Interior = interior, Color = Flag.ColorHex
        };
        int interval = EnvReader.Instance.GetIntValue("FLAG_RETURN_TIME") * 1000;

        Timer       = new Timer(interval, isRepeating: false, running: false);
        Timer.Tick += OnFlagIsNotRetrievedPeriodOfTime;
    }
        private T GetItem <T>(int id) where T : IDynamicWorldObject
        {
            if (typeof(DynamicTextLabel).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicTextLabel.Find(id));
            }

            if (typeof(DynamicPickup).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicPickup.Find(id));
            }

            if (typeof(DynamicRaceCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicRaceCheckpoint.Find(id));
            }

            if (typeof(DynamicObject).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicObject.Find(id));
            }

            if (typeof(DynamicMapIcon).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicMapIcon.Find(id));
            }

            if (typeof(DynamicCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicCheckpoint.Find(id));
            }

            if (typeof(DynamicArea).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicArea.Find(id));
            }

            if (typeof(DynamicActor).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicActor.Find(id));
            }

            throw new Exception("Unknown dynamic world object type.");
        }
 /// <summary>
 ///     Registers types this <see cref="T:SampSharp.GameMode.Controllers.ITypeProvider" /> requires the system to use.
 /// </summary>
 public virtual void RegisterTypes()
 {
     DynamicMapIcon.Register <DynamicMapIcon>();
 }
Beispiel #5
0
        /// <summary>
        ///     Raises the <see cref="E:SampSharp.GameMode.BaseMode.Initialized" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param>
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            var vehicle = BaseVehicle.Create(VehicleModelType.Alpha, Vector3.Up * 15, 0, -1, -1);

            vehicle.GetDamageStatus(out var panels, out var doors, out var lights, out var tires);
            Console.WriteLine(panels.ToString());
            Console.WriteLine(doors.ToString());
            Console.WriteLine(lights.ToString());
            Console.WriteLine(tires.ToString());

            var streamer = Services.GetService <IStreamer>();

            Console.WriteLine("Service: " + streamer);

            var area =
                DynamicArea.CreatePolygon(new[]
            {
                Vector3.One + new Vector3(-10, -10),
                Vector3.One + new Vector3(10, -10),
                Vector3.One + new Vector3(10, 10),
                Vector3.One + new Vector3(-10, 10)
            }, -100.0f, 100.0f);

            Console.WriteLine("Area handle: " + area.Id);

            area.Enter += (sender, args) => args.Player.SendClientMessage("Entered polygon");
            area.Leave += (sender, args) => args.Player.SendClientMessage("Left polygon");

            var isValid  = area.IsValid;
            var position = area.Position;
            var points   = area.GetPoints().ToArray();

            Console.WriteLine($"area.IsValid = {isValid}, area.Position = {position}, Points = {string.Join(", ", points)}");

            var area2 = DynamicArea.CreateRectangle(0, 0, 20, 20);

            area2.Enter += (sender, args) => args.Player.SendClientMessage("Entered Rectangle");
            area2.Leave += (sender, args) => args.Player.SendClientMessage("Left Rectangle");

            var icon = new DynamicMapIcon(new Vector3(1500, -1500, 0), Color.Blue, MapIconType.Global, -1, -1, null, 300);

            Console.WriteLine(icon.Position);
            icon.Position = new Vector3(50, 50, 5);
            Console.WriteLine(icon.Position);

            var pickup = new DynamicPickup(1274, 23, new Vector3(0, 0, 3), 100f,
                                           new[] { 11, 22, 33, 44, 0, 55, 66, 77, 88, 99 }); //Dollar icon

            pickup.PickedUp += (sender, args) => args.Player.SendClientMessage(Color.White, "Picked Up");

            var pickup2 = new DynamicPickup(1274, 23, Vector3.One, 42);

            Console.WriteLine("World: {0}", string.Join(",", pickup.Worlds));
            Console.WriteLine("World: {0}", string.Join(",", pickup2.Worlds));

            var checkpoint = new DynamicCheckpoint(new Vector3(10, 10, 3));

            checkpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered CP");
            checkpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left CP");

            var actor = new DynamicActor(100, new Vector3(20, 10, 5), 0);



            var racecheckpoint = new DynamicRaceCheckpoint(CheckpointType.Normal, new Vector3(-10, -10, 3), new Vector3());

            racecheckpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered RCP");
            racecheckpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left RCP");

            new DynamicTextLabel("[I am maroon]", Color.Maroon, pickup.Position + new Vector3(0, 0, 1), 100.0f);

            var obj = new DynamicObject(12991, new Vector3(10, 10, 3));

            Console.WriteLine("obj position after spawn " + obj.Position);
            var offset = Vector3.One;

            obj.SetMaterialText(1, "Test", ObjectMaterialSize.X512X512, "Arial", 30, false, Color.Black, Color.White);
            obj.Move(obj.Position + -offset, 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            obj.Moved += (sender, args) =>
            {
                Console.WriteLine("moved");
                obj.Move(obj.Position + (offset = -offset), 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            };


            Console.WriteLine("Test error handling...");
            streamer.IsErrorCallbackEnabled = true;
            streamer.Error += (sender, args) => { Console.WriteLine("Error CB: " + args.Error); };
            streamer.PrintStackTraceOnError = true;
            streamer.ItemType[StreamType.MapIcon].GetArray(9999, StreamerDataType.Color, 1);
            Console.WriteLine("Messages should have appeared above.");
        }