Ejemplo n.º 1
0
        /// <summary>
        /// Constructor call.  Creates a new Door object.
        /// </summary>
        /// <param name="content">The content manager to use when loading assets.</param>
        /// <param name="orient">The orientation of the room (either facing left or facing right).</param>
        /// <param name="roomName">The name of the room that the door leads to.</param>
        /// <param name="connectedDoorIndex">The index of the door that is linked to this one.</param>
        /// <param name="lockT">The type of lock that is on this door.</param>
        public Door(ContentManager content, AudioEngine audioEngine, DoorOrientations orient, string roomName, int connectedDoorIndex, Locks lockT)
            : base("Door", content)
        {
            Content = content;
            soundEngine = audioEngine;
            orientation = orient;
            linkedRoom = null;
            linkedRoomName = roomName;
            linkedDoorIndex = connectedDoorIndex;
            lockType = lockT;

            isOpen = false;
            isSolid = true;

            switch (lockType)
            {
                case Locks.Unlocked:
                    animation = Animations.Unlocked;
                    break;
                case Locks.Red:
                    animation = Animations.RedLock;
                    break;
                default:
                    animation = Animations.Unlocked;
                    break;
            }

            currentAnimation = (int)animation + (int)orientation;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor call
        /// </summary>
        public GameMenu()
        {
            Content = new ContentManager(GameResources.GameServices, "Content");
            soundEngine = new AudioEngine(Content, "Menu");

            newKeyState = Keyboard.GetState();
            newGamePadState = GamePad.GetState(PlayerIndex.One);
            oldKeyState = Keyboard.GetState();
            oldGamePadState = GamePad.GetState(PlayerIndex.One);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor call
 /// </summary>
 /// <param name="objType">The type of object that is represented.</param>
 /// <param name="content">The content manager to use.</param>
 /// <param name="spawnPosition">The default spawning position.</param>
 public GameObject(string objName, ContentManager content, Vector2 spawnPosition,
     bool graphics, AudioEngine audioEngine)
     : base(objName, content, graphics)
 {
     soundEngine = audioEngine;
     position = spawnPosition;
     isPhysicsObject = false;
     isDisintegrating = false;
     disintegrateTimer = 0;
     Initialize();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new Room object.
        /// </summary>
        /// <param name="roomName">The name of the room that is to be created.</param>
        /// <param name="content">The content manager to use for assets.</param>
        /// <param name="doorIndex">The index of the door to enter from.  If no index is specified, or the index is -1,
        /// the room's default spawn location will be used.</param>
        public Room(String name, int doorIndex)
        {
            roomName = name;
            Content = new ContentManager(GameResources.GameServices, "Content");
            soundEngine = new AudioEngine(Content, roomName);

            isLoaded = false;

            Load("Data/Rooms/" + roomName + ".txt", doorIndex);

            if (isPersistant)
                LoadRoomState();

            collisionMap = Content.Load<Texture2D>("Images/" + graphicsName + "Collisions");
            collisionColors = new Color[collisionMap.Width * collisionMap.Height];
            collisionMap.GetData<Color>(collisionColors);
            background = new GameObject(graphicsName, Content);
            background.Spawn(new Vector2(0, 0));
            if (hasLighting)
            {
                lightingMap = new GameObject(graphicsName + "LightingMap", Content);
                lightingMap.Spawn(new Vector2(0, 0));
            }
        }
Ejemplo n.º 5
0
        float WALL_JUMP_V_Y; //y-component of velocity when jumping off a wall. (Pixels/sec)

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new Player object
        /// </summary>
        public Player(ContentManager content, DelVoid saveMethod, DelRoom roomMethod, DelSB hudMethod)
            : base("Player", content)
        {
            isSpawned = false;
            JUMP_V = (float)(-Math.Sqrt(-2 * PhysicsEngine.GRAVITY * MAX_JUMP_HEIGHT));
            WALL_JUMP_V_X = (float)(JUMP_V * 0.7071);
            WALL_JUMP_V_Y = (float)(JUMP_V * 0.7071);

            itemArray = new bool[GameResources.NUM_ITEMS];
            for (int i = 0; i < itemArray.Length; i++)
                itemArray[i] = false;
            itemArray[0] = true;

            soundEngine = new AudioEngine(content, "Player");

            saveCallback = saveMethod;
            hudCallback = hudMethod;
            roomCallback = roomMethod;

            lifeCollisionXs = new short[collisionXs.Length];
            lifeCollisionYs = new short[collisionYs.Length];

            deathCollisionXs = new short[collisionYs.Length];
            deathCollisionYs = new short[collisionXs.Length];

            Array.Copy(collisionXs, lifeCollisionXs, collisionXs.Length);
            Array.Copy(collisionYs, lifeCollisionYs, collisionYs.Length);
            Array.Copy(collisionXs, deathCollisionYs, collisionXs.Length);
            Array.Copy(collisionYs, deathCollisionXs, collisionYs.Length);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Another constructor that also specifies position, whether the object is an enemy,
 /// whether it has graphics that will be drawn, and the source of its sounds, if it produces any.
 /// </summary>
 /// <param name="objName">The type of object that is represented.</param>
 /// <param name="content">The content manager to load assets to.</param>
 /// <param name="spawnPosition">The coordinates in the room at which the object will start.</param>
 /// <param name="graphics">Whether the object has graphics that will be drawn to the screen.</param>
 /// <param name="audioEngine">The AudioEngine object that produces this object's sounds.</param>
 /// <param name="enemy">Whether the object is an enemy.</param>
 public PhysicsObject(string objName, ContentManager content, Vector2 spawnPosition, bool graphics, AudioEngine audioEngine, bool enemy)
     : base(objName, content, spawnPosition, graphics, audioEngine)
 {
     CheckObjectType();
     if (isPhysicsObject)
     {
         velocityX = 0;
         velocityY = 0;
         accelerationX = 0;
         accelerationY = 0;
         velocityLimitX = 0;
         velocityLimitY = 0;
         displacementX = 0;
         displacementY = 0;
         isOnGround = false;
         currentHealth = maxHealth;
         riding = null;
         LoadObjectData();
     }
 }