Exemple #1
0
        public void GetResourceAsync(string path, BKAction <UnityEngine.Object> onComplete)
        {
            if (assetList.ContainsKey(path))
            {
                onComplete((assetList[path].RefTarget() as UnityEngine.Object));
                return;
            }

            var ab = GetAssetBundle(path);

            if (ab == null)
            {
                onComplete(null);
                return;
            }

            IResourceFile file = resourceTable.GetResourceFile(path);

            if (file == null)
            {
                BundleToAsset(path, file, ab, ab);
                onComplete(ab);
                return;
            }

            CoroutineMgr.StartCoroutine(DoGetResourceAsync(file, ab, onComplete));
        }
Exemple #2
0
    public override void OnEndDrag(PointerEventData eventData)
    {
        if (Status.REFRESH == state)
        {
            return;
        }

        base.OnEndDrag(eventData);

        if (Status.PULL == state)
        {
            refreshTip.pullTip.SetActive(false);
            refreshTip.releaseTip.SetActive(false);
            refreshTip.refreshTip.SetActive(true);
            state = Status.REFRESH;
            if (null != onTriggerRefresh)
            {
                CoroutineMgr.Start(delayOneSecond(() =>
                {
                    onTriggerRefresh();
                }));
            }
        }
        else
        {
            refreshTip.root.SetActive(false);
        }
    }
Exemple #3
0
        //录像出牌
        public virtual void Video_ChuCard(int card)
        {
            HideWinCard();
            _VideoHands.Remove(card);
            float animCardSize = 1f;

            if (ClientSeatIndex == 0)
            {
                animCardSize = 0.5f;
            }
            if (card == _VideoMoCardSize)
            {
                CoroutineMgr.StartCoroutinee(ChuCardAnimSound(card, _WinCard.gameObject.transform.position, animCardSize));
            }
            else
            {
                for (int i = 0; i < _liangCards.Count; i++)
                {
                    if (_liangCards[i].CardSize == card)
                    {
                        CoroutineMgr.StartCoroutinee(ChuCardAnimSound(card, _liangCards[i].gameObject.transform.position, animCardSize));
                        break;
                    }
                }
            }
            Video_RefreshHand();
        }
Exemple #4
0
 //显示碰杠信息
 private void ShowPengGangHnads()
 {
     ClearCards();//显示之前先清空一下牌
     //显示玩家的牌
     for (int i = 0; i < mData.PengGangInfos.Count; i++)
     {
         //碰杠的牌
         if (mData.PengGangInfos[i].OperateType == FiveStarOperateType.Peng)
         {
             ShowPengGang(mData.PengGangInfos[i].Card, 3);
         }
         else if (mData.PengGangInfos[i].OperateType == FiveStarOperateType.MingGang ||
                  mData.PengGangInfos[i].OperateType == FiveStarOperateType.AnGang ||
                  mData.PengGangInfos[i].OperateType == FiveStarOperateType.CaGang)
         {
             ShowPengGang(mData.PengGangInfos[i].Card, 4);
         }
     }
     //显示手牌
     ShowHand(mData.Hands);
     //如果是胡牌玩家还要显示赢的牌
     if (mData.PlayerResultType == FiveStarPlayerResultType.HuFangChong || mData.PlayerResultType == FiveStarPlayerResultType.ZiMoHu)
     {
         ShowHand(new RepeatedField <int>()
         {
             mData.WinCard
         });
     }
     //因为 UI布局不是实时生效 所以先隐藏 在显示就OK了
     CoroutineMgr.StartCoroutinee(AwaitShowHandGroups());
 }
