コード例 #1
0
    private void SetMotionConfigsAndGetCauseOfDestroy(GameObject createdPlatform, out PlatformCauseOfDestroy.CauseOfDestroy platformCausesOfDestroy)
    {
        // CauseOfDestroy в некоторых случаях может задаваться не при общей настройке правил генерации, а при определении правил движения вертикальной платформы.


        var movingTypeConfigs = PlatformGeneratorConfigs.PlatformConfigs.MovingTypeConfigs;

        platformCausesOfDestroy = PlatformGeneratorConfigs.PlatformConfigs.CauseOfDestroy;

        if (createdPlatform.TryGetComponent(out VerticalMotion verticalMotion))
        {
            VerticalMotionConfig verticalMotionConfig =
                (VerticalMotionConfig)movingTypeConfigs.ToList().Find(x => x is VerticalMotionConfig);

            VerticalMotionConfig.MotionConfigs config = verticalMotionConfig.Value != VerticalMotionConfig.MotionConfigs.Random
                ? verticalMotionConfig.Value
                : verticalMotionConfig.GetConcreteRandomEnumValue();

            if (platformCausesOfDestroy == PlatformCauseOfDestroy.CauseOfDestroy.LateInitialization)
            {
                platformCausesOfDestroy = new PlatformConfigsData().GetPlatformCauseOfDestroyByVerticalMotionConfig(config);

                if (platformCausesOfDestroy == PlatformCauseOfDestroy.CauseOfDestroy.LateInitialization)
                {
                    Debug.LogError("VerticalMotionConfigs shouldn't be Random!");
                }
            }

            verticalMotion.SetMotionConfigs(config);
        }

        if (createdPlatform.TryGetComponent(out CircularMotion circularMotion))
        {
            CircularMotionConfig circularMotionConfig =
                (CircularMotionConfig)movingTypeConfigs.ToList().Find(x => x is CircularMotionConfig);

            CircularMotionConfig.MotionConfigs config = circularMotionConfig.Value != CircularMotionConfig.MotionConfigs.Random
                ? circularMotionConfig.Value
                : circularMotionConfig.GetConcreteRandomEnumValue();

            circularMotion.SetMotionConfigs(config);
        }
    }
コード例 #2
0
    public void SetCauseOfDestroy(PlatformCauseOfDestroy.CauseOfDestroy platformCauseOfDestroy)
    {
        Predicate <float> IsAlive = causeOfDestroyDeterminator.GetCauseOfDestroy(platformCauseOfDestroy);

        switch (platformCauseOfDestroy)
        {
        case PlatformCauseOfDestroy.CauseOfDestroy.AsTimePasses:
        case PlatformCauseOfDestroy.CauseOfDestroy.NoLifeTime:
            IsAliveState = () => IsAlive(lifeTime);
            break;

        case PlatformCauseOfDestroy.CauseOfDestroy.TopBorder:
        case PlatformCauseOfDestroy.CauseOfDestroy.BottomBorder:
            IsAliveState = () => IsAlive(hight);
            break;

        default:
            throw new Exception($"{platformCauseOfDestroy} is unknown causeOfDestroy!");
        }
    }
コード例 #3
0
    public Predicate <float> GetCauseOfDestroy(PlatformCauseOfDestroy.CauseOfDestroy causeOfDestroy)
    {
        switch (causeOfDestroy)
        {
        case PlatformCauseOfDestroy.CauseOfDestroy.AsTimePasses:
            return(GetAsTimePassesCauseOfDestroy());

        case PlatformCauseOfDestroy.CauseOfDestroy.NoLifeTime:
            return(GetNoLifeTimeCauseOfDestroy());

        case PlatformCauseOfDestroy.CauseOfDestroy.TopBorder:
            return(GetTopBorderCauseOfDestroy());

        case PlatformCauseOfDestroy.CauseOfDestroy.BottomBorder:
            return(GetBottomBorderCauseOfDestroy());

        default:
            throw new Exception($"{causeOfDestroy} is unknown PlatformCauseOfDestroy!");
        }
    }