Esempio n. 1
0
    public void Destroy()
    {
        allSize = Mathf.Min(allSize, 1);
        Scale(allSize);
        instance = null;

        if (onEnd != null)
        {
            onEnd();
        }

        UpdateController.RemoveFixedUpdatable("BankMenu");
        UpdateController.AddFixedUpdatable("BankMenuDestroying", (f) => {
            allSize -= f * 2f;

            if (allSize <= 0)
            {
                foreach (var w in objects)
                {
                    w.Destroy();
                }

                black.Destroy();

                UpdateController.RemoveFixedUpdatable("BankMenuDestroying");
                return;
            }

            Scale(allSize);

            black.color            = new Color(1, 1, 1, allSize * 0.84f);
            black.positionInMeters = CameraController.cameraPosition;
        });
    }
    public void LoadScene <SceneController> (Actions.VoidAction beforeEnd = null) where SceneController : new ()
    {
        if (loadProgress > 0 && loadProgress < 1)
        {
            return;
        }

        if (beforeEnd == null)
        {
            beforeEnd = (a) => {
                a();
            };
        }

        Create();

        loadProgress = 0;
        isCreated    = false;

        onEnd = () => {
            beforeEnd(() => {
                if (AudioController.instance != null)
                {
                    AudioController.instance.ClearSounds();
                }

                new SceneController();
                UpdateController.OnSceneLoaded();

                OnSceneLoaded();
            });
        };

        UpdateController.AddFixedUpdatable("ScenePassageControllerUpdateOnlyDirectRemoving", Update);
    }
    public OptionsController(Actions.VoidVoid onExit, Actions.VoidVoid onReplay = null, bool isCreateReplay = true, float deltaLayer = -1f)
    {
        instance = this;

        isUnderSettingsOpening = false;

        var options = new GUIButton("Textures/UserInterface/Settings1", null, (0 + 226 / 4f), (10 + 127 / 4f), null, 127 / 2f, 127 / 2f, deltaLayer, true);

        options.OnClick = (t) => {
            GameController.isPaused = !GameController.isPaused;

            isUnderSettingsOpening = !isUnderSettingsOpening;

            if (isUnderSettingsOpening)
            {
                options.texture = Resources.Load("Textures/UserInterface/Settings2") as Texture;
            }
            else
            {
                options.texture = Resources.Load("Textures/UserInterface/Settings1") as Texture;
            }
        };
        underSettings = new GUIImage("Textures/UserInterface/UnderSettings", null, (0 + 226 / 2f + 35 + 612 / 2f) / 2f
                                     , (10 + 127 / 4f), null, 165 / 2f, 612 / 2f, -1 - 1f, true);
        underSettings.gameObject.GetComponent <BoxCollider> ().enabled = false;
        underSettingsExit         = new GUIButton("Textures/UserInterface/Exit", null, (0 + 226 / 4f), (10 + 127 / 4f), null, 81 / 2f, 92 / 2f, -0.5f + deltaLayer, true);
        underSettingsExit.OnClick = (t) => {
            onExit();
        };
        underSettingsMusic = new GUIButton("Textures/UserInterface/Music" + (Settings.music?"":"Off"), null, (0 + 226 / 4f)
                                           , (10 + 127 / 4f), null, 59 / 2f, 80 / 2f, -0.5f + deltaLayer, true);
        underSettingsMusic.OnClick = (t) => {
            Settings.music = !Settings.music;

            if (Settings.music)
            {
                underSettingsMusic.texture = Resources.Load("Textures/UserInterface/Music") as Texture;
            }
            else
            {
                underSettingsMusic.texture = Resources.Load("Textures/UserInterface/MusicOff") as Texture;
            }
        };
        underSettingsSounds = new GUIButton("Textures/UserInterface/Sounds" + (Settings.sounds?"":"Off"), null
                                            , (0 + 226 / 4f), (10 + 127 / 4f), null, 68 / 2f, 70 / 2f, -0.5f + deltaLayer, true);
        underSettingsSounds.OnClick = (t) => {
            Settings.sounds = !Settings.sounds;

            if (Settings.sounds)
            {
                underSettingsSounds.texture = Resources.Load("Textures/UserInterface/Sounds") as Texture;
            }
            else
            {
                underSettingsSounds.texture = Resources.Load("Textures/UserInterface/SoundsOff") as Texture;
            }
        };

        if (isCreateReplay)
        {
            underSettingsReplay = new GUIButton("Textures/UserInterface/Replay", null, (0 + 226 / 4f)
                                                , (10 + 127 / 4f), null, 75 / 2f, 64 / 2f, -0.5f + deltaLayer, true);
            underSettingsReplay.OnClick = (t) => {
                if (onReplay != null)
                {
                    onReplay();
                }
                //TODO
            };
        }
        else
        {
            underSettingsReplay = null;
        }
        underSettingsPosition = 0;


        UpdateController.AddFixedUpdatable("OptionsControllerFixedUpdate", Update);
    }