Exemple #5
0
        public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish)
        {
            string cache_asset = "";

            if (!_params.TryGetValue("cache_asset", out cache_asset))
            {
                Log.Error("Play2D", "need params cache_asset");
                return;
            }

            string track = "";

            if (!_params.TryGetValue("track", out track))
            {
                Log.Error("Play2D", "need params track");
                return;
            }

            int track_ = int.Parse(track);

            try
            {
                byte[]    bytes = UGCMgr.Take(cache_asset);
                AudioClip clip  = UGC.Audio.WAVUtil.BuildAudioClip(bytes);
                CoroutineMgr.Start(play2DSound(clip, track_, _onFinish));
            }
            catch (System.Exception e)
            {
                Log.Error("Play2dSound", "Parse json hsa error:" + e.Message);
            }
        }
    public override Vector2 GetNextWaypointPos()
    {
        if (isHitting || isCooldown)
        {
            return(transform.position);
        }

        if (playerInRange)
        {
            Vector2 moveDir = (Vector2)player.transform.position - (Vector2)transform.position;
            moveDir.y = 0;
            moveDir   = moveDir.normalized;

            // If enemy isn't moving in the same direction, wait
            if (!Utils.SameSign(moveDir.x, lastMoveDir.x))
            {
                CoroutineMgr.Start(StartCooldown(0.25f));
            }

            lastMoveDir = moveDir;
            Vector2 testLoc = (Vector2)testPoint.transform.position + moveDir;

            Collider2D Col = Physics2D.OverlapPoint(testLoc);
            if (Col == null || Col.isTrigger)
            {
                return(transform.position);
            }

            return(player.transform.position);
        }

        return(base.GetNextWaypointPos());
    }
Exemple #7
0
        public void GetResourceAsync <T>(string path, BKAction <T> onComplete) where T : UnityEngine.Object
        {
            if (assetList.ContainsKey(path))
            {
                onComplete((T)(assetList[path].RefTarget()));
                return;
            }

            var ab = GetAssetBundle(path);

            if (ab == null)
            {
                onComplete(default(T));
                return;
            }

            IResourceFile file = resourceTable.GetResourceFile(path);

            if (file == null)
            {
                BundleToAsset(path, file, ab, ab);
                onComplete((T)Convert.ChangeType(ab, typeof(T)));
                return;
            }

            CoroutineMgr.StartCoroutine(DoGetResourceAsync <T>(file, ab, onComplete));
        }
 //发牌操作
 private void Deal(Video_Deal deal)
 {
     for (int i = 0; i < deal.AllHands.Count; i++)
     {
         _Coroutines[i + 1] = CoroutineMgr.StartCoroutinee(_PlayerDic[i].Video_Deal(deal.AllHands[i]));
         ReduceCardTotalNum(deal.AllHands[i].Count);
     }
 }
Exemple #9
0
 void Awake()
 {
     Log.Init();
     Debug.Log("Init bookrpg Application");
     DontDestroyOnLoad(this);
     CoroutineMgr.Init(this);
     MessageMgr.messagePacker = new MessagePacker();
 }
