Пример #1
0
        public GameInput(MirrorEngine theEngine)
            : base(theEngine)
        {
            game = theEngine as Graven;

            playBindings = new InputBinding[Enum.GetValues(typeof(PlayBindings)).Length];
        }
Пример #2
0
        private Texture2D lastTex;                 //The last texture to be rendered

        /**
         * Constructor. Initializes openGL and creates a new window.
         *
         * @param engine the engine
         * @param width standard width of the window
         * @param height standard height of the window
         * @param fullscreen whether to start in fullscreen
         */
        public GraphicsComponent(MirrorEngine engine, int windowWidth = DEFAULTWIDTH, int windowHeight = DEFAULTHEIGHT, bool fullscreen = false)
            : base(engine)
        {
            this.windowWidth  = windowWidth;
            this.windowHeight = windowHeight;
            this.fullscreen   = fullscreen;
        }
Пример #3
0
        internal bool firstUpdate;                 //Whether or not the world has been updated previously

        /**
         * Constructor.
         *
         * @param engine the engine
         * @param file the Mapfile to load the world from
         */
        public World(MirrorEngine engine, Mapfile file) : base(engine)
        {
            this.file = file;

            if (engine.resourceComponent == null)
            {
                throw new Exception("World: ResourceComponent not initialized");
            }
        }
Пример #4
0
 public InputComponent(MirrorEngine theEngine) : base(theEngine)
 {
     previousKeyboardState = new KeyboardState();
     currentKeyboardState  = new KeyboardState();
     previousGamePadState  = new GamePadState();
     currentGamePadState   = new GamePadState();
     previousMouseState    = new MouseState();
     currentMouseState     = new MouseState();
 }
 public EditorWorld(MirrorEngine theEngine, String theMap) : base(theEngine, theMap)
 {
     tileTextureSet           = tileEngine.resourceComponent.getTextureSet("Tiles");
     currentTile              = new MapFile.TileData();
     currentTile.tileSetIndex = 0;
     currentTile.tileIndex    = 0;
     currentActor             = 0;
     editor = theEngine as Editor;
 }
        public Tile prevTile;                   //The previous Tile under the mouse

        /*
         * Constructor. Instantiates the current brushes.
         */
        public EditorComponent(MirrorEngine engine)
            : base(engine)
        {
            lastPos = new Vector2(0, 0);

            currentValues = new Mapfile.TileData("");
            currentTile.setToIgnore();
            currentTile.texture = currentValues.texture;

            isActive = false;
        }
Пример #7
0
        //Prepare the world object so that it can work with other components to prepare for initialization.
        //World is passed the Engine object and the filename of a saved map.
        public World(MirrorEngine theEngine, string fileName) : base(theEngine)
        {
            //Load the map from the filename passed to it.
            worldName = Path.GetFileNameWithoutExtension(fileName);
            FileStream fileStream = new FileStream(fileName, FileMode.Open);

            this.file = new MapFile(fileStream);

            //Make sure there are resources. If the world has no resources, something has gone wrong and it should exit.
            ResourceComponent res = theEngine.resourceComponent;

            if (res == null)
            {
                throw new Exception("World: Error retrieving TileSet: ResourceComponent not initialized");
            }
        }
Пример #8
0
        public GraphicsComponent(MirrorEngine theEngine, Vector2 windowedSize, bool fullscreen) : base(theEngine)
        {
            graphics          = new GraphicsDeviceManager(theEngine);
            this.windowedSize = windowedSize;
            this.fullscreen   = fullscreen;
            GameTime a;

            graphics.PreferredBackBufferWidth  = (int)windowedSize.X;
            graphics.PreferredBackBufferHeight = (int)windowedSize.Y;

            if (fullscreen)
            {
                graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                graphics.ToggleFullScreen();
            }
        }
        /**
         * Constructor initializes SDL Audio
         * allocates DEFAULTNUMCHANNELS channels
         * and sets the SDL ChannelFinished delegate
         *
         * @param theEngine The Engine.
         */
        public AudioComponent(MirrorEngine engine)
            : base(engine)
        {
            if (Sdl.SDL_InitSubSystem(Sdl.SDL_INIT_AUDIO) != 0)
            {
                throw new Exception("Could not init SDL Audio: " + Sdl.SDL_GetError());
            }

            if (SdlMixer.Mix_OpenAudio(44100, (short)Sdl.AUDIO_S16SYS, 2, 2048) == -1)
            {
                throw new Exception("Could not init SDL_Mixer: " + SdlMixer.Mix_GetError());
            }

            //Channel Setup
            openChannels = new LinkedList <int>();
            addChannels(DEFAULTNUMCHANNELS);
            cfinished = freeChannel;
            SdlMixer.Mix_ChannelFinished(cfinished);
        }
        }                                           //The active joysticks

        /**
         * desc here
         *
         * @param paramsdeschere
         *
         * @return returndeschere
         */
        public InputComponent(MirrorEngine theEngine)
            : base(theEngine)
        {
            // Set up joysticks
            Sdl.SDL_InitSubSystem(Sdl.SDL_INIT_JOYSTICK);

            // Open all joysticks
            joys = new JoyInfo[Sdl.SDL_NumJoysticks()];
            for (int i = 0; i < joys.Length; i++)
            {
                joys[i] = new JoyInfo(Sdl.SDL_JoystickOpen(i));
            }

            // Enable joystick events
            Sdl.SDL_JoystickEventState(Sdl.SDL_ENABLE);

            bindings        = new Dictionary <Tuple <Type, object>, InputBinding[]>();
            currentContexts = new Dictionary <Type, object>();
        }
