Пример #1
0
 protected void DestoryMagma()
 {
     if (this && gameObject)
     {
         AssetCacheMgr.SynReleaseInstance(this.gameObject);
     }
 }
Пример #2
0
    internal virtual void ReleaseResources()
    {
        foreach (var item in m_comChildren)
        {
            item.Value.ReleaseResources();
        }
        m_comChildren.Clear();

        if (m_inited)
        {
            m_inited = false;
            OnRelease();
            ClearComponent();
            m_myTransform = null;
        }

        if (m_bInited == true)
        {
            AssetCacheMgr.SynReleaseInstance(m_myGameObject);
            m_myGameObject = null;
            AssetCacheMgr.ReleasesResource(Resources);
            m_bInited        = false;
            m_bShow          = false;
            m_bLoading       = false;
            m_loadedCallback = null;
        }
    }
Пример #3
0
    void OnDestroy()
    {
        TimerHeap.DelTimer(createMagmaTimer);
        TimerHeap.DelTimer(disbaleMagmaTimer);

        if (this && gameObject)
        {
            AssetCacheMgr.SynReleaseInstance(this.gameObject);
        }
    }
Пример #4
0
 private void ClearCache(List <T> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         var obj = list[i].gameObject;
         AssetCacheMgr.SynReleaseInstance(obj);
         list[i] = null;
     }
     list.Clear();
 }
Пример #5
0
    private void BombDestroy()
    {
        sfxHandler.RemoveFXs(500102);
        // sfxHandler.RemoveFXs(6011);

        if (this && this.gameObject)
        {
            AssetCacheMgr.SynReleaseInstance(this.gameObject);
        }
    }
Пример #6
0
    protected void DeleteBomb(int missionID = 0, bool Instance = false)
    {
        handler.RemoveFXs(500102);
        handler.RemoveFXs(6011);
        handler.RemoveFXs(6004);

        if (this && gameObject)
        {
            AssetCacheMgr.SynReleaseInstance(this.gameObject);
        }

        if (hitPosition != null)
        {
            Destroy(hitPosition.gameObject);
        }
    }
Пример #7
0
 public void OnDailyTaskPanelCloseButtonPressed()
 {
     Driver.Instance.StopAllCoroutines();
     EventDispatcher.TriggerEvent <GameObject>(Events.MogoUIManagerEvent.SetCurrentUI, m_MogoMainUIPanel);
     m_MogoMainUIPanel.SetActive(!m_MogoMainUIPanel.activeSelf);
     m_DailyTaskUIPanel.SetActive(!m_DailyTaskUIPanel.activeSelf);
     if (SystemSwitch.DestroyAllUI)
     {
         AssetCacheMgr.SynReleaseInstance(m_DailyTaskUIPanel);
         m_DailyTaskUIPanel = null;
         m_MogoMainUIPanel  = null;
         m_DailyTaskView    = null;
         m_DailyTaskFXRoot  = null;
         AssetCacheMgr.ReleasesResource(new string[] { "DailyTaskUI.prefab", "Task.prefab" });
         m_bBeenInited = false;
     }
 }
Пример #8
0
 void OnDestroy()
 {
     m_TaskName              = null;
     m_ExpAmount             = null;
     m_GoldAmount            = null;
     m_CurrentStep           = null;
     m_TaskIcon              = null;
     m_GetAwardButton        = null;
     m_AlreadyGetAwardButton = null;
     m_UnfinishedButton      = null;
     m_ProgressBar           = null;
     m_FinishedText          = null;
     if (m_FinishedFX != null)
     {
         DestroyImmediate(m_FinishedFX);
         m_FinishedFX = null;
     }
     if (m_GetAwardFX != null)
     {
         DestroyImmediate(m_GetAwardFX);
         m_GetAwardFX = null;
     }
     AssetCacheMgr.SynReleaseInstance(gameObject);
 }