Exemple #10
0
        static void DebugFile(string file_name, VM vm, int port)
        {
            //Console.WriteLine(Environment.CurrentDirectory);
            Console.WriteLine($"Simple Script {VM.Version}");
            try
            {
                var func = vm.Parse(File.ReadAllText(file_name), file_name);

                if (port > 0)
                {
                    TcpListener serverSocket = new TcpListener(IPAddress.Parse("127.0.0.1"), port);
                    serverSocket.Start();
                    Console.WriteLine("DebugMode: Listen At {0}", port);

                    var socket = serverSocket.AcceptSocket();
                    if (socket != null)
                    {
                        Console.WriteLine("DebugMode: Build Connect With {0}", socket.RemoteEndPoint);
                        using (var stream = new NetworkStream(socket))
                        {
                            var pipe = new SimpleScript.DebugProtocol.NetServerPipe(stream);
                            vm.m_hooker.SetPipeServer(pipe);
                            vm.m_hooker.SetBreakMode(SimpleScript.DebugProtocol.BreakMode.StopForOnce);
                            vm.CallFunction(func);
                            // 测试协程,当成是事件循环也行
                            Console.WriteLine("Loop update for coroutine, You can close program to Exit!!");
                            while (true)
                            {
                                CoroutineMgr.Update();
                                System.Threading.Thread.Sleep(10);
                            }
                        }
                    }
                }
                else
                {
                    var pipe = new IOPipe();
                    vm.m_hooker.SetPipeServer(pipe);
                    vm.m_hooker.SetBreakMode(SimpleScript.DebugProtocol.BreakMode.StopForOnce);
                    vm.CallFunction(func);

                    // 测试协程,当成是事件循环也行
                    Console.WriteLine("Loop update for coroutine, You can close program to Exit!!");
                    while (true)
                    {
                        CoroutineMgr.Update();
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("Press Any Key To Exit");
            Console.ReadKey(true);
        }
Exemple #11
0
    static CoroutineMgr GetInstance()
    {
        if (Mgr == null)
        {
            GameObject CoroutineMgrObject = new GameObject("Coroutine Manager");
            DontDestroyOnLoad(CoroutineMgrObject);

            Mgr = CoroutineMgrObject.AddComponent <CoroutineMgr>();
        }

        return(Mgr);
    }
Exemple #12
0
        public override void StartGame(params object[] objs)
        {
            //参数1.List<object> 小局操作信息
            base.StartGame();
            Log.Debug("进入游戏卡五星录像");
            FiveStarVideoRoom cardFiveStarRoom = Game.Scene.AddComponent <FiveStarVideoRoom>();

            UIComponent.GetUiView <CardFiveStarRoomPanelComponent>().Show();
            UIComponent.GetUiView <CardFiveStarRoomPanelComponent>().CutWatchVideoInUI();
            UIComponent.GetUiView <CardFiveStarVideoPanelComponent>().Show();
            cardFiveStarRoom._Coroutines[0] = CoroutineMgr.StartCoroutinee(cardFiveStarRoom.StarPlay(objs[0] as List <object>));
        }
Exemple #13
0
    public static void Test()
    {
        TestWWW      test         = new TestWWW();
        CoroutineMgr coroutineMgr = new CoroutineMgr();

        coroutineMgr.StartCoroutine(test.TestWWWCoroutine());
        while (true)
        {
            coroutineMgr.Update();
            Thread.Sleep(33);
        }
    }
Exemple #14
0
 //SVMAPI
 public static void Play(string _cache_asset, int _track, SVMAPI.FinishDelegate _onFinish)
 {
     try
     {
         byte[]    bytes = UGCMgr.Take(_cache_asset);
         AudioClip clip  = UGC.Audio.WAVUtil.BuildAudioClip(bytes);
         CoroutineMgr.Start(play2DSound_SVMAPI(clip, _track, _onFinish));
     }
     catch (System.Exception e)
     {
         Log.Error("Play2dSound", "Parse json hsa error:" + e.Message);
     }
 }
Exemple #15
0
        private static void punchRotation(GameObject _go, Vector3 _position, float _duration, ActionDelegate _onFinish)
        {
            Hashtable hash = new Hashtable();

            hash.Add("amount", _position);
            hash.Add("time", _duration);

            iTween.PunchRotation(_go, hash);

            CoroutineMgr.Start(wait(_duration, () =>
            {
                _onFinish();
            }));
        }
Exemple #16
0
        public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish)
        {
            string duration = "0";

            if (!_params.TryGetValue("duration", out duration))
            {
                Log.Error("ActionMgr", "need params duration");
                return;
            }

            float timer = float.Parse(duration);

            CoroutineMgr.Start(sleep(timer, _onFinish));
        }
Exemple #17
0
        public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish)
        {
            string package = "";

            if (!_params.TryGetValue("package", out package))
            {
                Log.Error("Play2D", "need params package");
                return;
            }

            string file = "";

            if (!_params.TryGetValue("file", out file))
            {
                Log.Error("Play2D", "need params file");
                return;
            }

            string track = "";

            if (!_params.TryGetValue("track", out track))
            {
                Log.Error("Play2D", "need params track");
                return;
            }

            int track_ = int.Parse(track);

            try
            {
                ResourceMgr.LoadAudioClip(package, file, track_
                                          , () =>
                {
                    Log.Debug("Play2D", "ready");
                }
                                          , (_audioclip) =>
                {
                    AudioClip clip = _audioclip as AudioClip;
                    CoroutineMgr.Start(play2DSound(clip, track_, _onFinish));
                }
                                          , (_error) =>
                {
                    Log.Error("Play2D", _error);
                });
            }
            catch (System.Exception e)
            {
                Log.Error("Play2dSound", "Parse json hsa error:" + e.Message);
            }
        }
Exemple #18
0
        private static void scaleTo(GameObject _go, Vector3 _scale, float _duration, ActionDelegate _onFinish)
        {
            Hashtable hash = new Hashtable();

            hash.Add("easeType", iTween.EaseType.linear);
            hash.Add("scale", _scale);
            hash.Add("time", _duration);

            iTween.ScaleTo(_go, hash);

            CoroutineMgr.Start(wait(_duration, () =>
            {
                _onFinish();
            }));
        }
Exemple #19
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == Tags.Player)
        {
            collision.gameObject.GetComponent <PlayerController>()?.OnPortalEnter();

            Destroy(collision.gameObject);

            GameObject partObj = ObjectPool.Alloc(PortalParticles);
            partObj.transform.position = transform.position;
            partObj.transform.rotation = transform.rotation;

            CoroutineMgr.Start(WaitAndLoadNextLevel());
        }
    }
        public void Show(GameObject cardGo, int yaxleOfset)
        {
            if (_AnimCoroutine != null)
            {
                CoroutineMgr.StopCoroutinee(_AnimCoroutine);
            }

            JianTouGo.gameObject.SetActive(true);
            JianTouGo.transform.SetParent(UIComponent.GetUiView <CardFiveStarRoomPanelComponent>().gameObject.transform);
            JianTouGo.transform.localScale = Vector3.one;
            JianTouGo.transform.SetParent(cardGo.transform);
            _offsetVector3.y = yaxleOfset;
            JianTouGo.transform.localPosition = Vector3.zero + _offsetVector3;
            _AnimCoroutine = CoroutineMgr.StartCoroutinee(JinaTouAnim());
        }