Esempio n. 4
0
    public BankMenu(Actions.VoidVoid onMoneyChange = null, Actions.VoidVoid _onEnd = null, float deltaLayer = 0)
    {
        new SlideController(0, 0, SlideController.Mode.ReadOnly, 3);

        objects   = new List <GUIObject> ();
        sizes     = new List <Vector2> ();
        positions = new List <Vector2> ();

        onEnd = _onEnd;

        instance = this;

        objects.Add(new GUIImage("Textures/SelectLevel/Interface/" + (Settings.diamonds / 1000) % 10, -0.5f + deltaLayer
                                 , new Vector2(-0.1f, 5.54f), new Vector2(-1, -1)));
        objects.Add(new GUIImage("Textures/SelectLevel/Interface/" + (Settings.diamonds / 100) % 10, -0.5f + deltaLayer
                                 , new Vector2(0.4f, 5.54f), new Vector2(-1, -1)));
        objects.Add(new GUIImage("Textures/SelectLevel/Interface/" + (Settings.diamonds / 10) % 10, -0.5f + deltaLayer
                                 , new Vector2(0.9f, 5.54f), new Vector2(-1, -1)));
        objects.Add(new GUIImage("Textures/SelectLevel/Interface/" + (Settings.diamonds / 1) % 10, -0.5f + deltaLayer
                                 , new Vector2(1.39f, 5.54f), new Vector2(-1, -1)));

        objects.Add(new GUIImage("Textures/SelectLevel/Interface/DiamondsBar", -0.4f + deltaLayer, new Vector2(0.64f, 5.54f), new Vector2(-1, -1)));


        black = new GUIImageAlpha("Textures/Black", -1.2f + deltaLayer, new Vector2(0, 0) + CameraController.cameraPosition
                                  , new Vector2(CameraController.widthInMeters, CameraController.heightInMeters));
        black.color       = new Color(1, 1, 1, 0);
        black.isClickable = true;

        objects.Add(new GUIImage("Textures/Bank/Background", -1.1f + deltaLayer, new Vector2(0, 0), new Vector2(-1, -1)));

        var back = new GUIButton("Textures/Back", -1.0f + deltaLayer, new Vector2(7.31f, 5.58f), new Vector2(-1, -1));

        back.OnButtonDown = (b) => {
            back += "Pressed";
        };
        back.OnButtonUp = (b) => {
            back -= "Pressed";
        };
        back.OnClick = (b) => {
            Destroy();
        };

        objects.Add(back);


        //moneyText = new GUIText (Settings.money.ToString (), -0.5f + deltaLayer, new Vector2 (0.5f, 13f)
        //    , new Vector2 (0.3f, 0.3f), GUIText.FontName.Font5);

        //objects.Add (moneyText);

        CreateLine(onMoneyChange, onMoneyChange, new Vector2(-4f, 1.9f), 30, 0.99f, "USD", deltaLayer, "Textures/Bank/Video", true);
        CreateLine(onMoneyChange, onMoneyChange, new Vector2(4f, 1.9f), 100, 2.99f, "USD", deltaLayer);
        CreateLine(onMoneyChange, onMoneyChange, new Vector2(-4f, -2.99f), 200, 4.99f, "USD", deltaLayer);
        CreateLine(onMoneyChange, onMoneyChange, new Vector2(4f, -2.99f), 500, 9.99f, "USD", deltaLayer);
        //CreateLine (onMoneyChange, 1, 150, 1.5f, "USD", deltaLayer);
        //CreateLine (onMoneyChange, 2, 300, 3, "USD", deltaLayer);
        //CreateLine (onMoneyChange, 3, 750, 4.5f, "USD", deltaLayer);

        foreach (var w in objects)
        {
            sizes.Add(w.sizeInMeters);
            positions.Add(w.positionInMeters);
        }

        allSize = 0;
        bool isScaled = false;

        Scale(0);

        UpdateController.AddFixedUpdatable("BankMenu", (f) => {
            allSize += f * 2f;

            if (!isScaled)
            {
                if (allSize > 1)
                {
                    allSize  = 1f;
                    isScaled = true;
                }

                Scale(allSize);
            }

            if (!isScaled)
            {
                black.color = new Color(1, 1, 1, allSize * 0.84f);
            }

            black.positionInMeters = CameraController.cameraPosition;
        });
    }