Exemplo n.º 1
0
 public void SetImpulse(Vec3 target, float speed, float timeToLive = 10f)
 {
     Physics.Physicalize(5, EPhysicalizationType.ePT_Rigid);
     Physics.Action <pe_action_set_velocity>((impulse) =>
     {
         impulse.v = (target - Position).Normalized * speed;
     });
     timeToLiveTimer = new Timer(timeToLive, () => Destroy());
 }
Exemplo n.º 2
0
        void IMouseDown.OnMouseDown(MouseButton button)
        {
            Debug.Log("OnMouseDown!");

            if (button == MouseButton.Left)
            {
                var physImpulse = new pe_action_set_velocity()
                {
                    v = new Vec3(Vec3.Up * 15f),
                };
                Physics.Action(physImpulse);
            }
            else
            {
                Destroy();
            }
        }
Exemplo n.º 3
0
        public void Launch()
        {
            GetParticleEffect("particle_trail", (pfx) => NativeEntity.LoadParticleEmitter(1, pfx));

            // Launch the firework upwards.
            Physics.Action <pe_action_impulse>((action) =>
            {
                action.impulse = Rotation.Forward * 100f;
            });

            var rnd = new Random().Next((int)MinTime * 100, (int)MaxTime * 100) / 100f;

            // Start a timer that will trigger the explosion.
            new Timer(rnd, () =>
            {
                // Spawn the explosion effect then remove this entity.
                GetParticleEffect("particle_explosion", (pfx) => pfx.Spawn(Position));
                Remove();
            });
        }