/// <summary>
        /// The function generates models from the controller data
        /// </summary>
        /// <param name="g"></param>
        /// <param name="map"></param>
        /// <param name="style"></param>
        public void generate(GController g,Skinner map,Style style)
        {
            IEnumerator<GObject> iter = g.getEnumerator();

            while (iter.MoveNext())
            {
                models.Add(new SWFrameModel(iter.Current, map, style));
            }
        }
        public Texture2D getTexture(Style style,GObject g)
        {
            String alias;

            GButton ob = new GButton();

            //Check for buttons
            if (g.GetType().Equals(ob.GetType()))
            {
                //Determine whether the button is down
                ob = (GButton)g;

                if (ob.IsClicked== true)
                {
                    alias = style.getSkin("BUTTON_DOWN");
                    return (Assets.getInstance().get(alias).Texture);
                }

                alias = style.getSkin("BUTTON_UP");
                return (Assets.getInstance().get(alias).Texture);
            }

            //Check for Frames
            GFrame test = new GFrame();
            if(g.GetType().Equals(test.GetType()))
            {
                test = (GFrame)g;

                alias = test.Background;
                return(Assets.getInstance().get(alias).Texture);
            }

            GImageFrame image = new GImageFrame();
            //Check for image frames
            if(g.GetType().Equals(image.GetType()))
            {
                image=(GImageFrame) g;

                return(Assets.getInstance().get(image.Image).Texture);
            }

            return (null);
        }
        public SWFrameModel(GObject ov, Skinner map, Style style)
        {
            obj = ov;
            box = new Rectangle((int)obj.X, (int)obj.Y, obj.Width, obj.Height);
            models = new List<SWFrameModel>();
            texture = map.getTexture(style, ov);

            //Add Gobjects inside if owns other elements
            if (ov.isOwner() == true)
            {
                List<GObject> p = new List<GObject>();
                p = obj.getAllObjectsOwned(p);

                //Create models for all

                foreach (GObject g in p)
                {
                    models.Add(new SWFrameModel(g, map, style));
                }
            }
        }
Example #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Register the scripting
            PythonObject.getInstance().register();

            //Load the world
            WorldsKeeper.getInstance().init("worlds/world_info.xml");

            //Load the skins
            AssetsKeeper skinnerAssets = new AssetsKeeper();
            skinnerAssets.init("style/assets.xml");
            skinner = new Skinner();
            Style style=new Style();
            style.init("style/style.xml");

            //Connect the style

            //Connect python

            PythonObject.getInstance().getScope().SetVariable("WORLDSKEEPER", WorldsKeeper.getInstance());
            PythonObject.getInstance().getScope().SetVariable("LOG", Log.getInstance());
            PythonObject.getInstance().getScope().SetVariable("WINDOWCONTROL", gController);
            PythonObject.getInstance().getScope().SetVariable("WINDOWSKINNER", skinner);
            PythonObject.getInstance().getScope().SetVariable("MINDER", swMinder);
            PythonObject.getInstance().getScope().SetVariable("WINDOWSTYLE", style);
            PythonObject.getInstance().getScope().SetVariable("PLAYERS", playerCollection);

            PythonObject.getInstance().getScope().SetVariable("ANIMATIONSSPACE", AnimationAssets.getInstance());

            //Load the SimpleGameLib
            string path = Assembly.GetExecutingAssembly().Location;
            string dir = Directory.GetParent(path).FullName;
            string libPath = Path.Combine(dir, "SimpleGameLib.dll");

            Assembly assembly = Assembly.LoadFile(libPath);

            PythonObject.getInstance().getRuntime().LoadAssembly(assembly);

            //Load the SimpleWindowLib
            path = Assembly.GetExecutingAssembly().Location;
            dir = Directory.GetParent(path).FullName;
            libPath = Path.Combine(dir, "SimpleWindow.dll");

            assembly = Assembly.LoadFile(libPath);

            PythonObject.getInstance().getRuntime().LoadAssembly(assembly);

            //The animations

            //Add all animations here
            AnimationAssets.getInstance().addAsset(new AnimationWrapper("idle_animation", new List<string> {"dungeon","lava" }));

            //Player a = new Player("player two", "idle_animation", 50, 200);

            //playerCollection.add(a);

            //Load the start up script

            PythonObject.getInstance().executeString(ScriptKeeper.getInstance().getScript("start_up"));
        }