Пример #1
0
        public Roaches (GameState state, AIManager aiManager, RendererContext rendererContext)
        {
            RoachGameState = state;

            roachGroup = new RoachGroup (state.Scene);

            RoachEntity = EntityFactory.Instance.CreateWith("Roach." + InstanceCount++, state.MessageProxy,
                new[] { typeof (ArtificialIntelligenceComponent) },
                new[] { typeof (PhysicsSystem), typeof (RoachGroupSystem) });

            RoachEntity.GetComponent<RoachGroupComponent>().RoachGroup = roachGroup;

            RigidBody roachBody = new RigidBody (new CylinderShape (0.05f, 1));
            roachBody.AffectedByGravity = false;
            roachBody.AllowDeactivation = false;
            roachBody.Mass = 20;
            roachBody.Tag = roachGroup;
            RoachEntity.GetComponent<PhysicsComponent> ().RigidBody = roachBody;
            RoachEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
            RoachEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;

            state.PhysicsManager.World.AddBody (roachBody);

            RoachEntity.GetComponent<ArtificialIntelligenceComponent>().AIManager = aiManager;
            RoachEntity.GetComponent<ArtificialIntelligenceComponent>().ArtificialIntelligence =
                new RoachesAI (roachGroup, RoachEntity, state);
            aiManager.RegisterEntity (RoachEntity);
        }
Пример #2
0
        public RoachesAI (RoachGroup roachGroup, Entity entity, GameState state)
        {
            this.roachGroup = roachGroup;
            this.entity = entity;
            this.state = state;
            AIcomp = entity.GetComponent<ArtificialIntelligenceComponent>();

            Provider = state.MessageProxy;
            Provider += this;
        }