Пример #1
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);
 }
Пример #2
0
 public static EntityInfo CreatePlayerEndInfo(Vector2 startLocation)
 {
     EntityInfo playerEnd = new EntityInfo("PlayerEnd", startLocation);
     playerEnd.mProperties.Add("Shape", "Circle");
     playerEnd.mId = -2;
     return playerEnd;
 }
Пример #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]);
 }
Пример #4
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.POPUP_TYPE))
            {
                if (isImage = entity.mProperties[XmlKeys.POPUP_TYPE] == XmlKeys.POPUP_IMAGE)
                    this.Load(content, IMAGE_DIRECTORY + entity.mProperties[XmlKeys.IMAGE_FILE]);
                else
                    mText = entity.mProperties[XmlKeys.TEXT];
            }

            mFont = content.Load<SpriteFont>("Fonts/QuartzSmall");
        }
Пример #5
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;
            mOriginalInfo = entity;

            Load(content, mName);

            ID = entity.mId;

            mPosition = GridSpace.GetDrawingCoord(entity.mLocation);
            mInitialPosition = mPosition;
            mSize = new Vector2(mTexture.Width, mTexture.Height);

            mBoundingBox = new Rectangle((int)mPosition.X, (int)mPosition.Y, (int)mSize.X, (int)mSize.Y);
        }
Пример #6
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;
            mSpawnPoint = 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;
        }
Пример #7
0
 public Tile(ContentManager content, float friction, EntityInfo entity)
     : base(content, friction, entity)
 {
 }
Пример #8
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;
            mVelocity = new Vector2(0, 0);
            mOriginalPosition = mOriginalInfo.mLocation;
            mIsRail = mOriginalInfo.mProperties.ContainsKey(XmlKeys.RAIL);

            if (mIsRail)
                if (mOriginalInfo.mProperties[XmlKeys.RAIL] == XmlKeys.RAIL_X)
                {
                    mHiBound = GridSpace.GetDrawingCoord(mOriginalPosition).X + (int.Parse(mOriginalInfo.mProperties[XmlKeys.LENGTH]) * 64);
                    mLowBound = GridSpace.GetDrawingCoord(mOriginalPosition).X;
                    mAxis = GridSpace.GetDrawingCoord(mOriginalPosition).Y;
                }
                else
                {
                    mHiBound = GridSpace.GetDrawingCoord(mOriginalPosition).Y + (int.Parse(mOriginalInfo.mProperties[XmlKeys.LENGTH]) * 64);
                    mLowBound = GridSpace.GetDrawingCoord(mOriginalPosition).Y;
                    mAxis = GridSpace.GetDrawingCoord(mOriginalPosition).X;
                }
            else
                mHiBound = mLowBound = mAxis = 0;

            UpdateBoundingBoxes();
            mMass = 1;
        }
Пример #9
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)
 {
     mBeingAnimated = false;
     mAnimationTexture = new AnimatedSprite();
 }
Пример #10
0
 public PlayerFaceTrigger(ContentManager content, EntityInfo entity)
     : base(content, entity)
 {
     if (entity.mProperties.ContainsKey(XmlKeys.PLAYER_FACE))
         face = PlayerFaces.FromString(entity.mProperties[XmlKeys.PLAYER_FACE]);
 }
Пример #11
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.SOUND_FILE))
         soundByte = content.Load<SoundEffect>("SoundEffects\\" + entity.mProperties[XmlKeys.SOUND_FILE]);
 }
Пример #12
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)
 {
     this.mVelocity = Vector2.Zero;
 }
Пример #13
0
 public static EntityInfo CreateWallInfo()
 {
     EntityInfo info = new EntityInfo("", new Vector2());
     info.mProperties.Add("Shape", "Square");
     return info;
 }
Пример #14
0
 public static EntityInfo CreatePlayerInfo(Vector2 startLocation)
 {
     EntityInfo player = new EntityInfo("Player", startLocation);
     player.mProperties.Add("Shape", "Circle");
     player.mProperties.Add("Mass", "1");
     player.mId = -1;
     return player;
 }