Exemplo n.º 1
0
 public static void SetTimeout(GameObject timeObject, FCallback.FunVoid fCallback, float time, string name = "")
 {
     iTween.ValueTo(timeObject, iTween.Hash(
                        "name", "SetTimeout_" + name,
                        "time", time, "from", 0, "to", 1,
                        "onupdate", FCallback.CreateAction(delegate() { }),
                        "oncomplete", FCallback.CreateAction(delegate()
     {
         if (fCallback != null)
         {
             fCallback();
         }
     })
                        ));
 }
        private void TweenMask(float from, float to, FCallback.FunVoid fCallback, float time = 1.0f)
        {
            if (_maskGo == null)
            {
                fCallback();
                return;
            }

            _maskGo.SetActive(true);

            BoxCollider box = _maskGo.GetComponent <BoxCollider>();

            if (box != null)
            {
                box.enabled = true;
            }

            UIWidget widget = _maskGo.GetComponent <UIWidget>();

            if (widget == null)
            {
                fCallback();
                return;
            }

            widget.alpha = from;
            iTween.ValueTo(_maskGo, iTween.Hash(
                               "from", from,
                               "to", to,
                               "delay", .1f,
                               "time", time,
                               "easetype", iTween.EaseType.linear,
                               "onupdate", FCallback.CreateAction(delegate(object x)
            {
                float value  = Mathf.Clamp01((float)x);
                widget.alpha = value;
            }),
                               "onupdatetarget", gameObject,
                               "oncomplete", FCallback.CreateAction(delegate()
            {
                if (box != null)
                {
                    box.enabled = false;
                }
                fCallback();
            }),
                               "oncompletetarget", gameObject));
        }
Exemplo n.º 3
0
        private IEnumerator GotoSceneAsync(string value, FCallback.FunVoid fCallback)
        {
            yield return(null);

            if (value != Application.loadedLevelName)
            {
                sceneList.Add(Application.loadedLevelName);
                if (sceneList.Count > MAX_SCENECOUNT)
                {
                    sceneList.RemoveAt(0);
                }

                FLog.Debug("GotoSceneAsync() " + Application.loadedLevelName + " -> " + value);

                AsyncOperation asyncO = Application.LoadLevelAsync(value);
                yield return(asyncO);

                if (fCallback != null)
                {
                    fCallback();
                }
            }
        }
Exemplo n.º 4
0
 public void GotoScene(string value, FCallback.FunVoid fCallback = null)
 {
     StartCoroutine(GotoSceneAsync(value, fCallback));
 }
Exemplo n.º 5
0
        private IEnumerator LoadResources(string folder, FCallback.FunVoid fCallback)
        {
            yield return(null);

            DirectoryInfo dir = new DirectoryInfo(folder);

            if (dir.Exists)
            {
                FLog.Debug("LoadResources() start from folder: " + folder);

                if (resourceDic == null)
                {
                    resourceDic = new Dictionary <string, Sprite>();
                }

                int length = 0;

                FileInfo[] fInfo = dir.GetFiles();
                if (fInfo != null)
                {
                    length = fInfo.Length;
                    for (int i = 0; i < length; i++)
                    {
                        string name     = fInfo[i].Name;
                        string fullname = fInfo[i].FullName;

                        WWW www = new WWW("file://" + fullname);
                        yield return(www);

                        Texture2D texture = www.texture;
                        //texture = FTextureScaler.scaled(texture, 220, 220, FilterMode.Bilinear);
                        //FUtil.SaveToJpg(texture, "./User/" + name);

                        if (texture != null)
                        {
                            Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
                            if (sprite != null)
                            {
                                if (!resourceDic.ContainsKey(name))
                                {
                                    resourceDic.Add(name, sprite);
                                }

                                FLog.Debug("Load file: " + name + ", succeed.");
                            }
                            else
                            {
                                FLog.Debug("Load file: " + name + ", sprite create failed.");
                            }
                        }
                        else
                        {
                            FLog.Debug("Load file: " + name + ", www.texture is null.");
                        }
                    }
                }

                FLog.Debug("LoadResources() end, length = " + length.ToString());
            }
            else
            {
                FLog.Debug("LoadResources() error, directory is not exist.");
            }

            if (fCallback != null)
            {
                fCallback();
            }
        }
Exemplo n.º 6
0
 public void LoadResourcesAsyn(string folder, FCallback.FunVoid fCallback = null)
 {
     StartCoroutine(LoadResources(folder, fCallback));
 }
 protected override void SceneEaseOut(FCallback.FunVoid fCallback)
 {
     TweenMask(_alphaLight, _alphaDark, fCallback);
 }
 protected virtual void SceneEaseOut(FCallback.FunVoid fCallback)
 {
     fCallback();
 }