Ejemplo n.º 1
0
        private void MoveVertical_Animation(BaseTile[] datas, int offset)
        {
            var movetime = Mathf.Abs(MoveOneGridTime * offset);

            for (int i = 0; i < datas.Length; ++i)
            {
                int x = datas[i].ParentGrid.ColID;
                int y = datas[i].ParentGrid.RowID;

                int row_value  = y + offset;
                var targetGrid = datas[i].ParentGrid.GetRowOffsetGrid(offset);

                int dir = offset > 0 ? 2 : 1;

                //不连续的则说明不挨着,就需要有个用来填充表示的copytile
                if (Mathf.Abs(datas[i].ParentGrid.RowID - targetGrid.RowID) > 1)
                {
                    var copytargetRowID = targetGrid.RowID - offset;

                    datas[i].CopyMoveTo(x, row_value, x, copytargetRowID, x, targetGrid.RowID, movetime, dir);

                    datas[i].MoveTo(x, row_value, movetime, dir, true);
                }
                else
                {
                    datas[i].MoveTo(x, row_value, movetime, dir);
                }

                datas[i].ParentGrid = targetGrid;
            }

            MonoBehaviourHelper.StartCoroutine(WaitforUpdateVertical(datas, offset, movetime));
        }
Ejemplo n.º 2
0
    void GrowContext()
    {
        var targetBounds = bounds;

        targetBounds.center += Vector3.up;
        MonoBehaviourHelper.StartCoroutine(Grow(targetBounds));
    }
