コード例 #1
0
            private bool EvaluateCondition()
            {
                switch (currentCondition)
                {
                case Conditions.NONE:
                    return(true);

                case Conditions.PGRA:
                    double currentPGravity = control.GetNaturalGravity().Length();
                    switch (currentOperator)
                    {
                    case Operators.EQUAL:
                        return(currentPGravity == value);

                    case Operators.LESS:
                        return(currentPGravity < value);

                    case Operators.MORE:
                        return(currentPGravity > value);
                    }
                    break;

                case Conditions.AGRA:
                    double currentAGravity = control.GetArtificialGravity().Length();
                    switch (currentOperator)
                    {
                    case Operators.EQUAL:
                        return(currentAGravity == value);

                    case Operators.LESS:
                        return(currentAGravity < value);

                    case Operators.MORE:
                        return(currentAGravity > value);
                    }
                    break;

                case Conditions.SPEED:
                    double currentSpeed = control.GetShipSpeed();
                    switch (currentOperator)
                    {
                    case Operators.EQUAL:
                        return(currentSpeed == value);

                    case Operators.LESS:
                        return(currentSpeed < value);

                    case Operators.MORE:
                        return(currentSpeed > value);
                    }
                    break;

                case Conditions.TIME:
                    if (time == -1)
                    {
                        time = DateTime.Now.Millisecond;
                    }
                    if (DateTime.Now.Millisecond - time > value * 1000)
                    {
                        time = -1;
                        return(true);
                    }
                    return(false);

                case Conditions.LOCATION:
                    BoundingSphereD boundaries = control.CubeGrid.WorldVolume;
                    return(boundaries.Contains(conditionGPS) != ContainmentType.Disjoint);
                }
                return(false);
            }