예제 #1
0
파일: Main.cs 프로젝트: zifro-playground/ui
        private void SetSandboxSettings()
        {
            if (levelDefinition.sandbox != null)
            {
                SandboxSettings sandboxSettings = levelDefinition.sandbox.sandboxSettings;

                if (sandboxSettings == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(sandboxSettings.precode))
                {
                    PMWrapper.preCode = sandboxSettings.precode;
                }

                if (sandboxSettings.walkerStepTime > 0)
                {
                    PMWrapper.walkerStepTime = sandboxSettings.walkerStepTime;
                }
            }
        }
예제 #2
0
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        settings = new SandboxSettings();
        SandboxSettings sandboxSettings = settings;

        sandboxSettings.OnChangeElement = (System.Action)Delegate.Combine(sandboxSettings.OnChangeElement, (System.Action) delegate
        {
            elementSelector.button.GetComponentInChildren <LocText>().text = instance.settings.Element.name + " (" + instance.settings.Element.GetStateString() + ")";
            Tuple <Sprite, Color> uISprite = Def.GetUISprite(settings.Element, "ui", false);
            elementSelector.button.GetComponentsInChildren <Image>()[1].sprite = uISprite.first;
            elementSelector.button.GetComponentsInChildren <Image>()[1].color  = uISprite.second;
            temperatureSlider.SetRange(Mathf.Max(instance.settings.Element.lowTemp - 10f, 1f), Mathf.Min(9999f, instance.settings.Element.highTemp + 10f));
            temperatureSlider.SetValue(instance.settings.Element.defaultValues.temperature);
            massSlider.SetRange(0.1f, instance.settings.Element.defaultValues.mass * 2f);
        });
        SandboxSettings sandboxSettings2 = settings;

        sandboxSettings2.OnChangeDisease = (System.Action)Delegate.Combine(sandboxSettings2.OnChangeDisease, (System.Action) delegate
        {
            diseaseSelector.button.GetComponentInChildren <LocText>().text     = instance.settings.Disease.Name;
            diseaseSelector.button.GetComponentsInChildren <Image>()[1].sprite = Assets.GetSprite("germ");
            diseaseCountSlider.SetRange(0f, 1000000f);
        });
        SandboxSettings sandboxSettings3 = settings;

        sandboxSettings3.OnChangeEntity = (System.Action)Delegate.Combine(sandboxSettings3.OnChangeEntity, (System.Action) delegate
        {
            entitySelector.button.GetComponentInChildren <LocText>().text = instance.settings.Entity.GetProperName();
            Tuple <Sprite, Color> tuple = (!(settings.Entity.PrefabTag == (Tag)MinionConfig.ID)) ? Def.GetUISprite(settings.Entity.PrefabTag, "ui", false) : new Tuple <Sprite, Color>(Assets.GetSprite("ui_duplicant_portrait_placeholder"), Color.white);
            if (tuple != null)
            {
                entitySelector.button.GetComponentsInChildren <Image>()[1].sprite = tuple.first;
                entitySelector.button.GetComponentsInChildren <Image>()[1].color  = tuple.second;
            }
        });
        SandboxSettings sandboxSettings4 = settings;

        sandboxSettings4.OnChangeBrushSize = (System.Action)Delegate.Combine(sandboxSettings4.OnChangeBrushSize, (System.Action) delegate
        {
            if (PlayerController.Instance.ActiveTool is BrushTool)
            {
                (PlayerController.Instance.ActiveTool as BrushTool).SetBrushSize(settings.BrushSize);
            }
        });
        SandboxSettings sandboxSettings5 = settings;

        sandboxSettings5.OnChangeNoiseScale = (System.Action)Delegate.Combine(sandboxSettings5.OnChangeNoiseScale, (System.Action) delegate
        {
            if (PlayerController.Instance.ActiveTool is BrushTool)
            {
                (PlayerController.Instance.ActiveTool as BrushTool).SetBrushSize(settings.BrushSize);
            }
        });
        SandboxSettings sandboxSettings6 = settings;

        sandboxSettings6.OnChangeNoiseDensity = (System.Action)Delegate.Combine(sandboxSettings6.OnChangeNoiseDensity, (System.Action) delegate
        {
            if (PlayerController.Instance.ActiveTool is BrushTool)
            {
                (PlayerController.Instance.ActiveTool as BrushTool).SetBrushSize(settings.BrushSize);
            }
        });
        settings.InstantBuild = true;
        activateOnSpawn       = true;
        ConsumeMouseScroll    = true;
    }