Пример #11
0
        public ResourceComponent(ContentManager contentManager, MirrorEngine theEngine) : base(theEngine)
        {
            //Dynamic Loading
            this.contentManager          = contentManager;
            contentManager.RootDirectory = "Content";

            //Load TextureSets
            textureSets = new Dictionary <string, TextureSet>();
            discoverGUI();
            discoverTiles();
            discoverSprites();

            //Load AudioSets
            audioSets = new Dictionary <string, AudioSet>();
            discoverAudio();

            //Load Worlds
            worldNames = new Dictionary <string, uint>();
            discoverWorlds();
        }
        internal Dictionary <string, World> worlds;     //Dictionary of world-keys to Worlds

        /**
         * Constructor. Sets the rootDirectory based on the current build.
         * Initializes the cache, the scripting engine, freetype, and the world dictionary.
         *
         * @param engine the engine
         */
        public ResourceComponent(MirrorEngine engine)
            : base(engine)
        {
            // Set root directory
            rootDirectory = DEFAULTROOTDIRECTORY;
#if ENGINEDEVELOP
            rootDirectory = DEVELOPROOTPREFIX + rootDirectory;
#endif

            //Initialize cache
            cache       = new Handle[SIZE_OF_CACHE];
            cacheLookup = new Dictionary <string, int>();
            for (int i = 0; i < SIZE_OF_CACHE; i++)
            {
                freeList.AddLast(i);
            }

            // Initialize Scripting Engine
            Dictionary <string, object> opts = new Dictionary <string, object>();
            opts["Debug"] = true;
            ScriptEngine eng = Python.CreateEngine(opts);
            scriptRuntime = eng.Runtime;
            // Inject executing C# assembly
            scriptRuntime.LoadAssembly(Assembly.GetExecutingAssembly());
            // Inject game C# assembly
            scriptRuntime.LoadAssembly(Assembly.GetEntryAssembly());

            //Initialize script scopes dictionary
            scriptScopes = new Dictionary <ScriptScope, string>();

            //Initialize Freetype
            if (SdlTtf.TTF_Init() == -1)
            {
                throw new Exception("Could not initialize SDL_ttf");
            }

            //Intialize world Dictionary
            worlds = new Dictionary <string, World>();
        }
        protected const float UNKNOWNVALUE = -1f;   //Represents an unknown value to solve for

        public PhysicsComponent(MirrorEngine theEngine) : base(theEngine)
        {
        }
Пример #14
0
 public GameWorld(MirrorEngine theEngine, String theMap) : base(theEngine, theMap)
 {
     tileTextureSet = tileEngine.resourceComponent.getTextureSet("Tiles");
     game           = theEngine as Graven;
     actorFactory   = new GameActorFactory(this);
 }
 public Component(MirrorEngine theEngine)
 {
     this.tileEngine = theEngine;
 }
 public GameGraphics(MirrorEngine theEngine)
     : base(theEngine, screenSize, FULLSCREEN)
 {
     guiComponent = new GameGUIComponent(this);
 }
 public GameResources(ContentManager cm, MirrorEngine theEngine)
     : base(cm, theEngine)
 {
 }
Пример #18
0
 public EditorGraphics(MirrorEngine theEngine) : base(theEngine, screenSize, FULLSCREEN)
 {
     AMBIENT      = 0f;
     guiComponent = new EditorGUI(this);
 }
 public EditorAudio(MirrorEngine theEngine)
     : base(theEngine)
 {
 }
 public GameAudio(MirrorEngine theEngine) : base(theEngine)
 {
     
 }
Пример #21
0
 public AudioComponent(MirrorEngine theEngine) : base(theEngine)
 {
     resourceComponent = theEngine.resourceComponent;
     audioSets         = resourceComponent.audioSets;
 }
Пример #22
0
        public EditorInput(Editor editor) : base(editor as MirrorEngine)
        {
            theEngine = editor as Editor;

            editBindings = new InputBinding[Enum.GetValues(typeof(EditBindings)).Length];
        }
Пример #23
0
        //public int dieSound;

        public EditorResources(ContentManager cm, MirrorEngine theEngine)
            : base(cm, theEngine)
        {
            string path;

            path = Path.Combine("Test", "GUI");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Tiles");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "005_Arrow");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "001_Blob");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "000_Lucy");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "006_HealthOrb");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "007_ManaOrb");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "012_Octo");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "014_Spikon");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "015_Sentinel");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "003_FireShuriken");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "008_IceSpike");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "011_Numbers");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "004_FirstBoss");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "010_LevelUp");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "009_Laser");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "016_Zazzle");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "002_BlueBlob");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "013_RedBlob");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "017_DemonQuestionMark");
            textureSets.Add(path, new TextureSet(this, path));

            path = Path.Combine("Test", "Sprites", "018_EmptyActor");
            textureSets.Add(path, new TextureSet(this, path));
        }