/// <summary>
 /// Initializes a new instance of the <see cref="ParticleBouncer"/> class.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="particleDelay">The particle delay (in ticks).</param>
 /// <param name="action">The action.</param>
 public ParticleBouncer(Screen screen, long particleDelay, float particleLaunchVelocity, ParticleAction action)
     : base(particleDelay, particleLaunchVelocity, action, screen.Particles)
 {
     this.screen = screen;
     this.location = new Vector2(1920, 1080) / 2f;
     this.velocity = new Vector2(9, 5.7f);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 指定した番号の間の粒子に対して操作を実行する
 /// </summary>
 /// <param name="first">開始番号</param>
 /// <param name="last">終了番号</param>
 /// <param name="action">操作</param>
 void EachParticle(ulong first, ulong last, ParticleAction action)
 {
     // 各粒子について
     for (ulong i = first; i < last; i++)
     {
         // 操作を実行
         action(this.particles[i], i);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CircularParticleEmitter"/> class.
 /// </summary>
 /// <param name="particleDelay">The particle delay.</param>
 /// <param name="velocity">The velocity of a particle that is launched.</param>
 /// <param name="action">The action that draws and updates a particle.</param>
 /// <param name="particles">The particles to add a particle to.</param>
 public CircularParticleEmitter(long particleDelay, float velocity, ParticleAction action, ParticleContainer particles)
 {
     this.ParticleDelay = particleDelay;
     this.NextParticleTime = GameClock.Now + particleDelay;
     this.velocity = velocity;
     this.Action = action;
     this.particles = particles;
     this.random = new Random();
     this.previousPosition = new Vector2(float.MinValue);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CircularParticleEmitter"/> class.
 /// </summary>
 /// <param name="particleDelay">The particle delay.</param>
 /// <param name="velocity">The velocity of a particle that is launched.</param>
 /// <param name="action">The action that draws and updates a particle.</param>
 /// <param name="particles">The particles to add a particle to.</param>
 public CircularParticleEmitter(long particleDelay, float velocity, ParticleAction action, ParticleContainer particles)
 {
     this.ParticleDelay    = particleDelay;
     this.NextParticleTime = GameClock.Now + particleDelay;
     this.velocity         = velocity;
     this.Action           = action;
     this.particles        = particles;
     this.random           = new Random();
     this.previousPosition = new Vector2(float.MinValue);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Resets the specified x position.
 /// </summary>
 /// <param name="xPosition">The x position.</param>
 /// <param name="yPosition">The y position.</param>
 /// <param name="xVelocity">The x velocity.</param>
 /// <param name="yVelocity">The y velocity.</param>
 /// <param name="color">The color to overlay the drawn image with.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="rotation">The rotation.</param>
 /// <param name="rotationSpeed">The rotation speed.</param>
 /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
 /// For example, you may want to have one action which could draw one of several different
 /// images. You can set this value to indicate which image to draw. This does not have
 /// to be used.</param>
 /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
 public void Reset(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, float rotationSpeed, byte actionUniqueIdentifier, ParticleAction action)
 {
     this.Position.X             = xPosition;
     this.Position.Y             = yPosition;
     this.Velocity.X             = xVelocity;
     this.Velocity.Y             = yVelocity;
     this.Disposed               = false;
     this.CreationTime           = GameClock.Now;
     this.Action                 = action;
     this.color                  = color;
     this.Scale                  = scale;
     this.Rotation               = rotation;
     this.ActionUniqueIdentifier = actionUniqueIdentifier;
     this.RotationSpeed          = rotationSpeed;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Traverses all active particles.
 /// </summary>
 public void ForEach(ParticleAction action)
 {
     lock (particles)
     {
         if (ParticleCount > 0)
         {
             if (firstParticle < lastParticle)
             {
                 // ParticleConstroller<T>.Update requires the CurrentParticle to be the correct index.
                 for (CurrentParticle = firstParticle; CurrentParticle < lastParticle; CurrentParticle++)
                 {
                     if (particles[CurrentParticle].Age <= 1)
                     {
                         action(ref particles[CurrentParticle]);
                     }
                 }
             }
             else
             {
                 // UpdateParticles requires the enumeration to always start from firstParticle.
                 for (CurrentParticle = firstParticle; CurrentParticle < MaxParticleCount; CurrentParticle++)
                 {
                     if (particles[CurrentParticle].Age <= 1)
                     {
                         action(ref particles[CurrentParticle]);
                     }
                 }
                 for (CurrentParticle = 0; CurrentParticle < lastParticle; CurrentParticle++)
                 {
                     if (particles[CurrentParticle].Age <= 1)
                     {
                         action(ref particles[CurrentParticle]);
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// Resets the specified x position.
 /// </summary>
 /// <param name="xPosition">The x position.</param>
 /// <param name="yPosition">The y position.</param>
 /// <param name="xVelocity">The x velocity.</param>
 /// <param name="yVelocity">The y velocity.</param>
 /// <param name="color">The color to overlay the drawn image with.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="rotation">The rotation.</param>
 /// <param name="rotationSpeed">The rotation speed.</param>
 /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
 /// For example, you may want to have one action which could draw one of several different
 /// images. You can set this value to indicate which image to draw. This does not have
 /// to be used.</param>
 /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
 public void Reset(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, float rotationSpeed, byte actionUniqueIdentifier, ParticleAction action)
 {
     this.Position.X = xPosition;
     this.Position.Y = yPosition;
     this.Velocity.X = xVelocity;
     this.Velocity.Y = yVelocity;
     this.Disposed = false;
     this.CreationTime = GameClock.Now;
     this.Action = action;
     this.color = color;
     this.Scale = scale;
     this.Rotation = rotation;
     this.ActionUniqueIdentifier = actionUniqueIdentifier;
     this.RotationSpeed = rotationSpeed;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Particle"/> class.
 /// </summary>
 /// <param name="xPosition">The x position.</param>
 /// <param name="yPosition">The y position.</param>
 /// <param name="xVelocity">The x velocity.</param>
 /// <param name="yVelocity">The y velocity.</param>
 /// <param name="color">The color to overlay the drawn image with.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="rotation">The rotation.</param>
 /// <param name="rotationSpeed">The rotaiton speed.</param>
 /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
 /// For example, you may want to have one action which could draw one of several different
 /// images. You can set this value to indicate which image to draw. This does not have
 /// to be used.</param>
 /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
 public Particle(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, float rotationSpeed, byte actionUniqueIdentifier, ParticleAction action)
 {
     this.Position = new Vector2();
     this.Velocity = new Vector2();
     this.Reset(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, rotationSpeed, actionUniqueIdentifier, action);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RandomEmitter"/> class.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="particleDelay">The particle delay (in ticks).</param>
 /// <param name="action">The action.</param>
 public RandomEmitter(Screen screen, long particleDelay, float particleLaunchVelocity, ParticleAction action)
     : base(particleDelay, particleLaunchVelocity, action, screen.Particles)
 {
     this.location = new Vector2();
     this.screen = screen;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParticleBouncer"/> class.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="particleDelay">The particle delay (in ticks).</param>
 /// <param name="action">The action.</param>
 public ParticleBouncer(Screen screen, long particleDelay, float particleLaunchVelocity, ParticleAction action)
     : base(particleDelay, particleLaunchVelocity, action, screen.Particles)
 {
     this.screen   = screen;
     this.location = new Vector2(1920, 1080) / 2f;
     this.velocity = new Vector2(9, 5.7f);
 }
        /// <summary>
        /// Adds a Particle.
        /// </summary>
        /// <param name="xPosition">The x position.</param>
        /// <param name="yPosition">The y position.</param>
        /// <param name="xVelocity">The x velocity.</param>
        /// <param name="yVelocity">The y velocity.</param>
        /// <param name="color">The color to overlay the drawn image with.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
        /// For example, you may want to have one action which could draw one of several different
        /// images. You can set this value to indicate which image to draw. This does not have
        /// to be used.</param>
        /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
        /// <returns>
        /// False if the particle was not added, true if it was.
        /// </returns>
        public bool Add(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, byte actionUniqueIdentifier, ParticleAction action)
        {
            if (this.Particles.Count < this.maxParticles)
            {
                if (this.DeletedParticles.Count == 0)
                {
                    this.Particles.Enqueue(new Particle(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, actionUniqueIdentifier, action));
                }
                else
                {
                    Particle newParticle = this.DeletedParticles.Pop();
                    newParticle.Reset(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, actionUniqueIdentifier, action);
                    this.Particles.Enqueue(newParticle);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 全粒子に対して操作を実行する
 /// </summary>
 /// <param name="action">操作</param>
 void EachParticle(ParticleAction action)
 {
     // 全粒子に対して実行
     this.EachParticle(0, this.ParticleCount, action);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Particle"/> class.
 /// </summary>
 /// <param name="xPosition">The x position.</param>
 /// <param name="yPosition">The y position.</param>
 /// <param name="xVelocity">The x velocity.</param>
 /// <param name="yVelocity">The y velocity.</param>
 /// <param name="color">The color to overlay the drawn image with.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="rotation">The rotation.</param>
 /// <param name="rotationSpeed">The rotaiton speed.</param>
 /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
 /// For example, you may want to have one action which could draw one of several different
 /// images. You can set this value to indicate which image to draw. This does not have
 /// to be used.</param>
 /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
 public Particle(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, float rotationSpeed, byte actionUniqueIdentifier, ParticleAction action)
 {
     this.Position = new Vector2();
     this.Velocity = new Vector2();
     this.Reset(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, rotationSpeed, actionUniqueIdentifier, action);
 }
Exemplo n.º 14
0
        private SceneNode CreateSceneFromInput(Scene scene, SceneNode node)
        {
            // -------------------------------------------------------------------------------------
            // TODO: IMPORTANT, PLEASE IMPLEMENT BEFORE DEADLINE
            // -------------------------------------------------------------------------------------

            // Time limit needs fetching from the API settings and pushing to the time controller.
            _timeLimit += (float)((scene.SceneLength) / 1000);
            TimeController timeController = Controller.GetSimulationComponent <TimeController>();

            timeController.SetTimeLimit(_timeLimit);


            // -------------------------------------------------------------------------------------

            node.AddAttribute("VIDEO_URL", scene.SceneFile);
            //TODO: hardcoded at the moment

            node.AddAttribute("GENERAL_SETTINGS_TEXT", scene.GeneralSettings.Text);
            node.AddAttribute("GENERAL_SETTINGS_SCENE_BRIGHTNESS", scene.GeneralSettings.SceneBrightness.ToString());
            node.AddAttribute("GENERAL_SETTINGS_SOUND_VOLUME", scene.GeneralSettings.SoundVolume.ToString());
            node.AddAttribute("GENERAL_SETTINGS_ALARM_VOLUME", scene.GeneralSettings.AlarmVolume.ToString());
            if (scene.GeneralSettings.AlarmSoundPath != null)
            {
                node.AddAttribute("GENERAL_SETTINGS_ALARM_FILE", scene.GeneralSettings.AlarmSoundPath.ToString());
            }

            if (scene.GeneralSettings.ActionElements != null)
            {
                ParticleAction particleAction = new ParticleAction();
                foreach (var actionElement in scene.GeneralSettings.ActionElements)
                {
                    particleAction.AddParticleAction(actionElement);
                }
                particleAction.SetTimeOfAction(0.0f);
                node.AddAction(particleAction);
            }

            foreach (SceneBuilderWpf.DataModels.Decision decision in scene.DecisionList)
            {
                DecisionSet            decisionSet    = new DecisionSet();
                DecisionTimelineAction decisionAction = new DecisionTimelineAction();
                decisionSet.Time = decision.DecisionTime / 1000;
                bool transitionSet = false;

                foreach (SceneBuilderWpf.DataModels.ScenceChoice choice in decision.Choice)
                {
                    nextId++;
                    DecisionResult result = choice.Score < 0 ? DecisionResult.Incorrect : DecisionResult.Correct;
                    if (result == DecisionResult.Correct && !transitionSet && choice.Whereyougo != null)
                    {
                        TransitionTimelineAction transitionAction = new TransitionTimelineAction(nextId);
                        node.AddAttribute("DURATION", ((decision.DecisionTime + 20) / 1000).ToString());
                        transitionAction.SetTimeOfAction((decision.DecisionTime + 20) / 1000);
                        node.AddAction(transitionAction);
                        transitionSet = true;
                    }
                    decisionSet.AddDecision(new Decision(result, choice.Decision, choice.Feedback));

                    if (choice.Whereyougo != null)
                    {
                        SceneNode nextNode = CreateSceneNode(nextId);
                        nextNode.SetIdentifier(nextId);
                        CreateSceneFromInput(choice.Whereyougo, nextNode);
                    }
                }

                decisionAction.SetDecisionSet(decisionSet);
                node.AddAction(decisionAction);
            }
            return(node);
        }
Exemplo n.º 15
0
 /// <summary>
 /// 指定した番号の間の粒子に対して操作を実行する
 /// </summary>
 /// <param name="first">開始番号</param>
 /// <param name="last">終了番号</param>
 /// <param name="action">操作</param>
 void EachParticle(ulong first, ulong last, ParticleAction action)
 {
     // 各粒子について
     for(ulong i = first; i < last; i++)
     {
         // 操作を実行
         action(this.particles[i], i);
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// 全粒子に対して操作を実行する
 /// </summary>
 /// <param name="action">操作</param>
 void EachParticle(ParticleAction action)
 {
     // 全粒子に対して実行
     this.EachParticle(0, this.ParticleCount, action);
 }
        /// <summary>
        /// Adds a Particle.
        /// </summary>
        /// <param name="xPosition">The x position.</param>
        /// <param name="yPosition">The y position.</param>
        /// <param name="xVelocity">The x velocity.</param>
        /// <param name="yVelocity">The y velocity.</param>
        /// <param name="color">The color to overlay the drawn image with.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="rotationSpeed">The rotation speed.</param>
        /// <param name="actionUniqueIdentifier">This is used to identify what "type" in a custom action this particle belongs to.
        /// For example, you may want to have one action which could draw one of several different
        /// images. You can set this value to indicate which image to draw. This does not have
        /// to be used.</param>
        /// <param name="action">The action. This should be a reference to a STATIC object, for memory sake.</param>
        /// <returns>
        /// False if the particle was not added, true if it was.
        /// </returns>
        public bool Add(float xPosition, float yPosition, float xVelocity, float yVelocity, Color color, float scale, float rotation, float rotationSpeed, byte actionUniqueIdentifier, ParticleAction action)
        {
            if (this.Particles.Count < this.maxParticles)
            {
                if (this.DeletedParticles.Count == 0)
                {
                    this.Particles.Enqueue(new Particle(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, rotationSpeed, actionUniqueIdentifier, action));
                }
                else
                {
                    Particle newParticle = this.DeletedParticles.Pop();
                    newParticle.Reset(xPosition, yPosition, xVelocity, yVelocity, color, scale, rotation, rotationSpeed, actionUniqueIdentifier, action);
                    this.Particles.Enqueue(newParticle);
                }

                return true;
            }

            return false;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RandomEmitter"/> class.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="particleDelay">The particle delay (in ticks).</param>
 /// <param name="action">The action.</param>
 public RandomEmitter(Screen screen, long particleDelay, float particleLaunchVelocity, ParticleAction action)
     : base(particleDelay, particleLaunchVelocity, action, screen.Particles)
 {
     this.location = new Vector2();
     this.screen   = screen;
 }