protected virtual List <RopesByBallons> GetAllStructsWithBallonInternal(BalloonProperty p_ballon) { List <RopesByBallons> v_finalList = new List <RopesByBallons>(); if (p_ballon != null) { foreach (RopesByBallons v_struct in RopesByBallonsList) { if (v_struct != null && v_struct.Rope != null) { if (v_struct.DirectBallons.Contains(p_ballon)) { v_finalList.Add(v_struct); } else if (v_struct.IndirectBallons.Contains(p_ballon)) { v_finalList.Add(v_struct); } } else { _needRemoveNulls = true; } } } return(v_finalList); }
protected virtual void PlugBallon() { Rope2D.CleanUselessRopes(); BalloonProperty v_ballonPrefabComponent = m_windowInformation.Ballons != null && m_windowInformation.SelectedBallonIndex >= 0 && m_windowInformation.Ballons.Count > m_windowInformation.SelectedBallonIndex? m_windowInformation.Ballons[m_windowInformation.SelectedBallonIndex] : null; TackRope v_ropePrefabComponent = m_windowInformation.Ropes != null && m_windowInformation.SelectedRopeIndex >= 0 && m_windowInformation.Ropes.Count > m_windowInformation.SelectedRopeIndex? m_windowInformation.Ropes[m_windowInformation.SelectedRopeIndex] : null; if (v_ballonPrefabComponent != null && v_ropePrefabComponent != null && m_windowInformation.ObjectInSceneToPlug) { BalloonUtils.PlugBallonToObject(m_windowInformation.ObjectInSceneToPlug, v_ballonPrefabComponent, v_ropePrefabComponent, new Vector2(0.4f, 1f), new Vector2(-0.4f, 0.8f), true, true); } }
public static List <RopesByBallons> GetAllStructsWithBallon(BalloonProperty p_ballon, bool p_canCreateNewControllerIfDontExists = true) { RopesByBalloonsController v_instance = GetInstance(p_canCreateNewControllerIfDontExists); List <RopesByBallons> v_returnList = new List <RopesByBallons>(); if (v_instance != null) { v_returnList = v_instance.GetAllStructsWithBallonInternal(p_ballon); } return(v_returnList); }
protected virtual void OnGUI() { if (m_windowInformation == null) { m_windowInformation = new BalloonPluggerWindowInformation(); } EditorGUILayout.BeginHorizontal(); bool v_refreshClicked = GUILayout.Button("Refresh Informations"); EditorGUILayout.EndHorizontal(); if (v_refreshClicked) { Refresh(); } if (m_windowInformation.Ballons != null) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Ballon"); m_windowInformation.SelectedBallonIndex = EditorGUILayout.Popup(m_windowInformation.SelectedBallonIndex, m_windowInformation.Ballons.GetStringList().ToArray()); EditorGUILayout.EndHorizontal(); } if (m_windowInformation.Ropes != null) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Ropes"); m_windowInformation.SelectedRopeIndex = EditorGUILayout.Popup(m_windowInformation.SelectedRopeIndex, m_windowInformation.Ropes.GetStringList().ToArray()); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Plug In Selected Object In Scene"); m_windowInformation.PlugInSelectedObject = EditorGUILayout.BeginToggleGroup("", m_windowInformation.PlugInSelectedObject); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndHorizontal(); if (!m_windowInformation.PlugInSelectedObject) { EditorGUILayout.BeginHorizontal(); m_windowInformation.ObjectInSceneToPlug = (GameObject)EditorGUILayout.ObjectField("Object To Plug", m_windowInformation.ObjectInSceneToPlug, typeof(GameObject), true); EditorGUILayout.EndHorizontal(); } else { Transform v_transform = Selection.activeTransform; if (v_transform != null) { m_windowInformation.ObjectInSceneToPlug = v_transform.gameObject; } } BalloonProperty v_ballonPrefabComponent = m_windowInformation.Ballons != null && m_windowInformation.SelectedBallonIndex >= 0 && m_windowInformation.Ballons.Count > m_windowInformation.SelectedBallonIndex? m_windowInformation.Ballons[m_windowInformation.SelectedBallonIndex] : null; TackRope v_ropePrefabComponent = m_windowInformation.Ropes != null && m_windowInformation.SelectedRopeIndex >= 0 && m_windowInformation.Ropes.Count > m_windowInformation.SelectedRopeIndex? m_windowInformation.Ropes[m_windowInformation.SelectedRopeIndex] : null; if (m_windowInformation.ObjectInSceneToPlug != null && v_ballonPrefabComponent != null && v_ropePrefabComponent != null) { EditorGUILayout.BeginHorizontal(); bool v_buttonClicked = GUILayout.Button("Plug Ballon"); EditorGUILayout.EndHorizontal(); if (v_buttonClicked) { PlugBallon(); } } }
protected virtual List<RopesByBallons> GetAllStructsWithBallonInternal(BalloonProperty p_ballon) { List<RopesByBallons> v_finalList = new List<RopesByBallons>(); if(p_ballon != null) { foreach(RopesByBallons v_struct in RopesByBallonsList) { if(v_struct != null && v_struct.Rope != null) { if(v_struct.DirectBallons.Contains(p_ballon)) v_finalList.Add(v_struct); else if(v_struct.IndirectBallons.Contains(p_ballon)) v_finalList.Add(v_struct); } else _needRemoveNulls = true; } } return v_finalList; }
public static List<RopesByBallons> GetAllStructsWithBallon(BalloonProperty p_ballon, bool p_canCreateNewControllerIfDontExists = true) { RopesByBalloonsController v_instance = GetInstance(p_canCreateNewControllerIfDontExists); List<RopesByBallons> v_returnList = new List<RopesByBallons>(); if(v_instance != null) v_returnList = v_instance.GetAllStructsWithBallonInternal(p_ballon); return v_returnList; }
set => SetValue(BalloonProperty, value);
public static void PlugBallonToObject(GameObject p_object, BalloonProperty p_ballon, Rope2D p_rope, Vector2 p_minDistance, Vector2 p_maxDistance, bool p_ballonIsAPrefab = true, bool p_ropeIsAPrefab = true, bool p_useBallonPrefabScale = true, bool p_useRopePrefabScale = true, string p_errorSolverDirectory = "Prefabs") { GameObject v_ropeParentObject = GameObject.Find("RopesContainer"); GameObject v_blockParentObject = GameObject.Find("BlocksContainer"); GameObject v_ballonInScene = null; GameObject v_ropeInScene = null; //Try Solve Ballon Errors if (p_ballon == null) { BalloonProperty[] v_ballons = KiltUtils.FindAllResourcesComponentsAtFolder <BalloonProperty>(p_errorSolverDirectory); if (v_ballons.Length <= 0) { v_ballons = KiltUtils.FindAllResourcesComponentsOfType <BalloonProperty>(); } if (v_ballons.Length > 0 && v_ballons[0] != null) { v_ballonInScene = KiltUtils.Instantiate(v_ballons[0].gameObject); v_ballonInScene.transform.parent = v_blockParentObject != null? v_blockParentObject.transform : null; if (p_useBallonPrefabScale) { v_ballonInScene.transform.localScale = v_ballons[0].gameObject.transform.localScale; } } } else if (p_ballonIsAPrefab) { v_ballonInScene = KiltUtils.Instantiate(p_ballon.gameObject); v_ballonInScene.transform.parent = v_blockParentObject != null? v_blockParentObject.transform : null; if (p_useBallonPrefabScale) { v_ballonInScene.transform.localScale = p_ballon.gameObject.transform.localScale; } } else { v_ballonInScene = p_ballon.gameObject; } //Try Solve Rope Errors if (p_rope == null) { Rope2D[] v_ropes = KiltUtils.FindAllResourcesComponentsAtFolder <Rope2D>(p_errorSolverDirectory); if (v_ropes.Length <= 0) { v_ropes = KiltUtils.FindAllResourcesComponentsOfType <Rope2D>(); } if (v_ropes.Length > 0 && v_ropes[0] != null) { v_ropeInScene = KiltUtils.Instantiate(v_ropes[0].gameObject); v_ropeInScene.transform.parent = v_ropeParentObject != null? v_ropeParentObject.transform : null; if (p_useRopePrefabScale) { v_ropeInScene.transform.localScale = v_ropes[0].gameObject.transform.localScale; } } } else if (p_ropeIsAPrefab) { v_ropeInScene = KiltUtils.Instantiate(p_rope.gameObject); v_ropeInScene.transform.parent = v_ropeParentObject != null? v_ropeParentObject.transform : null; if (p_useRopePrefabScale) { v_ropeInScene.transform.localScale = p_rope.gameObject.transform.localScale; } } else { v_ropeInScene = p_rope.gameObject; } if (v_ballonInScene != null && p_object != null && v_ropeInScene != null) { v_ballonInScene.transform.localPosition = new Vector3(v_ballonInScene.transform.localPosition.x, v_ballonInScene.transform.localPosition.y, 20); // Prevent Rope Collider to be in front of this Object v_ballonInScene.name = v_ballonInScene.name.Replace("(Clone)", ""); v_ropeInScene.name = v_ropeInScene.name.Replace("(Clone)", "") + "[(" + p_object.name.Replace("(Selected)", "") + ") to (" + v_ballonInScene.name + ")]"; TackRope v_tackRope = v_ropeInScene.GetComponent <TackRope>(); if (v_tackRope != null) { v_tackRope.ObjectA = p_object; v_tackRope.ObjectB = v_ballonInScene; Vector2 v_newOffSetPosition = new Vector2(KiltUtils.RandomRange(p_minDistance.x, p_maxDistance.x), KiltUtils.RandomRange(p_minDistance.y, p_maxDistance.y)); v_ballonInScene.transform.position = new Vector3(p_object.transform.position.x + v_newOffSetPosition.x, p_object.transform.position.y + v_newOffSetPosition.y, p_object.transform.position.z); if (Application.isPlaying) { v_tackRope.CreateRope(); } } } if (v_ballonInScene != null && v_ballonInScene.GetComponent <BlockSelector>() == null) { v_ballonInScene.AddComponent <BlockSelector>(); } }
public static void PlugBallonToObject(GameObject p_object, BalloonProperty p_ballon, Rope2D p_rope, Vector2 p_minDistance, Vector2 p_maxDistance, bool p_ballonIsAPrefab = true, bool p_ropeIsAPrefab = true, bool p_useBallonPrefabScale = true, bool p_useRopePrefabScale = true, string p_errorSolverDirectory = "Prefabs") { GameObject v_ropeParentObject = GameObject.Find("RopesContainer"); GameObject v_blockParentObject = GameObject.Find("BlocksContainer"); GameObject v_ballonInScene = null; GameObject v_ropeInScene = null; //Try Solve Ballon Errors if(p_ballon == null) { BalloonProperty[] v_ballons = KiltUtils.FindAllResourcesComponentsAtFolder<BalloonProperty>(p_errorSolverDirectory); if(v_ballons.Length <= 0) v_ballons = KiltUtils.FindAllResourcesComponentsOfType<BalloonProperty>(); if(v_ballons.Length > 0 && v_ballons[0] != null) { v_ballonInScene = KiltUtils.Instantiate(v_ballons[0].gameObject); v_ballonInScene.transform.parent = v_blockParentObject != null? v_blockParentObject.transform : null; if(p_useBallonPrefabScale) v_ballonInScene.transform.localScale = v_ballons[0].gameObject.transform.localScale; } } else if(p_ballonIsAPrefab) { v_ballonInScene = KiltUtils.Instantiate(p_ballon.gameObject); v_ballonInScene.transform.parent = v_blockParentObject != null? v_blockParentObject.transform : null; if(p_useBallonPrefabScale) v_ballonInScene.transform.localScale = p_ballon.gameObject.transform.localScale; } else v_ballonInScene = p_ballon.gameObject; //Try Solve Rope Errors if(p_rope == null) { Rope2D[] v_ropes = KiltUtils.FindAllResourcesComponentsAtFolder<Rope2D>(p_errorSolverDirectory); if(v_ropes.Length <= 0) v_ropes = KiltUtils.FindAllResourcesComponentsOfType<Rope2D>(); if(v_ropes.Length > 0 && v_ropes[0] != null) { v_ropeInScene = KiltUtils.Instantiate(v_ropes[0].gameObject); v_ropeInScene.transform.parent = v_ropeParentObject != null? v_ropeParentObject.transform : null; if(p_useRopePrefabScale) v_ropeInScene.transform.localScale = v_ropes[0].gameObject.transform.localScale; } } else if(p_ropeIsAPrefab) { v_ropeInScene = KiltUtils.Instantiate(p_rope.gameObject); v_ropeInScene.transform.parent = v_ropeParentObject != null? v_ropeParentObject.transform : null; if(p_useRopePrefabScale) v_ropeInScene.transform.localScale = p_rope.gameObject.transform.localScale; } else v_ropeInScene = p_rope.gameObject; if(v_ballonInScene != null && p_object != null && v_ropeInScene != null) { v_ballonInScene.transform.localPosition = new Vector3(v_ballonInScene.transform.localPosition.x, v_ballonInScene.transform.localPosition.y, 20); // Prevent Rope Collider to be in front of this Object v_ballonInScene.name = v_ballonInScene.name.Replace("(Clone)",""); v_ropeInScene.name = v_ropeInScene.name.Replace("(Clone)", "") + "[(" + p_object.name.Replace("(Selected)","") +") to ("+ v_ballonInScene.name + ")]"; TackRope v_tackRope = v_ropeInScene.GetComponent<TackRope>(); if(v_tackRope != null) { v_tackRope.ObjectA = p_object; v_tackRope.ObjectB = v_ballonInScene; Vector2 v_newOffSetPosition = new Vector2(KiltUtils.RandomRange(p_minDistance.x, p_maxDistance.x), KiltUtils.RandomRange(p_minDistance.y, p_maxDistance.y)); v_ballonInScene.transform.position = new Vector3(p_object.transform.position.x + v_newOffSetPosition.x, p_object.transform.position.y + v_newOffSetPosition.y, p_object.transform.position.z); if(Application.isPlaying) v_tackRope.CreateRope(); } } if(v_ballonInScene != null && v_ballonInScene.GetComponent<BlockSelector>() == null) v_ballonInScene.AddComponent<BlockSelector>(); }