Пример #9
0
    ///// <param name="bone_path">绑特效的骨骼,默认为空(即使用xml里面指定的骨骼)</param>
    //private void HandleNormalFX(int id, string bone_path = "")
    //{
    //    if (!FXData.dataMap.ContainsKey(id))
    //    {
    //        Debug.LogWarning(string.Format("Can not find fx {0}", id));
    //        return;
    //    }

    //    HandleFX(id, FXData.dataMap[id], bone_path);
    //}

    /// <param name="bone_path">绑特效的骨骼,默认为空(即使用xml里面指定的骨骼)</param>
    private void PlayFX(int id, FXData fx, Action <GameObject, int> action = null, string bone_path = "")
    {
        //HandleWeaponTrial(fx);
        HandleAnim(fx);
        HandleFade(fx);

        if (!string.IsNullOrEmpty(fx.shader))
        {
            HandleShaderFX(fx);
        }
        if (!string.IsNullOrEmpty(fx.dissonShader))
        {
            HandleDissonFx(fx);
        }
        if (string.IsNullOrEmpty(fx.resourcePath))
        {
            return;
        }

        //销毁自身冲突
        if (fx.isConflict == FXConflict.Conflict && m_fxDic.ContainsKey(id))
        {
            RemoveFXs(id);
        }

        //去除组内冲突
        if (fx.group != 0)
        {
            RemoveFXByGroup(fx.group);
        }

        //AssetCacheMgr.GetResourceAutoRelease(fx.resourcePath, (obj) =>
        AssetCacheMgr.GetNoCacheInstance(fx.resourcePath, (prefab, guid, obj) =>
        {
            m_loadedFX.Add(fx.resourcePath);
            //Debug.LogError("m_loadedFX.Add: " + fx.resourcePath + " " + m_loadedFX.Count);
            //var go = GameObject.Instantiate(obj) as GameObject;
            //var guid = go.GetInstanceID();
            var go = obj as GameObject;
            if (!go || !this)
            {
                AssetCacheMgr.SynReleaseInstance(go);
                return;
            }
            if (!m_fxDic.ContainsKey(id))
            {
                m_fxDic[id] = new Dictionary <int, GameObject>();
            }
            m_fxDic[id].Add(guid, go);
            //处理音效
            var audio = go.GetComponent <AudioSource>();
            if (audio != null)
            {
                if (SettingsUIViewManager.Instance != null)
                {
                    audio.volume = SoundManager.SoundVolume;
                }

                FrameTimerHeap.AddTimer((uint)fx.soundDelay, 0, () =>
                {
                    if (audio != null)
                    {
                        audio.enabled = true;
                    }
                });
            }
            switch (fx.locationType)
            {
            case FXLocationType.SelfSlot:

                // 判断输入路径是否指定,若未指定则绑在预设的骨上
                if (bone_path == "")
                {
                    if (!m_locationDic.ContainsKey(fx.slot))
                    {
                        m_locationDic.Add(fx.slot, GetBone(transform, fx.slot));
                    }
                    go.transform.parent = m_locationDic[fx.slot];
                }

                // 若已经指定则绑在指定的骨上
                else
                {
                    if (!m_locationDic.ContainsKey(bone_path))
                    {
                        m_locationDic.Add(bone_path, GetBone(transform, bone_path));
                    }
                    go.transform.parent = m_locationDic[bone_path];

                    // 记下index,以便删除
                    slotCueHandler.SetFxList(id, bone_path, guid);
                }

                go.transform.localPosition = go.transform.position;
                go.transform.localRotation = go.transform.rotation;
                break;

            case FXLocationType.World:
                go.transform.position = fx.location;
                break;

            case FXLocationType.SelfLocal:
                go.transform.parent = transform;
                //Debug.Log(go.transform.position.x + " " + go.transform.position.y + " " + go.transform.position.z);
                go.transform.localPosition = go.transform.position;
                go.transform.localRotation = go.transform.rotation;
                go.transform.forward       = transform.forward;
                break;

            case FXLocationType.SelfWorld:
                go.transform.localPosition = transform.localPosition;
                go.transform.localRotation = go.transform.rotation;
                go.transform.position      = transform.position;
                go.transform.forward       = transform.forward;
                break;

            case FXLocationType.SlotWorld:

                if (!m_locationDic.ContainsKey(fx.slot))
                {
                    m_locationDic.Add(fx.slot, GetBone(transform, fx.slot));
                }

                var solt = m_locationDic[fx.slot];
                go.transform.localPosition = solt.transform.localPosition;
                go.transform.position      = solt.transform.position;
                go.transform.localRotation = solt.transform.rotation;
                break;

            default:
                break;
            }
            if (fx.isStatic == FXStatic.NotStatic)
            {
                Action actRemove = () =>
                {
                    if (this)
                    {
                        RemoveFX(id, guid, fx.group);
                    }
                };
                if (fx.duration > 0)
                {
                    FrameTimerHeap.AddTimer((uint)(fx.duration * 1000), 0, actRemove);
                }
                else
                {
                    FrameTimerHeap.AddTimer(3000, 0, actRemove);
                }
            }
            else
            {
                //如果技能为静态技能,分组标记非0,而且特效绑定到自身
                if (fx.group != 0 && (fx.locationType == FXLocationType.SelfSlot || fx.locationType == FXLocationType.SelfLocal))
                {
                    if (!m_groupFXList.ContainsKey(fx.group))
                    {
                        m_groupFXList.Add(fx.group, new List <int>());
                    }
                    m_groupFXList[fx.group].Add(id);
                }
            }
            if (action != null)
            {
                action(go, guid);
            }
        });
        //    m_fxDic.Add(id, new Dictionary<int, GameObject>());

        //return go;
    }
