This class represents the inbetween stage of XML and translated GameObject
Beispiel #1
0
 public static EntityInfo CreatePlayerEndInfo(Vector2 startLocation)
 {
     var playerEnd = new EntityInfo("PlayerEnd", startLocation);
     playerEnd.MProperties.Add("Shape", "Circle");
     playerEnd.MId = -2;
     return playerEnd;
 }
Beispiel #2
0
 /// <summary>
 /// Constructs a trigger that is capable of acting like a black hole
 /// </summary>
 /// <param name="content">Content Manager to use</param>
 /// <param name="entity">Info on this entity</param>
 public BlackHoleTrigger(ContentManager content, EntityInfo entity)
     : base(content, entity)
 {
     if (entity.MProperties.ContainsKey(XmlKeys.Force))
         _mForce = float.Parse(entity.MProperties[XmlKeys.Force]);
     _blackHole.Load(content, "BlackHole",3, 6);
 }
Beispiel #3
0
 public ForceTrigger(ContentManager content, EntityInfo entity)
     : base(content, entity)
 {
     if (entity.MProperties.ContainsKey(XmlKeys.Xforce))
         _mForce.X = float.Parse(entity.MProperties[XmlKeys.Xforce]);
     if (entity.MProperties.ContainsKey(XmlKeys.Yforce))
         _mForce.Y = float.Parse(entity.MProperties[XmlKeys.Yforce]);
 }
Beispiel #4
0
 public static EntityInfo CreatePlayerInfo(Vector2 startLocation)
 {
     var player = new EntityInfo("Player", startLocation);
     player.MProperties.Add("Shape", "Circle");
     player.MProperties.Add("Mass", "1");
     player.MId = -1;
     return player;
 }
