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 ScenePassageController() { if (instance != null) { return; } instance = this; onEnd = () => { }; }
public void ShowRewardedAd(Actions.VoidVoid _onEnd) { /* * onEnd = _onEnd; * * Debug.Log ("Try Show Rewarded Ad"); * * if (Advertisement.IsReady ("rewardedVideo")) { * * var options = new ShowOptions { resultCallback = HandleShowResult }; * Advertisement.Show ("rewardedVideo", options); * }*/ }
public Lazer(Vector2 _start, Killable _end, Color color, Actions.VoidVoid _onShot, float _length = 1f, float _height = 0.3f, float _speed = 8f) { start = _start; end = _end; height = _height; length = _length; speed = _speed; onShot = _onShot; body = new GUIImageAlpha("Sprites/MiddleSeg", end.layer - GUIController.layer, start, new Vector2(0, 0), false); body.color = color; edgePosition = start; LazerController.Add(this); }
public void Play(int _slidesCount, Actions.VoidVoid _OnEnd = null) // -1 - Play one Circle, -2 Play forever { OnEnd = _OnEnd; if (_slidesCount == -1) { slidesCount = textures.Count; } else { slidesCount = _slidesCount; } currentTexture = 0; deltaTime = 0; SetTexture(); }
public void Show(Actions.VoidVoid _onEnd) { onEnd = _onEnd; /*Debug.Log ("TryShow"); * * if (interstitial.IsLoaded ()) { * * Debug.Log ("Show"); * interstitial.Show (); * RequestInterstitial (); * onEnd (); * } else { */ onEnd(); // } }
private void MoveItems(bool isRight, Actions.VoidVoid onEnd) { ForbidController.Forbid("MovingItems"); var count = 20; var time = 0.5f; var distance = 3.7f * 2f; UpdateController.LaunchIt(count, time / count, (t) => { foreach (var i in itemObjects) { i.positionInMeters += new Vector2((isRight ? 1 : -1) * distance * (time / count), 0); } if (select != null) { select.positionInMeters += new Vector2((isRight ? 1 : -1) * distance * (time / count), 0); } }, () => { ForbidController.Allow("MovingItems"); onEnd(); }); }
private void CreateLine(Actions.VoidVoid onMoneyChange, Actions.VoidVoid onBuy, Vector2 position, int moneyGot , float moneyToSpend, string currency, float deltaLayer, string buttonTexture = "Textures/Bank/Buy", bool isVideo = false) { objects.Add(new GUIText(moneyGot.ToString(), -0.5f + deltaLayer, position - new Vector2(-4f, 1.9f) + new Vector2(-4.09f, 2.8f) , new Vector2(0.16f, 0.16f), GUIText.FontName.Font5, false, TextAnchor.MiddleLeft)); if (!isVideo) { var toSpend = new GUIText(moneyToSpend + " " + currency, -0.5f + deltaLayer, position - new Vector2(-4f, 1.9f) + new Vector2(-7.25f, 0.94f) , new Vector2(0.11f, 0.11f), GUIText.FontName.Font5, false, TextAnchor.MiddleLeft); objects.Add(toSpend); objects.Add(new GUIText("BUY", -0.5f + deltaLayer, position - new Vector2(-4f, 1.9f) + new Vector2(-2.44f, 0.94f) , new Vector2(0.11f, 0.11f), GUIText.FontName.Font5)); } var buy = new GUIButton(buttonTexture, -0.6f + deltaLayer, position - new Vector2(-4f, 1.9f) + new Vector2(-2.44f, 0.94f), new Vector2(-1, -1)); if (isVideo) { buy.positionInMeters = new Vector2(position.x, buy.positionInMeters.y); } buy.OnClick = (b) => { onBuy(); onMoneyChange(); }; buy.OnButtonDown = (b) => { buy += "Pressed"; }; buy.OnButtonUp = (b) => { buy -= "Pressed"; }; objects.Add(buy); }
public void BuyConsumable(int id, Actions.VoidVoid _onBought) { onBought = _onBought; BuyProductID(productIDConsumable [id]); }
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); }
public static void LaunchIt(float count, float deltaTime, Actions.VoidInt func, Actions.VoidVoid onEnd = null) { instance._LanunchIt(count, deltaTime, func, onEnd == null ? () => { } : onEnd); }
private void _Timer(float time, Actions.VoidVoid func) { StartCoroutine(IETimer(time, func)); }
private IEnumerator IETimer(float time, Actions.VoidVoid func) { yield return(new WaitForSeconds(time)); func(); }
public static void Preorder(List <PreoderItem> toPreorder, Actions.VoidIntInt onProcess = null, Actions.VoidVoid onEnd = null) { if (preorders == null) { Debug.LogError("Preorders are not created"); } else { int done = 0; int total = 0; for (int i = 0; i < toPreorder.Count; i++) { total += toPreorder [i].count; } UpdateController.LaunchIt(toPreorder.Count, 0, (q) => { List <GameObject> created = new List <GameObject> (); string realName = preoderNameTranslates.ContainsKey(toPreorder [q].target) ? preoderNameTranslates [toPreorder [q].target] : toPreorder [q].target; if (preorders.ContainsKey(realName)) { UpdateController.LaunchIt(toPreorder [q].count, 0, (i) => { created.Add(preorders [realName].Key()); toPreorder [q].onEnd(); done++; if (onProcess != null) { onProcess(done, total); } }, () => { for (int i = 0; i < toPreorder [q].count; i++) { preorders [realName].Value(created [i]); } if (done >= total) { Debug.Log(done + " " + total); if (onEnd != null) { onEnd(); } isPreordered = true; } }); } else { Debug.LogWarning("No such target: '" + toPreorder [q].target + "' as '" + realName + "'"); } }); } }
public static void CreateQueuedMenu(Actions.VoidVoid creator) { queue.Add(creator); CheckMenusQueue(); }
public PreoderItem(string _target, int _count, Actions.VoidVoid _onEnd) { target = _target; count = _count; onEnd = _onEnd; }
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; }); }
public static void Timer(float time, Actions.VoidVoid func) { instance._Timer(time, func); }
private IEnumerator IELaunchIt(float count, float deltaTime, Actions.VoidInt func, Actions.VoidVoid onEnd) { for (int i = 0; i < count; i++) { func(i); yield return(new WaitForSeconds(deltaTime)); } onEnd(); }
private void _LanunchIt(float count, float deltaTime, Actions.VoidInt func, Actions.VoidVoid onEnd) { StartCoroutine(IELaunchIt(count, deltaTime, func, onEnd)); }