Ejemplo n.º 3
0
 void OnClickDirect(BaseTile grid)
 {
     _clickMark.gameObject.SetActive(false);
     ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(true);
     ModuleManager.getInstance.GetModule <BattlefieldInputModule>().onClickedTile -= OnClickDirect;
     MonoBehaviourHelper.StartCoroutine(GuideRunning(1, "你已经成功的移动了,注意移动会消耗AP,如果AP全部消耗任务将会失败,继续移动吧", OnOpenClickPanel, OnStepFinish));
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 返回local version config
    /// </summary>
    private async Task <VersionConfig> GetLocalVersionConfig()
    {
        VersionConfig localVersionConfig;
        string        versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt");

        if (File.Exists(versionPath))
        {
            localVersionConfig = JsonHelper.FromJson <VersionConfig>(File.ReadAllText(versionPath));
        }
        else
        {
            versionPath = Path.Combine(PathHelper.AppResPath4Web, "Version.txt");
            UnityWebRequestAsync request = MonoBehaviourHelper.CreateTempComponent <UnityWebRequestAsync>();
            try
            {
                await request.DownloadAsync(versionPath);

                localVersionConfig = JsonHelper.FromJson <VersionConfig>(request.Request.downloadHandler.text);
            }
            catch (System.Exception e)
            {
                Debug.Log(e.ToString());
                localVersionConfig = null;
            }
            finally
            {
                Destroy(request.gameObject);
                request = null;
            }
        }
        return(localVersionConfig);
    }
Ejemplo n.º 5
0
    public static async Task StartDownLoadResources()
    {
        if (StaticData.isUseAssetBundle)
        {
            BundleDownloaderComponent bundleDownloaderComponent = null;
            try
            {
                bundleDownloaderComponent = MonoBehaviourHelper.CreateTempComponent <BundleDownloaderComponent>();
                var t        = bundleDownloaderComponent.LoadInfo();
                var needDown = await t;
                StaticData.isNotWifiDownload = true;
                if (needDown)
                {
                    GameObject goUpdateProcess = ResourcesHelper.InstantiatePrefabFromResourceSetDefault("UISceneLoading", UIRoot.instance.GetUIRootCanvas().transform);
                    UITipABUpdateProgressComponent uiTipABUpdateProgressComponent = goUpdateProcess.GetComponent <UITipABUpdateProgressComponent>();
                    uiTipABUpdateProgressComponent.DownLoadInfo = bundleDownloaderComponent.DownloadInfo;
                    var x1 = bundleDownloaderComponent.DownloadInfo.TotalSize / 1024;
                    var x  = x1 / 1024f;
                    StaticData.isNotWifiDownloadClick = false;
                    //如果大于1m 不是wifi才弹提示
                    if (x > 1 && Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
                    {
                        GameObject goWifiConfirm = ResourcesHelper.InstantiatePrefabFromResourceSetDefault("UITipABUpdateNotWifi", UIRoot.instance.GetUIRootCanvas().transform);
                        UITipABUpdateNotWifiComponent uiTipABUpdateNotWifiComponent = goWifiConfirm.GetComponent <UITipABUpdateNotWifiComponent>();
                        //取两位小数
                        int j = (int)(x * 100);
                        x = j / 100f;
                        uiTipABUpdateNotWifiComponent.TextShow.text = $"当前不是wifi环境, 更新需要消耗{x}M流量,\n是否更新 ? (点击取消将退出游戏)";
                        await UniTask.WaitUntil(() => StaticData.isNotWifiDownloadClick == true);
                    }


                    if (!StaticData.isNotWifiDownload)
                    {
                        StaticData.QuitApplication();
                        //永远不返回
                        await UniTask.WaitUntil(() => StaticData.isNotWifiDownload == true);
                    }
                    await bundleDownloaderComponent.Down();

                    uiTipABUpdateProgressComponent.DownLoadInfo.IsEnd = true;
                    GameObject.DestroyImmediate(goUpdateProcess);
                }


                await ResourcesComponent.instance.LoadOneBundleAsync("StreamingAssets");

                ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)ResourcesComponent.instance.GetAsset("StreamingAssets", "AssetBundleManifest");
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
            finally
            {
                GameObject.Destroy(bundleDownloaderComponent.gameObject);
            }
        }
    }
Ejemplo n.º 6
0
    public override void StartProcess(params object[] args)
    {
        base.StartProcess(args);

        _battleLogicObject = MonoBehaviourHelper.CreateObject("BattlefieldRoot");

        _battleLogicObject.StartCoroutine(LoadBattleScene());
    }
Ejemplo n.º 7
0
    public static async Task <bool> IsGameVersionCodeEqual()
    {
        UnityWebRequestAsync webRequestAsync = MonoBehaviourHelper.CreateTempComponent <UnityWebRequestAsync>();

        try
        {
            GlobalProto.VersionCodeInfo NowLineCodeInfo  = null;
            GlobalProto.VersionCodeInfo UpdatingCodeInfo = null;
            string PathNowLineCodeInfo = GlobalConfigComponent.intance.GlobalProto.GetNowLineCodeInfoPath();
            //下载PathNowLineCodeInfo
            await webRequestAsync.DownloadAsync(PathNowLineCodeInfo);

            NowLineCodeInfo = GlobalConfigComponent.intance.GlobalProto.GetNowLineCodeInfo(webRequestAsync.Request.downloadHandler.text);
            string PathUpdatingCodeInfo = GlobalConfigComponent.intance.GlobalProto.GetUpdatingCodeInfoPath();
            //下载PathUpdatingCodeInfo
            await webRequestAsync.DownloadAsync(PathUpdatingCodeInfo);

            UpdatingCodeInfo = GlobalConfigComponent.intance.GlobalProto.GetUpdatingCodeInfo(webRequestAsync.Request.downloadHandler.text);
            webRequestAsync.Dispose();
            //比较VersionCode
            StaticData.DebugGreen($"local versionGameCode:{StaticData.localVersionGameCode},remote NowLineCodeInfo GameVersionCode:{NowLineCodeInfo.GameVersionCode} remote NowLineCodeInfo ResVersionCode:{NowLineCodeInfo.ResVersionCode},remote UpdatingCodeInfo GameVersionCode:{UpdatingCodeInfo.GameVersionCode} remote UpdatingCodeInfo ResVersionCode:{UpdatingCodeInfo.ResVersionCode}");
            if (StaticData.localVersionGameCode < NowLineCodeInfo.GameVersionCode)
            {
                //强更
                TipsDifferentVersion();
                StaticData.intParentResABDirectory      = NowLineCodeInfo.ResVersionCode;
                StaticData.isUsePlatformUpdatingGateWay = false;
                return(false);
            }
            else if (StaticData.localVersionGameCode == NowLineCodeInfo.GameVersionCode)
            {
                //热更本地资源
                StaticData.intParentResABDirectory      = NowLineCodeInfo.ResVersionCode;
                StaticData.isUsePlatformUpdatingGateWay = false;
                return(true);
            }
            else
            {
                //已经是最新包,只需要更新最新包资源即可
                StaticData.intParentResABDirectory      = UpdatingCodeInfo.ResVersionCode;
                StaticData.isUsePlatformUpdatingGateWay = true;
                return(true);
            }
        }
        catch (Exception e)
        {
            if (e.Message.Contains("request error"))
            {
                Debug.Log($"load VersionGameCode error:'{e.Message}'");
                return(true);
            }
        }
        finally
        {
            GameObject.Destroy(webRequestAsync.gameObject);
        }
        return(false);
    }
Ejemplo n.º 8
0
 public override void StartProcess(params object[] args)
 {
     base.StartProcess(args);
     //显示ui
     if (_finalObject == null)
     {
         _finalObject = MonoBehaviourHelper.CreateObject("FinalObject");
     }
     _finalObject.StartCoroutine(LoadMainMenuScene());
 }
Ejemplo n.º 9
0
 public override void StartProcess(params object[] args)
 {
     base.StartProcess(args);
     //显示ui
     if (_titleLogicObject == null)
     {
         _titleLogicObject = MonoBehaviourHelper.CreateObject("MainMenuRoot");
     }
     _titleLogicObject.StartCoroutine(LoadMainMenuScene());
     //
     //ProcessManager.getInstance.Switch<BattlefieldProcess>();
 }
Ejemplo n.º 10
0
    private static async Task LoadAssetAsync(string assetBundleName, AssetBundle assetBundle, Action <float> actionProgress)
    {
        // 异步load资源到内存cache住
        UnityEngine.Object[] assets;


        AssetsLoaderAsync assetsLoaderAsync = MonoBehaviourHelper.CreateTempComponent <AssetsLoaderAsync>();

        assetsLoaderAsync.SetAB(assetBundle);
        assets = await assetsLoaderAsync.LoadAllAssetsAsync(actionProgress);

        Destroy(assetsLoaderAsync.gameObject);
    }
Ejemplo n.º 11
0
        public override void StartProcess(params object[] args)
        {
            base.StartProcess(args);

            var commonnode = MonoBehaviourHelper.GetCommonObject();

            commonnode.StartCoroutine(LoadScene());

            //LevelManager.getInstance.LoadLevelFiles();
            //LevelManager.getInstance.Load();

            //var levels = LevelManager.getInstance.GetAreaLevels(LevelManager.getInstance.LastArea);

            //UIModule.getInstance.Open<AreaPanel>(levels, LevelManager.getInstance.LastArea);
        }
        public override void Excute()
        {
            var objs = _cacheobjs;

            base.Excute();

            _isWorking = true;

            var obj = objs[0];

            BaseTile[] points = (BaseTile[])objs;

            MonoBehaviourHelper.StartCoroutine(WaitforDestroyTile(points));
            //消灭

            //_isWorking = false;
        }
Ejemplo n.º 13
0
    /// <summary>
    /// 返回是否需要下载
    /// </summary>
    /// <returns></returns>
    public async Task <bool> LoadInfo()
    {
        UnityWebRequestAsync webRequestAsync = MonoBehaviourHelper.CreateTempComponent <UnityWebRequestAsync>();
        string remoteVersionText             = string.Empty;

        try
        {
            //下载remote version.txt
            string versionUrl = LoadBundlePathRoot() + "StreamingAssets/Version.txt";
            await webRequestAsync.DownloadAsync(versionUrl);

            remoteVersionText = webRequestAsync.Request.downloadHandler.text;
        }
        catch (Exception e)
        {
            if (e.Message.Contains("request error"))
            {
                webRequestAsync.Dispose();
                Debug.Log($"load VersionText error:'{e.Message}'");
                StaticData.isUseStreamingAssetRes = true;
                OnFileServerNotReach(e.Message);
                return(false);
            }
        }
        finally
        {
            Destroy(webRequestAsync.gameObject);
        }
        Debug.Log($"remoteVersionText:{remoteVersionText}");
        if (!remoteVersionText.StartsWith("{"))
        {
            Debug.Log("remote version text is not a correct json");
            this.remoteVersionConfig = null;
            return(false);
        }
        this.remoteVersionConfig = JsonHelper.FromJson <VersionConfig>(remoteVersionText);
        var needDown = await AnalyseVersionConfig();

        if (needDown == false)
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 14
0
    public void Init()
    {
        soundsDict = new Dictionary <string, AudioClip>();
        var sd = Resources.Load <SoundData>("Sounds/SoundData");

        foreach (var sp in sd.audioClips)
        {
            soundsDict.Add(sp.soundName, sp.clip);
        }

        soundPlayers = new List <AudioSource>(SOUNDPLAYER_NUM);
        _gameObject  = MonoBehaviourHelper.CreateObject("SoundManager").gameObject;
        for (int i = 0; i < SOUNDPLAYER_NUM; ++i)
        {
            soundPlayers.Add(_gameObject.AddComponent <AudioSource>());
        }
        //临时将声音关闭
        SetMute(true);
    }
Ejemplo n.º 15
0
        public void DoDead()
        {
            dead_effect.gameObject.SetActive(true);
            dead_effect.SetTrigger("play");
            role_animator.SetTrigger("dead");
            var rac = dead_effect.runtimeAnimatorController;

            if (rac != null)
            {
                foreach (AnimationClip clip in rac.animationClips)
                {
                    if (clip.name == "bloody")
                    {
                        MonoBehaviourHelper.StartCoroutine(OnDeadEffectFinish(clip.length));
                        break;
                    }
                }
            }
            return;
        }
Ejemplo n.º 16
0
    private async Task DownServerBundle()
    {
        while (true)
        {
            try
            {
                this.webRequest      = MonoBehaviourHelper.CreateTempComponent <UnityWebRequestAsync>();
                DownloadInfo.IsStart = true;
                var bundlePath = LoadBundlePathRoot() + "StreamingAssets/" + this.downloadingBundle;
                await this.webRequest.DownloadAsync(bundlePath);

                byte[] data          = this.webRequest.Request.downloadHandler.data;
                string path          = Path.Combine(PathHelper.AppHotfixResPath, this.downloadingBundle);
                string directoryName = Path.GetDirectoryName(path);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }
                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    fs.Write(data, 0, data.Length);
                    Debug.Log($"更新Bundle:{path} 完成");
                }
                var p = this.Progress;
                BundleRealProgress?.Invoke(p);
                Destroy(this.webRequest.gameObject);
                this.webRequest = null;
            }
            catch (Exception e)
            {
                Debug.LogError($"download bundle error: {this.downloadingBundle}\n{e}");
                //如果报错了,等1秒
                await UniTask.Delay(1);

                continue;
            }

            break;
        }
    }
Ejemplo n.º 17
0
 public void ShowBossWarningVFX(float t, UnityAction evt)
 {
     MonoBehaviourHelper.StartCoroutine(_BossWarningVFX(t, evt));
 }
Ejemplo n.º 18
0
 public void ShowBossTalkingVFX(float t, string str, UnityAction evt)
 {
     MonoBehaviourHelper.StartCoroutine(_BossTalkingVFX(t, str, evt));
 }
Ejemplo n.º 19
0
 void OnElimination(int num)
 {
     ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(true);
     ModuleManager.getInstance.GetModule <GuideModule>().Field.OnElimination -= OnElimination;
     MonoBehaviourHelper.StartCoroutine(GuideRunning(1, "好的,你已经将同样颜色的水块消除掉了,继续将所有的水块都消除", OnOpenClickPanel, OnStepFinish));
 }
Ejemplo n.º 20
0
 public override void StartGame() => MonoBehaviourHelper.Start(UpdateGameState());
Ejemplo n.º 21
0
        public void OnNext()
        {
            if (!_canClick)
            {
                return;
            }


            switch (_step)
            {
            //介绍游戏玩法
            case 0:
            {
                ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(true);
                MonoBehaviourHelper.StartCoroutine(GuideRunning(1, "介绍游戏玩法", OnStepFinish));
            }
            break;

            case 1:
            {
                MonoBehaviourHelper.StartCoroutine(GuideRunning(1, "介绍游戏玩法2", OnStepFinish));
            }
            break;

            //AP介绍
            case 2:
            {
                MonoBehaviourHelper.StartCoroutine(GuideRunning(1, "请点击有方向箭头的色块", OnStepFinish));
            }
            break;

            //点击移动
            case 3:
            {
                _clickMark.gameObject.SetActive(true);
                OnCloseBar();
                ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(false);
                OnCloseClickPanel();
                ModuleManager.getInstance.GetModule <BattlefieldInputModule>().onClickedTile += OnClickDirect;
            }
            break;

            //消除
            case 4:
            {
                OnCloseBar();
                ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(false);
                OnCloseClickPanel();
                ModuleManager.getInstance.GetModule <GuideModule>().Field.OnElimination += OnElimination;
            }
            break;

            //过关
            case 5:
            {
                OnCloseBar();
                OnCloseClickPanel();
                ModuleManager.getInstance.GetModule <BattlefieldInputModule>().Pause(false);
            }
            break;
                //case 6:
                //    {
                //        ModuleManager.getInstance.GetModule<BattlefieldInputModule>().Pause(false);
                //    }
                //    break;
            }

            _step++;
        }
Ejemplo n.º 22
0
    async Task LoadOneBundleAsync <T>(string assetBundleName) where T : UnityEngine.Object
    {
        //Log.Debug($"---------------load one bundle {assetBundleName}");
        ABInfo abInfo;

        if (this.bundles.TryGetValue(assetBundleName, out abInfo))
        {
            ++abInfo.RefCount;
            return;
        }


        if (this.cacheDictionary.ContainsKey(assetBundleName))
        {
            abInfo = this.cacheDictionary[assetBundleName];
            ++abInfo.RefCount;
            this.bundles[assetBundleName] = abInfo;
            this.cacheDictionary.Remove(assetBundleName);
            return;
        }


        if (!StaticData.isUseAssetBundle)
        {
#if UNITY_EDITOR
            //string[] realPath = null;
            //realPath = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);
            //foreach (string s in realPath)
            //{
            //    string assetName = Path.GetFileNameWithoutExtension(s);
            //    string path = $"{assetBundleName}/{assetName}".ToLower();
            //    T resource = AssetDatabase.LoadAssetAtPath<T>(s);
            //    this.resourceCache[path] = resource;
            //}

            this.bundles[assetBundleName] = new ABInfo(assetBundleName, null);
#endif
            return;
        }

        string      p           = Path.Combine(PathHelper.AppHotfixResPath, assetBundleName);
        AssetBundle assetBundle = null;
        if (!File.Exists(p))
        {
            p = Path.Combine(PathHelper.AppResPath, assetBundleName);
        }

        AssetsBundleLoaderAsync assetsBundleLoaderAsync = MonoBehaviourHelper.CreateTempComponent <AssetsBundleLoaderAsync>();
        assetBundle = await assetsBundleLoaderAsync.LoadAsync(p);

        if (assetBundle == null)
        {
            throw new Exception($"assets bundle not found: {assetBundleName}");
        }

        //if (!assetBundle.isStreamedSceneAssetBundle)
        //{
        //    // 异步load资源到内存cache住
        //    UnityEngine.Object[] assets;
        //    using (AssetsLoaderAsync assetsLoaderAsync = ComponentFactory.Create<AssetsLoaderAsync, AssetBundle>(assetBundle))
        //    {
        //        assets = await assetsLoaderAsync.LoadAllAssetsAsync<T>();
        //    }
        //    foreach (UnityEngine.Object asset in assets)
        //    {
        //        string path = $"{assetBundleName}/{asset.name}".ToLower();
        //        this.resourceCache[path] = asset;
        //    }
        //}

        this.bundles[assetBundleName] = new ABInfo(assetBundleName, assetBundle);
    }
Ejemplo n.º 23
0
    public async Task LoadOneBundleAsync(string assetBundleName, Action <float> actionProgress = null)
    {
        //Log.Debug($"---------------load one bundle {assetBundleName}");
        ABInfo abInfo;

        if (this.bundles.TryGetValue(assetBundleName, out abInfo))
        {
            //Log.Debug($"读取到已经有的Bundle: {assetBundleName}");
            ++abInfo.RefCount;
            return;
        }


        if (this.cacheDictionary.ContainsKey(assetBundleName))
        {
            abInfo = this.cacheDictionary[assetBundleName];
            ++abInfo.RefCount;
            this.bundles[assetBundleName] = abInfo;
            this.cacheDictionary.Remove(assetBundleName);
            return;
        }


        if (!StaticData.isUseAssetBundle)
        {
#if UNITY_EDITOR
            //ZLog.Info("UNITY_EDITOR LoadOneBundleAsync");
            string[] realPath = null;
            realPath = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName);
            //foreach (string s in realPath)
            //{
            //	string assetName = Path.GetFileNameWithoutExtension(s);
            //	string path = $"{assetBundleName}/{assetName}".ToLower();
            //	UnityEngine.Object resource = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(s);
            //	this.resourceCache[path] = resource;
            //}

            this.bundles[assetBundleName] = new ABInfo(assetBundleName, null);
#endif
            return;
        }

        string      p           = Path.Combine(PathHelper.AppHotfixResPath, assetBundleName);
        AssetBundle assetBundle = null;
        if (!File.Exists(p))
        {
            p = Path.Combine(PathHelper.AppResPath, assetBundleName);
        }

        AssetsBundleLoaderAsync assetsBundleLoaderAsync = MonoBehaviourHelper.CreateTempComponent <AssetsBundleLoaderAsync>();
        DontDestroyOnLoad(assetsBundleLoaderAsync.gameObject);
        assetBundle = await assetsBundleLoaderAsync.LoadAsync(p, actionProgress);

        Destroy(assetsBundleLoaderAsync.gameObject);

        if (assetBundle == null)
        {
            throw new Exception($"assets bundle not found: {p}");
        }
        if (!assetBundle.isStreamedSceneAssetBundle && assetBundleName == "StreamingAssets")
        {
            await LoadAssetAsync(assetBundleName, assetBundle, actionProgress);
        }

        this.bundles[assetBundleName] = new ABInfo(assetBundleName, assetBundle);
    }
Ejemplo n.º 24
0
 void SplitContext()
 {
     MonoBehaviourHelper.StartCoroutine(Split());
 }
Ejemplo n.º 25
0
 void GenerateHLODContext()
 {
     MonoBehaviourHelper.StartCoroutine(GenerateHLOD());
 }