示例#1
0
    private void DoActivateTrigger()
    {
        triggerCount--;

        if (triggerCount == 0 || repeatTrigger)
        {
            CheckpointPassed?.Invoke(this, CheckpointId);
        }
    }
示例#2
0
        static LocalVehicle()
        {
            Screen = new Screen();
            HUD    = new HUD();

            Events.Car.PreExplode.SubscribeAll((sender, data) =>
            {
                BeforeExploded?.Invoke(null, System.EventArgs.Empty);
            });

            Events.Car.PreSplit.SubscribeAll((sender, data) =>
            {
                BeforeSplit?.Invoke(null, System.EventArgs.Empty);
            });

            Events.Car.CheckpointHit.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new CheckpointHitEventArgs(data.checkpointIndex_, data.trackT_);
                    CheckpointPassed?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Death.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new DestroyedEventArgs((DestructionCause)data.causeOfDeath);
                    Destroyed?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Explode.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new DestroyedEventArgs((DestructionCause)data.causeOfDeath);
                    Exploded?.Invoke(null, eventArgs);
                }
            });

            Events.RaceEnd.LocalCarHitFinish.Subscribe(data =>
            {
                BeforeFinished?.Invoke(null, System.EventArgs.Empty);
            });

            Events.Player.Finished.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>() != null)
                {
                    var eventArgs = new FinishedEventArgs((RaceEndType)data.finishType_, data.finishData_);
                    Finished?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Horn.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new HonkEventArgs(data.hornPercent_, new Position(data.position_.x, data.position_.y, data.position_.z));
                    Honked?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Impact.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new ImpactEventArgs(data.speed_, new Position(data.pos_.x, data.pos_.y, data.pos_.z), data.impactedCollider_.name);
                    Collided?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Jump.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    Jumped?.Invoke(null, System.EventArgs.Empty);
                }
            });

            Events.Car.ModeSpecial.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    SpecialModeEvent?.Invoke(null, System.EventArgs.Empty);
                }
            });

            Events.Player.CarRespawn.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>() != null)
                {
                    var pos       = new Position(data.position_.x, data.position_.y, data.position_.z);
                    var rot       = new Rotation(data.rotation_.x, data.rotation_.y, data.rotation_.z);
                    var eventArgs = new RespawnEventArgs(pos, rot, data.fastRespawn_);

                    Respawned?.Invoke(null, eventArgs);
                }
            });

            Events.Car.Split.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new SplitEventArgs(data.penetration, data.separationSpeed);
                    Split?.Invoke(null, eventArgs);
                }
            });

            Events.Car.TrickComplete.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    var eventArgs = new TrickCompleteEventArgs(data.cooldownAmount_, data.points_, data.wallRideMeters_, data.ceilingRideMeters_, data.grindMeters_);
                    TrickCompleted?.Invoke(null, eventArgs);
                }
            });

            Events.Car.WingsStateChange.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    if (data.open_)
                    {
                        WingsOpened?.Invoke(null, System.EventArgs.Empty);
                    }
                    else
                    {
                        WingsClosed?.Invoke(null, System.EventArgs.Empty);
                    }
                }
            });

            Events.Car.WingsAbilityStateChanged.SubscribeAll((sender, data) =>
            {
                if (sender.GetComponent <PlayerDataLocal>())
                {
                    if (data.enabled_)
                    {
                        WingsEnabled?.Invoke(null, System.EventArgs.Empty);
                    }
                    else
                    {
                        WingsDisabled?.Invoke(null, System.EventArgs.Empty);
                    }
                }
            });
        }