Exemple #21
0
        private static void lookFrom(GameObject _go, Vector3 _position, float _duration, ActionDelegate _onFinish)
        {
            Hashtable hash = new Hashtable();

            hash.Add("easeType", iTween.EaseType.linear);
            hash.Add("looktarget", _position);
            hash.Add("time", _duration);

            iTween.LookFrom(_go, hash);

            CoroutineMgr.Start(wait(_duration, () =>
            {
                _onFinish();
            }));
        }
Exemple #22
0
        private static void rotateAdd(GameObject _go, Vector3 _rotation, float _duration, ActionDelegate _onFinish)
        {
            Hashtable hash = new Hashtable();

            hash.Add("easeType", iTween.EaseType.linear);
            hash.Add("amount", _rotation);
            hash.Add("time", _duration);

            iTween.RotateAdd(_go, hash);

            CoroutineMgr.Start(wait(_duration, () =>
            {
                _onFinish();
            }));
        }
Exemple #23
0
        public virtual void Load(bool useCache = true, bool useBackupUrl = false)
        {
            #if RES_EDITOR
            gameObject = AssetDatabase.LoadMainAssetAtPath("Assets/" + url) as GameObject;
            #else
            if (isComplete || www != null || assetBundle != null)
            {
                throw new InvalidOperationException("Don't reuse Loader");
            }

            this.useCache = useCache;
            if (startTime == 0f)
            {
                startTime = Time.time;
            }
            lastProgressTime = Time.time;
            lastProgress     = 0f;
            isComplete       = false;
            string strUrl;

            if (useBackupUrl)
            {
                strUrl = GetActualUrl(url, backupBaseUrl);
                if (!string.IsNullOrEmpty(baseUrl) &&
                    !string.IsNullOrEmpty(backupBaseUrl) &&
                    strUrl.Contains(baseUrl))
                {
                    strUrl = strUrl.Replace(baseUrl, backupBaseUrl);
                }
            }
            else
            {
                strUrl = GetActualUrl(url, baseUrl);
            }

            actualUrl = strUrl;

            Log.Debug(logTag, string.Format("{4} load from {0}: {1}, version: {2}, useCache: {3}",
                                            useBackupUrl ? "backup url" : "url", strUrl, version, useCache,
                                            retryCount > 0 ? retryCount.ToString() + "st retry" : "Start"));

            CoroutineMgr.StartCoroutine(DoLoad(strUrl));
            #endif
        }
Exemple #24
0
    public override void OnDie()
    {
        AudioManager.PlaySfx(AudioEffects.PlayerDie);

        SpawnParticles(deathParticle);
        Gib.SpawnRandomGibs(transform.position, 5);

        GameGUI?.SetRickHealth(0);
        GameGUI?.AddScore(-10);

        gameObject.SetActive(false);
        vcam.enabled = false;

        // TODO: Coroutines
        //Respawn();
        //StartCoroutine(DelayAndRespawn());

        CoroutineMgr.Start(DelayAndRespawn());
    }