Пример #10
0
 public void Release()
 {
     AssetCacheMgr.SynReleaseInstance(m_mogoSingleBtn.gameObject);
     subControls.Clear();
 }
Пример #11
0
    /// <summary>
    /// 动态创建格子
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="NewCount">需要创建的格子</param>
    /// <param name="parentTrans">格子的父节点</param>
    /// <param name="loaded">创建完成后的回调</param>
    public void SetGridLayout <T>(int NewCount, Transform parentTrans, Action loaded) where T : Component
    {
        // 计算显示宽度高度
        if (width == 0)
        {
            width = ColSize * UnitWidth + (ColSize - 1) * XMargin;
        }
        if (height == 0)
        {
            height = RowSize * UnitHeight + (RowSize - 1) * YMargin;
        }
        int PageSize = ColSize * RowSize;

        MaxPageIndex = (byte)(Math.Ceiling((double)NewCount / PageSize) - 1);

        // 计算最末尾点的位置
        CalLastPoint(NewCount);

        int curMemoryCount = MemoryDataList.Count; // 当前已经创建的格子数量

        // [1]当前缓存的格子数量小于需要创建的格子数量
        if (curMemoryCount < NewCount)
        {
            // 继续创建还需要创建的格子数量
            for (int index = curMemoryCount; index < NewCount; index++)
            {
                var uniqueID   = index;
                var curPage    = index / PageSize;
                var curIndex   = index % PageSize;
                var curRow     = curIndex / ColSize;
                var curCol     = curIndex % ColSize;
                var startPoint = new Vector2();

                startPoint = getStartPoint(curPage);
                zeroPoint  = Vector2.zero;

                AssetCacheMgr.GetUIInstance(PrefabName + ".prefab", (prefab, id, go) =>
                {
                    GameObject obj              = (GameObject)go;
                    obj.transform.parent        = parentTrans;
                    obj.transform.localPosition = new Vector3(startPoint.x
                                                              + (curCol * (XMargin + UnitWidth) + UnitWidth / 2) * IsOpposite
                                                              ,
                                                              startPoint.y
                                                              - (curRow * (YMargin + UnitHeight) + UnitHeight / 2) * IsOpposite
                                                              , 0.0f);
                    obj.transform.localScale = new Vector3(1, 1, 1);
                    if (!IsOneButton)
                    {
                        var btnList = obj.transform.GetComponentsInChildren <MogoButton>(true);
                        foreach (var single in btnList)
                        {
                            single.pressHandler += PressHandler;
                            single.dragHandler  += DragHandler;
                        }
                    }

                    UnityEngine.Component unit = obj.AddComponent <T>();
                    if (MemoryDataList.ContainsKey(uniqueID))
                    {
                        if (MemoryDataList[uniqueID] != null)
                        {
                            AssetCacheMgr.SynReleaseInstance(MemoryDataList[uniqueID].gameObject);
                        }
                    }
                    MemoryDataList[uniqueID] = unit;

                    if (MemoryDataList.Count >= NewCount)
                    {
                        ShowGrid(NewCount);
                        if (loaded != null)
                        {
                            loaded();
                        }
                    }
                });
            }
        }
        // [2]当前缓存的格子数量大于或等于需要创建的格子数量
        else
        {
            ShowGrid(NewCount);
            if (loaded != null)
            {
                loaded();
            }
        }
    }