Exemplo 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()
        {
            graphics.PreferredBackBufferWidth  = WIDTH;
            graphics.PreferredBackBufferHeight = HEIGHT;
            graphics.ApplyChanges();

            spriteBatch = new SpriteBatch(GraphicsDevice);

            random = new Random();

            world = new EcsWorld(1000);

            world.RegisterComponentType <Sprite>();
            world.RegisterComponentType <Physics>();
            world.RegisterComponentType <Spring>();
            world.RegisterComponentType <Drift>();
            world.RegisterComponentType <Player>();
            world.RegisterComponentType <Kite>();
            world.RegisterComponentType <Rope>();
            world.RegisterComponentType <CatInterest>();
            world.RegisterComponentType <CatPounce>();
            world.RegisterComponentType <CatSlide>();
            world.RegisterComponentType <CatAbscond>();


            world.RegisterUpdateSystem(new PlayerSystem(world));
            world.RegisterUpdateSystem(new KiteSystem(world));
            world.RegisterUpdateSystem(new CatInterestSystem(world));
            world.RegisterUpdateSystem(new CatPounceSystem(world));
            world.RegisterUpdateSystem(new CatSlideSystem(world));
            world.RegisterUpdateSystem(new CatAbscondSystem(world));

            windSystem = new WindSystem(world);
            world.RegisterUpdateSystem(windSystem);

            world.RegisterUpdateSystem(new SpringSystem(world));
            world.RegisterUpdateSystem(new PhysicsSystem(world));
            world.RegisterUpdateSystem(new RopeSystem(world)); // should this just be a render system instead of giving the ropes sprites

            world.RegisterDrawSystem(new SpriteSystem(world, spriteBatch));

            var playerTexture   = Content.Load <Texture2D>("Debugging/player");
            var kiteTexture     = Content.Load <Texture2D>("Debugging/kite");
            var treeNodeTexture = Content.Load <Texture2D>("Debugging/tree");
            var ropeTexture     = Content.Load <Texture2D>("Debugging/rope");
            var catTexture      = Content.Load <Texture2D>("Debugging/cat");

            var playerEntity = CreatePlayer(playerTexture);
            var kiteEntity   = CreateKite(kiteTexture);
            var ropeEntities = CreateRope(ropeTexture, 32, 200f, world.GetComponent <Transform>(playerEntity).Position, world.GetComponent <Transform>(kiteEntity).Position);

            ConnectPlayerAndKiteWithRope(playerEntity, kiteEntity, ropeEntities);

            var cat1 = CreateCat(catTexture, 200f, 200f);
            var cat2 = CreateCat(catTexture, 300f, 300f);
            var cat3 = CreateCat(catTexture, 800f, 300f);
        }
Exemplo n.º 2
0
 private void Awake()
 {
     singleton = this;
     arrow     = GameObject.FindObjectOfType <WindArrow>();
 }