Exemple #25
0
        protected virtual void DoCompleted()
        {
            isComplete = true;

            CoroutineMgr.StopCoroutine("doLoad");

            timeElapsed = Time.time - startTime;

            isCacheHit = www != null && www.size == 0 && www.assetBundle != null;
            if (isCacheHit)
            {
                Log.Debug(logTag, string.Format("Cache hit, url: {0}, version: {1}", actualUrl, version));
            }
            else
            {
                Log.Debug(logTag, string.Format(
                              "Load complete, url: {3}, version: {2}, time: {0}s, bytesLoaded: {1}, retryCount: {5}, error: {4}",
                              timeElapsed, bytesLoaded, version, url, !hasError ? "no" : error, retryCount));
            }

            if (!hasError && www != null)
            {
                _bytesLoaded = isCacheHit ? size : www.bytesDownloaded;

                if (www.assetBundle != null)
                {
                    orgAssetBundle = www.assetBundle;
                    assetBundle    = new ResourceBundle(orgAssetBundle);
                    //only retain assetBundle, to save memery
                    if (onlyRetainAssetBundle)
                    {
                        www.Dispose();
                        www = null;
                    }
                }
            }
            else
            {
                _bytesLoaded = 0;
            }

//            onComplete.InvokeAndRemove(this);
        }
Exemple #26
0
        /// <summary>
        /// Use by LoaderMgr, usually user need't use it
        /// </summary>
        public virtual void DisposeImmediate()
        {
            if (www != null)
            {
                if (orgAssetBundle != null)
                {
//                    orgAssetBundle.Unload(false);
                    orgAssetBundle = null;
                    assetBundle.Dispose();
                    assetBundle = null;
                }
                www.Dispose();
                www = null;
            }
            customData = null;
            CoroutineMgr.StopCoroutine("doLoad");
            hasDisposed = true;
            GC.SuppressFinalize(this);
        }
Exemple #27
0
        public void GetAllResourcesAsync <T>(string path, BKAction <T[]> onComplete) where T : UnityEngine.Object
        {
            IResourceFile file = resourceTable.GetResourceFile(path);

            if (file != null && file.singleDirectResource && assetList.ContainsKey(file.srcFile))
            {
                onComplete(new T[] { (T)assetList[file.srcFile].RefTarget() });
                return;
            }

            var ab = GetAssetBundle(path);

            if (ab == null)
            {
                return;
            }

            CoroutineMgr.StartCoroutine(DoGetAllResourcesAsync <T>(ab, onComplete));
        }
Exemple #28
0
        public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish)
        {
            string durationStr = "";

            if (!_params.TryGetValue("duration", out durationStr))
            {
                Log.Error("Move", "need params duration");
                return;
            }
            float duration = float.Parse(durationStr);

            try
            {
                CoroutineMgr.Start(move(duration, _onFinish));
            }
            catch (System.Exception e)
            {
                Log.Error("VRPushByTime", "Parse json has error: " + e.Message);
            }
        }
 //清空面板和协程还要所有玩家的牌
 public void ClearUIAndCoroutine()
 {
     for (int i = 0; i < _Coroutines.Length; i++)
     {
         if (_Coroutines[i] != null)
         {
             CoroutineMgr.StopCoroutinee(_Coroutines[i]);
         }
     }
     //隐藏明牌提示面板 和漂分面板 还要小结算面板
     UIComponent.GetUiView <FiveStarMingPaiHintPanelComponent>().Hide();
     UIComponent.GetUiView <SelectPiaoNumPanelComponent>().Hide();
     UIComponent.GetUiView <FiveStarSmallResultPanelComponent>().Hide();
     //隐藏所有牌 和漂分
     foreach (var player in _PlayerDic)
     {
         player.Value.HideAllCard();
         player.Value._PlayerHead.HidePiaoNum();
     }
 }
        //出牌
        public override void ChuCard(int card)
        {
            Vector3 playCardPoint;

            if (CardFiveStarHandComponent.Ins._DragPlayPoint != Vector3.zero)//如果拖动出牌的 位置 不是0 就用拖动出牌的位置
            {
                playCardPoint = CardFiveStarHandComponent.Ins._DragPlayPoint;
                CardFiveStarHandComponent.Ins._DragPlayPoint = Vector3.zero;
            }
            else if (CardFiveStarHandComponent.Ins.UpChuCardHand != null)
            {
                playCardPoint = CardFiveStarHandComponent.Ins.UpChuCardHand.gameObject.transform.position;
            }
            else
            {
                playCardPoint = CardFiveStarHandComponent.Ins._NewHand.gameObject.transform.position;
            }
            CardFiveStarHandComponent.Ins.ChuCard(card);//UpChuCardHand 可能为空 这个方法会判断并赋值
            CoroutineMgr.StartCoroutinee(ChuCardAnimSound(card, playCardPoint, 0.5f));
        }