예제 #1
0
 private void Update()
 {
     if (_run == -1)
     {//游戏结束
         Debug.LogWarning("==========游戏结束清理资源开始=============");
         _run = 0;
         StopAllCoroutines();       //结束所有携程
         AssetbundleLoader.Clear(); //释放资源
         EndNetWork();
         method        = null;
         method_update = null;
         method_out    = null;
         appdomain     = null;
         Debug.LogWarning("==========游戏结束清理资源结束=============");
     }
     else if (_run == 100)
     {
         Debug.LogWarning("==========开始加载游戏=============");
         load_game(gamename);
     }
     else if (_run > 0)
     {
         if (network != null)
         {
             network.Update();
         }
         appdomain.Invoke(method_update, null, null);
     }
 }
예제 #2
0
    public override void OnExit(System.Action callback)
    {
        //캐릭터 정보도 다삭제
        var enumerator = townUnitList.GetEnumerator();

        while (enumerator.MoveNext())
        {
            Destroy(enumerator.Current.Value);
        }
        townUnitList.Clear();

        if (CameraManager.instance.mainCamera.gameObject.GetComponentInChildren <ColorCorrectionCurves> ())
        {
            CameraManager.instance.mainCamera.gameObject.GetComponentInChildren <ColorCorrectionCurves> ().enabled = false;
        }
        CameraManager.instance.mainCamera.clearFlags = CameraClearFlags.Skybox;

        //< 마을에서 사용했던 리소스들은 삭제
        AssetbundleLoader.ClearAssetList();
        SoundManager.instance.Clean();

        effectPool.SetDestroy();

        UIHelper.SetMainCameraActive(true);
        base.OnExit(callback);

        TownActive = false;

        //StructureMgr.instance.DemolishAll();
        //NetData.instance.VillageUnitDic.Clear();
    }
예제 #3
0
    private void load_game(string game)
    {
        Screen.orientation = ScreenOrientation.Portrait;
        if (_run == -1)
        {                              //游戏结束
            Debug.LogWarning("==========游戏开始但是上一次没有清理资源=============");
            AssetbundleLoader.Clear(); //释放资源
            EndNetWork();
            method        = null;
            method_update = null;
            method_out    = null;
            appdomain     = null;
        }
        _run = 0;

#if UNITY_EDITOR || UNITY_ANDROID
        data_path = Application.persistentDataPath;
#elif UNITY_IOS
        data_path = Application.temporaryCachePath;
#endif

        epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

        Debug.Log("开始加载游戏:" + data_path);
        //===ab初始化====
        AssetbundleLoader.Init(data_path, game);
        //===加载热更新代码===
        LoadHotFixAssembly(game);
        Debug.Log("启动完成");
    }
예제 #4
0
    protected override void ComputeComponents()
    {
        base.ComputeComponents();

        float modelX = 1.43f; // comData.dataInfo.modelX;
        float modelY = 1.9f;  // comData.dataInfo.modelY;
        float modelZ = 1.43f; // comData.dataInfo.modelZ;

        navAgent.radius = (modelX / 2) * Model.OriginalScale;
        navAgent.height = modelY * Model.OriginalScale;
        //navAgent.baseOffset = CharInfo.AirHeight;
        navAgent.baseOffset = 0f;

        UnitCollider        = gameObject.GetComponent <BoxCollider>();
        UnitCollider.size   = Vector3.Scale(new Vector3(modelX, modelY, modelZ), Model.ScaleVec3);
        UnitCollider.center = new Vector3(UnitCollider.center.x, UnitCollider.size.y * 0.5f, UnitCollider.center.z);

        if (GameDefine.skillPushTest)
        {
            if (syncData._isPartner)
            {
                //파트너면 CapsuleColider를 꺼줌
                CapsuleCollider colider = gameObject.GetComponent <CapsuleCollider>();
                colider.enabled = false;
            }
        }

        if (syncData._isPartner)
        {
            gameObject.layer = LayerMask.NameToLayer("Unit");
        }

        Radius = navAgent.radius;
        Height = UnitCollider.size.y;

        AddShadow(new Vector3(UnitCollider.size.x, UnitCollider.size.z, 1));

        // RootMotion을 위한 셋팅
        if (rootMotion != null)
        {
            string AniRMName = "";

            if (syncData._isPartner)
            {
                AniRMName = _LowDataMgr.instance.GetPartnerInfo(syncData._partnerID).prefab;
            }
            else
            {
                AniRMName = _LowDataMgr.instance.GetLowDataCostumeInfo(syncData._CostumeItem).Bodyprefab;
            }

            AssetbundleLoader.GetRMCurves(AniRMName, (dic) =>
            {
                rootMotion.Init(dic, transform, Animator.Animation, Model.FindAndCaching("Bip001"));
            });
        }
    }
