Ejemplo n.º 1
0
        public void Add(Entity entity)
        {
            if (entities.Contains(entity))
            {
                return;
            }

            entities.Add(entity);

            if (entity is WallModelEntity)
            {
                WallModelEntity wallentity = entity as WallModelEntity;

                wallentity.BuildWall(plane);
                physics.Add(wallentity.body);
            }

            if (entity is Bubble)
            {
                Bubble bubble = entity as Bubble;
                physics.Add(bubble.body);
            }

            if (entity is Enemy)
            {
                Enemy enemy = entity as Enemy;
                physics.Add(enemy.body);
            }

            if (entity is Character)
            {
                player = entity as Character;
            }
        }
        private void GetPhysicsFromConfig()
        {
            Physics.Clear();

            foreach (var phys in Config.Physics)
            {
                Physics.Add(new CharacterAdventurePhysicsPair(phys.Key, phys.Value));
            }

            CurrentPhysics = Physics.First();
        }
        public PlayerController(PlayerEntity playerEntity, float cameraHight)
        {
            _playerEntity = playerEntity;

            _PlayerCamera = new Camera(_playerEntity.transform);
            _PlayerCamera._cameraTrnasform.Position = new Vector3(0, cameraHight, 0);//Set the position of the camera

            _CharacterController = new CharacterController();

            _CharacterController.Body.Position = new BEPUutilities.Vector3(playerEntity.transform.Position.X, playerEntity.transform.Position.Y, playerEntity.transform.Position.Z);
            //_CharacterController.Body.BecomeKinematic();
            Physics.Add(_CharacterController);
        }
Ejemplo n.º 4
0
 protected void AddElementsToPhysicsWorld(List <Element> elements)
 {
     elements.ForEach(element => Physics.Add(element.PhysicsBody));
 }
Ejemplo n.º 5
0
        internal override bool ParseNodeBodyElement(string id, VRMLParser parser)
        {
            int line = parser.Line;

            if (id == "appearance")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    Appearance = node as X3DAppearanceNode;
                    if (Appearance == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "createParticles")
            {
                CreateParticles = parser.ParseBoolValue();
            }
            else if (id == "geometry")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    Geometry = node as X3DGeometryNode;
                    if (Geometry == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "enabled")
            {
                Enabled = parser.ParseBoolValue();
            }
            else if (id == "lifetimeVariation")
            {
                LifetimeVariation = parser.ParseDoubleValue();
            }
            else if (id == "maxParticles")
            {
                MaxParticles = parser.ParseIntValue();
            }
            else if (id == "particleLifetime")
            {
                ParticleLifetime = parser.ParseDoubleValue();
            }
            else if (id == "particleSize")
            {
                ParticleSize = parser.ParseSFVec2fValue();
            }
            else if (id == "bboxCenter")
            {
                BBoxCenter = parser.ParseSFVec3fValue();
            }
            else if (id == "bboxSize")
            {
                BBoxSize = parser.ParseSFVec3fValue();
            }
            else if (id == "colorRamp")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    ColorRamp = node as X3DColorNode;
                    if (ColorRamp == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "colorKey")
            {
                ColorKey.AddRange(parser.ParseSFFloatOrMFFloatValue());
            }
            else if (id == "emitter")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    Emitter = node as X3DParticleEmitterNode;
                    if (Emitter == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "geometryType")
            {
                GeometryType = parser.ParseStringValue();
            }
            else if (id == "physics")
            {
                List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue();
                foreach (X3DNode node in nodes)
                {
                    X3DParticlePhysicsModelNode ppmn = node as X3DParticlePhysicsModelNode;
                    if (ppmn == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                    else
                    {
                        Physics.Add(ppmn);
                    }
                }
            }
            else if (id == "texCoordRamp")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    TexCoordRamp = node as X3DTextureCoordinateNode;
                    if (TexCoordRamp == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "texCoordKey")
            {
                TexCoordKey.AddRange(parser.ParseSFFloatOrMFFloatValue());
            }
            else
            {
                return(false);
            }
            return(true);
        }