コード例 #1
0
 /// <summary>
 /// 获取资源实例。
 /// </summary>
 /// <param name="resourceName">资源文件名(不带路径,带后缀)</param>
 /// <param name="loaded">资源实例加载完成回调</param>
 public static void GetCharacterInstance(string resourceName, Action <String, int, Object> loaded)
 {
     AssetCacheMgr.GetNoCacheInstance(resourceName, (pref, guid, go) =>
     {
         m_loadedCharacterResources.Add(resourceName);
         if (loaded != null)
         {
             loaded(pref, guid, go);
         }
     });
 }
コード例 #2
0
 public void LoadScene(string sceneName, Action callback = null)
 {
     AssetCacheMgr.GetNoCacheInstance(sceneName, (prefab, guid, obj) =>
     {
         m_currentScene = obj as GameObject;
         StaticBatchingUtility.Combine(m_currentScene);
         if (callback != null)
         {
             callback();
         }
     });
 }
コード例 #3
0
ファイル: NpcExportAgent.cs プロジェクト: mengtest/xxxxx
    void Start()
    {
        type         = "NPC";
        theTransform = transform;
        temp         = gameObject;

        if (AvatarModelData.dataMap == null)
        {
            GameDataControler.Init();
        }

        if (!AvatarModelData.dataMap.ContainsKey(mode_i) && mode_i != 150000)
        {
            Debug.Log("mode_i wrong: " + mode_i);
            return;
        }

        Debug.Log("mode_i: " + AvatarModelData.dataMap[mode_i].prefabName);

        if (mode_i != 150000)
        {
            AssetCacheMgr.GetNoCacheInstance(AvatarModelData.dataMap[mode_i].prefabName,
                                             (prefab, guid, go) =>
            {
                if (go == null)
                {
                    Debug.Log("prefabName wrong");
                }
                temp = go as GameObject;
                temp.transform.position = transform.position;
                temp.transform.rotation = transform.rotation;
            });
        }
        else
        {
            temp.transform.position = transform.position;
            temp.transform.rotation = transform.rotation;
        }

        mapx_i     = temp.transform.position.x;
        mapy_i     = temp.transform.position.z;
        rotation_l = (new Vector3(transform.rotation.x, transform.rotation.y, transform.rotation.z)).ToString();
    }
コード例 #4
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;
    }