Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Player" /> class.
        /// </summary>
        /// <param name="playerScene">The player scene.</param>
        public Player(Scene playerScene)
        {
            this.scene = playerScene;

            // Left Pad
            this.leftPad = new PadBody(Color.Transparent);
            this.leftPad.PadBehavior.Joint = JointType.HandLeft;
            this.scene.EntityManager.Add(this.leftPad);

            // Right Pad
            this.rightPad = new PadBody(Color.Transparent);
            this.rightPad.PadBehavior.Joint = JointType.HandRight;
            this.scene.EntityManager.Add(this.rightPad);

            // Burning effects. Not neccesary but cool!
            this.leftParticleEntity = new Entity()
                .AddComponent(new Transform2D())
                .AddComponent(ParticleSystemFactory.CreateFireParticle())
                .AddComponent(new FollowPadParticlesBehavior())
                .AddComponent(new Material2D(new BasicMaterial2D("Content/particleFire.wpk", DefaultLayers.Additive)))
                .AddComponent(new ParticleSystemRenderer2D("particleRenderer"));
            this.scene.EntityManager.Add(this.leftParticleEntity);

            this.rightParticleEntity = new Entity()
                .AddComponent(new Transform2D())
                .AddComponent(ParticleSystemFactory.CreateFireParticle())
                .AddComponent(new FollowPadParticlesBehavior())
                .AddComponent(new Material2D(new BasicMaterial2D("Content/particleFire.wpk", DefaultLayers.Additive)))
                .AddComponent(new ParticleSystemRenderer2D("particleRenderer"));
            this.scene.EntityManager.Add(this.rightParticleEntity);
        }
Пример #2
0
        /// <summary>
        /// Removes the player.
        /// </summary>
        private void RemovePlayer()
        {
            this.scene.EntityManager.Remove(this.leftPad);
            this.scene.EntityManager.Remove(this.rightPad);

            this.leftPad = null;
            this.rightPad = null;
        }