Exemple #1
0
    private GameObject _GetPooledGameObjLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos, Quaternion rot, bool useRotation, out bool isInit)
    {
        string realPath = null;

        isInit = false;
        if (this.m_resourcesNotExist.ContainsKey(prefabName))
        {
            return(null);
        }
        this.GetPrefabLOD <GameObject>(prefabName, isParticle, out realPath);
        GameObject obj2 = null;

        if (useRotation)
        {
            obj2 = Singleton <CGameObjectPool> .GetInstance().GetGameObject(realPath, pos, rot, enResourceType.BattleScene, out isInit);
        }
        else
        {
            obj2 = Singleton <CGameObjectPool> .GetInstance().GetGameObject(realPath, pos, enResourceType.BattleScene, out isInit);
        }
        if (obj2 != null)
        {
            obj2.transform.SetParent(this.rootObjs[(int)sceneObjType].transform);
            obj2.transform.position = pos;
        }
        return(obj2);
    }
Exemple #2
0
    public GameObject Spawn(string name, SceneObjType sceneObjType, VInt3 position, VInt3 forward)
    {
        GameObject gameObject          = null;
        string     fullPathInResources = this.emptyActorPrefabs[(int)sceneObjType];

        if (fullPathInResources != null)
        {
            GameObject content = Singleton <CResourceManager> .GetInstance().GetResource(fullPathInResources, typeof(GameObject), enResourceType.BattleScene, true, false).m_content as GameObject;

            gameObject = Singleton <CGameObjectPool> .GetInstance().GetGameObject(fullPathInResources, enResourceType.BattleScene);

            if ((gameObject != null) && (content != null))
            {
                gameObject.layer = content.layer;
                gameObject.tag   = content.tag;
            }
        }
        else
        {
            gameObject = new GameObject();
        }
        gameObject.name = name;
        gameObject.transform.position = (Vector3)position;
        gameObject.transform.rotation = Quaternion.LookRotation((Vector3)forward);
        gameObject.transform.parent   = this.rootObjs[(int)sceneObjType].transform;
        return(gameObject);
    }
Exemple #3
0
 public void AddToRoot(GameObject obj, SceneObjType sceneObjType)
 {
     if (obj != null)
     {
         obj.transform.parent = this.rootObjs[(int)sceneObjType].transform;
     }
 }
Exemple #4
0
    public GameObject Spawn(string name, SceneObjType sceneObjType)
    {
        GameObject obj2;

        return(new GameObject {
            name = string.Format("{0}({1})", name, obj2.GetInstanceID()), transform = { parent = this.rootObjs[(int)sceneObjType].transform }
        });
    }
    public GameObject Spawn(string name, SceneObjType sceneObjType)
    {
        GameObject gameObject = new GameObject();

        gameObject.name             = string.Format("{0}({1})", name, gameObject.GetInstanceID());
        gameObject.transform.parent = this.rootObjs[(int)sceneObjType].transform;
        return(gameObject);
    }
Exemple #6
0
 public void AddToRoot(GameObject obj, SceneObjType sceneObjType, Vector3 pos, Quaternion rot)
 {
     if (obj != null)
     {
         obj.transform.parent   = this.rootObjs[(int)sceneObjType].transform;
         obj.transform.position = pos;
         obj.transform.rotation = rot;
     }
 }
Exemple #7
0
    public GameObject InstantiateLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos)
    {
        GameObject obj2 = this.InstantiateLOD(prefabName, isParticle, sceneObjType);

        if (obj2 != null)
        {
            obj2.transform.position = pos;
        }
        return(obj2);
    }
    public GameObject InstantiateLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos, Quaternion rot)
    {
        GameObject gameObject = this.InstantiateLOD(prefabName, isParticle, sceneObjType);

        if (gameObject != null)
        {
            gameObject.transform.position = pos;
            gameObject.transform.rotation = rot;
        }
        return(gameObject);
    }
Exemple #9
0
    private void ClearObjs(SceneObjType type)
    {
        GameObject obj2 = this.rootObjs[(int)type];

        while (obj2.transform.childCount > 0)
        {
            GameObject gameObject = obj2.transform.GetChild(obj2.transform.childCount - 1).gameObject;
            gameObject.transform.parent = null;
            UnityEngine.Object.Destroy(gameObject);
        }
    }
Exemple #10
0
    public GameObject Spawn(string name, SceneObjType sceneObjType, Vector3 position, Vector3 forward)
    {
        GameObject obj2 = new GameObject {
            name = name
        };

        obj2.transform.position = position;
        obj2.transform.rotation = Quaternion.LookRotation(forward);
        obj2.transform.parent   = this.rootObjs[(int)sceneObjType].transform;
        return(obj2);
    }
 public GameObject Spawn(string name, SceneObjType sceneObjType, Vector3 position, Quaternion rotation)
 {
     return(new GameObject
     {
         name = name,
         transform =
         {
             position = position,
             rotation = rotation,
             parent   = this.rootObjs[(int)sceneObjType].transform
         }
     });
 }