Beispiel #5
0
 public PlayerEnd(ContentManager content,EntityInfo entity)
     : base(content, .8f, entity)
 {
     MIsSquare = false;
         PlayerFaces.Load(content);
         MCurrentTexture = PlayerFaces.FromString("GirlSmile");
         MTimer = 0.0;
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new popup trigger
        /// </summary>
        /// <param name="content">Content manager that loads our stuff</param>
        /// <param name="entity">Information from xml about this entity</param>
        public PopupTrigger(ContentManager content, EntityInfo entity)
            : base(content, entity)
        {
            if (entity.MProperties.ContainsKey(XmlKeys.PopupType))
            {
                if (_isImage = entity.MProperties[XmlKeys.PopupType] == XmlKeys.PopupImage)
                    Load(content, ImageDirectory + entity.MProperties[XmlKeys.ImageFile]);
                else
                    _mText = entity.MProperties[XmlKeys.Text];
            }

            _mFont = content.Load<SpriteFont>("Fonts/QuartzSmall");
        }
Beispiel #7
0
        public MusicTrigger(ContentManager content, EntityInfo entity)
            : base(content, entity)
        {
            if (entity.MProperties.ContainsKey(XmlKeys.MusicFile))
            {
                _musicByte = content.Load<SoundEffect>("Music\\" + entity.MProperties[XmlKeys.MusicFile]);
                _musicByteInstance = _musicByte.CreateInstance();
                _musicByteInstance.Volume = GameSound.Volume;

            }
            if(entity.MProperties.ContainsKey(XmlKeys.Loop))
                _musicByteInstance.IsLooped = entity.MProperties[XmlKeys.Loop] == XmlKeys.True;
        }
Beispiel #8
0
        /// <summary>
        /// Construcsts a new trigger
        /// 
        /// See Static object for parameter defs
        /// </summary>
        /// <param name="width">Width of the trigger activation field</param>
        /// <param name="height">Height of the trigger activation field</param>
        public Trigger(ContentManager content, EntityInfo entity)
            : base(content, .0f, entity)
        {
            MSize = new Vector2(3, 3);
            if(entity.MProperties.ContainsKey(XmlKeys.Width)) MSize.X = int.Parse(entity.MProperties[XmlKeys.Width]);
            if (entity.MProperties.ContainsKey(XmlKeys.Height)) MSize.Y = int.Parse(entity.MProperties[XmlKeys.Height]);

            MSize = GridSpace.GetDrawingCoord(MSize);
            var boundingBox = BoundingBox;
            boundingBox.X -= (int)MSize.X / 2;
            boundingBox.Y -= (int)MSize.Y / 2;
            boundingBox.Width = (int)MSize.X;
            boundingBox.Height = (int)MSize.Y;

            BoundingBox = boundingBox;
        }
Beispiel #9
0
        /// <summary>
        /// Constructs a GameObject
        /// </summary>
        /// <param name="content">The games content manager</param>
        /// <param name="name">Name of the Object("Images/{Type}/{Name}"</param>
        /// <param name="initialPosition">Starting position</param>
        /// <param name="friction">Friction that reacts to physics objects</param>
        /// <param name="isSquare">True if the object should behave like a square</param>
        /// <param name="isHazardous">True if the object should kill the player when touched</param>
        public GameObject(ContentManager content, float friction, EntityInfo entity)
        {
            MName = "Images\\" + entity.MTextureFile;
            MFriction = friction;
            MIsSquare = !entity.MProperties.ContainsKey("Shape") || entity.MProperties["Shape"] == "Square";
            MCollisionType = entity.MCollisionType;
            OriginalInfo = entity;

            Load(content, MName);

            Id = entity.MId;

            MPosition = GridSpace.GetDrawingCoord(entity.MLocation);
            _mInitialPosition = MPosition;
            MSize = new Vector2(Texture.Width, Texture.Height);

            BoundingBox = new Rectangle((int)MPosition.X, (int)MPosition.Y, (int)MSize.X, (int)MSize.Y);
        }
Beispiel #10
0
        /// <summary>
        /// Construcs a player object, that can live in a physical realm
        /// </summary>
        /// <param name="content">Content manager for the game</param>
        /// <param name="name">Name of the image resource for the player</param>
        /// <param name="initialPosition">Initial posisition in the level</param>
        /// <param name="controlScheme">Controller scheme for the player(Controller or keyboard)</param>
        public Player(ContentManager content, ref PhysicsEnvironment environment, IControlScheme controlScheme, float friction, EntityInfo entity)
            : base(content, ref environment,friction, entity)
        {
            _mControls = controlScheme;
            SpawnPoint = MPosition;
            _mRotation = 0.0f;
            _mGoalRotation = 0.0f;

            _mFaceGoalRotation = 0.0f;
            _mFaceRotation = 0.0f;

            Id = entity.MId;

            PlayerFaces.Load(content);

            MCurrentTexture = PlayerFaces.FromString("Smile");
            MSize = new Vector2(MCurrentTexture.Width, MCurrentTexture.Height);
            _mPreviousDirection = GravityDirections.Down;
        }
Beispiel #11
0
        /// <summary>
        /// Constructs a PhysicsObject; Loads the required info from the content pipeline, and defines its size and location
        /// </summary>
        /// <param name="content">Content pipeline</param>
        /// <param name="spriteBatch">The drawing canvas of the game. Used for collision detection with the level</param>
        /// <param name="name">Name of the physics object so that it can be loaded</param>
        /// <param name="scalingFactors">Factor for the image resource(i.e. half the size would be (.5,.5)</param>
        /// <param name="initialPosition">Position of where this object starts in the level</param>
        public PhysicsObject(ContentManager content, ref PhysicsEnvironment environment, float friction, EntityInfo entity)
            : base(content, friction, entity)
        {
            MEnvironment = environment;
            Velocity = new Vector2(0, 0);
            _mOriginalPosition = OriginalInfo.MLocation;
            IsRail = OriginalInfo.MProperties.ContainsKey(XmlKeys.Rail);

            if (IsRail)
                if (OriginalInfo.MProperties[XmlKeys.Rail] == XmlKeys.RailX)
                {
                    _mHiBound = GridSpace.GetDrawingCoord(_mOriginalPosition).X + (int.Parse(OriginalInfo.MProperties[XmlKeys.Length]) * 64);
                    _mLowBound = GridSpace.GetDrawingCoord(_mOriginalPosition).X;
                    _mAxis = GridSpace.GetDrawingCoord(_mOriginalPosition).Y;
                }
                else
                {
                    _mHiBound = GridSpace.GetDrawingCoord(_mOriginalPosition).Y + (int.Parse(OriginalInfo.MProperties[XmlKeys.Length]) * 64);
                    _mLowBound = GridSpace.GetDrawingCoord(_mOriginalPosition).Y;
                    _mAxis = GridSpace.GetDrawingCoord(_mOriginalPosition).X;
                }
            else
                _mHiBound = _mLowBound = _mAxis = 0;

            UpdateBoundingBoxes();
            MMass = 1;
        }
Beispiel #12
0
 /// <summary>
 /// Constructs a tile that reacts to gravity in the opposite direction
 /// </summary>
 /// <param name="content">The games content manager</param>
 /// <param name="name">Name of the Object("Images/{Type}/{Name}"</param>
 /// <param name="initialPosition">Starting position</param>
 /// <param name="friction">Friction that reacts to physics objects</param>
 /// <param name="isSquare">True if the object should behave like a square</param>
 /// <param name="isHazardous">True if the object should kill the player when touched</param>
 public ReverseTile(ContentManager content, ref PhysicsEnvironment environment, float friction, EntityInfo entity)
     : base(content, ref environment, friction, entity)
 {
     BeingAnimated = false;
     _mAnimationTexture = new AnimatedSprite();
 }
Beispiel #13
0
 public Tile(ContentManager content, float friction, EntityInfo entity)
     : base(content, friction, entity)
 {
 }
Beispiel #14
0
 /// <summary>
 /// Constructs a new static object
 /// </summary>
 /// <param name="content">The games content manager</param>
 /// <param name="name">Name of the Object("Images/{Type}/{Name}"</param>
 /// <param name="initialPosition">Starting position</param>
 /// <param name="friction">Friction that reacts to physics objects</param>
 /// <param name="isSquare">True if the object should behave like a square</param>
 /// <param name="isHazardous">True if the object should kill the player when touched</param>
 public StaticObject(ContentManager content, float friction, EntityInfo entity)
     : base(content, friction, entity)
 {
     Velocity = Vector2.Zero;
 }
Beispiel #15
0
 public static EntityInfo CreateWallInfo()
 {
     var info = new EntityInfo("", new Vector2());
     info.MProperties.Add("Shape", "Square");
     return info;
 }
Beispiel #16
0
 public PlayerFaceTrigger(ContentManager content, EntityInfo entity)
     : base(content, entity)
 {
     if (entity.MProperties.ContainsKey(XmlKeys.PlayerFace))
         _face = PlayerFaces.FromString(entity.MProperties[XmlKeys.PlayerFace]);
 }
Beispiel #17
0
 /// <summary>
 /// Constructs a trigger that will play a sound effect
 /// </summary>
 /// <param name="content">Content to load from</param>
 /// <param name="entity">Entity information</param>
 public FxTrigger(ContentManager content, EntityInfo entity)
     : base(content, entity)
 {
     if (entity.MProperties.ContainsKey(XmlKeys.SoundFile))
         _soundByte = content.Load<SoundEffect>("SoundEffects\\" + entity.MProperties[XmlKeys.SoundFile]);
 }