Esempio n. 1
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);
            serviceManager = new ServiceManager();

            // TODO: use this.Content to load your game content

            GameObject obj  = new GameObject();
            GameObject obj2 = new GameObject();

            obj.AddComponent <SpriteRenderer>();
            obj.GetComponent <SpriteRenderer>().sprite.Image = Content.Load <Texture2D>("Test_CobbleStoneTile");
            obj.GetComponent <SpriteRenderer>().sprite.Scale = new Vector2(3.0f, 3.0f); //scales the sprite
            obj.transform.Scale(new Vector2(3.0f, 3.0f));                               //scales the Object
            obj2.transform.Scale(new Vector2(5.0f, 5.0f));
            obj.transform.Rotate(45.0f, AngleType.DEGREES);
            obj.AddComponent <InputController>();
            obj.AddComponent <Camera>();

            obj2.AddComponent <SpriteRenderer>();
            obj2.GetComponent <SpriteRenderer>().sprite.Image = Content.Load <Texture2D>("Test_CobbleStoneTile");

            obj.Load();
            obj2.Load();

            //obj.SetChild(obj2);

            //Button Testing
            //Texture2D[] buttonSprites = { Content.Load<Texture2D>("Test_Button_Unpressed"), Content.Load<Texture2D>("Test_Button_Pressed") };
            //ButtonClicked btn = new ButtonClicked(Action);
            //Button button = new Button(buttonSprites, new Vector2(0, 0));
            //button.GetComponent<ButtonController>().buttonClicked += Action;
            //uiObjects.Add(button);
            ////////////////
            ///


            //*****DEBUG: Collision Testing*****

            floor   = new GameObject();
            object1 = new GameObject();

            Vector2[] floorVertices  = new Vector2[3];
            Vector2[] objectVertices = new Vector2[4];

            floorVertices[0] = new Vector2(0, 0);
            floorVertices[1] = new Vector2(15, 0);
            floorVertices[2] = new Vector2(15, 15);
            //floorVertices[3] = new Vector2(0, 15);

            objectVertices[0] = new Vector2(0, 0);
            objectVertices[1] = new Vector2(4, 0);
            objectVertices[2] = new Vector2(4, 4);
            objectVertices[3] = new Vector2(0, 4);

            object1.Components.Add(new Hitbox(objectVertices, object1));
            object1.Components.Add(new CollisionComponent(object1));
            //object1.AddComponent<SpriteRenderer>();
            object1.transform.SetPosition(new Vector2(0.0f, 0.0f));

            floor.Components.Add(new Hitbox(floorVertices, floor));
            floor.Components.Add(new CollisionComponent(floor, true));
            floor.AddComponent <SpriteRenderer>();
            floor.transform.SetPosition(new Vector2(2.0f, 2.0f));

            object1.Load();
            floor.Load();

            //******************End collision testing*****************

            serviceManager.GetService <CameraManager>().SetMainCamera(obj.GetComponent <Camera>());
        }