예제 #1
0
        // Check collisions between physic models, and apply gravity to them
        protected override void Update(PhysicWorldModel world)
        {
            PhysicPointModel      pointModel;
            PhysicPointController pointController;

            // Get all planes to check collisions
            List <PhysicPlaneModel> allPlanes = GetAllPlanes(world);

            foreach (uint pointModelId in world.pointModels)
            {
                pointModel = StateManager.state.GetModel(pointModelId) as PhysicPointModel;
                if (pointModel == null)
                {
                    // someone removed it in some other way!!
                    RetroBread.Debug.LogWarning("Point model removed outside world");
                    continue;
                }
                pointController = pointModel.Controller() as PhysicPointController;
                if (pointController == null)
                {
                    // not controlled, can't react to anything
                    continue;
                }

                // apply gravity
                if (pointModel.isActive || PhysicPointController.IsGrounded(pointModel))
                {
                    ApplyGravityToPoint(world, pointModel, pointController);
                }
                CheckCollisionsAgainstPlanes(world, pointModel, pointController, allPlanes);
            }
        }
예제 #2
0
        // ----------------------
        // Ground and Wall checks

        public static bool IsGrounded(GameEntityModel model)
        {
            PhysicPointModel pointModel = GameEntityController.GetPointModel(model);

            if (pointModel == null)
            {
                return(false);
            }
            return(PhysicPointController.IsGrounded(pointModel));
        }
        // Grounded
        private static EventCondition <GameEntityModel> .EvaluationDelegate BuildGrounded(Storage.GenericParameter parameter, out int keyFrame, Storage.CharacterAnimation animation)
        {
            keyFrame = InvalidKeyframe;
            // Read negation
            bool positiveCheck = !parameter.SafeBool(0);

            // Return delegate
            return(delegate(GameEntityModel mainModel, List <GameEntityModel>[] subjectModels){
                PhysicPointModel pointModel;
                pointModel = StateManager.state.GetModel(mainModel.physicsModelId) as PhysicPointModel;
                if (pointModel == null)
                {
                    return false;
                }
                return PhysicPointController.IsGrounded(pointModel) == positiveCheck;
            });
        }