예제 #1
0
파일: PowerUp.cs 프로젝트: K-Cully/SticKart
        /// <summary>
        /// Initializes a new instance of the <see cref="PowerUp"/> class.
        /// </summary>
        /// <param name="physicsWorld">The physics world.</param>
        /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
        /// <param name="contentManager">The game's content manager.</param>
        /// <param name="description">The entity description.</param>
        /// <param name="settings">The power up settings.</param>
        public PowerUp(ref World physicsWorld, SpriteBatch spriteBatch, ContentManager contentManager, InteractiveEntityDescription description, PowerUpSetting settings)
            : base(ref physicsWorld, description)
        {
            this.name = settings.Name;
            this.timeOfEffect = settings.TimeOfEffect;

            switch (this.name)
            {
                case EntityConstants.InvincibleName:
                    this.type = PowerUpType.Invincibility;
                    break;
                case EntityConstants.HealthName:
                    this.type = PowerUpType.Health;
                    break;
                case EntityConstants.JumpName:
                    this.type = PowerUpType.Jump;
                    break;
                case EntityConstants.SpeedName:
                    this.type = PowerUpType.Speed;
                    break;
                default:
                    this.type = PowerUpType.None;
                    break;
            }

            this.PhysicsBody.UserData = new InteractiveEntityUserData(InteractiveEntityType.PowerUp, this.timeOfEffect, this.type);
            this.InitializeAndLoad(spriteBatch, contentManager);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractiveEntity"/> class.
 /// </summary>
 /// <param name="physicsWorld">The physics world.</param>
 /// <param name="description">The description of the entity.</param>
 public InteractiveEntity(ref World physicsWorld, InteractiveEntityDescription description)
 {
     this.destroyed = false;
     this.Sound     = null;
     this.Sprite    = new Sprite();
     this.SetUpPhysics(ref physicsWorld, description);
 }
예제 #3
0
파일: Level.cs 프로젝트: K-Cully/SticKart
        /// <summary>
        /// Adds an interactive entity to the level.
        /// </summary>
        /// <param name="name">The name of the entity.</param>
        /// <param name="position">The position of the entity.</param>
        /// <param name="size">The size of the entity in display coordinates.</param>
        public void AddInteractiveEntity(string name, Vector2 position, Vector2 size)
        {
            InteractiveEntityDescription entityDescription = new InteractiveEntityDescription();

            entityDescription.Position   = position;
            entityDescription.Name       = name;
            entityDescription.Dimensions = size;
            this.interactiveEntityDescriptions.Add(entityDescription);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BonusOrObstacle"/> class.
 /// </summary>
 /// <param name="physicsWorld">The physics world.</param>
 /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
 /// <param name="contentManager">The game's content manager.</param>
 /// <param name="description">The entity description.</param>
 /// <param name="setting">The entity's settings.</param>
 public BonusOrObstacle(ref World physicsWorld, SpriteBatch spriteBatch, ContentManager contentManager, InteractiveEntityDescription description, ObstacleOrBonusSetting setting)
     : base(ref physicsWorld, description)
 {
     this.Type = setting.IsBonus ? InteractiveEntityType.Bonus : InteractiveEntityType.Obstacle;
     this.name = setting.Name;
     this.Value = setting.Value;
     this.PhysicsBody.UserData = new InteractiveEntityUserData(this.Type, this.Value);
     this.InitializeAndLoad(spriteBatch, contentManager);
 }
예제 #5
0
파일: Level.cs 프로젝트: K-Cully/SticKart
        /// <summary>
        /// Draws an interactive entity.
        /// </summary>
        /// <param name="entityDescription">The entity's description.</param>
        private void DrawInteractiveEntity(InteractiveEntityDescription entityDescription)
        {
            switch (entityDescription.Name)
            {
            case EntityConstants.FireName:
                Camera2D.Draw(this.fireSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.SpikeName:
                Camera2D.Draw(this.spikeSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.RockName:
                Camera2D.Draw(this.rockSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.InvincibleName:
                Camera2D.Draw(this.invincibleSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.HealthName:
                Camera2D.Draw(this.healthSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.SpeedName:
                Camera2D.Draw(this.speedSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.JumpName:
                Camera2D.Draw(this.jumpSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.CoinName:
                Camera2D.Draw(this.coinSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.DiamondName:
                Camera2D.Draw(this.diamondSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.RubyName:
                Camera2D.Draw(this.rubySprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.Switch:
                Camera2D.Draw(this.switchSprite, entityDescription.Position, 0.0f);
                break;

            case EntityConstants.CartBody:
                Camera2D.Draw(this.cartSprite, entityDescription.Position, 0.0f);
                break;

            default:
                break;
            }
        }
예제 #6
0
파일: Level.cs 프로젝트: K-Cully/SticKart
 /// <summary>
 /// Adds a switch to the level.
 /// </summary>
 /// <param name="position">The position of the entity.</param>
 /// <param name="size">The size of the entity in display coordinates.</param>
 public void AddSwitch(Vector2 position, Vector2 size)
 {
     if (this.switchIndex == -1)
     {
         this.switchIndex = this.interactiveEntityDescriptions.Count;
         InteractiveEntityDescription entityDescription = new InteractiveEntityDescription();
         entityDescription.Position   = position;
         entityDescription.Name       = EntityConstants.Switch;
         entityDescription.Dimensions = size;
         this.interactiveEntityDescriptions.Add(entityDescription);
     }
     else
     {
         this.interactiveEntityDescriptions[this.switchIndex].Position   = position;
         this.interactiveEntityDescriptions[this.switchIndex].Dimensions = size;
     }
 }
예제 #7
0
 /// <summary>
 /// Sets up the physics body for an interactive entity.
 /// </summary>
 /// <param name="physicsWorld">The physics world to create the body in.</param>
 /// <param name="description">The description of the interactive entity.</param>
 protected virtual void SetUpPhysics(ref World physicsWorld, InteractiveEntityDescription description)
 {
     this.PhysicsBody = BodyFactory.CreateRectangle(physicsWorld, ConvertUnits.ToSimUnits(description.Dimensions.X), ConvertUnits.ToSimUnits(description.Dimensions.Y), 3.0f, ConvertUnits.ToSimUnits(description.Position));
     this.PhysicsBody.CollisionCategories = EntityConstants.InteractiveEntityCategory;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BonusOrObstacle"/> class.
 /// </summary>
 /// <param name="physicsWorld">The physics world.</param>
 /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
 /// <param name="contentManager">The game's content manager.</param>
 /// <param name="description">The entity description.</param>
 /// <param name="setting">The entity's settings.</param>
 public BonusOrObstacle(ref World physicsWorld, SpriteBatch spriteBatch, ContentManager contentManager, InteractiveEntityDescription description, ObstacleOrBonusSetting setting)
     : base(ref physicsWorld, description)
 {
     this.Type  = setting.IsBonus ? InteractiveEntityType.Bonus : InteractiveEntityType.Obstacle;
     this.name  = setting.Name;
     this.Value = setting.Value;
     this.PhysicsBody.UserData = new InteractiveEntityUserData(this.Type, this.Value);
     this.InitializeAndLoad(spriteBatch, contentManager);
 }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PowerUp"/> class.
        /// </summary>
        /// <param name="physicsWorld">The physics world.</param>
        /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
        /// <param name="contentManager">The game's content manager.</param>
        /// <param name="description">The entity description.</param>
        /// <param name="settings">The power up settings.</param>
        public PowerUp(ref World physicsWorld, SpriteBatch spriteBatch, ContentManager contentManager, InteractiveEntityDescription description, PowerUpSetting settings)
            : base(ref physicsWorld, description)
        {
            this.name         = settings.Name;
            this.timeOfEffect = settings.TimeOfEffect;

            switch (this.name)
            {
            case EntityConstants.InvincibleName:
                this.type = PowerUpType.Invincibility;
                break;

            case EntityConstants.HealthName:
                this.type = PowerUpType.Health;
                break;

            case EntityConstants.JumpName:
                this.type = PowerUpType.Jump;
                break;

            case EntityConstants.SpeedName:
                this.type = PowerUpType.Speed;
                break;

            default:
                this.type = PowerUpType.None;
                break;
            }

            this.PhysicsBody.UserData = new InteractiveEntityUserData(InteractiveEntityType.PowerUp, this.timeOfEffect, this.type);
            this.InitializeAndLoad(spriteBatch, contentManager);
        }