예제 #5
0
    void OnLevelWasLoaded(int level)
    {
        if (Application.loadedLevelName != "maintown")
        {
            return;
        }

        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        long time1 = SceneManager.instance.showStopWatchTimer("MainTown scene loaded,  TownState.OnLevelWasLoaded start");

        ResourceMgr.Clear();

        bAddtiveSceneLoadFinish = false;

        NativeHelper.instance.DisableNavUI();

        TownActive = true;

        //< 인게임에서 사용했던 리소스들도 삭제
        AssetbundleLoader.ClearAssetList();
        SoundManager.instance.Clean();

        //< 맵 로드
        IsMapLoad = true;

        SceneSetting();

        SetupMainCamera(true, GAME_MODE.NONE);

        effectPool = PoolManager.Pools["Effect"];

        //CameraManager.instance.mainCamera.GetComponent<CameraMouseZoom>().SetInitPos();

        MapEnvironmentSetting(Application.loadedLevelName);         // move to here.

        sendQueryForHeroAndTown();

        // 여기서 컷씬플레이여부 비교판단 해야함.
//		if (NeedPlayTownCutScene ()) {
//			return;
//		}

        StartCoroutine(OnLevelWasLoaded2Part1());
        StartCoroutine(OnLevelWasLoaded2Part2());

        long time2 = SceneManager.instance.showStopWatchTimer("TownState.OnLevelWasLoaded end");

        Debug.Log("<color=green>[StopWatch]</color> OnLevelLoaded take time " + ((time2 - time1) / 1000f));
        sw.Stop();
    }
예제 #6
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(Screen.width / 2, 100, 100, 100), "create"))
     {
         bundle = AssetbundleLoader.LoadAssetBundleDependcy("Examples/ABResources/Prefab/Character/Cha_Bow_003.prefab");
         GameObject go = AssetbundleLoader.LoadRes <GameObject>("Cha_Bow_003", bundle);
         character = GameObject.Instantiate(go);
     }
     if (GUI.Button(new Rect(Screen.width / 2, 200, 100, 100), "destroy"))
     {
         if (character != null && bundle != null)
         {
             GameObject.Destroy(character);
             //bundle.Unload(true);
         }
         Resources.UnloadUnusedAssets();
     }
 }
예제 #7
0
    public static void SpawnProjectTile(string prefabName, Transform parent, System.Action <GameObject> call)
    {
        if (!G_GameInfo.ProjectilePool.prefabs.ContainsKey(prefabName))
        {
            if (ProjectTileLoads.ContainsKey(prefabName))
            {
                ProjectTileLoads[prefabName].Add(call);
                return;
            }

            ProjectTileLoads.Add(prefabName, new List <System.Action <GameObject> >());
            ProjectTileLoads[prefabName].Add(call);

            //< 프로젝트타일 가져오기
            AssetbundleLoader.GetProjectTile(prefabName, (tile) =>
            {
                CreatePoolItem(_GameInfo.projectilePool, tile);
                //SpawnProjectTile(prefabName, parent, call);

                GameObject projectobj = G_GameInfo.ProjectilePool.Spawn(prefabName, parent.position, parent.rotation, parent).gameObject;

                //< 레이어 설정
                NGUITools.SetChildLayer(projectobj.transform, parent.gameObject.layer);

                for (int i = 0; i < ProjectTileLoads[prefabName].Count; i++)
                {
                    ProjectTileLoads[prefabName][i](projectobj);
                }

                ProjectTileLoads[prefabName].Clear();
                ProjectTileLoads.Remove(prefabName);
            });
        }
        else
        {
            GameObject projectobj = G_GameInfo.ProjectilePool.Spawn(prefabName, parent.position, parent.rotation, parent).gameObject;

            //< 레이어 설정
            NGUITools.SetChildLayer(projectobj.transform, parent.gameObject.layer);

            call(projectobj);
        }
    }
예제 #8
0
        static StackObject *InstantiateGameObject_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.String suffix = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String path = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String bundle_name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = AssetbundleLoader.InstantiateGameObject(bundle_name, path, suffix);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
