Esempio n. 1
0
        public EntityFormation(List<Entity> entities, DisFieldMixer disFieldMixer, int2 goalPos)
        {
            this.entities = entities;
            this.disFieldMixer = disFieldMixer;
            this.goalPos = goalPos;

            int formationIndex = 0;

            entities.Sort(delegate(Entity a, Entity b)
            {
                // sort by formationIndex
                return a.GetComponent<component.Formation>().FormationIndex.CompareTo(b.GetComponent<component.Formation>().FormationIndex);
            });

            foreach(Entity e in entities)
            {
                if (!e.HasComponent<component.Physics>())
                    continue;

                e.GetComponent<component.Physics>().Body.OnCollision += this.onEntityCollision;

                e.GetComponent<component.Formation>().FormationIndex = formationIndex;
                formationIndex++;
            }
        }
Esempio n. 2
0
 public UnitController(InputManager inputManager, InputState inputState, EntityWorld entityWorld, DisFieldMixer disFieldMixer, Lord lord)
 {
     this.inputManager = inputManager;
     this.inputState = inputState;
     this.entityWorld = entityWorld;
     this.disFieldMixer = disFieldMixer;
     this.lord = lord;
     pathGoal = null;
 }
Esempio n. 3
0
        protected override void Initialize()
        {
            _inputState = new InputState();
            tileManager = new TileManager();
            tileMap = new TileMap(tileManager, new int2(Global.mapWidth, Global.mapHeight));
            entityWorld = new EntityWorld();
            entityTileMap = new EntityTileMap(entityWorld, new int2(Global.mapWidth, Global.mapHeight));
            disFieldMixer = new DisFieldMixer();
            textureManager = new TextureManager();
            animationManager = new AnimationManager();
            world = new FarseerPhysics.Dynamics.World(new Vector2(0f, 0f));
            generator = new Generator(tileMap);
            lord = new Lord("Obama", Color.Red, 0);
            enemyLord = new Lord("Justin Bieber", Color.Brown, 1);
            unitController = new UnitController(null, _inputState, entityWorld, disFieldMixer, lord);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            graphics.PreferredBackBufferWidth = Global.ViewportWidth;
            graphics.PreferredBackBufferHeight = Global.ViewportHeight;
            graphics.ApplyChanges();

            EntitySystem.BlackBoard.SetEntry<SpriteBatch>("SpriteBatch", spriteBatch);
            EntitySystem.BlackBoard.SetEntry<TextureManager>("TextureManager", textureManager);
            EntitySystem.BlackBoard.SetEntry<TileMap>("TileMap", tileMap);
            EntitySystem.BlackBoard.SetEntry<EntityTileMap>("EntityTileMap", entityTileMap);
            EntitySystem.BlackBoard.SetEntry<DisFieldMixer>("DisFieldMixer", disFieldMixer);
            EntitySystem.BlackBoard.SetEntry<FarseerPhysics.Dynamics.World>("PhysicsWorld", world);
            EntitySystem.BlackBoard.SetEntry<Generator>("Generator", generator);
            EntitySystem.BlackBoard.SetEntry<AnimationManager>("AnimationManager", animationManager);

            this.entityWorld.InitializeAll(true);

            base.Initialize();
        }