//---------------------------------------------------------------------------- private void UpdateSignObjectAndPosition(SignDatabase.SignItem item) { MapDatabase.MapItem map = MapDatabase.GetMaByUniqueId(item.m_mapUniqueId); if (map != null) { foreach (Transform obj in map.m_mapPrefab.transform) { GameObject sign = obj.gameObject; if (sign.name.Equals("Sign")) { foreach (Transform insideObj in sign.transform) { GameObject signCollision = insideObj.gameObject; if (signCollision.name.Equals("Collision")) { PolygonCollider2D collider = signCollision.GetComponent <PolygonCollider2D> (); if (collider && item.m_indexSignOnMap < collider.pathCount) { item.m_position = collider.GetPath(item.m_indexSignOnMap)[1]; return; } } } } } } }
//---------------------------------------------------------------------------- protected override void DrawElement(Rect rect, int id, bool selected, bool focused) { MapDatabase.MapItem item = MapDatabase.GetMaByUniqueId(id); if (item != null) { if (!string.IsNullOrEmpty(item.m_name)) { GUI.Label(rect, item.m_name); } else { GUI.Label(rect, "Un-named!"); } if (selected) { if (m_currentlySelected != id) { m_listUnfolded = false; m_currentlySelected = id; this.Repaint(); } } } }
//---------------------------------------------------------------------------- protected override void OnInternalInspectorGUI() { MapDatabase.MapItem item = MapDatabase.GetMaByUniqueId(m_currentlySelected); if (item != null) { GUILayout.BeginVertical(); { EditorGUILayout.LabelField("Map unique ID", item.m_uniqueId.ToString()); item.m_levelIndex = EditorGUILayout.IntField("Map level index", item.m_levelIndex); item.m_name = EditorGUILayout.TextField("Map Name", item.m_name); item.m_mapPrefab = EditorGUILayout.ObjectField("Map prefab", item.m_mapPrefab, typeof(GameObject), false) as GameObject; // Attack list GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Encounterable wild Pokemons"); if (GUILayout.Button(m_listUnfolded ? "Hide" : "Show")) { m_listUnfolded = !m_listUnfolded; } } GUILayout.EndHorizontal(); if (m_listUnfolded) { foreach (MapDatabase.MapWildPokemon element in item.m_wildPokemonList) { GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40)); element.m_pokemonId = EditorGUILayout.Popup(element.m_pokemonId, m_pokemonNames); EditorGUILayout.LabelField(" ", GUILayout.Width(20)); element.m_minLvl = EditorGUILayout.IntField("Level min", element.m_minLvl); EditorGUILayout.LabelField(" ", GUILayout.Width(20)); element.m_maxLvl = EditorGUILayout.IntField("Level max", element.m_maxLvl); EditorGUILayout.LabelField(" ", GUILayout.Width(20)); element.m_proba = EditorGUILayout.IntField("Encounter Proba", element.m_proba); EditorGUILayout.LabelField(" ", GUILayout.Width(20)); if (GUILayout.Button("-")) { m_delete = true; m_elementToDelete = new KeyValuePair <int, MapDatabase.MapWildPokemon> (item.m_uniqueId, element); } } GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40)); if (GUILayout.Button("+")) { AddNewWildPokemon(item.m_uniqueId); } } GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); } // Delay deletion so we don't do it during the for each loop if (m_delete) { RemoveWildPokemon(m_elementToDelete.Key, m_elementToDelete.Value); m_delete = false; } if (GUI.changed) { EditorUtility.SetDirty(target); } }