public static GameObjectInfo Build(GameObject go) { var goInfo = new GameObjectInfo(); goInfo.name = go.name; var cs = go.GetComponents <Component>(); foreach (var c in cs) { var info = BuildCom(c); if (info != null && !string.IsNullOrEmpty(info.data)) { goInfo.coms.Add(info); } } if (go.transform.childCount > 0) { for (int i = 0; i < go.transform.childCount; i++) { var childInfo = Build(go.transform.GetChild(i).gameObject); childInfo.instanceID = i; if (childInfo.coms.Count > 0) { goInfo.childs.Add(childInfo); } } } return(goInfo); }
public void AddGameObjectInfo(GameObjectInfo gameObjectInfo) { if (gameObjectInfo == null) { return; } if (gameObjectInfo.Type != GameObjectTypes.Terrain) { allGameObjectInfos.Add(gameObjectInfo); if (gameObjectInfo.Type == GameObjectTypes.Effect) { effects.Add(gameObjectInfo); } else if (gameObjectInfo.Type == GameObjectTypes.Block) { blocks.Add(gameObjectInfo); } else if (gameObjectInfo.Type == GameObjectTypes.NonBlock) { nonblocks.Add(gameObjectInfo); } else if (gameObjectInfo.Type == GameObjectTypes.Light) { lights.Add(gameObjectInfo); } } else { terrainInfo = gameObjectInfo; } }
public string ToXMLString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<?xml version='1.0' encoding='utf-8'?>\n"); stringBuilder.Append("<table n='SceneConfig'>\n"); allGameObjectInfos.Add(terrainInfo); GameObjectInfo gameObjectInfo = null; int length = allGameObjectInfos.Count; for (int i = 0; i < length; ++i) { stringBuilder.Append("\t"); gameObjectInfo = allGameObjectInfos[i]; stringBuilder.Append(gameObjectInfo.ToXMLString()); stringBuilder.Append("\n"); } allGameObjectInfos.Remove(terrainInfo); //stringBuilder.Append("\t"); //stringBuilder.Append("<a n='GS'>"); //stringBuilder.Append(gridsContent); //stringBuilder.Append("</a>"); //stringBuilder.Append("\n"); stringBuilder.Append("</table>"); return(stringBuilder.ToString()); }
private void ReceiveGOInfo(GameObjectInfo info) { Transform objTransf; if (!Gameobjects.TryGetValue(info.Main.Id, out objTransf)) { Gameobjects.Add(info.Main.Id, objTransf = new GameObject().transform); } if (info.Main.ParentId != int.MinValue) { Transform cachedTr; if (!Gameobjects.TryGetValue(info.Main.ParentId, out cachedTr)) { Gameobjects.Add(info.Main.ParentId, cachedTr = new GameObject().transform); } objTransf.parent = cachedTr; } objTransf.localPosition = info.Main.LocalPos; objTransf.localEulerAngles = info.Main.LocalEulerAngles; objTransf.localScale = info.Main.LocalScale; objTransf.name = info.Name; }
private void OnCopySelectedHandler(string copyName) { Debug.Log(copyName); copyInfo = ConfigManager.GetCopyInfo(copyName); if (copyInfo == null) { Debug.LogError("缺少配置:" + copyName + ".xml"); } else { sceneInfo = ConfigManager.GetSceneConfigInfo(copyInfo.ResName); if (sceneInfo == null) { Debug.LogError("缺少配置:" + copyInfo.ResName + ".xml"); } else { ConfigManager.ParseSceneGrids(copyInfo.ResName); for (int i = 0; i < sceneInfo.AllGameObjectInfos.Count; ++i) { GameObjectInfo gameObjectInfo = sceneInfo.AllGameObjectInfos[i]; if (gameObjectInfo.Type == GameObjectTypes.Effect) { assetbundleList.Add(GameConst.SceneEffectABDirectory + gameObjectInfo.PrefabName + GameConst.ABExtensionName); } else { assetbundleList.Add(GameConst.SceneModelABDirectory + gameObjectInfo.PrefabName + GameConst.ABExtensionName); } } Alert.Show("初始化中,请稍等......"); Load(); } } }
public IEnumerator MoveLerp(GameObjectInfo gameObjectInfo) { if (!gameObjectInfo.m_oneTimeInstiate) { gameObjectInfo.m_oneTimeInstiate = true; if (gameObjectInfo.m_tempObjCnt < gameObjectInfo.m_movingObjsCnt) { GameObject moveobject = Instantiate(gameObjectInfo.m_ObjectToMove, gameObjectInfo.m_poin0.position, Quaternion.Euler(gameObjectInfo.setAngle)); if (gameObjectInfo.m_ObjectToMove != null) { if (gameObjectInfo.m_ObjectToMove.name == "Enemy4") { Globals.enemy4List.Add(moveobject); } } moveobject.transform.SetParent(gameObjectInfo.m_parent.transform); moveobject.AddComponent <LerpMovement>(); moveobject.GetComponent <LerpMovement>().m_gameObjectInfo = gameObjectInfo; yield return(new WaitForSeconds(3f)); gameObjectInfo.m_oneTimeInstiate = false; gameObjectInfo.m_tempObjCnt++; } } }
private OrganIndex GetOrganIndex(string meshName, BranchIndex fromBranchIndex, GameObjectInfo objectInfo) { /* * 根据名字确定其对应的Mesh * 根据Mesh即可确定该器官类型、模型 */ Mesh matchedMesh = m_MeshGroup.Find(mesh => mesh.Name.Equals(meshName)); //寻找Mesh集中对应的Mesh if (matchedMesh == null) { throw new InvalidOperationException("Error Mesh Name in Rules"); //未能找到对应Mesh } switch (matchedMesh.Type) { case OrganType.Leaf: return(GetLeafIndex(matchedMesh, fromBranchIndex, objectInfo)); case OrganType.Flower: return(GetMaleIndex(matchedMesh, fromBranchIndex, objectInfo)); case OrganType.Fruit: return(GetFemaleIndex(matchedMesh, fromBranchIndex, objectInfo)); default: return(GetLeafIndex(matchedMesh, fromBranchIndex, objectInfo)); } }
bool EditGameObject(GameObjectInfo info) { if (!info.IsEditable()) { return(false); } try { Selectable selectable = info.go.GetComponent <Selectable>(); if (selectable == null) { Debug.LogError("Not Found " + info.go.name); } else { selectable.colors = ColorBlock.defaultColorBlock; } return(true); } catch (System.Exception e) { Debug.LogError(e.Message); return(false); } }
private FemaleIndex GetFemaleIndex(Mesh mesh, BranchIndex fromBranchIndex, GameObjectInfo objectInfo) { FemaleIndex femaleIndex; int index = GetIndexWithSameType <FemaleIndex>(OrganType.Fruit, fromBranchIndex, out femaleIndex); if (index >= 1) { femaleIndex.HairMesh = mesh; return(null); } else { femaleIndex = new FemaleIndex(); femaleIndex.Index = index; femaleIndex.CornMesh = mesh; femaleIndex.Radius = objectInfo.Radius; femaleIndex.Rotation = objectInfo.Rotation; femaleIndex.From = fromBranchIndex; return(femaleIndex); } }
public byte[] GameObjectsToBytes() { ByteBuffer byteBuffer = new ByteBuffer(); if (!allGameObjectInfos.Contains(terrainInfo)) { allGameObjectInfos.Add(terrainInfo); } GameObjectInfo gameObjectInfo = null; Byte[] bytes; int length = allGameObjectInfos.Count; byteBuffer.WriteUShort((ushort)(length)); for (int i = 0; i < length; ++i) { gameObjectInfo = allGameObjectInfos[i]; bytes = gameObjectInfo.ToBytes(); byteBuffer.WriteInt(bytes.Length); byteBuffer.WriteBytes(bytes); } allGameObjectInfos.Remove(terrainInfo); return(byteBuffer.ToBytes()); }
private LeafIndex GetLeafIndex(Mesh mesh, BranchIndex fromBranchIndex, GameObjectInfo objectInfo) { LeafIndex index = new LeafIndex(); /* * 存储信息: * 索引值和器官类型 * 用于后续判断不同时期的两个器官索引是否为相同索引 */ index.Index = GetIndexWithSameType(OrganType.Leaf, fromBranchIndex); index.LeafMesh = mesh; /* * 存储空间信息: * 半径、旋转方向 * 用于后续绘制 */ index.Radius = objectInfo.Radius; index.Rotation = objectInfo.Rotation; /* * 存储上下文信息: * 从属枝干 */ index.From = fromBranchIndex; /* * 病虫害信息: * 细胞纹理 */ index.CelluarTex = CellularTexMemory.GetInstance().GetCellularTex(0); return(index); }
/// <summary> /// 释放一个战斗单位 /// </summary> /// <param name="id"></param> public void ReleaseGameObject(int id) { if (m_gameObjectMap.ContainsKey(id)) { Debug.LogWarning(this.GetType().Name + " Warning : 释放GameObject失败,缓存字典里并不存在这个GameObject, id:" + id); return; } GameObjectInfo info = m_gameObjectMap[id]; if (info.IsReuse) { if (!m_gameObjectPool.ContainsKey(info.prototypeName)) { Stack <GameObject> stack = new Stack <GameObject>(); stack.Push(info.gameObj); m_gameObjectPool[info.prototypeName] = stack; } else { m_gameObjectPool[info.prototypeName].Push(info.gameObj); } } else { GameObject.Destroy(info.gameObj); } m_gameObjectMap.Remove(id); }
public static GameObjectInfo GetObjectInfoById(int id) { GameObjectInfo info = null; _infoDictionary.TryGetValue(id, out info); return(info); }
/// <summary> /// 将一个GO放入单位缓存列表 /// </summary> /// <param name="id"></param> /// <param name="prototypeName"></param> /// <param name="name"></param> /// <param name="isReuse"></param> /// <param name="go"></param> private void PutGOIntoMap(int id, string prototypeName, string name, bool isReuse, GameObject go) { go.SetActive(true); go.name = name; GameObjectInfo goInfo = new GameObjectInfo(id, name, prototypeName, go, isReuse); m_gameObjectMap.Add(id, goInfo); }
public void Editor_CreateName() { for (int i = 0, imax = list_Info.Count; i < imax; i++) { GameObjectInfo _info = list_Info[i]; _info.name = _info.prefab.name; } }
void Start() { GameObjectInfo.GetObjectInfoById(gameObject.GetInstanceID()).Team = Team; _unitManager.RegisterUnit(gameObject.GetInstanceID(), this); CurrHealth = MaxHealth; HealtBar.maxValue = MaxHealth; HealtBar.value = CurrHealth; }
/// <summary> /// 得到已实例化的一个GameObject,如果不存在则返回null /// </summary> /// <param name="id"></param> /// <returns></returns> public GameObject GetGameObjectById(int id) { GameObjectInfo obj = null; m_gameObjectMap.TryGetValue(id, out obj); return(obj == null ? null : obj.gameObj); }
public static ItemInfo GetFromItem(Item item) { ItemInfo r = new ItemInfo(); r.name = item.name; r.description = item.description; r.gameObject = GameObjectInfo.GetFromGameObject(item.gameObject); return(r); }
/// <summary> /// 设定物体的ID /// </summary> void SetID() { GameObjectInfo gameObjectInfo = GetComponent <GameObjectInfo>(); if (null != gameObjectInfo) { gameObjectInfo.UniqueId = uniqueID; } }
public void Awake() { gameObjectInfo = GetComponent <GameObjectInfo>(); if (MeshRenderer == null) { MeshRenderer = GetComponent <MeshRenderer>(); } OrginalMaterial = MeshRenderer.material; }
public ShadowGameObject(GameScreen screen, IGameObject obj) { this.screen = screen; Info = new GameObjectInfo (); Obj = obj; Info.IsVisible = true; Info.IsSelectable = false; Info.IsMovable = false; }
private GameObjectInfo GetGameObjectInfo(int id) { GameObjectInfo ret = null; if (m_GameObjects.ContainsKey(id)) { ret = m_GameObjects[id]; } return(ret); }
public void Init(GameObjectInfo goInfo) { gameObjectInfo = goInfo; position = new Vector3(gameObjectInfo.X, gameObjectInfo.Y, gameObjectInfo.Z); scale = new Vector3(gameObjectInfo.ScaleX, gameObjectInfo.ScaleY, gameObjectInfo.ScaleZ); rotation = new Vector3(gameObjectInfo.RotationX, gameObjectInfo.RotationY, gameObjectInfo.RotationZ); string head = gameObjectInfo.Type == GameObjectTypes.Effect ? GameConst.SceneEffectABDirectory : GameConst.SceneModelABDirectory; abPath = string.Format("{0}{1}", head, gameObjectInfo.PrefabName); }
private void AddGameObjectToListView(GameObjectInfo gameobject) { ListViewItem lvi = new ListViewItem(); lvi.Text = gameobject.ID.ToString(); lvi.SubItems.Add(gameobject.Type.ToString()); lvi.SubItems.Add(gameobject.DisplayId.ToString()); lvi.SubItems.Add(gameobject.Name); // Add this gameobject to the listview. lstData.Items.Add(lvi); }
public GameObjectInfo Clone() { GameObjectInfo result = new GameObjectInfo(); result.Length = Length; result.Radius = Radius; result.Position = Position; result.Rotation = Rotation; result.Scale = Scale; return(result); }
public void FirstInitDependencies() { if (firstInit) { return; } if ((extension.ToLower() == "fbx" || extension.ToLower() == "prefab") && obj is GameObject) { GameObject goT = obj as GameObject; GameObject goTmp = Object.Instantiate(goT); goTmp.name = goT.name; var filters = goTmp.GetComponentsInChildren <MeshFilter>(); var skins = goTmp.GetComponentsInChildren <SkinnedMeshRenderer>(); List <MeshInfo> meshes = new List <MeshInfo>(); foreach (var fltr in filters) { if (fltr.sharedMesh != null) { meshes.Add(new MeshInfo() { mesh = fltr.sharedMesh, path = GameObjectInfo.GetGameObjectPath(fltr.transform), type = MeshInfo.Type.MeshFilter }); } } foreach (var skin in skins) { if (skin.sharedMesh != null) { meshes.Add(new MeshInfo() { mesh = skin.sharedMesh, path = GameObjectInfo.GetGameObjectPath(skin.transform), type = MeshInfo.Type.SkinnedMesh }); } } fbxInfs = meshes.ToArray(); Object.DestroyImmediate(goTmp); } List <string> depsRecList = new List <string>(AssetDatabase.GetDependencies(path, false)); List <string> depsNoRecList = new List <string>(AssetDatabase.GetDependencies(path, true)); depsRecList.Remove(path); depsRecList.Sort(); depsNoRecList.Sort(); dependencyRecurPathes = depsRecList.ToArray(); dependencyNoRecurPathes = depsNoRecList.ToArray(); firstInit = true; }
public void AddObject(Object root, string path) { GameObjectInfo info = objInfo.Find((o) => { return(o._obj == root); }); if (info == null) { info = new GameObjectInfo(root); objInfo.Add(info); } info.AddPath(path); }
// TODO create a MethodsPopup that uses EditorGUI instead of EditorGUILayout. /// <summary> /// Customized EditorGUILayout.Popup for displaying a GameObject's methods. /// </summary> /// <returns> /// Returns the index of the selected popup item. /// </returns> /// <param name="selectedMethod"> /// Holds data about the selected component method. /// </param> public static int ComponentMethodsPopup(string label, int selected, GameObject gameObject, out ComponentMethodInfo selectedMethod) { // Bail out if there's no object to scan. This will cause the popup control to disappear completely if (!gameObject) { selectedMethod = null; return 0; } GameObjectInfo _info = new GameObjectInfo (gameObject); List<string> _names = new List<string> (); List<ComponentMethodInfo> _componentMethods = new List<ComponentMethodInfo> (); // Find all accessible methods belonging to the given GameObject if (gameObject != null) { foreach (ComponentInfo component in _info.Components) { foreach (ComponentMethodInfo method in component.Methods) { // Ignore the Transform component if (component.ComponentType == typeof(Transform)) continue; // Find supported parameters string parameterName = ""; if (method.HasParameter) parameterName = method.Parameter.ValueTypeName + " "; // Display methods in the form of "ComponentName.MethodName ( parameterType )" // FIXME display a dot in the UI instead of a slash, // but pass a slash to EditorGUI.Popup so that it will generate sub-menus _names.Add (component.Name + "/" + method.Name + " ( " + parameterName + ")"); _componentMethods.Add (method); } } } // FIXME this doesn't belong here. Place it where the popup value is changed GUI.changed = true; // FIXME check for index out of bounds selectedMethod = new ComponentMethodInfo (_componentMethods [selected].Component, _componentMethods [selected]); if (_componentMethods.Count < 1) { string[] empty = {""}; selected = EditorGUILayout.Popup (label, 0, empty); } else { selected = EditorGUILayout.Popup (label, selected, _names.ToArray ()); } return selected; // FIXME if the array of available methods has changed (such as by adding or removing a method in a script, // try to re-connect to the previously held method regardless of the popup's current index. // FIXME provide an option for "none" at the end of the methods list }
/// <summary> /// 向前移动一定距离但不渲染 /// </summary> /// <param name="BottomPosition">移动前的位置</param> /// <param name="Length">移动的长度</param> /// <param name="Angles">旋转角度</param> /// <param name="OrderOfAngles">旋转的先后顺序</param> /// <returns>移动后的位置</returns> private Vector3 MoveForward(GameObjectInfo ObjectInfo) { GameObject tempObject = new GameObject(); tempObject.transform.position = ObjectInfo.Position + new Vector3(0, ObjectInfo.Length, 0); //移动到指定位置 RotationGameObject(tempObject, ObjectInfo.Position, ObjectInfo.Rotation); //旋转 Vector3 Position = tempObject.transform.position; GameObject.Destroy(tempObject, 0f); return(Position); }
public override void Initialized() { if (Entity != null) { GameObjectInfo Info = new GameObjectInfo() { ID = Owner.ID, GameObjectType = Owner.GetType() }; Entity.Tag = Info; PhysicsManager.AddEntity(Entity); } base.Initialized(); }
private MaleIndex GetMaleIndex(Mesh mesh, BranchIndex fromBranchIndex, GameObjectInfo objectInfo) { MaleIndex maleIndex = new MaleIndex(); maleIndex.Index = GetIndexWithSameType(OrganType.Flower, fromBranchIndex); maleIndex.MaleMesh = mesh; maleIndex.Radius = objectInfo.Radius; maleIndex.Rotation = objectInfo.Rotation; maleIndex.From = fromBranchIndex; return(maleIndex); }
private void RememberGameObject(int id, GameObject obj, SharedGameObjectInfo info) { if (m_GameObjects.ContainsKey(id)) { GameObject oldObj = m_GameObjects[id].ObjectInstance; oldObj.SetActive(false); m_GameObjectIds.Remove(oldObj); GameObject.Destroy(oldObj); m_GameObjects[id] = new GameObjectInfo(obj, info); } else { m_GameObjects.Add(id, new GameObjectInfo(obj, info)); } m_GameObjectIds.Add(obj, id); }
public override bool Equals(GameObjectInfo other) { if (other == null) { return false; } if (other is PipeModelInfo) { if (this.Edge == (other as PipeModelInfo).Edge && base.Equals (other)) { return true; } else { return false; } } else { return base.Equals (other); } }
public void Load(GameObjectInfo info) { this.hasPhysics = info.GetProperty<bool>("HasPhysics"); if (hasPhysics) { CreatePhysicsBody(); } Position = info.GetProperty<Vector2>("Position"); this.blockTexture = Game.Content.Load<Texture2D>(info.GetProperty<string>("Texture")); blockInfo = new BlockInfo() { Texture = info.GetProperty<string>("Texture"), HasPhysics = hasPhysics }; }
public GameObjectInfo Save() { var info = new GameObjectInfo(); info.Type = GetType().FullName; info.Properties.Add("Texture", BlockInfo.Texture); info.Properties.Add("Position", Position); info.Properties.Add("HasPhysics", hasPhysics); return info; }
public override bool Equals(GameObjectInfo other) { if (other == null) { return false; } if (other is ArrowModelInfo) { if (this.Position == other.Position && this.Direction == (other as ArrowModelInfo).Direction && base.Equals (other)) { return true; } else { return false; } } else { return base.Equals (other); } }
public override bool Equals(GameObjectInfo other) { if (other == null) { return false; } if (other is GameModelInfo) { if (this.Texturename == (other as GameModelInfo).Modelname && base.Equals (other)) { return true; } else { return false; } } else { return base.Equals (other); } }
/// <summary> /// Initialize the Game. /// </summary> public override void Initialize() { // world world = new World (this); // input knotInput = new KnotInputHandler (this, world); // overlay overlay = new Overlay (this, world); // pointer pointer = new MousePointer (this); // picker picker = new ModelMouseHandler (this, world); // pipe renderer var knotRenderInfo = new GameObjectInfo (); knotRenderInfo.Position = Vector3.Zero; renderer = new KnotRenderer (this, knotRenderInfo); world.Add (renderer as IGameObject); // pipe movements movement = new EdgeMovement (this, world, knotRenderInfo); world.Add (movement as IGameObject); // pipe colors coloring = new EdgeColoring (this); // load nodes Node.Scale = 100; Knot = new Knot (); }
bool EditGameObject(GameObjectInfo info) { if (!info.IsEditable()) return false; try { Selectable selectable = info.go.GetComponent<Selectable>(); if (selectable == null) { Debug.LogError("Not Found " + info.go.name); } else { selectable.colors = ColorBlock.defaultColorBlock; } return true; } catch(System.Exception e ) { Debug.LogError(e.Message); return false; } }