예제 #9
0
    protected override void ComputeComponents()
    {
        base.ComputeComponents();

        //UnitLowData.DataInfo _data = LowDataMgr.GetUnitData(comData.Info.UnitId);
        float ModelX = 1.43f; // _data.modelX;
        float ModelY = 1.9f;  //  _data.modelY;
        float ModelZ = 1.43f; // _data.modelZ;

        navAgent.radius = (ModelX > ModelZ ? ModelX / 2 : ModelZ / 2) * Model.OriginalScale;
        navAgent.height = ModelY * Model.OriginalScale;

        BoxCollider collider = gameObject.GetComponent <BoxCollider>();

        UnitCollider    = collider;
        collider.size   = Vector3.Scale(new Vector3(ModelX * 0.9f, ModelY, ModelZ * 0.9f), Model.ScaleVec3);
        collider.center = new Vector3(UnitCollider.center.x, (collider.size.y * 0.5f), UnitCollider.center.z);

        Radius = navAgent.radius;
        Height = collider.size.y;

        //< 보스라면 안밀리도록 처리
        if (UnitType == global::UnitType.Boss || isMiddleBoss)
        {
            navAgent.avoidancePriority = 20;
            collider.isTrigger         = true;
        }

        AddShadow(new Vector3(Mathf.Max(collider.size.x, Model.OriginalScale), Mathf.Max(collider.size.z, Model.OriginalScale), 1));


        // RootMotion을 위한 셋팅
        if (rootMotion != null)
        {
            AssetbundleLoader.GetRMCurves(npcInfo.prefab, (dic) =>
            {
                rootMotion.Init(dic, transform, Animator.Animation, Model.FindAndCaching("Bip001"));
            });
        }
    }
예제 #10
0
    private void AssetbundmgrSet()
    {
        if (assetlist.Count > 0)
        {
            //AssetbundleLoader.AddRealAssetName(assetlist[0], System.Text.RegularExpressions.Regex.Replace(assetlist[0], "[#][0-9]{10,}", ""));

            string firstStr = assetlist[0].Split('^')[0];
            AssetbundleLoader.AddRealAssetName(firstStr.Substring(0, firstStr.LastIndexOf(".")), assetlist[0]);

            assetlist.RemoveAt(0);
            if (assetlist.Count > 0)
            {
                TempUtil.StartCoroutine(DownAssetFileCo(assetlist[0]));
            }
        }

        if ((file_count == localcount) && isLoad == false)
        {
            isLoad = true;
            //foreach (string tem in soundassetlist)
            //{
            //Debug.Log(tem);
            //}

            //for (int a_nn = 0; a_nn < Rc_SoundMgr.instance.g_SoundABNameList.Count; a_nn++)
            //{
            //    if (Rc_SoundMgr.instance.g_SoundABNameList[a_nn] == null)
            //        continue;

            //    Debug.Log(Rc_SoundMgr.instance.g_SoundABNameList[a_nn]);
            //}

            if (www != null)
            {
                www.Dispose();
            }
        }
    }
예제 #11
0
 public static void SkeletonLoadFromName(string name, System.Action <GameObject> loadedCallback)
 {
     AssetbundleLoader.AssetLoad("Skeleton_" + name, loadedCallback);
 }
예제 #12
0
 public static void SkillEffectLoadFromName(string name, System.Action <GameObject> loadedCallback)
 {
     AssetbundleLoader.AssetLoad(name, loadedCallback);
 }
예제 #13
0
 public void LoadEnemyPrefabs()
 {
     StartCoroutine(AssetbundleLoader.LoadResOfType <GameObject>("prefabs/enemyprefabs", this));
 }
예제 #14
0
 public void LoadTowerPrefabsAndTowerIconSprite()
 {
     StartCoroutine(AssetbundleLoader.LoadResOfType <GameObject>("prefabs/towerprefabs", this));
     StartCoroutine(AssetbundleLoader.LoadResOfType <Sprite>("icons/towericons", this));
 }
예제 #15
0
 private void DoInit()
 {
     StartCoroutine(AssetbundleLoader.LoadResOfType <Sprite>("icons/techtreeicons", this));
     StartCoroutine(waitForAssetsLoad());
 }
예제 #16
0
 public void LoadEnemyIconPrefabs()
 {
     StartCoroutine(AssetbundleLoader.LoadResOfType <Sprite>("icons/enemyicons", this));
 }