Exemple #12
0
    public GameObject InstantiateLOD(string prefabName, bool isParticle, SceneObjType sceneObjType)
    {
        string     realPath = null;
        GameObject original = this.GetPrefabLOD <GameObject>(prefabName, isParticle, out realPath);

        if (original == null)
        {
            return(null);
        }
        GameObject obj3 = UnityEngine.Object.Instantiate(original) as GameObject;

        if (obj3 != null)
        {
            obj3.transform.parent = this.rootObjs[(int)sceneObjType].transform;
        }
        return(obj3);
    }
    public GameObject InstantiateLOD(string prefabName, bool isParticle, SceneObjType sceneObjType)
    {
        string     text      = null;
        GameObject prefabLOD = this.GetPrefabLOD <GameObject>(prefabName, isParticle, out text);

        if (prefabLOD == null)
        {
            return(null);
        }
        GameObject gameObject = Object.Instantiate(prefabLOD) as GameObject;

        if (gameObject)
        {
            gameObject.transform.parent = this.rootObjs[(int)sceneObjType].transform;
        }
        return(gameObject);
    }
    public GameObject GetPooledGameObjLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos, Quaternion rot)
    {
        bool flag = false;

        return(this.GetPooledGameObjLOD(prefabName, isParticle, sceneObjType, pos, rot, out flag));
    }
Exemple #15
0
        private void ReadObjsInConfig(SceneVo scene_vo, string scene_content, string pattern, Dictionary <int, List <SceneObjVo> > dic, SceneObjType obj_type)
        {
            Match match = Regex.Match(scene_content, pattern);

            if (match.Groups.Count < 2)
            {
                return;
            }

            bool  is_first = true;
            Match m        = Regex.Match(match.Groups[1].ToString(), "id=(\\d*), x=(\\d*), y=(\\d*)");

            while (m.Success)
            {
                if (m.Groups.Count >= 4)
                {
                    SceneObjVo vo = new SceneObjVo();
                    vo.sceneId = scene_vo.sceneId;
                    vo.id      = Convert.ToInt32(m.Groups[1].ToString());
                    vo.x       = Convert.ToInt32(m.Groups[2].ToString());
                    vo.y       = Convert.ToInt32(m.Groups[3].ToString());

                    // 普通场景的限制
                    if (0 == scene_vo.sceneType)
                    {
                        if (SceneObjType.NPC == obj_type && dic.ContainsKey(vo.id))
                        {
                            Command.Instance.PrintLog(string.Format("错误:有相同的NPC,可能导致任务寻路失败, scene_id={0}, npc_id = {1}", vo.sceneId, vo.id), Color.Red);
                        }

                        if (is_first)
                        {
                            is_first = false;
                            if (SceneObjType.MONSTER == obj_type && dic.ContainsKey(vo.id))
                            {
                                Command.Instance.PrintLog(string.Format("警告:不同场景有相同的怪物,可能导致任务寻路失败, scene_id={0}, monster_id = {1}", vo.sceneId, vo.id), Color.YellowGreen);
                            }

                            if (SceneObjType.GATHER == obj_type && dic.ContainsKey(vo.id))
                            {
                                Command.Instance.PrintLog(string.Format("错误:不同场景有相同的的采集物,可能导致任务寻路失败, scene_id={0}, gather_id = {1}", vo.sceneId, vo.id), Color.Red);
                            }
                        }
                    }

                    List <SceneObjVo> vo_list;
                    if (!dic.TryGetValue(vo.id, out vo_list))
                    {
                        vo_list = new List <SceneObjVo>();
                        dic.Add(vo.id, vo_list);
                    }

                    vo_list.Add(vo);
                }

                m = m.NextMatch();
            }
        }
Exemple #16
0
    public GameObject GetPooledGameObjLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos)
    {
        bool isInit = false;

        return(this.GetPooledGameObjLOD(prefabName, isParticle, sceneObjType, pos, out isInit));
    }
Exemple #17
0
 public GameObject GetPooledGameObjLOD(string prefabName, bool isParticle, SceneObjType sceneObjType, Vector3 pos, Quaternion rot, out bool isInit)
 {
     return(this._GetPooledGameObjLOD(prefabName, isParticle, sceneObjType, pos, rot, true, out isInit));
 }
Exemple #18
0
 public GameObject GetRoot(SceneObjType sceneObjType)
 {
     return(this.rootObjs[(int)sceneObjType]);
 }